@c4a/extract 0.6.18 → 0.7.0

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/index.js CHANGED
@@ -100,17 +100,17 @@ var require_visit = __commonJS((exports) => {
100
100
  visit.BREAK = BREAK;
101
101
  visit.SKIP = SKIP;
102
102
  visit.REMOVE = REMOVE;
103
- function visit_(key, node2, visitor, path) {
104
- const ctrl = callVisitor(key, node2, visitor, path);
103
+ function visit_(key, node2, visitor, path2) {
104
+ const ctrl = callVisitor(key, node2, visitor, path2);
105
105
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
106
- replaceNode(key, path, ctrl);
107
- return visit_(key, ctrl, visitor, path);
106
+ replaceNode(key, path2, ctrl);
107
+ return visit_(key, ctrl, visitor, path2);
108
108
  }
109
109
  if (typeof ctrl !== "symbol") {
110
110
  if (identity.isCollection(node2)) {
111
- path = Object.freeze(path.concat(node2));
111
+ path2 = Object.freeze(path2.concat(node2));
112
112
  for (let i = 0;i < node2.items.length; ++i) {
113
- const ci = visit_(i, node2.items[i], visitor, path);
113
+ const ci = visit_(i, node2.items[i], visitor, path2);
114
114
  if (typeof ci === "number")
115
115
  i = ci - 1;
116
116
  else if (ci === BREAK)
@@ -121,13 +121,13 @@ var require_visit = __commonJS((exports) => {
121
121
  }
122
122
  }
123
123
  } else if (identity.isPair(node2)) {
124
- path = Object.freeze(path.concat(node2));
125
- const ck = visit_("key", node2.key, visitor, path);
124
+ path2 = Object.freeze(path2.concat(node2));
125
+ const ck = visit_("key", node2.key, visitor, path2);
126
126
  if (ck === BREAK)
127
127
  return BREAK;
128
128
  else if (ck === REMOVE)
129
129
  node2.key = null;
130
- const cv = visit_("value", node2.value, visitor, path);
130
+ const cv = visit_("value", node2.value, visitor, path2);
131
131
  if (cv === BREAK)
132
132
  return BREAK;
133
133
  else if (cv === REMOVE)
@@ -148,17 +148,17 @@ var require_visit = __commonJS((exports) => {
148
148
  visitAsync.BREAK = BREAK;
149
149
  visitAsync.SKIP = SKIP;
150
150
  visitAsync.REMOVE = REMOVE;
151
- async function visitAsync_(key, node2, visitor, path) {
152
- const ctrl = await callVisitor(key, node2, visitor, path);
151
+ async function visitAsync_(key, node2, visitor, path2) {
152
+ const ctrl = await callVisitor(key, node2, visitor, path2);
153
153
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
154
- replaceNode(key, path, ctrl);
155
- return visitAsync_(key, ctrl, visitor, path);
154
+ replaceNode(key, path2, ctrl);
155
+ return visitAsync_(key, ctrl, visitor, path2);
156
156
  }
157
157
  if (typeof ctrl !== "symbol") {
158
158
  if (identity.isCollection(node2)) {
159
- path = Object.freeze(path.concat(node2));
159
+ path2 = Object.freeze(path2.concat(node2));
160
160
  for (let i = 0;i < node2.items.length; ++i) {
161
- const ci = await visitAsync_(i, node2.items[i], visitor, path);
161
+ const ci = await visitAsync_(i, node2.items[i], visitor, path2);
162
162
  if (typeof ci === "number")
163
163
  i = ci - 1;
164
164
  else if (ci === BREAK)
@@ -169,13 +169,13 @@ var require_visit = __commonJS((exports) => {
169
169
  }
170
170
  }
171
171
  } else if (identity.isPair(node2)) {
172
- path = Object.freeze(path.concat(node2));
173
- const ck = await visitAsync_("key", node2.key, visitor, path);
172
+ path2 = Object.freeze(path2.concat(node2));
173
+ const ck = await visitAsync_("key", node2.key, visitor, path2);
174
174
  if (ck === BREAK)
175
175
  return BREAK;
176
176
  else if (ck === REMOVE)
177
177
  node2.key = null;
178
- const cv = await visitAsync_("value", node2.value, visitor, path);
178
+ const cv = await visitAsync_("value", node2.value, visitor, path2);
179
179
  if (cv === BREAK)
180
180
  return BREAK;
181
181
  else if (cv === REMOVE)
@@ -202,23 +202,23 @@ var require_visit = __commonJS((exports) => {
202
202
  }
203
203
  return visitor;
204
204
  }
205
- function callVisitor(key, node2, visitor, path) {
205
+ function callVisitor(key, node2, visitor, path2) {
206
206
  if (typeof visitor === "function")
207
- return visitor(key, node2, path);
207
+ return visitor(key, node2, path2);
208
208
  if (identity.isMap(node2))
209
- return visitor.Map?.(key, node2, path);
209
+ return visitor.Map?.(key, node2, path2);
210
210
  if (identity.isSeq(node2))
211
- return visitor.Seq?.(key, node2, path);
211
+ return visitor.Seq?.(key, node2, path2);
212
212
  if (identity.isPair(node2))
213
- return visitor.Pair?.(key, node2, path);
213
+ return visitor.Pair?.(key, node2, path2);
214
214
  if (identity.isScalar(node2))
215
- return visitor.Scalar?.(key, node2, path);
215
+ return visitor.Scalar?.(key, node2, path2);
216
216
  if (identity.isAlias(node2))
217
- return visitor.Alias?.(key, node2, path);
217
+ return visitor.Alias?.(key, node2, path2);
218
218
  return;
219
219
  }
220
- function replaceNode(key, path, node2) {
221
- const parent = path[path.length - 1];
220
+ function replaceNode(key, path2, node2) {
221
+ const parent = path2[path2.length - 1];
222
222
  if (identity.isCollection(parent)) {
223
223
  parent.items[key] = node2;
224
224
  } else if (identity.isPair(parent)) {
@@ -775,10 +775,10 @@ var require_Collection = __commonJS((exports) => {
775
775
  var createNode = require_createNode();
776
776
  var identity = require_identity();
777
777
  var Node = require_Node();
778
- function collectionFromPath(schema, path, value) {
778
+ function collectionFromPath(schema, path2, value) {
779
779
  let v = value;
780
- for (let i = path.length - 1;i >= 0; --i) {
781
- const k = path[i];
780
+ for (let i = path2.length - 1;i >= 0; --i) {
781
+ const k = path2[i];
782
782
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
783
783
  const a = [];
784
784
  a[k] = v;
@@ -797,7 +797,7 @@ var require_Collection = __commonJS((exports) => {
797
797
  sourceObjects: new Map
798
798
  });
799
799
  }
800
- var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done;
800
+ var isEmptyPath = (path2) => path2 == null || typeof path2 === "object" && !!path2[Symbol.iterator]().next().done;
801
801
 
802
802
  class Collection extends Node.NodeBase {
803
803
  constructor(type, schema) {
@@ -818,11 +818,11 @@ var require_Collection = __commonJS((exports) => {
818
818
  copy.range = this.range.slice();
819
819
  return copy;
820
820
  }
821
- addIn(path, value) {
822
- if (isEmptyPath(path))
821
+ addIn(path2, value) {
822
+ if (isEmptyPath(path2))
823
823
  this.add(value);
824
824
  else {
825
- const [key, ...rest] = path;
825
+ const [key, ...rest] = path2;
826
826
  const node2 = this.get(key, true);
827
827
  if (identity.isCollection(node2))
828
828
  node2.addIn(rest, value);
@@ -832,8 +832,8 @@ var require_Collection = __commonJS((exports) => {
832
832
  throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
833
833
  }
834
834
  }
835
- deleteIn(path) {
836
- const [key, ...rest] = path;
835
+ deleteIn(path2) {
836
+ const [key, ...rest] = path2;
837
837
  if (rest.length === 0)
838
838
  return this.delete(key);
839
839
  const node2 = this.get(key, true);
@@ -842,8 +842,8 @@ var require_Collection = __commonJS((exports) => {
842
842
  else
843
843
  throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
844
844
  }
845
- getIn(path, keepScalar) {
846
- const [key, ...rest] = path;
845
+ getIn(path2, keepScalar) {
846
+ const [key, ...rest] = path2;
847
847
  const node2 = this.get(key, true);
848
848
  if (rest.length === 0)
849
849
  return !keepScalar && identity.isScalar(node2) ? node2.value : node2;
@@ -858,15 +858,15 @@ var require_Collection = __commonJS((exports) => {
858
858
  return n == null || allowScalar && identity.isScalar(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag;
859
859
  });
860
860
  }
861
- hasIn(path) {
862
- const [key, ...rest] = path;
861
+ hasIn(path2) {
862
+ const [key, ...rest] = path2;
863
863
  if (rest.length === 0)
864
864
  return this.has(key);
865
865
  const node2 = this.get(key, true);
866
866
  return identity.isCollection(node2) ? node2.hasIn(rest) : false;
867
867
  }
868
- setIn(path, value) {
869
- const [key, ...rest] = path;
868
+ setIn(path2, value) {
869
+ const [key, ...rest] = path2;
870
870
  if (rest.length === 0) {
871
871
  this.set(key, value);
872
872
  } else {
@@ -3248,9 +3248,9 @@ var require_Document = __commonJS((exports) => {
3248
3248
  if (assertCollection(this.contents))
3249
3249
  this.contents.add(value);
3250
3250
  }
3251
- addIn(path, value) {
3251
+ addIn(path2, value) {
3252
3252
  if (assertCollection(this.contents))
3253
- this.contents.addIn(path, value);
3253
+ this.contents.addIn(path2, value);
3254
3254
  }
3255
3255
  createAlias(node2, name) {
3256
3256
  if (!node2.anchor) {
@@ -3299,30 +3299,30 @@ var require_Document = __commonJS((exports) => {
3299
3299
  delete(key) {
3300
3300
  return assertCollection(this.contents) ? this.contents.delete(key) : false;
3301
3301
  }
3302
- deleteIn(path) {
3303
- if (Collection.isEmptyPath(path)) {
3302
+ deleteIn(path2) {
3303
+ if (Collection.isEmptyPath(path2)) {
3304
3304
  if (this.contents == null)
3305
3305
  return false;
3306
3306
  this.contents = null;
3307
3307
  return true;
3308
3308
  }
3309
- return assertCollection(this.contents) ? this.contents.deleteIn(path) : false;
3309
+ return assertCollection(this.contents) ? this.contents.deleteIn(path2) : false;
3310
3310
  }
3311
3311
  get(key, keepScalar) {
3312
3312
  return identity.isCollection(this.contents) ? this.contents.get(key, keepScalar) : undefined;
3313
3313
  }
3314
- getIn(path, keepScalar) {
3315
- if (Collection.isEmptyPath(path))
3314
+ getIn(path2, keepScalar) {
3315
+ if (Collection.isEmptyPath(path2))
3316
3316
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
3317
- return identity.isCollection(this.contents) ? this.contents.getIn(path, keepScalar) : undefined;
3317
+ return identity.isCollection(this.contents) ? this.contents.getIn(path2, keepScalar) : undefined;
3318
3318
  }
3319
3319
  has(key) {
3320
3320
  return identity.isCollection(this.contents) ? this.contents.has(key) : false;
3321
3321
  }
3322
- hasIn(path) {
3323
- if (Collection.isEmptyPath(path))
3322
+ hasIn(path2) {
3323
+ if (Collection.isEmptyPath(path2))
3324
3324
  return this.contents !== undefined;
3325
- return identity.isCollection(this.contents) ? this.contents.hasIn(path) : false;
3325
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path2) : false;
3326
3326
  }
3327
3327
  set(key, value) {
3328
3328
  if (this.contents == null) {
@@ -3331,13 +3331,13 @@ var require_Document = __commonJS((exports) => {
3331
3331
  this.contents.set(key, value);
3332
3332
  }
3333
3333
  }
3334
- setIn(path, value) {
3335
- if (Collection.isEmptyPath(path)) {
3334
+ setIn(path2, value) {
3335
+ if (Collection.isEmptyPath(path2)) {
3336
3336
  this.contents = value;
3337
3337
  } else if (this.contents == null) {
3338
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path), value);
3338
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path2), value);
3339
3339
  } else if (assertCollection(this.contents)) {
3340
- this.contents.setIn(path, value);
3340
+ this.contents.setIn(path2, value);
3341
3341
  }
3342
3342
  }
3343
3343
  setSchema(version, options = {}) {
@@ -5226,9 +5226,9 @@ var require_cst_visit = __commonJS((exports) => {
5226
5226
  visit.BREAK = BREAK;
5227
5227
  visit.SKIP = SKIP;
5228
5228
  visit.REMOVE = REMOVE;
5229
- visit.itemAtPath = (cst, path) => {
5229
+ visit.itemAtPath = (cst, path2) => {
5230
5230
  let item = cst;
5231
- for (const [field, index] of path) {
5231
+ for (const [field, index] of path2) {
5232
5232
  const tok = item?.[field];
5233
5233
  if (tok && "items" in tok) {
5234
5234
  item = tok.items[index];
@@ -5237,23 +5237,23 @@ var require_cst_visit = __commonJS((exports) => {
5237
5237
  }
5238
5238
  return item;
5239
5239
  };
5240
- visit.parentCollection = (cst, path) => {
5241
- const parent = visit.itemAtPath(cst, path.slice(0, -1));
5242
- const field = path[path.length - 1][0];
5240
+ visit.parentCollection = (cst, path2) => {
5241
+ const parent = visit.itemAtPath(cst, path2.slice(0, -1));
5242
+ const field = path2[path2.length - 1][0];
5243
5243
  const coll = parent?.[field];
5244
5244
  if (coll && "items" in coll)
5245
5245
  return coll;
5246
5246
  throw new Error("Parent collection not found");
5247
5247
  };
5248
- function _visit(path, item, visitor) {
5249
- let ctrl = visitor(item, path);
5248
+ function _visit(path2, item, visitor) {
5249
+ let ctrl = visitor(item, path2);
5250
5250
  if (typeof ctrl === "symbol")
5251
5251
  return ctrl;
5252
5252
  for (const field of ["key", "value"]) {
5253
5253
  const token = item[field];
5254
5254
  if (token && "items" in token) {
5255
5255
  for (let i = 0;i < token.items.length; ++i) {
5256
- const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
5256
+ const ci = _visit(Object.freeze(path2.concat([[field, i]])), token.items[i], visitor);
5257
5257
  if (typeof ci === "number")
5258
5258
  i = ci - 1;
5259
5259
  else if (ci === BREAK)
@@ -5264,10 +5264,10 @@ var require_cst_visit = __commonJS((exports) => {
5264
5264
  }
5265
5265
  }
5266
5266
  if (typeof ctrl === "function" && field === "key")
5267
- ctrl = ctrl(item, path);
5267
+ ctrl = ctrl(item, path2);
5268
5268
  }
5269
5269
  }
5270
- return typeof ctrl === "function" ? ctrl(item, path) : ctrl;
5270
+ return typeof ctrl === "function" ? ctrl(item, path2) : ctrl;
5271
5271
  }
5272
5272
  exports.visit = visit;
5273
5273
  });
@@ -7177,8 +7177,8 @@ var require_utils = __commonJS((exports) => {
7177
7177
  }
7178
7178
  return output;
7179
7179
  };
7180
- exports.basename = (path, { windows } = {}) => {
7181
- const segs = path.split(windows ? /[\\/]/ : "/");
7180
+ exports.basename = (path2, { windows } = {}) => {
7181
+ const segs = path2.split(windows ? /[\\/]/ : "/");
7182
7182
  const last = segs[segs.length - 1];
7183
7183
  if (last === "") {
7184
7184
  return segs[segs.length - 2];
@@ -8775,6 +8775,51 @@ var FactRelation;
8775
8775
  FactRelation2["Supersedes"] = "supersedes";
8776
8776
  FactRelation2["References"] = "references";
8777
8777
  })(FactRelation ||= {});
8778
+ // ../core/src/types/refPointer.ts
8779
+ var REF_POINTER_PATTERN = /^ref:(entity|relation|content):(.+)$/;
8780
+ function parseRef(pointer) {
8781
+ const match = REF_POINTER_PATTERN.exec(pointer);
8782
+ if (!match) {
8783
+ return null;
8784
+ }
8785
+ const [, type, id] = match;
8786
+ if (!id) {
8787
+ return null;
8788
+ }
8789
+ return { type, id };
8790
+ }
8791
+ function buildRef(type, id) {
8792
+ return `ref:${type}:${id}`;
8793
+ }
8794
+ function isRefPointer(value) {
8795
+ return typeof value === "string" && parseRef(value) !== null;
8796
+ }
8797
+ function extractAllRefs(data) {
8798
+ const results = [];
8799
+ const visit = (value, path) => {
8800
+ if (typeof value === "string") {
8801
+ if (isRefPointer(value)) {
8802
+ results.push({ pointer: value, fieldPath: path });
8803
+ }
8804
+ return;
8805
+ }
8806
+ if (Array.isArray(value)) {
8807
+ value.forEach((item, index) => {
8808
+ const nextPath = path ? `${path}[${index}]` : `[${index}]`;
8809
+ visit(item, nextPath);
8810
+ });
8811
+ return;
8812
+ }
8813
+ if (value && typeof value === "object") {
8814
+ for (const [key, entry] of Object.entries(value)) {
8815
+ const nextPath = path ? `${path}.${key}` : key;
8816
+ visit(entry, nextPath);
8817
+ }
8818
+ }
8819
+ };
8820
+ visit(data, "");
8821
+ return results;
8822
+ }
8778
8823
  // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
8779
8824
  var exports_external = {};
8780
8825
  __export(exports_external, {
@@ -12929,6 +12974,34 @@ var PathFilterConfigSchema = exports_external.object({
12929
12974
  exclude: exports_external.array(exports_external.string()).default([])
12930
12975
  }).default({})
12931
12976
  });
12977
+ var DEFAULT_PATH_FILTER = {
12978
+ package: {
12979
+ include: [
12980
+ "**/{package.json,pyproject.toml,setup.py,go.mod,Cargo.toml,pom.xml,build.gradle}"
12981
+ ]
12982
+ },
12983
+ code: {
12984
+ include: ["**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}"],
12985
+ exclude: [
12986
+ "**/__{tests,test,e2e,mocks,fixtures,snapshots}__/**",
12987
+ "**/*.{test,spec}.{ts,tsx,mts,cts,js,jsx,mjs,cjs}",
12988
+ "**/*.d.{ts,mts,cts}"
12989
+ ]
12990
+ },
12991
+ doc: {
12992
+ include: ["*.md", "docs/**/*.md"],
12993
+ exclude: ["**/CHANGELOG.md"]
12994
+ }
12995
+ };
12996
+ function resolvePathFilter(metadata) {
12997
+ const raw = metadata?.path_filter;
12998
+ if (raw == null)
12999
+ return { config: DEFAULT_PATH_FILTER, isDefault: true };
13000
+ const parsed = PathFilterConfigSchema.safeParse(raw);
13001
+ if (!parsed.success)
13002
+ return { config: DEFAULT_PATH_FILTER, isDefault: true };
13003
+ return { config: parsed.data, isDefault: false };
13004
+ }
12932
13005
  // ../core/src/schemas/baseSchema.ts
12933
13006
  var sourceRefSpanSchema = exports_external.object({
12934
13007
  start: exports_external.number().int().min(1),
@@ -13054,6 +13127,501 @@ var factSchema = exports_external.union([
13054
13127
  activeFactSchema,
13055
13128
  deprecatedFactSchema
13056
13129
  ]);
13130
+ // ../core/src/schemas/indexerEvidenceAdapterSchema.ts
13131
+ import { createHash } from "node:crypto";
13132
+
13133
+ // ../core/src/indexerOutputRedaction.ts
13134
+ var INDEXER_OUTPUT_REDACTION_MARKER = "[REDACTED:indexer-output]";
13135
+ var SECRET_TOKEN = /^(?:password|passwd|pwd|secret|token|credential|credentials|cookie)$/u;
13136
+ var SECRET_COMPOUND = /^(?:api-key|access-key|private-key|client-secret|access-token|refresh-token)$/u;
13137
+ var NON_SECRET_SUFFIX = new Set([
13138
+ "budget",
13139
+ "count",
13140
+ "digest",
13141
+ "fingerprint",
13142
+ "hash",
13143
+ "index",
13144
+ "kind",
13145
+ "length",
13146
+ "limit",
13147
+ "name",
13148
+ "ref",
13149
+ "reference",
13150
+ "references",
13151
+ "refs",
13152
+ "status",
13153
+ "type"
13154
+ ]);
13155
+ function keyTokens(key) {
13156
+ return key.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").replace(/[^A-Za-z0-9]+/gu, "-").toLowerCase().split("-").filter(Boolean);
13157
+ }
13158
+ function sensitiveKey(key, value) {
13159
+ const tokens = keyTokens(key);
13160
+ if (tokens.length === 0)
13161
+ return false;
13162
+ const normalized = tokens.join("-");
13163
+ if (normalized === "authorization" && value !== null && typeof value === "object") {
13164
+ return false;
13165
+ }
13166
+ if (NON_SECRET_SUFFIX.has(tokens.at(-1)))
13167
+ return false;
13168
+ return SECRET_COMPOUND.test(normalized) || tokens.some((token) => SECRET_TOKEN.test(token)) || normalized === "authorization";
13169
+ }
13170
+ function escapeRegExp(value) {
13171
+ return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
13172
+ }
13173
+ function normalizedBlockedScalars(policy) {
13174
+ const identities = new Set;
13175
+ const values = [];
13176
+ for (const value of policy.blocked_scalars ?? []) {
13177
+ if (typeof value === "number" && !Number.isFinite(value))
13178
+ continue;
13179
+ if (typeof value === "string" && value.length === 0)
13180
+ continue;
13181
+ const identity = `${typeof value}:${String(value)}`;
13182
+ if (identities.has(identity))
13183
+ continue;
13184
+ identities.add(identity);
13185
+ values.push(value);
13186
+ }
13187
+ return values.sort((left, right) => String(right).length - String(left).length);
13188
+ }
13189
+ function replaceWithCount(value, pattern, replacement, count) {
13190
+ return value.replace(pattern, (...args) => {
13191
+ count.replacements += 1;
13192
+ if (typeof replacement === "string")
13193
+ return replacement;
13194
+ return replacement(...args.slice(0, -2));
13195
+ });
13196
+ }
13197
+ function redactKnownText(value, count) {
13198
+ let output = value;
13199
+ output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
13200
+ output = replaceWithCount(output, /(\bauthorization\s*:\s*(?:bearer|basic)\s+)[^\s,;]+/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
13201
+ output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
13202
+ output = replaceWithCount(output, /([?&](?:access_token|refresh_token|api_key|password|secret)=)[^&#\s]+/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
13203
+ const key = "(?:[A-Za-z0-9_.-]*(?:password|passwd|pwd|secret|token|credential|cookie)[A-Za-z0-9_.-]*|api[-_]?key|access[-_]?(?:key|token)|private[-_]?key|client[-_]?secret|authorization)";
13204
+ const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
13205
+ output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
13206
+ return output;
13207
+ }
13208
+ function redactBlockedText(value, blocked, count) {
13209
+ let output = value;
13210
+ for (const scalar of blocked) {
13211
+ const pattern = typeof scalar === "number" ? new RegExp(`(?<![0-9.])${escapeRegExp(String(scalar))}(?![0-9.])`, "gu") : new RegExp(escapeRegExp(scalar), "gu");
13212
+ output = replaceWithCount(output, pattern, INDEXER_OUTPUT_REDACTION_MARKER, count);
13213
+ }
13214
+ return output;
13215
+ }
13216
+ function redactText(value, blocked, count) {
13217
+ return redactBlockedText(redactKnownText(value, count), blocked, count);
13218
+ }
13219
+ function blockedScalar(value, blocked) {
13220
+ return blocked.some((candidate) => typeof candidate === typeof value && Object.is(candidate, value));
13221
+ }
13222
+ function redactStructured(value, blocked, count, seen) {
13223
+ if (blockedScalar(value, blocked)) {
13224
+ count.replacements += 1;
13225
+ return INDEXER_OUTPUT_REDACTION_MARKER;
13226
+ }
13227
+ if (typeof value === "string")
13228
+ return redactText(value, blocked, count);
13229
+ if (value === null || typeof value !== "object")
13230
+ return value;
13231
+ if (seen.has(value))
13232
+ throw new TypeError("Indexer output redaction requires an acyclic value");
13233
+ seen.add(value);
13234
+ if (value instanceof Date) {
13235
+ const redacted2 = redactText(value.toISOString(), blocked, count);
13236
+ seen.delete(value);
13237
+ return redacted2;
13238
+ }
13239
+ if (value instanceof Error) {
13240
+ const redacted2 = {
13241
+ name: redactText(value.name, blocked, count),
13242
+ message: redactText(value.message, blocked, count)
13243
+ };
13244
+ seen.delete(value);
13245
+ return redacted2;
13246
+ }
13247
+ if (Array.isArray(value)) {
13248
+ const redacted2 = value.map((item) => redactStructured(item, blocked, count, seen));
13249
+ seen.delete(value);
13250
+ return redacted2;
13251
+ }
13252
+ const redacted = {};
13253
+ for (const [key, item] of Object.entries(value)) {
13254
+ const safeKey = redactText(key, blocked, count);
13255
+ if (sensitiveKey(key, item)) {
13256
+ count.replacements += 1;
13257
+ redacted[safeKey] = INDEXER_OUTPUT_REDACTION_MARKER;
13258
+ } else {
13259
+ redacted[safeKey] = redactStructured(item, blocked, count, seen);
13260
+ }
13261
+ }
13262
+ seen.delete(value);
13263
+ return redacted;
13264
+ }
13265
+ function redactIndexerOutput(input) {
13266
+ const count = { replacements: 0 };
13267
+ const blocked = normalizedBlockedScalars(input.policy ?? {});
13268
+ const value = typeof input.value === "string" ? redactText(input.value, blocked, count) : redactStructured(input.value, blocked, count, new WeakSet);
13269
+ return {
13270
+ value,
13271
+ redacted: count.replacements > 0,
13272
+ replacement_count: count.replacements
13273
+ };
13274
+ }
13275
+ function redactIndexerOutputText(input) {
13276
+ return redactIndexerOutput(input).value;
13277
+ }
13278
+ function assertIndexerOutputSafe(input) {
13279
+ const result = redactIndexerOutput(input);
13280
+ if (result.redacted) {
13281
+ throw new TypeError(`Indexer ${input.channel} was blocked by the common output redaction boundary`);
13282
+ }
13283
+ return input.value;
13284
+ }
13285
+
13286
+ // ../core/src/schemas/indexerEvidenceAdapterSchema.ts
13287
+ var digestSchema = exports_external.string().regex(/^sha256:[a-f0-9]{64}$/u);
13288
+ var idSchema = exports_external.string().regex(/^[a-z0-9][a-z0-9._/-]*$/u).superRefine((value, context) => {
13289
+ if (value.split("/").some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
13290
+ context.addIssue({
13291
+ code: exports_external.ZodIssueCode.custom,
13292
+ message: "must not contain empty, current-directory, or parent-directory segments"
13293
+ });
13294
+ }
13295
+ });
13296
+ var semverSchema = exports_external.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u);
13297
+ var canonicalRefSchema = exports_external.string().regex(/^[a-z][a-z0-9.-]*:[A-Za-z0-9][A-Za-z0-9._~:/#@+-]*$/u);
13298
+ var packageCoordinateSchema = exports_external.string().regex(/^(?:@[a-z0-9._-]+\/)?[a-z0-9][a-z0-9._-]*$/u);
13299
+ var portablePathSchema = exports_external.string().superRefine((value, context) => {
13300
+ const segments = value.split("/");
13301
+ if (value.length === 0 || value.includes("\x00") || value.includes("\\") || value.startsWith("/") || /^[A-Za-z]:\//u.test(value) || segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
13302
+ context.addIssue({
13303
+ code: exports_external.ZodIssueCode.custom,
13304
+ message: "must be a portable relative path"
13305
+ });
13306
+ }
13307
+ });
13308
+ function addDuplicateIssues(values, context, field) {
13309
+ const seen = new Set;
13310
+ values.forEach((value, index) => {
13311
+ if (seen.has(value)) {
13312
+ context.addIssue({
13313
+ code: exports_external.ZodIssueCode.custom,
13314
+ message: `${field} must not contain duplicate value ${value}`,
13315
+ path: [index]
13316
+ });
13317
+ }
13318
+ seen.add(value);
13319
+ });
13320
+ }
13321
+ var adapterIdentitySchema = exports_external.object({
13322
+ id: idSchema,
13323
+ package: packageCoordinateSchema,
13324
+ export: exports_external.string().regex(/^[A-Za-z_$][A-Za-z0-9_$.-]*$/u),
13325
+ version: semverSchema,
13326
+ digest: digestSchema
13327
+ }).strict();
13328
+ var adapterLocatorSchema = exports_external.object({
13329
+ source_ref: canonicalRefSchema,
13330
+ module_ref: canonicalRefSchema.nullable(),
13331
+ normalized_path: portablePathSchema,
13332
+ qualified_item_path: exports_external.string().min(1).max(1024),
13333
+ signature_digest: digestSchema
13334
+ }).strict();
13335
+ var indexerEvidenceAdapterFactSchema = exports_external.object({
13336
+ fact_ref: canonicalRefSchema,
13337
+ kind: idSchema,
13338
+ locator: adapterLocatorSchema,
13339
+ payload_digest: digestSchema,
13340
+ denominator: exports_external.enum(["none", "eligible-file", "loc", "symbol", "protocol-item"])
13341
+ }).strict();
13342
+ var indexerEvidenceAdapterFileSchema = exports_external.object({
13343
+ file_ref: canonicalRefSchema,
13344
+ source_ref: canonicalRefSchema,
13345
+ module_ref: canonicalRefSchema.nullable(),
13346
+ normalized_path: portablePathSchema,
13347
+ role: exports_external.enum(["primary-owner", "enricher"]),
13348
+ coverage_tier: exports_external.enum(["ast-catalog", "lightweight-evidence"]),
13349
+ disposition: exports_external.enum(["analyzed", "unsupported", "excluded"]),
13350
+ facts: exports_external.array(indexerEvidenceAdapterFactSchema)
13351
+ }).strict().superRefine((value, context) => {
13352
+ addDuplicateIssues(value.facts.map((fact2) => fact2.fact_ref), context, "facts");
13353
+ if (value.disposition !== "analyzed" && value.facts.length > 0) {
13354
+ context.addIssue({
13355
+ code: exports_external.ZodIssueCode.custom,
13356
+ message: "unsupported or excluded files cannot publish facts",
13357
+ path: ["facts"]
13358
+ });
13359
+ }
13360
+ if ((value.role === "enricher" || value.coverage_tier === "lightweight-evidence") && value.facts.some((fact2) => fact2.denominator !== "none")) {
13361
+ context.addIssue({
13362
+ code: exports_external.ZodIssueCode.custom,
13363
+ message: "enricher and lightweight evidence facts cannot contribute denominators",
13364
+ path: ["facts"]
13365
+ });
13366
+ }
13367
+ });
13368
+ var toolchainStepSchema = exports_external.object({
13369
+ step: idSchema,
13370
+ package: packageCoordinateSchema,
13371
+ export: exports_external.string().regex(/^[A-Za-z_$][A-Za-z0-9_$.-]*$/u),
13372
+ version: semverSchema,
13373
+ digest: digestSchema,
13374
+ capabilities: exports_external.array(idSchema).min(1),
13375
+ input_digest: digestSchema,
13376
+ output_digest: digestSchema
13377
+ }).strict().superRefine((value, context) => {
13378
+ addDuplicateIssues(value.capabilities, context, "capabilities");
13379
+ });
13380
+ var adapterDiagnosticSchema = exports_external.object({
13381
+ code: idSchema,
13382
+ fact_ref: canonicalRefSchema.optional(),
13383
+ severity: exports_external.enum(["info", "warning", "error"]),
13384
+ detail_digest: digestSchema
13385
+ }).strict();
13386
+ var indexerEvidenceAdapterResultSchema = exports_external.object({
13387
+ protocol: exports_external.literal("context.indexer.evidence-adapter-result/v1"),
13388
+ adapter: adapterIdentitySchema,
13389
+ authorized_scope: exports_external.object({
13390
+ source_ref: canonicalRefSchema,
13391
+ module_refs: exports_external.array(canonicalRefSchema),
13392
+ scope_digest: digestSchema
13393
+ }).strict(),
13394
+ input_digest: digestSchema,
13395
+ precedence: exports_external.number().int().nonnegative(),
13396
+ files: exports_external.array(indexerEvidenceAdapterFileSchema).min(1),
13397
+ diagnostics: exports_external.array(adapterDiagnosticSchema),
13398
+ toolchain: exports_external.array(toolchainStepSchema).min(1),
13399
+ output_digest: digestSchema
13400
+ }).strict().superRefine((value, context) => {
13401
+ addDuplicateIssues(value.authorized_scope.module_refs, context, "authorized_scope.module_refs");
13402
+ addDuplicateIssues(value.files.map((file) => file.file_ref), context, "files");
13403
+ addDuplicateIssues(value.toolchain.map((step) => step.step), context, "toolchain");
13404
+ });
13405
+ var FACT_PAYLOADS = new WeakMap;
13406
+ function canonicalFactPayload(value, seen = new WeakSet, path = "$") {
13407
+ if (value === null || typeof value === "boolean" || typeof value === "string") {
13408
+ return value;
13409
+ }
13410
+ if (typeof value === "number") {
13411
+ if (!Number.isFinite(value)) {
13412
+ throw new TypeError("Indexer Evidence Adapter fact payload numbers must be finite");
13413
+ }
13414
+ return value;
13415
+ }
13416
+ if (typeof value !== "object") {
13417
+ throw new TypeError(`Indexer Evidence Adapter fact payload ${path} must contain only JSON values`);
13418
+ }
13419
+ if (seen.has(value)) {
13420
+ throw new TypeError(`Indexer Evidence Adapter fact payload ${path} must be acyclic`);
13421
+ }
13422
+ seen.add(value);
13423
+ if (Array.isArray(value)) {
13424
+ const output2 = value.map((item, index) => canonicalFactPayload(item, seen, `${path}[${index}]`));
13425
+ seen.delete(value);
13426
+ return output2;
13427
+ }
13428
+ if (Object.prototype.toString.call(value) !== "[object Object]") {
13429
+ throw new TypeError(`Indexer Evidence Adapter fact payload ${path} must use plain JSON objects; received ${Object.prototype.toString.call(value)}`);
13430
+ }
13431
+ const output = {};
13432
+ for (const [key, item] of Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0)) {
13433
+ output[key] = canonicalFactPayload(item, seen, `${path}.${key}`);
13434
+ }
13435
+ seen.delete(value);
13436
+ return output;
13437
+ }
13438
+ function canonicalize(value) {
13439
+ if (Array.isArray(value))
13440
+ return value.map(canonicalize);
13441
+ if (value !== null && typeof value === "object") {
13442
+ return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => [key, canonicalize(item)]));
13443
+ }
13444
+ return value;
13445
+ }
13446
+ function indexerEvidenceAdapterProtocolDigest(value) {
13447
+ const canonical = JSON.stringify(canonicalize(value));
13448
+ return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
13449
+ }
13450
+ function indexerEvidenceAdapterFileRef(input) {
13451
+ return `adapter-file:${indexerEvidenceAdapterProtocolDigest(input)}`;
13452
+ }
13453
+ function indexerEvidenceAdapterFactRef(input) {
13454
+ return `adapter-fact:${indexerEvidenceAdapterProtocolDigest(input)}`;
13455
+ }
13456
+ function createIndexerEvidenceAdapterFact(input) {
13457
+ const payload = canonicalFactPayload(input.payload);
13458
+ const qualifiedItemPath = input.qualified_item_path.length <= 1024 ? input.qualified_item_path : `${input.qualified_item_path.slice(0, 950)}#${indexerEvidenceAdapterProtocolDigest(input.qualified_item_path)}`;
13459
+ const locator = {
13460
+ source_ref: input.source_ref,
13461
+ module_ref: input.module_ref,
13462
+ normalized_path: input.normalized_path,
13463
+ qualified_item_path: qualifiedItemPath,
13464
+ signature_digest: indexerEvidenceAdapterProtocolDigest(input.signature)
13465
+ };
13466
+ const fact2 = {
13467
+ fact_ref: indexerEvidenceAdapterFactRef({ ...locator, kind: input.kind }),
13468
+ kind: input.kind,
13469
+ locator,
13470
+ payload_digest: indexerEvidenceAdapterProtocolDigest(payload),
13471
+ denominator: input.denominator
13472
+ };
13473
+ FACT_PAYLOADS.set(fact2, payload);
13474
+ return fact2;
13475
+ }
13476
+ function indexerEvidenceAdapterFactPayloads(result) {
13477
+ const payloads = result.files.flatMap((file) => file.facts.map((fact2) => {
13478
+ const payload = FACT_PAYLOADS.get(fact2);
13479
+ if (payload === undefined) {
13480
+ throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is no longer materialized in this process`);
13481
+ }
13482
+ if (indexerEvidenceAdapterProtocolDigest(payload) !== fact2.payload_digest) {
13483
+ throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is stale`);
13484
+ }
13485
+ return { fact_ref: fact2.fact_ref, payload };
13486
+ })).sort((left, right) => compareCanonicalText(left.fact_ref, right.fact_ref));
13487
+ return assertIndexerOutputSafe({ channel: "ipc-envelope", value: payloads });
13488
+ }
13489
+ function materializeIndexerEvidenceAdapterResult(result) {
13490
+ return {
13491
+ result,
13492
+ fact_payloads: indexerEvidenceAdapterFactPayloads(result)
13493
+ };
13494
+ }
13495
+ function indexerEvidenceAdapterOutputDigest(value) {
13496
+ return indexerEvidenceAdapterProtocolDigest(value);
13497
+ }
13498
+ function compareCanonicalText(left, right) {
13499
+ if (left < right)
13500
+ return -1;
13501
+ if (left > right)
13502
+ return 1;
13503
+ return 0;
13504
+ }
13505
+ function buildIndexerEvidenceAdapterResult(input) {
13506
+ const canonical = {
13507
+ ...input,
13508
+ authorized_scope: {
13509
+ ...input.authorized_scope,
13510
+ module_refs: [...input.authorized_scope.module_refs].sort(compareCanonicalText)
13511
+ },
13512
+ files: input.files.map((file) => ({
13513
+ ...file,
13514
+ facts: [...file.facts].sort((left, right) => compareCanonicalText(left.fact_ref, right.fact_ref))
13515
+ })).sort((left, right) => compareCanonicalText(left.file_ref, right.file_ref)),
13516
+ diagnostics: [...input.diagnostics].sort((left, right) => compareCanonicalText(left.fact_ref ?? "", right.fact_ref ?? "") || compareCanonicalText(left.code, right.code) || compareCanonicalText(left.severity, right.severity) || compareCanonicalText(left.detail_digest, right.detail_digest)),
13517
+ toolchain: input.toolchain.map((step) => ({
13518
+ ...step,
13519
+ capabilities: [...step.capabilities].sort(compareCanonicalText)
13520
+ }))
13521
+ };
13522
+ const payloads = new Map;
13523
+ for (const file of canonical.files) {
13524
+ for (const fact2 of file.facts) {
13525
+ const payload = FACT_PAYLOADS.get(fact2);
13526
+ if (payload !== undefined)
13527
+ payloads.set(fact2.fact_ref, payload);
13528
+ }
13529
+ }
13530
+ const parsed = indexerEvidenceAdapterResultSchema.parse({
13531
+ ...canonical,
13532
+ output_digest: indexerEvidenceAdapterOutputDigest(canonical)
13533
+ });
13534
+ for (const file of parsed.files) {
13535
+ for (const fact2 of file.facts) {
13536
+ const payload = payloads.get(fact2.fact_ref);
13537
+ if (payload !== undefined)
13538
+ FACT_PAYLOADS.set(fact2, payload);
13539
+ }
13540
+ }
13541
+ return assertIndexerOutputSafe({ channel: "success-payload", value: parsed });
13542
+ }
13543
+ // ../core/src/errors/c4aError.ts
13544
+ class C4AError extends Error {
13545
+ code;
13546
+ details;
13547
+ constructor(code, message, details, options) {
13548
+ super(message, options);
13549
+ this.name = "C4AError";
13550
+ this.code = code;
13551
+ this.details = details;
13552
+ }
13553
+ toResponse() {
13554
+ if (this.details === undefined) {
13555
+ return { code: this.code, message: this.message };
13556
+ }
13557
+ return { code: this.code, message: this.message, details: this.details };
13558
+ }
13559
+ }
13560
+ // ../core/src/errors/errorCodes.ts
13561
+ var ErrorCode;
13562
+ ((ErrorCode2) => {
13563
+ ErrorCode2["VALIDATION_FAILED"] = "VALIDATION_FAILED";
13564
+ ErrorCode2["VALIDATION_SCHEMA"] = "VALIDATION_SCHEMA";
13565
+ ErrorCode2["STORAGE_FAILED"] = "STORAGE_FAILED";
13566
+ ErrorCode2["STORAGE_NOT_FOUND"] = "STORAGE_NOT_FOUND";
13567
+ ErrorCode2["STORAGE_CONFLICT"] = "STORAGE_CONFLICT";
13568
+ ErrorCode2["PARSE_FAILED"] = "PARSE_FAILED";
13569
+ ErrorCode2["PARSE_YAML"] = "PARSE_YAML";
13570
+ ErrorCode2["API_NOT_IMPLEMENTED"] = "API_NOT_IMPLEMENTED";
13571
+ ErrorCode2["API_UNAUTHORIZED"] = "API_UNAUTHORIZED";
13572
+ ErrorCode2["API_RATE_LIMITED"] = "API_RATE_LIMITED";
13573
+ ErrorCode2["ENTITY_NOT_FOUND"] = "ENTITY_NOT_FOUND";
13574
+ ErrorCode2["ENTITY_DUPLICATE"] = "ENTITY_DUPLICATE";
13575
+ ErrorCode2["RELATION_INVALID"] = "RELATION_INVALID";
13576
+ ErrorCode2["BATCH_PARTIAL_FAILURE"] = "BATCH_PARTIAL_FAILURE";
13577
+ ErrorCode2["QUERY_INVALID_PARAMS"] = "QUERY_INVALID_PARAMS";
13578
+ ErrorCode2["BACKUP_FAILED"] = "BACKUP_FAILED";
13579
+ ErrorCode2["RESTORE_FAILED"] = "RESTORE_FAILED";
13580
+ ErrorCode2["PURGE_FAILED"] = "PURGE_FAILED";
13581
+ ErrorCode2["BACKUP_VERSION_INCOMPATIBLE"] = "BACKUP_VERSION_INCOMPATIBLE";
13582
+ ErrorCode2["BACKUP_MANIFEST_INVALID"] = "BACKUP_MANIFEST_INVALID";
13583
+ ErrorCode2["BACKUP_DIR_NOT_FOUND"] = "BACKUP_DIR_NOT_FOUND";
13584
+ ErrorCode2["EMBEDDING_NOT_AVAILABLE"] = "EMBEDDING_NOT_AVAILABLE";
13585
+ ErrorCode2["EMBEDDING_FAILED"] = "EMBEDDING_FAILED";
13586
+ ErrorCode2["LLM_NOT_AVAILABLE"] = "LLM_NOT_AVAILABLE";
13587
+ ErrorCode2["LLM_CALL_FAILED"] = "LLM_CALL_FAILED";
13588
+ ErrorCode2["LLM_AUTH_FAILED"] = "LLM_AUTH_FAILED";
13589
+ ErrorCode2["AUTH_REQUIRED"] = "AUTH_REQUIRED";
13590
+ ErrorCode2["AUTH_INVALID_TOKEN"] = "AUTH_INVALID_TOKEN";
13591
+ ErrorCode2["AUTH_INVALID_API_KEY"] = "AUTH_INVALID_API_KEY";
13592
+ ErrorCode2["AUTH_PROVIDER_ERROR"] = "AUTH_PROVIDER_ERROR";
13593
+ ErrorCode2["AUTH_RESERVED_NAME"] = "AUTH_RESERVED_NAME";
13594
+ ErrorCode2["DAEMON_OFFLINE"] = "DAEMON_OFFLINE";
13595
+ ErrorCode2["SOURCE_NOT_FOUND"] = "SOURCE_NOT_FOUND";
13596
+ ErrorCode2["REPO_PATH_NOT_FOUND"] = "REPO_PATH_NOT_FOUND";
13597
+ ErrorCode2["COMMIT_NOT_FOUND"] = "COMMIT_NOT_FOUND";
13598
+ ErrorCode2["INDEX_IN_PROGRESS"] = "INDEX_IN_PROGRESS";
13599
+ ErrorCode2["DIGEST_NOT_FOUND"] = "DIGEST_NOT_FOUND";
13600
+ ErrorCode2["INVALID_REGEX"] = "INVALID_REGEX";
13601
+ ErrorCode2["SOURCE_ACCESS_DENIED"] = "SOURCE_ACCESS_DENIED";
13602
+ ErrorCode2["NOT_INDEXED"] = "NOT_INDEXED";
13603
+ ErrorCode2["QUERY_TIMEOUT"] = "QUERY_TIMEOUT";
13604
+ ErrorCode2["INTENT_NOT_AVAILABLE"] = "INTENT_NOT_AVAILABLE";
13605
+ ErrorCode2["SUB_PATH_CONFLICT"] = "SUB_PATH_CONFLICT";
13606
+ ErrorCode2["WORKSPACE_ISOLATION"] = "WORKSPACE_ISOLATION";
13607
+ ErrorCode2["VECTOR_DIMENSION_MISMATCH"] = "VECTOR_DIMENSION_MISMATCH";
13608
+ ErrorCode2["VECTOR_REBUILD_PARTIAL"] = "VECTOR_REBUILD_PARTIAL";
13609
+ ErrorCode2["COMMIT_NOT_AVAILABLE"] = "COMMIT_NOT_AVAILABLE";
13610
+ ErrorCode2["DAEMON_AUTO_START_FAILED"] = "DAEMON_AUTO_START_FAILED";
13611
+ ErrorCode2["GIT_ARCHIVE_FAILED"] = "GIT_ARCHIVE_FAILED";
13612
+ ErrorCode2["GIT_HOST_NOT_CONFIGURED"] = "GIT_HOST_NOT_CONFIGURED";
13613
+ ErrorCode2["GIT_API_RATE_LIMITED"] = "GIT_API_RATE_LIMITED";
13614
+ ErrorCode2["GIT_API_TREE_TRUNCATED"] = "GIT_API_TREE_TRUNCATED";
13615
+ ErrorCode2["GIT_API_AUTH_FAILED"] = "GIT_API_AUTH_FAILED";
13616
+ ErrorCode2["GIT_API_REPO_NOT_FOUND"] = "GIT_API_REPO_NOT_FOUND";
13617
+ ErrorCode2["GIT_API_NETWORK_ERROR"] = "GIT_API_NETWORK_ERROR";
13618
+ ErrorCode2["DOC_INDEX_LLM_UNAVAILABLE"] = "DOC_INDEX_LLM_UNAVAILABLE";
13619
+ ErrorCode2["DOC_INDEX_EMBEDDING_UNAVAILABLE"] = "DOC_INDEX_EMBEDDING_UNAVAILABLE";
13620
+ ErrorCode2["DOC_INDEX_CONTENT_MISSING"] = "DOC_INDEX_CONTENT_MISSING";
13621
+ ErrorCode2["DOC_INDEX_PARSE_FAILED"] = "DOC_INDEX_PARSE_FAILED";
13622
+ ErrorCode2["DOC_INDEX_LLM_EXHAUSTED"] = "DOC_INDEX_LLM_EXHAUSTED";
13623
+ ErrorCode2["UNKNOWN"] = "UNKNOWN";
13624
+ })(ErrorCode ||= {});
13057
13625
  // ../core/src/errors/httpStatus.ts
13058
13626
  var ERROR_CODE_HTTP_STATUS = {
13059
13627
  ["VALIDATION_FAILED" /* VALIDATION_FAILED */]: 400,
@@ -13118,21 +13686,102 @@ var ERROR_CODE_HTTP_STATUS = {
13118
13686
  ["UNKNOWN" /* UNKNOWN */]: 500,
13119
13687
  ["WORKSPACE_ISOLATION" /* WORKSPACE_ISOLATION */]: 400
13120
13688
  };
13689
+ function mapErrorCodeToStatus(code) {
13690
+ return ERROR_CODE_HTTP_STATUS[code] ?? 500;
13691
+ }
13692
+ // ../core/src/utils/id.ts
13693
+ import { createHash as createHash2, randomUUID } from "node:crypto";
13694
+ function generateId(type, parentId, name) {
13695
+ const input = `${type}:${parentId}:${name}`;
13696
+ const hash = createHash2("sha256").update(input).digest("hex");
13697
+ const hex32 = hash.slice(0, 32);
13698
+ return `${type}_${hex32}`;
13699
+ }
13700
+ function generateUUID() {
13701
+ return randomUUID();
13702
+ }
13121
13703
  // ../core/src/utils/hash.ts
13122
- import { createHash } from "node:crypto";
13704
+ import { createHash as createHash3 } from "node:crypto";
13123
13705
  function contentHash(content) {
13124
- return createHash("sha256").update(content).digest("hex");
13706
+ return createHash3("sha256").update(content).digest("hex");
13707
+ }
13708
+ // ../core/src/utils/object.ts
13709
+ function isPlainObject(value) {
13710
+ return typeof value === "object" && value !== null && !Array.isArray(value);
13711
+ }
13712
+ function mergeDefaults(defaults, override) {
13713
+ const result = { ...defaults };
13714
+ for (const [key, value] of Object.entries(override)) {
13715
+ if (!(key in defaults))
13716
+ continue;
13717
+ const defaultValue = defaults[key];
13718
+ if (isPlainObject(defaultValue)) {
13719
+ if (isPlainObject(value)) {
13720
+ result[key] = mergeDefaults(defaultValue, value);
13721
+ }
13722
+ } else if (value !== undefined && value !== null) {
13723
+ result[key] = value;
13724
+ }
13725
+ }
13726
+ return result;
13727
+ }
13728
+ // ../core/src/utils/path.ts
13729
+ import path from "node:path";
13730
+ function isPathSafe(inputPath) {
13731
+ if (inputPath.length === 0) {
13732
+ return false;
13733
+ }
13734
+ if (inputPath.includes("\x00")) {
13735
+ return false;
13736
+ }
13737
+ if (path.isAbsolute(inputPath)) {
13738
+ return false;
13739
+ }
13740
+ if (/^[a-zA-Z]:/.test(inputPath)) {
13741
+ return false;
13742
+ }
13743
+ if (inputPath.startsWith("~")) {
13744
+ return false;
13745
+ }
13746
+ const normalized = path.posix.normalize(inputPath.replaceAll("\\", "/"));
13747
+ const parts = normalized.split("/");
13748
+ return !parts.some((part) => part === ".." || part === "");
13125
13749
  }
13126
13750
  // ../core/src/utils/yaml.ts
13127
13751
  var import_yaml = __toESM(require_dist(), 1);
13752
+ function serializeYaml(value) {
13753
+ return import_yaml.default.stringify(value);
13754
+ }
13755
+ function parseYaml(value) {
13756
+ try {
13757
+ return import_yaml.default.parse(value);
13758
+ } catch (error) {
13759
+ const message = error instanceof Error ? error.message : "Failed to parse YAML";
13760
+ throw new C4AError("PARSE_YAML" /* PARSE_YAML */, message, { input: value });
13761
+ }
13762
+ }
13128
13763
  // ../core/src/utils/glob.ts
13129
13764
  var import_picomatch = __toESM(require_picomatch2(), 1);
13765
+ var globToRegex = (glob) => import_picomatch.default.makeRe(glob, { dot: false });
13130
13766
  function createPathMatcher(rules) {
13131
13767
  if (rules.include.length === 0)
13132
13768
  return () => false;
13133
13769
  const isIncluded = import_picomatch.default(rules.include, { dot: false });
13134
13770
  const isExcluded = rules.exclude.length > 0 ? import_picomatch.default(rules.exclude, { dot: false }) : () => false;
13135
- return (path) => isIncluded(path) && !isExcluded(path);
13771
+ return (path2) => isIncluded(path2) && !isExcluded(path2);
13772
+ }
13773
+ function matchesPathFilter(path2, category, config) {
13774
+ const section = config[category];
13775
+ const include = section.include;
13776
+ const exclude = "exclude" in section ? section.exclude : [];
13777
+ if (include.length === 0)
13778
+ return false;
13779
+ const isIncluded = import_picomatch.default.isMatch(path2, include, { dot: false });
13780
+ if (!isIncluded)
13781
+ return false;
13782
+ if (exclude.length > 0 && import_picomatch.default.isMatch(path2, exclude, { dot: false }))
13783
+ return false;
13784
+ return true;
13136
13785
  }
13137
13786
  // ../core/src/utils/version.ts
13138
13787
  var VERSION_LABEL_REGEX = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(alpha|beta|rc)\.(0|[1-9]\d*))?$/i;
@@ -13169,7 +13818,38 @@ function encodeVersionLabel(label) {
13169
13818
  }
13170
13819
  return major * 1e6 + minor * 1e4 + patch * 100 + prerelease;
13171
13820
  }
13821
+ function isVersionVisible(record, versionCode) {
13822
+ if (versionCode == null) {
13823
+ return true;
13824
+ }
13825
+ return (record.valid_from == null || record.valid_from <= versionCode) && (record.valid_until == null || record.valid_until > versionCode);
13826
+ }
13827
+ // ../core/src/utils/factContent.ts
13828
+ var SEARCH_PREFIX_RE = /^\[c4a:search [^\]\n]+\]\n\n/;
13829
+ function buildSearchPrefix(keywords) {
13830
+ if (!keywords || keywords.length === 0)
13831
+ return "";
13832
+ const cleaned = keywords.map((k) => k.trim()).filter((k) => k.length > 0);
13833
+ if (cleaned.length === 0)
13834
+ return "";
13835
+ return `[c4a:search ${cleaned.join(" ")}]
13836
+
13837
+ `;
13838
+ }
13839
+ function stripSearchPrefix(content) {
13840
+ if (!content)
13841
+ return content ?? "";
13842
+ return content.replace(SEARCH_PREFIX_RE, "");
13843
+ }
13172
13844
  // ../core/src/constants.ts
13845
+ var DEFAULT_WORKSPACE_NAME = "My Brain";
13846
+ var DEFAULT_CLOUD_LIBRARY_NAME = "My Drive";
13847
+ var SUPERTEST_EMAIL = "supertest@context4ai.org";
13848
+ var SUPERTEST_USER_NAME = "SuperTest";
13849
+ var RESERVED_USER_NAMES = ["SuperTest"];
13850
+ var DAEMON_HEARTBEAT_INTERVAL = 30000;
13851
+ var DAEMON_OFFLINE_THRESHOLD = 60000;
13852
+ var CLOUD_DAEMON_IDLE_TIMEOUT = 300000;
13173
13853
  var SCAN_EXCLUDED_DIRS = new Set([
13174
13854
  ".git",
13175
13855
  ".svn",
@@ -13205,6 +13885,17 @@ var SCAN_EXCLUDED_DIRS = new Set([
13205
13885
  "fixtures",
13206
13886
  ".tmp"
13207
13887
  ]);
13888
+ var CODE_DIGEST_TYPE = "code_tc_b";
13889
+ var hasExcludedSegment = (filePath) => {
13890
+ const segments = filePath.split("/");
13891
+ for (let i = 0;i < segments.length - 1; i++) {
13892
+ const seg = segments[i];
13893
+ if (SCAN_EXCLUDED_DIRS.has(seg) || seg.startsWith(".") && seg !== "." || seg.endsWith(".egg-info")) {
13894
+ return true;
13895
+ }
13896
+ }
13897
+ return false;
13898
+ };
13208
13899
  // ../core/src/contentTypeRegistry.ts
13209
13900
  var DEFAULT_CONTENT_TYPES = [
13210
13901
  {
@@ -13218,7 +13909,15 @@ var DEFAULT_CONTENT_TYPES = [
13218
13909
  {
13219
13910
  id: "typescript",
13220
13911
  category: "code",
13221
- match: { extensions: [".ts", ".tsx"] },
13912
+ match: { extensions: [".ts", ".tsx", ".mts", ".cts"] },
13913
+ cas: { encoding: "utf8", hashInput: "content" },
13914
+ pipeline: { digest: ["ast", "summary"], extraction: ["entities", "relations"] },
13915
+ display: { icon: "\uD83D\uDCDC", renderer: "code" }
13916
+ },
13917
+ {
13918
+ id: "javascript",
13919
+ category: "code",
13920
+ match: { extensions: [".js", ".jsx", ".mjs", ".cjs"] },
13222
13921
  cas: { encoding: "utf8", hashInput: "content" },
13223
13922
  pipeline: { digest: ["ast", "summary"], extraction: ["entities", "relations"] },
13224
13923
  display: { icon: "\uD83D\uDCDC", renderer: "code" }
@@ -13326,6 +14025,15 @@ var INDEXABLE_EXTENSIONS = new Set([
13326
14025
  var UPLOAD_ALLOWED_EXTENSIONS = collectExtensions(() => true);
13327
14026
  var TEXT_EXTENSIONS = collectExtensions((definition) => definition.cas.encoding === "utf8");
13328
14027
  var UPLOAD_MAX_FILE_SIZE = 5 * 1024 * 1024;
14028
+ var UPLOAD_MAX_FILES = 20;
14029
+ function getFileExtension(name) {
14030
+ const dot = name.lastIndexOf(".");
14031
+ return dot >= 0 ? name.slice(dot).toLowerCase() : "";
14032
+ }
14033
+ function isIndexableFile(fileName, manifestFiles) {
14034
+ const baseName = fileName.includes("/") ? fileName.split("/").pop() : fileName;
14035
+ return defaultRegistry.resolve(baseName) !== null;
14036
+ }
13329
14037
  // src/types.ts
13330
14038
  var symbolKindSchema2 = exports_external.enum(Object.values(SymbolKind));
13331
14039
  var visibilitySchema2 = exports_external.enum(Object.values(Visibility));
@@ -13385,6 +14093,23 @@ var fileInfoSchema = exports_external.object({
13385
14093
  language: exports_external.string().min(1),
13386
14094
  lines: exports_external.number().int().nonnegative()
13387
14095
  });
14096
+ var extractionDiagnosticSchema = exports_external.object({
14097
+ code: exports_external.string().min(1),
14098
+ severity: exports_external.enum(["info", "warning", "error"]),
14099
+ file: exports_external.string().min(1),
14100
+ line: exports_external.number().int().positive(),
14101
+ column: exports_external.number().int().positive()
14102
+ });
14103
+ var extractionCoverageSchema = exports_external.object({
14104
+ tier: exports_external.enum(["ast-catalog", "lightweight-evidence"]),
14105
+ capabilities: exports_external.array(exports_external.string().min(1)),
14106
+ files: exports_external.array(exports_external.object({
14107
+ path: exports_external.string().min(1),
14108
+ disposition: exports_external.enum(["analyzed", "unsupported", "excluded"]),
14109
+ diagnosticCodes: exports_external.array(exports_external.string().min(1))
14110
+ })),
14111
+ diagnostics: exports_external.array(extractionDiagnosticSchema)
14112
+ });
13388
14113
  var extractionMetaSchema = exports_external.object({
13389
14114
  extractedAt: exports_external.string().datetime(),
13390
14115
  pluginId: exports_external.string().min(1),
@@ -13411,6 +14136,7 @@ var extractionResultSchema = exports_external.object({
13411
14136
  files: exports_external.array(fileInfoSchema),
13412
14137
  symbols: exports_external.array(symbolInfoSchema),
13413
14138
  relations: exports_external.array(relationInfoSchema),
14139
+ coverage: extractionCoverageSchema.optional(),
13414
14140
  stats: extractionStatsSchema
13415
14141
  });
13416
14142
  var digestStatsSchema = exports_external.object({
@@ -13427,6 +14153,7 @@ var digestDataSchema = exports_external.object({
13427
14153
  files: exports_external.array(fileInfoSchema),
13428
14154
  symbols: exports_external.array(symbolInfoSchema),
13429
14155
  relations: exports_external.array(relationInfoSchema),
14156
+ coverage: extractionCoverageSchema.optional(),
13430
14157
  stats: digestStatsSchema
13431
14158
  });
13432
14159
  var symbolDiffSchema = exports_external.object({
@@ -13548,6 +14275,7 @@ var generateDigest = (result) => {
13548
14275
  files: result.files,
13549
14276
  symbols: allSymbols,
13550
14277
  relations: result.relations,
14278
+ ...result.coverage ? { coverage: result.coverage } : {},
13551
14279
  stats: {
13552
14280
  files: result.stats.files,
13553
14281
  lines: result.stats.lines,
@@ -13570,7 +14298,7 @@ var generateSymbolDiff = (current, previous) => {
13570
14298
  };
13571
14299
  // src/documentEvidence.ts
13572
14300
  import { Buffer as Buffer2 } from "node:buffer";
13573
- import { createHash as createHash2 } from "node:crypto";
14301
+ import { createHash as createHash4 } from "node:crypto";
13574
14302
 
13575
14303
  // src/documentCaptureFidelity.ts
13576
14304
  var DOCUMENT_RESOURCE_SOURCE_MISSING_REASON_CODE = "document.resource.source-missing";
@@ -13588,15 +14316,15 @@ function requiredString(value, field) {
13588
14316
  return value.trim();
13589
14317
  }
13590
14318
  function resourceAssetPath(value, field) {
13591
- const path2 = requiredString(value, field);
13592
- if (path2.startsWith("/") || path2.includes("\\") || path2.includes("\x00") || /^[a-zA-Z]:/u.test(path2)) {
14319
+ const path3 = requiredString(value, field);
14320
+ if (path3.startsWith("/") || path3.includes("\\") || path3.includes("\x00") || /^[a-zA-Z]:/u.test(path3)) {
13593
14321
  throw new TypeError(`${field} must be a POSIX relative path`);
13594
14322
  }
13595
- const segments = path2.split("/");
14323
+ const segments = path3.split("/");
13596
14324
  if (segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
13597
14325
  throw new TypeError(`${field} must not contain empty, dot, or parent segments`);
13598
14326
  }
13599
- return path2;
14327
+ return path3;
13600
14328
  }
13601
14329
  function counts(value, field) {
13602
14330
  if (!isRecord(value))
@@ -13713,7 +14441,7 @@ function parseDocumentResourceMaterialization(value, field) {
13713
14441
  if (item.status !== "materialized" && item.status !== "reference-only" && item.status !== "failed") {
13714
14442
  throw new TypeError(`${field}.items[${index}].status is invalid`);
13715
14443
  }
13716
- if (typeof item.required !== "boolean" || !Array.isArray(item.asset_paths) || item.asset_paths.some((path2) => typeof path2 !== "string" || path2.trim().length === 0)) {
14444
+ if (typeof item.required !== "boolean" || !Array.isArray(item.asset_paths) || item.asset_paths.some((path3) => typeof path3 !== "string" || path3.trim().length === 0)) {
13717
14445
  throw new TypeError(`${field}.items[${index}] must include required and asset_paths`);
13718
14446
  }
13719
14447
  const reasonCode = item.reason_code === undefined ? undefined : requiredString(item.reason_code, `${field}.items[${index}].reason_code`);
@@ -13723,7 +14451,7 @@ function parseDocumentResourceMaterialization(value, field) {
13723
14451
  locator: requiredString(item.locator, `${field}.items[${index}].locator`),
13724
14452
  status: item.status,
13725
14453
  required: item.required,
13726
- asset_paths: item.asset_paths.map((path2, pathIndex) => resourceAssetPath(path2, `${field}.items[${index}].asset_paths[${pathIndex}]`)),
14454
+ asset_paths: item.asset_paths.map((path3, pathIndex) => resourceAssetPath(path3, `${field}.items[${index}].asset_paths[${pathIndex}]`)),
13727
14455
  ...reasonCode !== undefined ? { reason_code: reasonCode } : {},
13728
14456
  ...reason !== undefined ? { reason } : {}
13729
14457
  };
@@ -13768,7 +14496,7 @@ function bytesOf(value) {
13768
14496
  return typeof value === "string" ? Buffer2.from(value, "utf8") : Buffer2.from(value);
13769
14497
  }
13770
14498
  function sha256Hex(value) {
13771
- return createHash2("sha256").update(bytesOf(value)).digest("hex");
14499
+ return createHash4("sha256").update(bytesOf(value)).digest("hex");
13772
14500
  }
13773
14501
  function normalizeHashId(value) {
13774
14502
  const trimmed = value.trim().toLowerCase();
@@ -13802,29 +14530,29 @@ function normalizeDocumentSourceName(name) {
13802
14530
  }
13803
14531
  return value;
13804
14532
  }
13805
- function normalizeSnapshotRelativePath(path2) {
13806
- const value = path2.trim();
14533
+ function normalizeSnapshotRelativePath(path3) {
14534
+ const value = path3.trim();
13807
14535
  if (value.length === 0 || value.includes("\x00") || value.startsWith("/") || /^[a-zA-Z]:[\\/]/u.test(value)) {
13808
- throw new TypeError(`snapshot path must be a POSIX relative path: ${path2}`);
14536
+ throw new TypeError(`snapshot path must be a POSIX relative path: ${path3}`);
13809
14537
  }
13810
14538
  if (value.includes("\\")) {
13811
- throw new TypeError(`snapshot path must use POSIX separators: ${path2}`);
14539
+ throw new TypeError(`snapshot path must use POSIX separators: ${path3}`);
13812
14540
  }
13813
14541
  const segments = value.split("/");
13814
14542
  if (segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
13815
- throw new TypeError(`snapshot path must not contain empty, dot, or traversal segments: ${path2}`);
14543
+ throw new TypeError(`snapshot path must not contain empty, dot, or traversal segments: ${path3}`);
13816
14544
  }
13817
14545
  return value;
13818
14546
  }
13819
- function encodeSnapshotLocatorPath(path2) {
13820
- return normalizeSnapshotRelativePath(path2).split("/").map((segment) => encodeURIComponent(segment)).join("/");
14547
+ function encodeSnapshotLocatorPath(path3) {
14548
+ return normalizeSnapshotRelativePath(path3).split("/").map((segment) => encodeURIComponent(segment)).join("/");
13821
14549
  }
13822
- function decodeSnapshotLocatorPath(path2) {
14550
+ function decodeSnapshotLocatorPath(path3) {
13823
14551
  try {
13824
- return normalizeSnapshotRelativePath(path2.split("/").map((segment) => decodeURIComponent(segment)).join("/"));
14552
+ return normalizeSnapshotRelativePath(path3.split("/").map((segment) => decodeURIComponent(segment)).join("/"));
13825
14553
  } catch (error) {
13826
14554
  const message = error instanceof Error ? error.message : String(error);
13827
- throw new TypeError(`invalid encoded snapshot locator path: ${path2}: ${message}`);
14555
+ throw new TypeError(`invalid encoded snapshot locator path: ${path3}: ${message}`);
13828
14556
  }
13829
14557
  }
13830
14558
  function parseDocumentSourceLocator(source) {
@@ -13886,7 +14614,7 @@ function countMarkdownLines(bytes) {
13886
14614
  `).length;
13887
14615
  }
13888
14616
  function computeLogicalRawHash(files) {
13889
- const hash2 = createHash2("sha256");
14617
+ const hash2 = createHash4("sha256");
13890
14618
  const sorted = [...files].map((file) => ({
13891
14619
  path: normalizeSnapshotRelativePath(file.path),
13892
14620
  bytes: bytesOf(file.bytes)
@@ -14034,14 +14762,14 @@ function sourceSpanHashMatches(refHash, fullSpanHash) {
14034
14762
  return SOURCE_SPAN_HASH_RE.test(refHash) && /^[a-f0-9]{64}$/u.test(fullSpanHash) && fullSpanHash.startsWith(refHash);
14035
14763
  }
14036
14764
  function createDocumentSnapshotFileEntry(input) {
14037
- const path2 = normalizeSnapshotRelativePath(input.path);
14765
+ const path3 = normalizeSnapshotRelativePath(input.path);
14038
14766
  const sourcePath = input.source_path === undefined ? undefined : normalizeSnapshotRelativePath(input.source_path);
14039
14767
  if ((input.title?.trim().length ?? 0) === 0 && (input.locator?.trim().length ?? 0) === 0) {
14040
- throw new TypeError(`snapshot file "${path2}" must include title or locator`);
14768
+ throw new TypeError(`snapshot file "${path3}" must include title or locator`);
14041
14769
  }
14042
14770
  return {
14043
- path: path2,
14044
- ...sourcePath !== undefined && sourcePath !== path2 ? { source_path: sourcePath } : {},
14771
+ path: path3,
14772
+ ...sourcePath !== undefined && sourcePath !== path3 ? { source_path: sourcePath } : {},
14045
14773
  content_hash: computeDocumentContentHash(input.bytes),
14046
14774
  line_count: countMarkdownLines(input.bytes),
14047
14775
  ...input.title !== undefined ? { title: input.title.trim() } : {},
@@ -14169,13 +14897,13 @@ function optionalRouteFiles(value, field) {
14169
14897
  if (!isRecord2(item)) {
14170
14898
  throw new TypeError(`${field}[${index}] must be an object`);
14171
14899
  }
14172
- const path2 = optionalMetadataString(item.path, `${field}[${index}].path`);
14173
- if (path2 === undefined) {
14900
+ const path3 = optionalMetadataString(item.path, `${field}[${index}].path`);
14901
+ if (path3 === undefined) {
14174
14902
  throw new TypeError(`${field}[${index}].path must be a non-empty string`);
14175
14903
  }
14176
14904
  const routes = optionalMetadataStringArray(item.routes, `${field}[${index}].routes`) ?? [];
14177
14905
  return {
14178
- path: normalizeSnapshotRelativePath(path2),
14906
+ path: normalizeSnapshotRelativePath(path3),
14179
14907
  routes
14180
14908
  };
14181
14909
  }).filter((item) => item.routes.length > 0);
@@ -14210,8 +14938,8 @@ function captureReportMetadata(value) {
14210
14938
  return;
14211
14939
  if (!isRecord2(value))
14212
14940
  throw new TypeError("snapshot manifest metadata.capture.report must be an object");
14213
- const path2 = optionalMetadataString(value.path, "snapshot manifest metadata.capture.report.path");
14214
- if (path2 === undefined)
14941
+ const path3 = optionalMetadataString(value.path, "snapshot manifest metadata.capture.report.path");
14942
+ if (path3 === undefined)
14215
14943
  throw new TypeError("snapshot manifest metadata.capture.report.path is required");
14216
14944
  const fidelityStatus = value.fidelityStatus;
14217
14945
  const evidenceStatus = value.evidenceStatus;
@@ -14230,7 +14958,7 @@ function captureReportMetadata(value) {
14230
14958
  throw new TypeError("snapshot manifest metadata.capture.report.resourceStatus is invalid");
14231
14959
  }
14232
14960
  return {
14233
- path: normalizeSnapshotRelativePath(path2),
14961
+ path: normalizeSnapshotRelativePath(path3),
14234
14962
  fidelityStatus,
14235
14963
  evidenceStatus,
14236
14964
  projectionStatus,
@@ -14345,7 +15073,7 @@ function parseDocumentSnapshotManifest(value) {
14345
15073
  }
14346
15074
  // src/repository.ts
14347
15075
  import { readFile as readFile2, readdir as readdir2, stat } from "node:fs/promises";
14348
- import path2 from "node:path";
15076
+ import path3 from "node:path";
14349
15077
 
14350
15078
  // src/scanner.ts
14351
15079
  import { execFile } from "node:child_process";
@@ -14355,11 +15083,20 @@ import { promisify } from "node:util";
14355
15083
  var execFileAsync = promisify(execFile);
14356
15084
  var isScanExcludedDir = (name) => SCAN_EXCLUDED_DIRS.has(name) || name.startsWith(".") && name !== "." || name.endsWith(".egg-info");
14357
15085
  var DEFAULT_EXCLUDED_FILE_PATTERNS = [
14358
- /\.test\.ts$/i,
14359
- /\.spec\.ts$/i,
14360
- /\.d\.ts$/i
15086
+ /\.test\.(?:[cm]?[jt]sx?)$/i,
15087
+ /\.spec\.(?:[cm]?[jt]sx?)$/i,
15088
+ /\.d\.(?:ts|mts|cts)$/i
14361
15089
  ];
14362
- var SUPPORTED_EXTENSIONS = new Set([".ts", ".tsx"]);
15090
+ var SUPPORTED_EXTENSIONS = new Set([
15091
+ ".ts",
15092
+ ".tsx",
15093
+ ".mts",
15094
+ ".cts",
15095
+ ".js",
15096
+ ".jsx",
15097
+ ".mjs",
15098
+ ".cjs"
15099
+ ]);
14363
15100
  var toPosixPath = (value) => value.split(sep).join("/");
14364
15101
  var shouldExcludeFile = (fileName) => DEFAULT_EXCLUDED_FILE_PATTERNS.some((pattern) => pattern.test(fileName));
14365
15102
  var isSupportedSourceFile = (fileName) => SUPPORTED_EXTENSIONS.has(extname(fileName));
@@ -14511,11 +15248,7 @@ var countFileLines = async (filePath) => {
14511
15248
  const contents = await readFile(filePath, "utf-8");
14512
15249
  if (contents === "")
14513
15250
  return 0;
14514
- const lines = contents.split(/\r\n|\r|\n/);
14515
- if (lines[lines.length - 1] === "") {
14516
- lines.pop();
14517
- }
14518
- return lines.length;
15251
+ return contents.split(/\r\n|\r|\n/).filter((line) => line.trim().length > 0).length;
14519
15252
  };
14520
15253
  var MANIFEST_FILES = [
14521
15254
  "package.json",
@@ -14661,13 +15394,19 @@ var findSubModuleDirs = async (rootDir, excludeDirs, gitFiles, pathFilter2) => {
14661
15394
  var buildModule = async (repoRoot, moduleDir, moduleName, childModuleDirs, ref, pathFilter2, gitFiles) => {
14662
15395
  const excludes = childModuleDirs.size > 0 ? childModuleDirs : undefined;
14663
15396
  const moduleFiles = gitFiles !== undefined && gitFiles !== null && gitFiles.size > 0 ? filterGitSourceFiles(resolve(moduleDir), gitFiles, excludes, pathFilter2) : await scanSourceFiles(moduleDir, excludes, ref, pathFilter2);
15397
+ const broadPathFilter = pathFilter2 === undefined ? undefined : { ...pathFilter2, code: { ...pathFilter2.code, exclude: [] } };
15398
+ const allMatchedFiles = broadPathFilter === undefined ? moduleFiles : gitFiles !== undefined && gitFiles !== null && gitFiles.size > 0 ? filterGitSourceFiles(resolve(moduleDir), gitFiles, excludes, broadPathFilter) : await scanSourceFiles(moduleDir, excludes, ref, broadPathFilter);
15399
+ const included = new Set(moduleFiles);
15400
+ const excludedModuleFiles = allMatchedFiles.filter((file) => !included.has(file));
14664
15401
  const modulePath = toPosixPath(relative(repoRoot, moduleDir)) || ".";
14665
15402
  const totalLines = await Promise.all(moduleFiles.map((file) => countFileLines(join(moduleDir, file))));
14666
15403
  const files = modulePath === "." ? moduleFiles : moduleFiles.map((file) => toPosixPath(join(modulePath, file)));
15404
+ const excludedFiles = modulePath === "." ? excludedModuleFiles : excludedModuleFiles.map((file) => toPosixPath(join(modulePath, file)));
14667
15405
  return {
14668
15406
  name: moduleName,
14669
15407
  path: modulePath,
14670
15408
  files,
15409
+ ...excludedFiles.length === 0 ? {} : { excludedFiles },
14671
15410
  fileCount: files.length,
14672
15411
  totalLines: totalLines.reduce((sum, value) => sum + value, 0)
14673
15412
  };
@@ -14779,10 +15518,10 @@ class ExtractionInputError extends Error {
14779
15518
  // src/repository.ts
14780
15519
  var PACKAGE_JSON = "package.json";
14781
15520
  var GO_MOD = "go.mod";
14782
- var toPosixPath2 = (value) => value.split(path2.sep).join("/");
15521
+ var toPosixPath2 = (value) => value.split(path3.sep).join("/");
14783
15522
  function safeSourceRelativePath(value) {
14784
15523
  const slashPath = value.trim().replace(/\\/gu, "/");
14785
- const normalized = path2.posix.normalize(slashPath).replace(/^\.\//u, "");
15524
+ const normalized = path3.posix.normalize(slashPath).replace(/^\.\//u, "");
14786
15525
  if (normalized.length === 0 || normalized === "." || normalized === ".." || normalized.startsWith("../") || normalized.startsWith("/") || /^[A-Za-z]:\//u.test(normalized)) {
14787
15526
  throw new Error(`Extraction entry must be a source-relative file path: ${value}`);
14788
15527
  }
@@ -14800,7 +15539,7 @@ function moduleRelativeEntryPath(modulePath, sourcePath) {
14800
15539
  function entrySubpath(filePath, index) {
14801
15540
  if (index === 0)
14802
15541
  return ".";
14803
- const withoutExtension = filePath.replace(/\.(?:d\.)?(?:ts|tsx|mts|cts|go)$/u, "");
15542
+ const withoutExtension = filePath.replace(/\.(?:d\.)?(?:ts|tsx|mts|cts|js|jsx|mjs|cjs|go)$/u, "");
14804
15543
  return `./${withoutExtension}`;
14805
15544
  }
14806
15545
  function selectedEntryFiles(input) {
@@ -14846,11 +15585,11 @@ var resolveRepoRelativePath = (modulePath, value) => {
14846
15585
  return normalizedValue;
14847
15586
  return `${normalizeRelativePath(modulePath)}/${normalizedValue}`;
14848
15587
  };
14849
- var resolveModuleDir = (repoPath, modulePath) => modulePath === "." ? repoPath : path2.join(repoPath, modulePath);
15588
+ var resolveModuleDir = (repoPath, modulePath) => modulePath === "." ? repoPath : path3.join(repoPath, modulePath);
14850
15589
  var resolveModuleFsPath = (moduleDir, filePath) => {
14851
- const candidate = path2.isAbsolute(filePath) ? filePath : path2.resolve(moduleDir, filePath);
14852
- const relativePath = path2.relative(moduleDir, candidate);
14853
- if (relativePath.startsWith("..") || path2.isAbsolute(relativePath)) {
15590
+ const candidate = path3.isAbsolute(filePath) ? filePath : path3.resolve(moduleDir, filePath);
15591
+ const relativePath = path3.relative(moduleDir, candidate);
15592
+ if (relativePath.startsWith("..") || path3.isAbsolute(relativePath)) {
14854
15593
  throw new Error(`Path escapes module root: ${filePath}`);
14855
15594
  }
14856
15595
  return candidate;
@@ -14930,7 +15669,20 @@ var prefixExtractionPaths = (extraction, modulePath, commitHash) => ({
14930
15669
  ...file,
14931
15670
  path: resolveRepoRelativePath(modulePath, file.path)
14932
15671
  })),
14933
- symbols: extraction.symbols.map((symbol) => prefixSymbolPaths(symbol, modulePath))
15672
+ symbols: extraction.symbols.map((symbol) => prefixSymbolPaths(symbol, modulePath)),
15673
+ ...extraction.coverage ? {
15674
+ coverage: {
15675
+ ...extraction.coverage,
15676
+ files: extraction.coverage.files.map((file) => ({
15677
+ ...file,
15678
+ path: resolveRepoRelativePath(modulePath, file.path)
15679
+ })),
15680
+ diagnostics: extraction.coverage.diagnostics.map((diagnostic) => ({
15681
+ ...diagnostic,
15682
+ file: resolveRepoRelativePath(modulePath, diagnostic.file)
15683
+ }))
15684
+ }
15685
+ } : {}
14934
15686
  });
14935
15687
  var normalizeExtractionPaths = (extraction, entryDetection, modulePath, commitHash) => ({
14936
15688
  entryDetection: prefixEntryDetectionPaths(entryDetection, modulePath),
@@ -14982,7 +15734,7 @@ var resolveRequestedModules = async (repoPath, modulePaths, ref, pathFilter2) =>
14982
15734
  return { modules, moduleErrors };
14983
15735
  };
14984
15736
  var runRepositoryExtraction = async (input) => {
14985
- const repoPath = path2.resolve(input.repoPath);
15737
+ const repoPath = path3.resolve(input.repoPath);
14986
15738
  input.onProgress?.({ phase: "scanning", progress: 0, message: "detecting modules" });
14987
15739
  const { modules, moduleErrors } = await resolveRequestedModules(repoPath, input.modules, input.ref, input.pathFilter);
14988
15740
  const registry = new ExtractionPluginRegistry;
@@ -15365,7 +16117,7 @@ var buildCodeSnapshot = (input) => {
15365
16117
  // src/runner.ts
15366
16118
  import { readFile as readFile3 } from "node:fs/promises";
15367
16119
  import { createRequire as createRequire2 } from "node:module";
15368
- import path3 from "node:path";
16120
+ import path4 from "node:path";
15369
16121
  import { pathToFileURL } from "node:url";
15370
16122
  var pluginSpecSchema = exports_external.object({
15371
16123
  package: exports_external.string().min(1),
@@ -15416,9 +16168,9 @@ var isPlugin = (value) => {
15416
16168
  var resolvePluginModule = (packageName, cwd) => {
15417
16169
  if (packageName.startsWith(".") || packageName.startsWith("/") || packageName.startsWith("file:")) {
15418
16170
  const filePath = packageName.startsWith("file:") ? packageName.slice("file:".length) : packageName;
15419
- return path3.resolve(cwd, filePath);
16171
+ return path4.resolve(cwd, filePath);
15420
16172
  }
15421
- const require2 = createRequire2(path3.join(cwd, "package.json"));
16173
+ const require2 = createRequire2(path4.join(cwd, "package.json"));
15422
16174
  return require2.resolve(packageName);
15423
16175
  };
15424
16176
  var loadRunnerPlugins = async (pluginSpecs, cwd = process.cwd()) => {
@@ -15488,11 +16240,15 @@ var runCodeExtractCli = async () => {
15488
16240
  const input = stdin.trim() ? JSON.parse(stdin) : {};
15489
16241
  const events = await runCodeExtractRunner(input);
15490
16242
  for (const event of events) {
15491
- process.stdout.write(JSON.stringify(event) + `
16243
+ const filtered = redactIndexerOutput({ channel: "stdout", value: event });
16244
+ process.stdout.write(JSON.stringify(filtered.value) + `
15492
16245
  `);
15493
16246
  }
15494
16247
  } catch (error) {
15495
- const message = error instanceof Error ? error.message : String(error);
16248
+ const message = redactIndexerOutputText({
16249
+ channel: "exception-message",
16250
+ value: error instanceof Error ? error.message : String(error)
16251
+ });
15496
16252
  process.stdout.write(JSON.stringify({ type: "error", code: "runner-failed", message }) + `
15497
16253
  `);
15498
16254
  process.exitCode = 1;
@@ -15500,62 +16256,2803 @@ var runCodeExtractCli = async () => {
15500
16256
  };
15501
16257
  var runCodeExtractCliFromFile = async (inputFile) => {
15502
16258
  const content = await readFile3(inputFile, "utf-8");
15503
- return runCodeExtractRunner(JSON.parse(content), path3.dirname(path3.resolve(inputFile)));
15504
- };
15505
- // src/parser.ts
15506
- import Parser from "web-tree-sitter";
15507
- import { existsSync } from "node:fs";
15508
- import { fileURLToPath } from "node:url";
15509
- var parserInitPromise = null;
15510
- var parsedBytesSinceReset = 0;
15511
- var parserDead = false;
15512
- var PARSER_RESET_THRESHOLD = 16 * 1024 * 1024;
15513
- var resolveWasmPath = (relativePath) => fileURLToPath(new URL(relativePath, import.meta.url));
15514
- var createParserInstance = async () => {
15515
- const localWasm = resolveWasmPath("./wasm/tree-sitter.wasm");
15516
- const initOptions = existsSync(localWasm) ? { locateFile: (scriptName) => resolveWasmPath(`./wasm/${scriptName}`) } : undefined;
15517
- await Parser.init(initOptions);
15518
- const parser = new Parser;
15519
- const tsLanguage = await Parser.Language.load(resolveWasmPath("./wasm/tree-sitter-typescript.wasm"));
15520
- const tsxLanguage = await Parser.Language.load(resolveWasmPath("./wasm/tree-sitter-tsx.wasm"));
15521
- return { parser, tsLanguage, tsxLanguage };
15522
- };
15523
- var initParser = async () => {
15524
- if (!parserInitPromise) {
15525
- parserInitPromise = (async () => {
15526
- try {
15527
- parsedBytesSinceReset = 0;
15528
- return await createParserInstance();
15529
- } catch (error) {
15530
- parserInitPromise = null;
15531
- throw error;
15532
- }
15533
- })();
15534
- }
15535
- return parserInitPromise;
15536
- };
15537
- var resetParser = () => {
15538
- parserInitPromise = null;
15539
- parsedBytesSinceReset = 0;
15540
- parserDead = false;
16259
+ return runCodeExtractRunner(JSON.parse(content), path4.dirname(path4.resolve(inputFile)));
15541
16260
  };
15542
- var tryParse = async (source, isTsx) => {
15543
- const { parser, tsLanguage, tsxLanguage } = await initParser();
15544
- parser.setLanguage(isTsx ? tsxLanguage : tsLanguage);
15545
- const tree = parser.parse(source);
15546
- parsedBytesSinceReset += source.length;
15547
- if (tree.rootNode.hasError()) {
15548
- return null;
16261
+ // src/evidenceAdapter.ts
16262
+ function fact2(input) {
16263
+ return createIndexerEvidenceAdapterFact({
16264
+ source_ref: input.sourceRef,
16265
+ module_ref: input.moduleRef,
16266
+ normalized_path: input.normalizedPath,
16267
+ qualified_item_path: input.qualifiedItemPath,
16268
+ kind: input.kind,
16269
+ signature: input.signature,
16270
+ payload: input.payload,
16271
+ denominator: input.denominator
16272
+ });
16273
+ }
16274
+ function semanticExtractionPayload(extraction) {
16275
+ return {
16276
+ version: extraction.version,
16277
+ meta: {
16278
+ pluginId: extraction.meta.pluginId,
16279
+ commitHash: extraction.meta.commitHash,
16280
+ language: extraction.meta.language
16281
+ },
16282
+ package: extraction.package,
16283
+ files: extraction.files,
16284
+ symbols: extraction.symbols,
16285
+ relations: extraction.relations,
16286
+ coverage: extraction.coverage,
16287
+ stats: extraction.stats
16288
+ };
16289
+ }
16290
+ function relationSourceFile(relation, symbols) {
16291
+ const candidates = symbols.filter((symbol) => symbol.name === relation.from);
16292
+ if (candidates.length === 1)
16293
+ return candidates[0].file;
16294
+ if (relation.line !== undefined) {
16295
+ const containing = candidates.filter((symbol) => symbol.line <= relation.line && symbol.endLine >= relation.line);
16296
+ if (containing.length === 1)
16297
+ return containing[0].file;
15549
16298
  }
15550
- return tree;
15551
- };
15552
- var parseFile = async (source, isTsx) => {
15553
- if (parserDead)
15554
- return null;
15555
- if (parsedBytesSinceReset > PARSER_RESET_THRESHOLD) {
15556
- resetParser();
16299
+ return null;
16300
+ }
16301
+ function diagnosticPayload(diagnostic) {
16302
+ return {
16303
+ code: diagnostic.code,
16304
+ severity: diagnostic.severity,
16305
+ file: diagnostic.file,
16306
+ line: diagnostic.line,
16307
+ column: diagnostic.column
16308
+ };
16309
+ }
16310
+ function extractionResultToEvidenceAdapterResult(extraction, invocation) {
16311
+ const coverage = extraction.coverage;
16312
+ if (!coverage) {
16313
+ throw new TypeError("ExtractionResult coverage is required for Evidence Adapter Result conversion");
16314
+ }
16315
+ if (coverage.capabilities.length === 0) {
16316
+ throw new TypeError("ExtractionResult coverage must declare at least one parser capability");
16317
+ }
16318
+ const coverageByPath = new Map(coverage.files.map((file) => [file.path, file]));
16319
+ const fileInfoByPath = new Map(extraction.files.map((file) => [file.path, file]));
16320
+ for (const file of extraction.files) {
16321
+ if (!coverageByPath.has(file.path)) {
16322
+ throw new TypeError(`ExtractionResult file ${file.path} has no coverage disposition`);
16323
+ }
16324
+ }
16325
+ for (const symbol of extraction.symbols) {
16326
+ const disposition = coverageByPath.get(symbol.file)?.disposition;
16327
+ if (disposition !== "analyzed") {
16328
+ throw new TypeError(`ExtractionResult symbol ${symbol.name} belongs to a file without analyzed disposition`);
16329
+ }
16330
+ }
16331
+ const role = invocation.role ?? "primary-owner";
16332
+ const ownsDenominators = role === "primary-owner" && coverage.tier === "ast-catalog";
16333
+ const generatedDiagnostics = [];
16334
+ const relationsByFile = new Map;
16335
+ for (const relation of extraction.relations) {
16336
+ const file = relationSourceFile(relation, extraction.symbols);
16337
+ if (file === null || coverageByPath.get(file)?.disposition !== "analyzed") {
16338
+ generatedDiagnostics.push({
16339
+ code: "relation-locator-unresolved",
16340
+ severity: "warning",
16341
+ detail_digest: indexerEvidenceAdapterProtocolDigest(relation)
16342
+ });
16343
+ continue;
16344
+ }
16345
+ const current = relationsByFile.get(file) ?? [];
16346
+ current.push(relation);
16347
+ relationsByFile.set(file, current);
15557
16348
  }
15558
- try {
16349
+ const files = coverage.files.map((coverageFile) => {
16350
+ const normalizedPath = coverageFile.path;
16351
+ const fileRef = indexerEvidenceAdapterFileRef({
16352
+ source_ref: invocation.authorized_scope.source_ref,
16353
+ module_ref: invocation.module_ref,
16354
+ normalized_path: normalizedPath
16355
+ });
16356
+ const fileInfo = fileInfoByPath.get(normalizedPath);
16357
+ if (coverageFile.disposition === "analyzed" && !fileInfo) {
16358
+ throw new TypeError(`Analyzed file ${normalizedPath} has no ExtractionResult file metadata`);
16359
+ }
16360
+ const facts = [];
16361
+ if (coverageFile.disposition === "analyzed" && fileInfo) {
16362
+ facts.push(fact2({
16363
+ sourceRef: invocation.authorized_scope.source_ref,
16364
+ moduleRef: invocation.module_ref,
16365
+ normalizedPath,
16366
+ qualifiedItemPath: "file",
16367
+ kind: "source-file",
16368
+ signature: { path: normalizedPath, language: fileInfo.language },
16369
+ payload: fileInfo,
16370
+ denominator: ownsDenominators ? "eligible-file" : "none"
16371
+ }));
16372
+ facts.push(fact2({
16373
+ sourceRef: invocation.authorized_scope.source_ref,
16374
+ moduleRef: invocation.module_ref,
16375
+ normalizedPath,
16376
+ qualifiedItemPath: "loc",
16377
+ kind: "source-loc",
16378
+ signature: { path: normalizedPath },
16379
+ payload: { lines: fileInfo.lines },
16380
+ denominator: ownsDenominators ? "loc" : "none"
16381
+ }));
16382
+ for (const symbol of extraction.symbols.filter((item) => item.file === normalizedPath)) {
16383
+ facts.push(fact2({
16384
+ sourceRef: invocation.authorized_scope.source_ref,
16385
+ moduleRef: invocation.module_ref,
16386
+ normalizedPath,
16387
+ qualifiedItemPath: `symbol:${symbol.kind}:${symbol.name}@${symbol.line}`,
16388
+ kind: "code-symbol",
16389
+ signature: {
16390
+ name: symbol.name,
16391
+ kind: symbol.kind,
16392
+ signature: symbol.signature ?? null,
16393
+ params: symbol.params ?? null,
16394
+ returnType: symbol.returnType ?? null,
16395
+ typeAnnotation: symbol.typeAnnotation ?? null
16396
+ },
16397
+ payload: symbol,
16398
+ denominator: ownsDenominators ? "symbol" : "none"
16399
+ }));
16400
+ }
16401
+ for (const relation of relationsByFile.get(normalizedPath) ?? []) {
16402
+ facts.push(fact2({
16403
+ sourceRef: invocation.authorized_scope.source_ref,
16404
+ moduleRef: invocation.module_ref,
16405
+ normalizedPath,
16406
+ qualifiedItemPath: `relation:${relation.type}:${relation.from}->${relation.to}@${relation.line ?? 0}`,
16407
+ kind: "code-relation",
16408
+ signature: relation,
16409
+ payload: relation,
16410
+ denominator: "none"
16411
+ }));
16412
+ }
16413
+ }
16414
+ return {
16415
+ file_ref: fileRef,
16416
+ source_ref: invocation.authorized_scope.source_ref,
16417
+ module_ref: invocation.module_ref,
16418
+ normalized_path: normalizedPath,
16419
+ role,
16420
+ coverage_tier: coverage.tier,
16421
+ disposition: coverageFile.disposition,
16422
+ facts
16423
+ };
16424
+ });
16425
+ const diagnostics = [
16426
+ ...coverage.diagnostics.map((diagnostic) => {
16427
+ const coverageFile = coverageByPath.get(diagnostic.file);
16428
+ const fileRef = coverageFile ? indexerEvidenceAdapterFileRef({
16429
+ source_ref: invocation.authorized_scope.source_ref,
16430
+ module_ref: invocation.module_ref,
16431
+ normalized_path: diagnostic.file
16432
+ }) : undefined;
16433
+ return {
16434
+ code: diagnostic.code,
16435
+ severity: diagnostic.severity,
16436
+ detail_digest: indexerEvidenceAdapterProtocolDigest(diagnosticPayload(diagnostic)),
16437
+ ...fileRef ? { fact_ref: fileRef } : {}
16438
+ };
16439
+ }),
16440
+ ...generatedDiagnostics
16441
+ ];
16442
+ const parserOutputDigest = indexerEvidenceAdapterProtocolDigest(semanticExtractionPayload(extraction));
16443
+ return buildIndexerEvidenceAdapterResult({
16444
+ protocol: "context.indexer.evidence-adapter-result/v1",
16445
+ adapter: invocation.adapter,
16446
+ authorized_scope: invocation.authorized_scope,
16447
+ input_digest: invocation.input_digest,
16448
+ precedence: invocation.precedence,
16449
+ files,
16450
+ diagnostics,
16451
+ toolchain: [{
16452
+ step: "parse-source",
16453
+ package: invocation.adapter.package,
16454
+ export: invocation.adapter.export,
16455
+ version: invocation.adapter.version,
16456
+ digest: invocation.adapter.digest,
16457
+ capabilities: coverage.capabilities,
16458
+ input_digest: invocation.input_digest,
16459
+ output_digest: parserOutputDigest
16460
+ }]
16461
+ });
16462
+ }
16463
+ function extractionResultToEvidenceAdapterMaterialization(extraction, invocation) {
16464
+ return materializeIndexerEvidenceAdapterResult(extractionResultToEvidenceAdapterResult(extraction, invocation));
16465
+ }
16466
+ // ../../node_modules/.bun/eslint-visitor-keys@5.0.1/node_modules/eslint-visitor-keys/lib/visitor-keys.js
16467
+ var KEYS = {
16468
+ ArrayExpression: ["elements"],
16469
+ ArrayPattern: ["elements"],
16470
+ ArrowFunctionExpression: ["params", "body"],
16471
+ AssignmentExpression: ["left", "right"],
16472
+ AssignmentPattern: ["left", "right"],
16473
+ AwaitExpression: ["argument"],
16474
+ BinaryExpression: ["left", "right"],
16475
+ BlockStatement: ["body"],
16476
+ BreakStatement: ["label"],
16477
+ CallExpression: ["callee", "arguments"],
16478
+ CatchClause: ["param", "body"],
16479
+ ChainExpression: ["expression"],
16480
+ ClassBody: ["body"],
16481
+ ClassDeclaration: ["id", "superClass", "body"],
16482
+ ClassExpression: ["id", "superClass", "body"],
16483
+ ConditionalExpression: ["test", "consequent", "alternate"],
16484
+ ContinueStatement: ["label"],
16485
+ DebuggerStatement: [],
16486
+ DoWhileStatement: ["body", "test"],
16487
+ EmptyStatement: [],
16488
+ ExperimentalRestProperty: ["argument"],
16489
+ ExperimentalSpreadProperty: ["argument"],
16490
+ ExportAllDeclaration: ["exported", "source", "attributes"],
16491
+ ExportDefaultDeclaration: ["declaration"],
16492
+ ExportNamedDeclaration: [
16493
+ "declaration",
16494
+ "specifiers",
16495
+ "source",
16496
+ "attributes"
16497
+ ],
16498
+ ExportSpecifier: ["local", "exported"],
16499
+ ExpressionStatement: ["expression"],
16500
+ ForInStatement: ["left", "right", "body"],
16501
+ ForOfStatement: ["left", "right", "body"],
16502
+ ForStatement: ["init", "test", "update", "body"],
16503
+ FunctionDeclaration: ["id", "params", "body"],
16504
+ FunctionExpression: ["id", "params", "body"],
16505
+ Identifier: [],
16506
+ IfStatement: ["test", "consequent", "alternate"],
16507
+ ImportAttribute: ["key", "value"],
16508
+ ImportDeclaration: ["specifiers", "source", "attributes"],
16509
+ ImportDefaultSpecifier: ["local"],
16510
+ ImportExpression: ["source", "options"],
16511
+ ImportNamespaceSpecifier: ["local"],
16512
+ ImportSpecifier: ["imported", "local"],
16513
+ JSXAttribute: ["name", "value"],
16514
+ JSXClosingElement: ["name"],
16515
+ JSXClosingFragment: [],
16516
+ JSXElement: ["openingElement", "children", "closingElement"],
16517
+ JSXEmptyExpression: [],
16518
+ JSXExpressionContainer: ["expression"],
16519
+ JSXFragment: ["openingFragment", "children", "closingFragment"],
16520
+ JSXIdentifier: [],
16521
+ JSXMemberExpression: ["object", "property"],
16522
+ JSXNamespacedName: ["namespace", "name"],
16523
+ JSXOpeningElement: ["name", "attributes"],
16524
+ JSXOpeningFragment: [],
16525
+ JSXSpreadAttribute: ["argument"],
16526
+ JSXSpreadChild: ["expression"],
16527
+ JSXText: [],
16528
+ LabeledStatement: ["label", "body"],
16529
+ Literal: [],
16530
+ LogicalExpression: ["left", "right"],
16531
+ MemberExpression: ["object", "property"],
16532
+ MetaProperty: ["meta", "property"],
16533
+ MethodDefinition: ["key", "value"],
16534
+ NewExpression: ["callee", "arguments"],
16535
+ ObjectExpression: ["properties"],
16536
+ ObjectPattern: ["properties"],
16537
+ PrivateIdentifier: [],
16538
+ Program: ["body"],
16539
+ Property: ["key", "value"],
16540
+ PropertyDefinition: ["key", "value"],
16541
+ RestElement: ["argument"],
16542
+ ReturnStatement: ["argument"],
16543
+ SequenceExpression: ["expressions"],
16544
+ SpreadElement: ["argument"],
16545
+ StaticBlock: ["body"],
16546
+ Super: [],
16547
+ SwitchCase: ["test", "consequent"],
16548
+ SwitchStatement: ["discriminant", "cases"],
16549
+ TaggedTemplateExpression: ["tag", "quasi"],
16550
+ TemplateElement: [],
16551
+ TemplateLiteral: ["quasis", "expressions"],
16552
+ ThisExpression: [],
16553
+ ThrowStatement: ["argument"],
16554
+ TryStatement: ["block", "handler", "finalizer"],
16555
+ UnaryExpression: ["argument"],
16556
+ UpdateExpression: ["argument"],
16557
+ VariableDeclaration: ["declarations"],
16558
+ VariableDeclarator: ["id", "init"],
16559
+ WhileStatement: ["test", "body"],
16560
+ WithStatement: ["object", "body"],
16561
+ YieldExpression: ["argument"]
16562
+ };
16563
+ var NODE_TYPES = Object.keys(KEYS);
16564
+ for (const type of NODE_TYPES) {
16565
+ Object.freeze(KEYS[type]);
16566
+ }
16567
+ Object.freeze(KEYS);
16568
+ var visitor_keys_default = KEYS;
16569
+
16570
+ // ../../node_modules/.bun/eslint-visitor-keys@5.0.1/node_modules/eslint-visitor-keys/lib/index.js
16571
+ var KEY_BLACKLIST = new Set([
16572
+ "parent",
16573
+ "leadingComments",
16574
+ "trailingComments"
16575
+ ]);
16576
+ function unionWith(additionalKeys) {
16577
+ const retv = Object.assign({}, visitor_keys_default);
16578
+ for (const type of Object.keys(additionalKeys)) {
16579
+ if (Object.hasOwn(retv, type)) {
16580
+ const keys = new Set(additionalKeys[type]);
16581
+ for (const key of retv[type]) {
16582
+ keys.add(key);
16583
+ }
16584
+ retv[type] = Object.freeze(Array.from(keys));
16585
+ } else {
16586
+ retv[type] = Object.freeze(Array.from(additionalKeys[type]));
16587
+ }
16588
+ }
16589
+ return Object.freeze(retv);
16590
+ }
16591
+
16592
+ // ../../node_modules/.bun/toml-eslint-parser@1.0.3/node_modules/toml-eslint-parser/lib/index.mjs
16593
+ function last(arr) {
16594
+ return arr[arr.length - 1] ?? null;
16595
+ }
16596
+ function toKeyName(node2) {
16597
+ return node2.type === "TOMLBare" ? node2.name : node2.value;
16598
+ }
16599
+ var TOMLVerImpl = class {
16600
+ constructor(major, minor) {
16601
+ this.major = major;
16602
+ this.minor = minor;
16603
+ }
16604
+ lt(major, minor) {
16605
+ return this.major < major || this.major === major && this.minor < minor;
16606
+ }
16607
+ gte(major, minor) {
16608
+ return this.major > major || this.major === major && this.minor >= minor;
16609
+ }
16610
+ };
16611
+ var TOML_VERSION_1_0 = new TOMLVerImpl(1, 0);
16612
+ var TOML_VERSION_1_1 = new TOMLVerImpl(1, 1);
16613
+ var DEFAULT_TOML_VERSION = TOML_VERSION_1_1;
16614
+ var SUPPORTED_TOML_VERSIONS = {
16615
+ "1.0": TOML_VERSION_1_0,
16616
+ "1.0.0": TOML_VERSION_1_0,
16617
+ "1.1": TOML_VERSION_1_1,
16618
+ "1.1.0": TOML_VERSION_1_1,
16619
+ latest: TOML_VERSION_1_1,
16620
+ next: TOML_VERSION_1_1
16621
+ };
16622
+ function getTOMLVer(v) {
16623
+ return v && SUPPORTED_TOML_VERSIONS[v] || DEFAULT_TOML_VERSION;
16624
+ }
16625
+ var MESSAGES = {
16626
+ "unterminated-string": "Unterminated string constant",
16627
+ "unterminated-table-key": "Unterminated table-key",
16628
+ "unterminated-array": "Unterminated array",
16629
+ "unterminated-inline-table": "Unterminated inline table",
16630
+ "missing-key": "Empty bare keys are not allowed",
16631
+ "missing-newline": "Must be a newline",
16632
+ "missing-equals-sign": "Expected equal (=) token",
16633
+ "missing-value": "Unspecified values are invalid",
16634
+ "missing-comma": "Expected comma (,) token",
16635
+ "dupe-keys": "Defining a key multiple times is invalid",
16636
+ "unexpected-char": "Unexpected character",
16637
+ "unexpected-token": "Unexpected token",
16638
+ "invalid-control-character": "Control characters (codes < 0x1f and 0x7f) are not allowed",
16639
+ "invalid-comment-character": "Invalid code point {{cp}} within comments",
16640
+ "invalid-key-value-newline": "The key, equals sign, and value must be on the same line",
16641
+ "invalid-inline-table-newline": "No newlines are allowed between the curly braces unless they are valid within a value",
16642
+ "invalid-underscore": "Underscores are allowed between digits",
16643
+ "invalid-space": "Unexpected spaces",
16644
+ "invalid-three-quotes": "Three or more quotes are not permitted",
16645
+ "invalid-date": "Unexpected invalid date",
16646
+ "invalid-time": "Unexpected invalid time",
16647
+ "invalid-leading-zero": "Leading zeros are not allowed",
16648
+ "invalid-trailing-comma-in-inline-table": "Trailing comma is not permitted in an inline table",
16649
+ "invalid-char-in-escape-sequence": "Invalid character in escape sequence",
16650
+ "invalid-consecutive-dots-in-key": "Consecutive dots are not permitted in keys",
16651
+ "invalid-code-point": "Invalid code point {{cp}}",
16652
+ "invalid-trailing-dot-in-key": "Keys cannot end with a dot",
16653
+ "invalid-leading-dot-in-key": "Keys cannot start with a dot"
16654
+ };
16655
+ function getMessage(code, data) {
16656
+ if (data)
16657
+ return MESSAGES[code].replace(/\{\{(.*?)\}\}/gu, (_, name$2) => {
16658
+ if (name$2 in data)
16659
+ return data[name$2];
16660
+ return `{{${name$2}}}`;
16661
+ });
16662
+ return MESSAGES[code];
16663
+ }
16664
+ var ParseError = class extends SyntaxError {
16665
+ constructor(code, offset, line, column, data) {
16666
+ super(getMessage(code, data));
16667
+ this.index = offset;
16668
+ this.lineNumber = line;
16669
+ this.column = column;
16670
+ }
16671
+ };
16672
+ var CodePoint = {
16673
+ EOF: -1,
16674
+ NULL: 0,
16675
+ SOH: 1,
16676
+ BACKSPACE: 8,
16677
+ TABULATION: 9,
16678
+ LINE_FEED: 10,
16679
+ FORM_FEED: 12,
16680
+ CARRIAGE_RETURN: 13,
16681
+ ESCAPE: 27,
16682
+ SO: 14,
16683
+ US: 31,
16684
+ SPACE: 32,
16685
+ QUOTATION_MARK: 34,
16686
+ HASH: 35,
16687
+ SINGLE_QUOTE: 39,
16688
+ PLUS_SIGN: 43,
16689
+ COMMA: 44,
16690
+ DASH: 45,
16691
+ DOT: 46,
16692
+ DIGIT_0: 48,
16693
+ DIGIT_1: 49,
16694
+ DIGIT_2: 50,
16695
+ DIGIT_3: 51,
16696
+ DIGIT_7: 55,
16697
+ DIGIT_9: 57,
16698
+ COLON: 58,
16699
+ EQUALS_SIGN: 61,
16700
+ LATIN_CAPITAL_A: 65,
16701
+ LATIN_CAPITAL_E: 69,
16702
+ LATIN_CAPITAL_F: 70,
16703
+ LATIN_CAPITAL_T: 84,
16704
+ LATIN_CAPITAL_U: 85,
16705
+ LATIN_CAPITAL_Z: 90,
16706
+ LEFT_BRACKET: 91,
16707
+ BACKSLASH: 92,
16708
+ RIGHT_BRACKET: 93,
16709
+ UNDERSCORE: 95,
16710
+ LATIN_SMALL_A: 97,
16711
+ LATIN_SMALL_B: 98,
16712
+ LATIN_SMALL_E: 101,
16713
+ LATIN_SMALL_F: 102,
16714
+ LATIN_SMALL_I: 105,
16715
+ LATIN_SMALL_L: 108,
16716
+ LATIN_SMALL_N: 110,
16717
+ LATIN_SMALL_O: 111,
16718
+ LATIN_SMALL_R: 114,
16719
+ LATIN_SMALL_S: 115,
16720
+ LATIN_SMALL_T: 116,
16721
+ LATIN_SMALL_U: 117,
16722
+ LATIN_SMALL_X: 120,
16723
+ LATIN_SMALL_Z: 122,
16724
+ LEFT_BRACE: 123,
16725
+ RIGHT_BRACE: 125,
16726
+ TILDE: 126,
16727
+ DELETE: 127,
16728
+ PAD: 128,
16729
+ SUPERSCRIPT_TWO: 178,
16730
+ SUPERSCRIPT_THREE: 179,
16731
+ SUPERSCRIPT_ONE: 185,
16732
+ VULGAR_FRACTION_ONE_QUARTER: 188,
16733
+ VULGAR_FRACTION_THREE_QUARTERS: 190,
16734
+ LATIN_CAPITAL_LETTER_A_WITH_GRAVE: 192,
16735
+ LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS: 214,
16736
+ LATIN_CAPITAL_LETTER_O_WITH_STROKE: 216,
16737
+ LATIN_SMALL_LETTER_O_WITH_DIAERESIS: 246,
16738
+ LATIN_SMALL_LETTER_O_WITH_STROKE: 248,
16739
+ GREEK_SMALL_REVERSED_DOTTED_LUNATE_SIGMA_SYMBOL: 891,
16740
+ GREEK_CAPITAL_LETTER_YOT: 895,
16741
+ CP_1FFF: 8191,
16742
+ ZERO_WIDTH_NON_JOINER: 8204,
16743
+ ZERO_WIDTH_JOINER: 8205,
16744
+ UNDERTIE: 8255,
16745
+ CHARACTER_TIE: 8256,
16746
+ SUPERSCRIPT_ZERO: 8304,
16747
+ CP_218F: 8591,
16748
+ CIRCLED_DIGIT_ONE: 9312,
16749
+ NEGATIVE_CIRCLED_DIGIT_ZERO: 9471,
16750
+ GLAGOLITIC_CAPITAL_LETTER_AZU: 11264,
16751
+ CP_2FEF: 12271,
16752
+ IDEOGRAPHIC_COMMA: 12289,
16753
+ CP_D7FF: 55295,
16754
+ CP_E000: 57344,
16755
+ CJK_COMPATIBILITY_IDEOGRAPH_F900: 63744,
16756
+ ARABIC_LIGATURE_SALAAMUHU_ALAYNAA: 64975,
16757
+ ARABIC_LIGATURE_SALLA_USED_AS_KORANIC_STOP_SIGN_ISOLATED_FORM: 65008,
16758
+ REPLACEMENT_CHARACTER: 65533,
16759
+ LINEAR_B_SYLLABLE_B008_A: 65536,
16760
+ CP_EFFFF: 983039,
16761
+ CP_10FFFF: 1114111
16762
+ };
16763
+ function isControl(cp) {
16764
+ return cp >= CodePoint.NULL && cp <= CodePoint.US;
16765
+ }
16766
+ function isWhitespace(cp) {
16767
+ return cp === CodePoint.TABULATION || cp === CodePoint.SPACE;
16768
+ }
16769
+ function isEOL(cp) {
16770
+ return cp === CodePoint.LINE_FEED || cp === CodePoint.CARRIAGE_RETURN;
16771
+ }
16772
+ function isUpperLetter(cp) {
16773
+ return cp >= CodePoint.LATIN_CAPITAL_A && cp <= CodePoint.LATIN_CAPITAL_Z;
16774
+ }
16775
+ function isLowerLetter(cp) {
16776
+ return cp >= CodePoint.LATIN_SMALL_A && cp <= CodePoint.LATIN_SMALL_Z;
16777
+ }
16778
+ function isLetter(cp) {
16779
+ return isLowerLetter(cp) || isUpperLetter(cp);
16780
+ }
16781
+ function isDigit(cp) {
16782
+ return cp >= CodePoint.DIGIT_0 && cp <= CodePoint.DIGIT_9;
16783
+ }
16784
+ function isHexDig(cp) {
16785
+ return isDigit(cp) || cp >= CodePoint.LATIN_SMALL_A && cp <= CodePoint.LATIN_SMALL_F || cp >= CodePoint.LATIN_CAPITAL_A && cp <= CodePoint.LATIN_CAPITAL_F;
16786
+ }
16787
+ function isOctalDig(cp) {
16788
+ return cp >= CodePoint.DIGIT_0 && cp <= CodePoint.DIGIT_7;
16789
+ }
16790
+ function isUnicodeScalarValue(cp) {
16791
+ return cp >= 0 && cp <= 55295 || cp >= 57344 && cp <= 1114111;
16792
+ }
16793
+ function sortedLastIndex(array, value) {
16794
+ let low = 0;
16795
+ let high = array.length;
16796
+ while (low < high) {
16797
+ const mid = low + high >>> 1;
16798
+ const val = array[mid];
16799
+ if (val === value)
16800
+ return mid + 1;
16801
+ if (val < value)
16802
+ low = mid + 1;
16803
+ else
16804
+ high = mid;
16805
+ }
16806
+ return low;
16807
+ }
16808
+ var Locations = class {
16809
+ constructor() {
16810
+ this.offsets = [];
16811
+ }
16812
+ addOffset(offset) {
16813
+ for (let i = this.offsets.length - 1;i >= 0; i--) {
16814
+ const element = this.offsets[i];
16815
+ if (element === offset)
16816
+ return;
16817
+ if (element < offset)
16818
+ break;
16819
+ }
16820
+ this.offsets.push(offset);
16821
+ }
16822
+ getLocFromIndex(offset) {
16823
+ const line = sortedLastIndex(this.offsets, offset) + 1;
16824
+ return {
16825
+ line,
16826
+ column: offset - (line === 1 ? 0 : this.offsets[line - 2])
16827
+ };
16828
+ }
16829
+ };
16830
+ var CodePointIterator = class {
16831
+ constructor(text) {
16832
+ this.locs = new Locations;
16833
+ this.lastCodePoint = CodePoint.NULL;
16834
+ this.start = -1;
16835
+ this.end = 0;
16836
+ this.text = text;
16837
+ }
16838
+ next() {
16839
+ if (this.lastCodePoint === CodePoint.EOF)
16840
+ return CodePoint.EOF;
16841
+ return this.lastCodePoint = this.moveAt(this.end);
16842
+ }
16843
+ getLocFromIndex(index) {
16844
+ return this.locs.getLocFromIndex(index);
16845
+ }
16846
+ eat(cp) {
16847
+ if (this.text.codePointAt(this.end) === cp) {
16848
+ this.next();
16849
+ return true;
16850
+ }
16851
+ return false;
16852
+ }
16853
+ moveAt(offset) {
16854
+ this.start = this.end = offset;
16855
+ const cp = this.text.codePointAt(this.start) ?? CodePoint.EOF;
16856
+ if (cp === CodePoint.EOF) {
16857
+ this.end = this.start;
16858
+ return cp;
16859
+ }
16860
+ this.end += cp >= 65536 ? 2 : 1;
16861
+ if (cp === CodePoint.LINE_FEED)
16862
+ this.locs.addOffset(this.end);
16863
+ else if (cp === CodePoint.CARRIAGE_RETURN) {
16864
+ if (this.text.codePointAt(this.end) === CodePoint.LINE_FEED) {
16865
+ this.end++;
16866
+ this.locs.addOffset(this.end);
16867
+ }
16868
+ return CodePoint.LINE_FEED;
16869
+ }
16870
+ return cp;
16871
+ }
16872
+ };
16873
+ var HAS_BIGINT = typeof BigInt !== "undefined";
16874
+ var RADIX_PREFIXES = {
16875
+ 16: "0x",
16876
+ 10: "",
16877
+ 8: "0o",
16878
+ 2: "0b"
16879
+ };
16880
+ var ESCAPES_1_0 = {
16881
+ [CodePoint.QUOTATION_MARK]: CodePoint.QUOTATION_MARK,
16882
+ [CodePoint.BACKSLASH]: CodePoint.BACKSLASH,
16883
+ [CodePoint.LATIN_SMALL_B]: CodePoint.BACKSPACE,
16884
+ [CodePoint.LATIN_SMALL_F]: CodePoint.FORM_FEED,
16885
+ [CodePoint.LATIN_SMALL_N]: CodePoint.LINE_FEED,
16886
+ [CodePoint.LATIN_SMALL_R]: CodePoint.CARRIAGE_RETURN,
16887
+ [CodePoint.LATIN_SMALL_T]: CodePoint.TABULATION
16888
+ };
16889
+ var ESCAPES_LATEST = {
16890
+ ...ESCAPES_1_0,
16891
+ [CodePoint.LATIN_SMALL_E]: CodePoint.ESCAPE
16892
+ };
16893
+ var Tokenizer = class {
16894
+ constructor(text, parserOptions) {
16895
+ this.backCode = false;
16896
+ this.lastCodePoint = CodePoint.NULL;
16897
+ this.state = "DATA";
16898
+ this.token = null;
16899
+ this.tokenStart = -1;
16900
+ this.valuesEnabled = false;
16901
+ this.text = text;
16902
+ this.parserOptions = parserOptions || {};
16903
+ this.codePointIterator = new CodePointIterator(text);
16904
+ this.tomlVersion = getTOMLVer(this.parserOptions.tomlVersion);
16905
+ this.ESCAPES = this.tomlVersion.gte(1, 1) ? ESCAPES_LATEST : ESCAPES_1_0;
16906
+ }
16907
+ get start() {
16908
+ return this.codePointIterator.start;
16909
+ }
16910
+ get end() {
16911
+ return this.codePointIterator.end;
16912
+ }
16913
+ getLocFromIndex(index) {
16914
+ return this.codePointIterator.getLocFromIndex(index);
16915
+ }
16916
+ reportParseError(code, data) {
16917
+ const offset = this.codePointIterator.start;
16918
+ const loc = this.codePointIterator.getLocFromIndex(offset);
16919
+ throw new ParseError(code, offset, loc.line, loc.column, data);
16920
+ }
16921
+ nextToken() {
16922
+ let token = this.token;
16923
+ if (token != null) {
16924
+ this.token = null;
16925
+ return token;
16926
+ }
16927
+ let cp = this.lastCodePoint;
16928
+ while (cp !== CodePoint.EOF && !this.token) {
16929
+ cp = this.nextCode();
16930
+ const nextState = this[this.state](cp);
16931
+ if (!nextState)
16932
+ throw new Error(`Unknown error: pre state=${this.state}`);
16933
+ this.state = nextState;
16934
+ }
16935
+ token = this.token;
16936
+ this.token = null;
16937
+ return token;
16938
+ }
16939
+ nextCode() {
16940
+ if (this.lastCodePoint === CodePoint.EOF)
16941
+ return CodePoint.EOF;
16942
+ if (this.backCode) {
16943
+ this.backCode = false;
16944
+ return this.lastCodePoint;
16945
+ }
16946
+ return this.lastCodePoint = this.codePointIterator.next();
16947
+ }
16948
+ eatCode(cp) {
16949
+ if (this.lastCodePoint === CodePoint.EOF)
16950
+ return false;
16951
+ if (this.backCode) {
16952
+ if (this.lastCodePoint === cp) {
16953
+ this.backCode = false;
16954
+ return true;
16955
+ }
16956
+ return false;
16957
+ }
16958
+ return this.codePointIterator.eat(cp);
16959
+ }
16960
+ moveAt(loc) {
16961
+ if (this.backCode)
16962
+ this.backCode = false;
16963
+ this.lastCodePoint = this.codePointIterator.moveAt(loc);
16964
+ }
16965
+ back(state) {
16966
+ this.backCode = true;
16967
+ return state;
16968
+ }
16969
+ punctuatorToken() {
16970
+ this.startToken();
16971
+ this.endToken("Punctuator", "end");
16972
+ }
16973
+ startToken() {
16974
+ this.tokenStart = this.codePointIterator.start;
16975
+ }
16976
+ endToken(type, pos, option1, option2) {
16977
+ const { tokenStart } = this;
16978
+ const end = this.codePointIterator[pos];
16979
+ const range = [tokenStart, end];
16980
+ const loc = {
16981
+ start: this.codePointIterator.getLocFromIndex(tokenStart),
16982
+ end: this.codePointIterator.getLocFromIndex(end)
16983
+ };
16984
+ if (type === "Block")
16985
+ this.token = {
16986
+ type,
16987
+ value: this.text.slice(tokenStart + 1, end),
16988
+ range,
16989
+ loc
16990
+ };
16991
+ else {
16992
+ let token;
16993
+ const value = this.text.slice(tokenStart, end);
16994
+ if (type === "BasicString" || type === "LiteralString" || type === "MultiLineBasicString" || type === "MultiLineLiteralString")
16995
+ token = {
16996
+ type,
16997
+ value,
16998
+ string: option1,
16999
+ range,
17000
+ loc
17001
+ };
17002
+ else if (type === "Integer") {
17003
+ const text = option1;
17004
+ token = {
17005
+ type,
17006
+ value,
17007
+ number: parseInt(text, option2),
17008
+ bigint: HAS_BIGINT ? BigInt(RADIX_PREFIXES[option2] + text) : null,
17009
+ range,
17010
+ loc
17011
+ };
17012
+ } else if (type === "Float")
17013
+ token = {
17014
+ type,
17015
+ value,
17016
+ number: option1,
17017
+ range,
17018
+ loc
17019
+ };
17020
+ else if (type === "Boolean")
17021
+ token = {
17022
+ type,
17023
+ value,
17024
+ boolean: option1,
17025
+ range,
17026
+ loc
17027
+ };
17028
+ else if (type === "LocalDate" || type === "LocalTime" || type === "LocalDateTime" || type === "OffsetDateTime")
17029
+ token = {
17030
+ type,
17031
+ value,
17032
+ date: option1,
17033
+ range,
17034
+ loc
17035
+ };
17036
+ else
17037
+ token = {
17038
+ type,
17039
+ value,
17040
+ range,
17041
+ loc
17042
+ };
17043
+ this.token = token;
17044
+ }
17045
+ }
17046
+ DATA(cp) {
17047
+ while (isWhitespace(cp) || isEOL(cp))
17048
+ cp = this.nextCode();
17049
+ if (cp === CodePoint.HASH) {
17050
+ this.startToken();
17051
+ return "COMMENT";
17052
+ }
17053
+ if (cp === CodePoint.QUOTATION_MARK) {
17054
+ this.startToken();
17055
+ return "BASIC_STRING";
17056
+ }
17057
+ if (cp === CodePoint.SINGLE_QUOTE) {
17058
+ this.startToken();
17059
+ return "LITERAL_STRING";
17060
+ }
17061
+ if (cp === CodePoint.DOT || cp === CodePoint.EQUALS_SIGN || cp === CodePoint.LEFT_BRACKET || cp === CodePoint.RIGHT_BRACKET || cp === CodePoint.LEFT_BRACE || cp === CodePoint.RIGHT_BRACE || cp === CodePoint.COMMA) {
17062
+ this.punctuatorToken();
17063
+ return "DATA";
17064
+ }
17065
+ if (this.valuesEnabled) {
17066
+ if (cp === CodePoint.DASH || cp === CodePoint.PLUS_SIGN) {
17067
+ this.startToken();
17068
+ return "SIGN";
17069
+ }
17070
+ if (cp === CodePoint.LATIN_SMALL_N || cp === CodePoint.LATIN_SMALL_I) {
17071
+ this.startToken();
17072
+ return this.back("NAN_OR_INF");
17073
+ }
17074
+ if (isDigit(cp)) {
17075
+ this.startToken();
17076
+ return this.back("NUMBER");
17077
+ }
17078
+ if (cp === CodePoint.LATIN_SMALL_T || cp === CodePoint.LATIN_SMALL_F) {
17079
+ this.startToken();
17080
+ return this.back("BOOLEAN");
17081
+ }
17082
+ } else if (isUnquotedKeyChar(cp, this.tomlVersion)) {
17083
+ this.startToken();
17084
+ return "BARE";
17085
+ }
17086
+ if (cp === CodePoint.EOF)
17087
+ return "DATA";
17088
+ return this.reportParseError("unexpected-char");
17089
+ }
17090
+ COMMENT(cp) {
17091
+ const processCommentChar = this.tomlVersion.gte(1, 1) ? (c) => {
17092
+ if (!isNonEOL(c))
17093
+ this.reportParseError("invalid-comment-character", { cp: JSON.stringify(String.fromCodePoint(c)).slice(1, -1) });
17094
+ } : (c) => {
17095
+ if (isControlOtherThanTab(c))
17096
+ this.reportParseErrorControlChar();
17097
+ };
17098
+ while (!isEOL(cp) && cp !== CodePoint.EOF) {
17099
+ processCommentChar(cp);
17100
+ cp = this.nextCode();
17101
+ }
17102
+ this.endToken("Block", "start");
17103
+ return "DATA";
17104
+ }
17105
+ BARE(cp) {
17106
+ while (isUnquotedKeyChar(cp, this.tomlVersion))
17107
+ cp = this.nextCode();
17108
+ this.endToken("Bare", "start");
17109
+ return this.back("DATA");
17110
+ }
17111
+ BASIC_STRING(cp) {
17112
+ if (cp === CodePoint.QUOTATION_MARK) {
17113
+ cp = this.nextCode();
17114
+ if (cp === CodePoint.QUOTATION_MARK)
17115
+ return "MULTI_LINE_BASIC_STRING";
17116
+ this.endToken("BasicString", "start", "");
17117
+ return this.back("DATA");
17118
+ }
17119
+ const out = [];
17120
+ while (cp !== CodePoint.QUOTATION_MARK && cp !== CodePoint.EOF && cp !== CodePoint.LINE_FEED) {
17121
+ if (isControlOtherThanTab(cp))
17122
+ return this.reportParseErrorControlChar();
17123
+ if (cp === CodePoint.BACKSLASH) {
17124
+ cp = this.nextCode();
17125
+ const ecp = this.ESCAPES[cp];
17126
+ if (ecp) {
17127
+ out.push(ecp);
17128
+ cp = this.nextCode();
17129
+ continue;
17130
+ } else if (cp === CodePoint.LATIN_SMALL_U) {
17131
+ const code = this.parseUnicode(4);
17132
+ out.push(code);
17133
+ cp = this.nextCode();
17134
+ continue;
17135
+ } else if (cp === CodePoint.LATIN_CAPITAL_U) {
17136
+ const code = this.parseUnicode(8);
17137
+ out.push(code);
17138
+ cp = this.nextCode();
17139
+ continue;
17140
+ } else if (cp === CodePoint.LATIN_SMALL_X && this.tomlVersion.gte(1, 1)) {
17141
+ const code = this.parseUnicode(2);
17142
+ out.push(code);
17143
+ cp = this.nextCode();
17144
+ continue;
17145
+ }
17146
+ return this.reportParseError("invalid-char-in-escape-sequence");
17147
+ }
17148
+ out.push(cp);
17149
+ cp = this.nextCode();
17150
+ }
17151
+ if (cp !== CodePoint.QUOTATION_MARK)
17152
+ return this.reportParseError("unterminated-string");
17153
+ this.endToken("BasicString", "end", String.fromCodePoint(...out));
17154
+ return "DATA";
17155
+ }
17156
+ MULTI_LINE_BASIC_STRING(cp) {
17157
+ const out = [];
17158
+ if (cp === CodePoint.LINE_FEED)
17159
+ cp = this.nextCode();
17160
+ while (cp !== CodePoint.EOF) {
17161
+ if (cp !== CodePoint.LINE_FEED && isControlOtherThanTab(cp))
17162
+ return this.reportParseErrorControlChar();
17163
+ if (cp === CodePoint.QUOTATION_MARK) {
17164
+ const startPos = this.codePointIterator.start;
17165
+ if (this.eatCode(CodePoint.QUOTATION_MARK) && this.eatCode(CodePoint.QUOTATION_MARK)) {
17166
+ if (this.eatCode(CodePoint.QUOTATION_MARK)) {
17167
+ out.push(CodePoint.QUOTATION_MARK);
17168
+ if (this.eatCode(CodePoint.QUOTATION_MARK)) {
17169
+ out.push(CodePoint.QUOTATION_MARK);
17170
+ if (this.eatCode(CodePoint.QUOTATION_MARK)) {
17171
+ this.moveAt(startPos);
17172
+ return this.reportParseError("invalid-three-quotes");
17173
+ }
17174
+ }
17175
+ }
17176
+ this.endToken("MultiLineBasicString", "end", String.fromCodePoint(...out));
17177
+ return "DATA";
17178
+ }
17179
+ this.moveAt(startPos);
17180
+ }
17181
+ if (cp === CodePoint.BACKSLASH) {
17182
+ cp = this.nextCode();
17183
+ const ecp = this.ESCAPES[cp];
17184
+ if (ecp) {
17185
+ out.push(ecp);
17186
+ cp = this.nextCode();
17187
+ continue;
17188
+ } else if (cp === CodePoint.LATIN_SMALL_U) {
17189
+ const code = this.parseUnicode(4);
17190
+ out.push(code);
17191
+ cp = this.nextCode();
17192
+ continue;
17193
+ } else if (cp === CodePoint.LATIN_CAPITAL_U) {
17194
+ const code = this.parseUnicode(8);
17195
+ out.push(code);
17196
+ cp = this.nextCode();
17197
+ continue;
17198
+ } else if (cp === CodePoint.LATIN_SMALL_X && this.tomlVersion.gte(1, 1)) {
17199
+ const code = this.parseUnicode(2);
17200
+ out.push(code);
17201
+ cp = this.nextCode();
17202
+ continue;
17203
+ } else if (cp === CodePoint.LINE_FEED) {
17204
+ cp = this.nextCode();
17205
+ while (isWhitespace(cp) || cp === CodePoint.LINE_FEED)
17206
+ cp = this.nextCode();
17207
+ continue;
17208
+ } else if (isWhitespace(cp)) {
17209
+ let valid = true;
17210
+ const startPos = this.codePointIterator.start;
17211
+ let nextCp;
17212
+ while ((nextCp = this.nextCode()) !== CodePoint.EOF) {
17213
+ if (nextCp === CodePoint.LINE_FEED)
17214
+ break;
17215
+ if (!isWhitespace(nextCp)) {
17216
+ this.moveAt(startPos);
17217
+ valid = false;
17218
+ break;
17219
+ }
17220
+ }
17221
+ if (valid) {
17222
+ cp = this.nextCode();
17223
+ while (isWhitespace(cp) || cp === CodePoint.LINE_FEED)
17224
+ cp = this.nextCode();
17225
+ continue;
17226
+ }
17227
+ }
17228
+ return this.reportParseError("invalid-char-in-escape-sequence");
17229
+ }
17230
+ out.push(cp);
17231
+ cp = this.nextCode();
17232
+ }
17233
+ return this.reportParseError("unterminated-string");
17234
+ }
17235
+ LITERAL_STRING(cp) {
17236
+ if (cp === CodePoint.SINGLE_QUOTE) {
17237
+ cp = this.nextCode();
17238
+ if (cp === CodePoint.SINGLE_QUOTE)
17239
+ return "MULTI_LINE_LITERAL_STRING";
17240
+ this.endToken("LiteralString", "start", "");
17241
+ return this.back("DATA");
17242
+ }
17243
+ const out = [];
17244
+ while (cp !== CodePoint.SINGLE_QUOTE && cp !== CodePoint.EOF && cp !== CodePoint.LINE_FEED) {
17245
+ if (isControlOtherThanTab(cp))
17246
+ return this.reportParseErrorControlChar();
17247
+ out.push(cp);
17248
+ cp = this.nextCode();
17249
+ }
17250
+ if (cp !== CodePoint.SINGLE_QUOTE)
17251
+ return this.reportParseError("unterminated-string");
17252
+ this.endToken("LiteralString", "end", String.fromCodePoint(...out));
17253
+ return "DATA";
17254
+ }
17255
+ MULTI_LINE_LITERAL_STRING(cp) {
17256
+ const out = [];
17257
+ if (cp === CodePoint.LINE_FEED)
17258
+ cp = this.nextCode();
17259
+ while (cp !== CodePoint.EOF) {
17260
+ if (cp !== CodePoint.LINE_FEED && isControlOtherThanTab(cp))
17261
+ return this.reportParseErrorControlChar();
17262
+ if (cp === CodePoint.SINGLE_QUOTE) {
17263
+ const startPos = this.codePointIterator.start;
17264
+ if (this.eatCode(CodePoint.SINGLE_QUOTE) && this.eatCode(CodePoint.SINGLE_QUOTE)) {
17265
+ if (this.eatCode(CodePoint.SINGLE_QUOTE)) {
17266
+ out.push(CodePoint.SINGLE_QUOTE);
17267
+ if (this.eatCode(CodePoint.SINGLE_QUOTE)) {
17268
+ out.push(CodePoint.SINGLE_QUOTE);
17269
+ if (this.eatCode(CodePoint.SINGLE_QUOTE)) {
17270
+ this.moveAt(startPos);
17271
+ return this.reportParseError("invalid-three-quotes");
17272
+ }
17273
+ }
17274
+ }
17275
+ this.endToken("MultiLineLiteralString", "end", String.fromCodePoint(...out));
17276
+ return "DATA";
17277
+ }
17278
+ this.moveAt(startPos);
17279
+ }
17280
+ out.push(cp);
17281
+ cp = this.nextCode();
17282
+ }
17283
+ return this.reportParseError("unterminated-string");
17284
+ }
17285
+ SIGN(cp) {
17286
+ if (cp === CodePoint.LATIN_SMALL_N || cp === CodePoint.LATIN_SMALL_I)
17287
+ return this.back("NAN_OR_INF");
17288
+ if (isDigit(cp))
17289
+ return this.back("NUMBER");
17290
+ return this.reportParseError("unexpected-char");
17291
+ }
17292
+ NAN_OR_INF(cp) {
17293
+ if (cp === CodePoint.LATIN_SMALL_N) {
17294
+ const startPos = this.codePointIterator.start;
17295
+ if (this.eatCode(CodePoint.LATIN_SMALL_A) && this.eatCode(CodePoint.LATIN_SMALL_N)) {
17296
+ this.endToken("Float", "end", NaN);
17297
+ return "DATA";
17298
+ }
17299
+ this.moveAt(startPos);
17300
+ } else if (cp === CodePoint.LATIN_SMALL_I) {
17301
+ const startPos = this.codePointIterator.start;
17302
+ if (this.eatCode(CodePoint.LATIN_SMALL_N) && this.eatCode(CodePoint.LATIN_SMALL_F)) {
17303
+ this.endToken("Float", "end", this.text[this.tokenStart] === "-" ? -Infinity : Infinity);
17304
+ return "DATA";
17305
+ }
17306
+ this.moveAt(startPos);
17307
+ }
17308
+ return this.reportParseError("unexpected-char");
17309
+ }
17310
+ NUMBER(cp) {
17311
+ const start = this.text[this.tokenStart];
17312
+ const sign = start === "+" ? CodePoint.PLUS_SIGN : start === "-" ? CodePoint.DASH : CodePoint.NULL;
17313
+ if (cp === CodePoint.DIGIT_0) {
17314
+ if (sign === CodePoint.NULL) {
17315
+ const startPos = this.codePointIterator.start;
17316
+ const nextCp$1 = this.nextCode();
17317
+ if (isDigit(nextCp$1)) {
17318
+ const nextNextCp = this.nextCode();
17319
+ if (nextNextCp === CodePoint.COLON) {
17320
+ this.data = {
17321
+ hasDate: false,
17322
+ year: 0,
17323
+ month: 0,
17324
+ day: 0,
17325
+ hour: Number(String.fromCodePoint(CodePoint.DIGIT_0, nextCp$1)),
17326
+ minute: 0,
17327
+ second: 0
17328
+ };
17329
+ return "TIME_MINUTE";
17330
+ }
17331
+ if (isDigit(nextNextCp)) {
17332
+ const nextNextNextCp = this.nextCode();
17333
+ if (isDigit(nextNextNextCp) && this.eatCode(CodePoint.DASH)) {
17334
+ this.data = {
17335
+ hasDate: true,
17336
+ year: Number(String.fromCodePoint(CodePoint.DIGIT_0, nextCp$1, nextNextCp, nextNextNextCp)),
17337
+ month: 0,
17338
+ day: 0,
17339
+ hour: 0,
17340
+ minute: 0,
17341
+ second: 0
17342
+ };
17343
+ return "DATE_MONTH";
17344
+ }
17345
+ }
17346
+ this.moveAt(startPos);
17347
+ return this.reportParseError("invalid-leading-zero");
17348
+ }
17349
+ this.moveAt(startPos);
17350
+ }
17351
+ cp = this.nextCode();
17352
+ if (cp === CodePoint.LATIN_SMALL_X || cp === CodePoint.LATIN_SMALL_O || cp === CodePoint.LATIN_SMALL_B) {
17353
+ if (sign !== CodePoint.NULL)
17354
+ return this.reportParseError("unexpected-char");
17355
+ return cp === CodePoint.LATIN_SMALL_X ? "HEX" : cp === CodePoint.LATIN_SMALL_O ? "OCTAL" : "BINARY";
17356
+ }
17357
+ if (cp === CodePoint.LATIN_SMALL_E || cp === CodePoint.LATIN_CAPITAL_E) {
17358
+ this.data = {
17359
+ minus: sign === CodePoint.DASH,
17360
+ left: [CodePoint.DIGIT_0]
17361
+ };
17362
+ return "EXPONENT_RIGHT";
17363
+ }
17364
+ if (cp === CodePoint.DOT) {
17365
+ this.data = {
17366
+ minus: sign === CodePoint.DASH,
17367
+ absInt: [CodePoint.DIGIT_0]
17368
+ };
17369
+ return "FRACTIONAL_RIGHT";
17370
+ }
17371
+ this.endToken("Integer", "start", "0", 10);
17372
+ return this.back("DATA");
17373
+ }
17374
+ const { out, nextCp, hasUnderscore } = this.parseDigits(cp, isDigit);
17375
+ if (nextCp === CodePoint.DASH && sign === CodePoint.NULL && !hasUnderscore && out.length === 4) {
17376
+ this.data = {
17377
+ hasDate: true,
17378
+ year: Number(String.fromCodePoint(...out)),
17379
+ month: 0,
17380
+ day: 0,
17381
+ hour: 0,
17382
+ minute: 0,
17383
+ second: 0
17384
+ };
17385
+ return "DATE_MONTH";
17386
+ }
17387
+ if (nextCp === CodePoint.COLON && sign === CodePoint.NULL && !hasUnderscore && out.length === 2) {
17388
+ this.data = {
17389
+ hasDate: false,
17390
+ year: 0,
17391
+ month: 0,
17392
+ day: 0,
17393
+ hour: Number(String.fromCodePoint(...out)),
17394
+ minute: 0,
17395
+ second: 0
17396
+ };
17397
+ return "TIME_MINUTE";
17398
+ }
17399
+ if (nextCp === CodePoint.LATIN_SMALL_E || nextCp === CodePoint.LATIN_CAPITAL_E) {
17400
+ this.data = {
17401
+ minus: sign === CodePoint.DASH,
17402
+ left: out
17403
+ };
17404
+ return "EXPONENT_RIGHT";
17405
+ }
17406
+ if (nextCp === CodePoint.DOT) {
17407
+ this.data = {
17408
+ minus: sign === CodePoint.DASH,
17409
+ absInt: out
17410
+ };
17411
+ return "FRACTIONAL_RIGHT";
17412
+ }
17413
+ this.endToken("Integer", "start", sign === CodePoint.DASH ? String.fromCodePoint(CodePoint.DASH, ...out) : String.fromCodePoint(...out), 10);
17414
+ return this.back("DATA");
17415
+ }
17416
+ HEX(cp) {
17417
+ const { out } = this.parseDigits(cp, isHexDig);
17418
+ this.endToken("Integer", "start", String.fromCodePoint(...out), 16);
17419
+ return this.back("DATA");
17420
+ }
17421
+ OCTAL(cp) {
17422
+ const { out } = this.parseDigits(cp, isOctalDig);
17423
+ this.endToken("Integer", "start", String.fromCodePoint(...out), 8);
17424
+ return this.back("DATA");
17425
+ }
17426
+ BINARY(cp) {
17427
+ const { out } = this.parseDigits(cp, (c) => c === CodePoint.DIGIT_0 || c === CodePoint.DIGIT_1);
17428
+ this.endToken("Integer", "start", String.fromCodePoint(...out), 2);
17429
+ return this.back("DATA");
17430
+ }
17431
+ FRACTIONAL_RIGHT(cp) {
17432
+ const { minus, absInt } = this.data;
17433
+ const { out, nextCp } = this.parseDigits(cp, isDigit);
17434
+ const absNum = [
17435
+ ...absInt,
17436
+ CodePoint.DOT,
17437
+ ...out
17438
+ ];
17439
+ if (nextCp === CodePoint.LATIN_SMALL_E || nextCp === CodePoint.LATIN_CAPITAL_E) {
17440
+ this.data = {
17441
+ minus,
17442
+ left: absNum
17443
+ };
17444
+ return "EXPONENT_RIGHT";
17445
+ }
17446
+ const value = Number(minus ? String.fromCodePoint(CodePoint.DASH, ...absNum) : String.fromCodePoint(...absNum));
17447
+ this.endToken("Float", "start", value);
17448
+ return this.back("DATA");
17449
+ }
17450
+ EXPONENT_RIGHT(cp) {
17451
+ const { left, minus: leftMinus } = this.data;
17452
+ let minus = false;
17453
+ if (cp === CodePoint.DASH || cp === CodePoint.PLUS_SIGN) {
17454
+ minus = cp === CodePoint.DASH;
17455
+ cp = this.nextCode();
17456
+ }
17457
+ const { out } = this.parseDigits(cp, isDigit);
17458
+ const right = out;
17459
+ if (minus)
17460
+ right.unshift(CodePoint.DASH);
17461
+ const value = Number(leftMinus ? String.fromCodePoint(CodePoint.DASH, ...left, CodePoint.LATIN_SMALL_E, ...right) : String.fromCodePoint(...left, CodePoint.LATIN_SMALL_E, ...right));
17462
+ this.endToken("Float", "start", value);
17463
+ return this.back("DATA");
17464
+ }
17465
+ BOOLEAN(cp) {
17466
+ if (cp === CodePoint.LATIN_SMALL_T) {
17467
+ const startPos = this.codePointIterator.start;
17468
+ if (this.eatCode(CodePoint.LATIN_SMALL_R) && this.eatCode(CodePoint.LATIN_SMALL_U) && this.eatCode(CodePoint.LATIN_SMALL_E)) {
17469
+ this.endToken("Boolean", "end", true);
17470
+ return "DATA";
17471
+ }
17472
+ this.moveAt(startPos);
17473
+ } else if (cp === CodePoint.LATIN_SMALL_F) {
17474
+ const startPos = this.codePointIterator.start;
17475
+ if (this.eatCode(CodePoint.LATIN_SMALL_A) && this.eatCode(CodePoint.LATIN_SMALL_L) && this.eatCode(CodePoint.LATIN_SMALL_S) && this.eatCode(CodePoint.LATIN_SMALL_E)) {
17476
+ this.endToken("Boolean", "end", false);
17477
+ return "DATA";
17478
+ }
17479
+ this.moveAt(startPos);
17480
+ }
17481
+ return this.reportParseError("unexpected-char");
17482
+ }
17483
+ DATE_MONTH(cp) {
17484
+ const start = this.codePointIterator.start;
17485
+ if (!isDigit(cp))
17486
+ return this.reportParseError("unexpected-char");
17487
+ cp = this.nextCode();
17488
+ if (!isDigit(cp))
17489
+ return this.reportParseError("unexpected-char");
17490
+ cp = this.nextCode();
17491
+ if (cp !== CodePoint.DASH)
17492
+ return this.reportParseError("unexpected-char");
17493
+ const end = this.codePointIterator.start;
17494
+ const data = this.data;
17495
+ data.month = Number(this.text.slice(start, end));
17496
+ return "DATE_DAY";
17497
+ }
17498
+ DATE_DAY(cp) {
17499
+ const start = this.codePointIterator.start;
17500
+ if (!isDigit(cp))
17501
+ return this.reportParseError("unexpected-char");
17502
+ cp = this.nextCode();
17503
+ if (!isDigit(cp))
17504
+ return this.reportParseError("unexpected-char");
17505
+ const end = this.codePointIterator.end;
17506
+ const data = this.data;
17507
+ data.day = Number(this.text.slice(start, end));
17508
+ if (!isValidDate(data.year, data.month, data.day))
17509
+ return this.reportParseError("invalid-date");
17510
+ cp = this.nextCode();
17511
+ if (cp === CodePoint.LATIN_CAPITAL_T || cp === CodePoint.LATIN_SMALL_T)
17512
+ return "TIME_HOUR";
17513
+ if (cp === CodePoint.SPACE) {
17514
+ const startPos = this.codePointIterator.start;
17515
+ if (isDigit(this.nextCode()) && isDigit(this.nextCode())) {
17516
+ this.moveAt(startPos);
17517
+ return "TIME_HOUR";
17518
+ }
17519
+ this.moveAt(startPos);
17520
+ }
17521
+ const dateValue = getDateFromDateTimeData(data, "");
17522
+ this.endToken("LocalDate", "start", dateValue);
17523
+ return this.back("DATA");
17524
+ }
17525
+ TIME_HOUR(cp) {
17526
+ const start = this.codePointIterator.start;
17527
+ if (!isDigit(cp))
17528
+ return this.reportParseError("unexpected-char");
17529
+ cp = this.nextCode();
17530
+ if (!isDigit(cp))
17531
+ return this.reportParseError("unexpected-char");
17532
+ cp = this.nextCode();
17533
+ if (cp !== CodePoint.COLON)
17534
+ return this.reportParseError("unexpected-char");
17535
+ const end = this.codePointIterator.start;
17536
+ const data = this.data;
17537
+ data.hour = Number(this.text.slice(start, end));
17538
+ return "TIME_MINUTE";
17539
+ }
17540
+ TIME_MINUTE(cp) {
17541
+ const start = this.codePointIterator.start;
17542
+ if (!isDigit(cp))
17543
+ return this.reportParseError("unexpected-char");
17544
+ cp = this.nextCode();
17545
+ if (!isDigit(cp))
17546
+ return this.reportParseError("unexpected-char");
17547
+ const end = this.codePointIterator.end;
17548
+ const data = this.data;
17549
+ data.minute = Number(this.text.slice(start, end));
17550
+ cp = this.nextCode();
17551
+ if (cp === CodePoint.COLON)
17552
+ return "TIME_SECOND";
17553
+ if (this.tomlVersion.lt(1, 1))
17554
+ return this.reportParseError("unexpected-char");
17555
+ if (!isValidTime(data.hour, data.minute, data.second))
17556
+ return this.reportParseError("invalid-time");
17557
+ return this.processTimeEnd(cp, data);
17558
+ }
17559
+ TIME_SECOND(cp) {
17560
+ const start = this.codePointIterator.start;
17561
+ if (!isDigit(cp))
17562
+ return this.reportParseError("unexpected-char");
17563
+ cp = this.nextCode();
17564
+ if (!isDigit(cp))
17565
+ return this.reportParseError("unexpected-char");
17566
+ const end = this.codePointIterator.end;
17567
+ const data = this.data;
17568
+ data.second = Number(this.text.slice(start, end));
17569
+ if (!isValidTime(data.hour, data.minute, data.second))
17570
+ return this.reportParseError("invalid-time");
17571
+ cp = this.nextCode();
17572
+ if (cp === CodePoint.DOT)
17573
+ return "TIME_SEC_FRAC";
17574
+ return this.processTimeEnd(cp, data);
17575
+ }
17576
+ TIME_SEC_FRAC(cp) {
17577
+ if (!isDigit(cp))
17578
+ return this.reportParseError("unexpected-char");
17579
+ const start = this.codePointIterator.start;
17580
+ while (isDigit(cp))
17581
+ cp = this.nextCode();
17582
+ const end = this.codePointIterator.start;
17583
+ const data = this.data;
17584
+ data.frac = this.text.slice(start, end);
17585
+ return this.processTimeEnd(cp, data);
17586
+ }
17587
+ processTimeEnd(cp, data) {
17588
+ if (data.hasDate) {
17589
+ if (cp === CodePoint.DASH || cp === CodePoint.PLUS_SIGN) {
17590
+ data.offsetSign = cp;
17591
+ return "TIME_OFFSET";
17592
+ }
17593
+ if (cp === CodePoint.LATIN_CAPITAL_Z || cp === CodePoint.LATIN_SMALL_Z) {
17594
+ const dateValue$2 = getDateFromDateTimeData(data, "Z");
17595
+ this.endToken("OffsetDateTime", "end", dateValue$2);
17596
+ return "DATA";
17597
+ }
17598
+ const dateValue$1 = getDateFromDateTimeData(data, "");
17599
+ this.endToken("LocalDateTime", "start", dateValue$1);
17600
+ return this.back("DATA");
17601
+ }
17602
+ const dateValue = getDateFromDateTimeData(data, "");
17603
+ this.endToken("LocalTime", "start", dateValue);
17604
+ return this.back("DATA");
17605
+ }
17606
+ TIME_OFFSET(cp) {
17607
+ if (!isDigit(cp))
17608
+ return this.reportParseError("unexpected-char");
17609
+ const hourStart = this.codePointIterator.start;
17610
+ cp = this.nextCode();
17611
+ if (!isDigit(cp))
17612
+ return this.reportParseError("unexpected-char");
17613
+ cp = this.nextCode();
17614
+ if (cp !== CodePoint.COLON)
17615
+ return this.reportParseError("unexpected-char");
17616
+ const hourEnd = this.codePointIterator.start;
17617
+ cp = this.nextCode();
17618
+ const minuteStart = this.codePointIterator.start;
17619
+ if (!isDigit(cp))
17620
+ return this.reportParseError("unexpected-char");
17621
+ cp = this.nextCode();
17622
+ if (!isDigit(cp))
17623
+ return this.reportParseError("unexpected-char");
17624
+ const minuteEnd = this.codePointIterator.end;
17625
+ const hour = Number(this.text.slice(hourStart, hourEnd));
17626
+ const minute = Number(this.text.slice(minuteStart, minuteEnd));
17627
+ if (!isValidTime(hour, minute, 0))
17628
+ return this.reportParseError("invalid-time");
17629
+ const data = this.data;
17630
+ const dateValue = getDateFromDateTimeData(data, `${String.fromCodePoint(data.offsetSign)}${padStart(hour, 2)}:${padStart(minute, 2)}`);
17631
+ this.endToken("OffsetDateTime", "end", dateValue);
17632
+ return "DATA";
17633
+ }
17634
+ parseDigits(cp, checkDigit) {
17635
+ if (cp === CodePoint.UNDERSCORE)
17636
+ return this.reportParseError("invalid-underscore");
17637
+ if (!checkDigit(cp))
17638
+ return this.reportParseError("unexpected-char");
17639
+ const out = [];
17640
+ let before = CodePoint.NULL;
17641
+ let hasUnderscore = false;
17642
+ while (checkDigit(cp) || cp === CodePoint.UNDERSCORE) {
17643
+ if (cp === CodePoint.UNDERSCORE) {
17644
+ hasUnderscore = true;
17645
+ if (before === CodePoint.UNDERSCORE)
17646
+ return this.reportParseError("invalid-underscore");
17647
+ } else
17648
+ out.push(cp);
17649
+ before = cp;
17650
+ cp = this.nextCode();
17651
+ }
17652
+ if (before === CodePoint.UNDERSCORE)
17653
+ return this.reportParseError("invalid-underscore");
17654
+ return {
17655
+ out,
17656
+ nextCp: cp,
17657
+ hasUnderscore
17658
+ };
17659
+ }
17660
+ parseUnicode(count) {
17661
+ const startLoc = this.codePointIterator.start;
17662
+ const start = this.codePointIterator.end;
17663
+ let charCount = 0;
17664
+ let cp;
17665
+ while ((cp = this.nextCode()) !== CodePoint.EOF) {
17666
+ if (!isHexDig(cp)) {
17667
+ this.moveAt(startLoc);
17668
+ return this.reportParseError("invalid-char-in-escape-sequence");
17669
+ }
17670
+ charCount++;
17671
+ if (charCount >= count)
17672
+ break;
17673
+ }
17674
+ const end = this.codePointIterator.end;
17675
+ const code = this.text.slice(start, end);
17676
+ const codePoint = parseInt(code, 16);
17677
+ if (!isUnicodeScalarValue(codePoint))
17678
+ return this.reportParseError("invalid-code-point", { cp: code });
17679
+ return codePoint;
17680
+ }
17681
+ reportParseErrorControlChar() {
17682
+ return this.reportParseError("invalid-control-character");
17683
+ }
17684
+ };
17685
+ function isUnquotedKeyChar(cp, tomlVersion) {
17686
+ if (isLetter(cp) || isDigit(cp) || cp === CodePoint.UNDERSCORE || cp === CodePoint.DASH)
17687
+ return true;
17688
+ if (tomlVersion.lt(1, 1))
17689
+ return false;
17690
+ return false;
17691
+ }
17692
+ function isControlOtherThanTab(cp) {
17693
+ return isControl(cp) && cp !== CodePoint.TABULATION || cp === CodePoint.DELETE;
17694
+ }
17695
+ function isNonEOL(cp) {
17696
+ return cp === CodePoint.TABULATION || CodePoint.SPACE <= cp && cp <= CodePoint.TILDE || isNonAscii(cp);
17697
+ }
17698
+ function isNonAscii(cp) {
17699
+ return CodePoint.PAD <= cp && cp <= CodePoint.CP_D7FF || CodePoint.CP_E000 <= cp && cp <= CodePoint.CP_10FFFF;
17700
+ }
17701
+ function isValidDate(y, m, d) {
17702
+ if (y >= 0 && m <= 12 && m >= 1 && d >= 1)
17703
+ return d <= (m === 2 ? y & 3 || !(y % 25) && y & 15 ? 28 : 29 : 30 + (m + (m >> 3) & 1));
17704
+ return false;
17705
+ }
17706
+ function isValidTime(h, m, s) {
17707
+ if (h >= 24 || h < 0 || m > 59 || m < 0 || s > 60 || s < 0)
17708
+ return false;
17709
+ return true;
17710
+ }
17711
+ function getDateFromDateTimeData(data, timeZone) {
17712
+ const year = padStart(data.year, 4);
17713
+ const month = data.month ? padStart(data.month, 2) : "01";
17714
+ const day = data.day ? padStart(data.day, 2) : "01";
17715
+ const hour = padStart(data.hour, 2);
17716
+ const minute = padStart(data.minute, 2);
17717
+ const second = padStart(data.second, 2);
17718
+ const textDate = `${year}-${month}-${day}`;
17719
+ const frac = data.frac ? `.${data.frac}` : "";
17720
+ const dateValue = /* @__PURE__ */ new Date(`${textDate}T${hour}:${minute}:${second}${frac}${timeZone}`);
17721
+ if (!isNaN(dateValue.getTime()) || data.second !== 60)
17722
+ return dateValue;
17723
+ return /* @__PURE__ */ new Date(`${textDate}T${hour}:${minute}:59${frac}${timeZone}`);
17724
+ }
17725
+ function padStart(num, maxLength) {
17726
+ return String(num).padStart(maxLength, "0");
17727
+ }
17728
+ var VALUE_KIND_VALUE = Symbol("VALUE_KIND_VALUE");
17729
+ var VALUE_KIND_INTERMEDIATE = Symbol("VALUE_KIND_INTERMEDIATE");
17730
+ var KeysResolver = class {
17731
+ constructor(ctx) {
17732
+ this.rootKeys = /* @__PURE__ */ new Map;
17733
+ this.tables = [];
17734
+ this.ctx = ctx;
17735
+ }
17736
+ applyResolveKeyForTable(node2) {
17737
+ let keys = this.rootKeys;
17738
+ const peekKeyIndex = node2.key.keys.length - 1;
17739
+ for (let index = 0;index < peekKeyIndex; index++) {
17740
+ const keyNode = node2.key.keys[index];
17741
+ const keyName = toKeyName(keyNode);
17742
+ node2.resolvedKey.push(keyName);
17743
+ let keyStore = keys.get(keyName);
17744
+ if (!keyStore) {
17745
+ keyStore = {
17746
+ node: keyNode,
17747
+ keys: /* @__PURE__ */ new Map
17748
+ };
17749
+ keys.set(keyName, keyStore);
17750
+ } else if (keyStore.table === "array") {
17751
+ const peekIndex = keyStore.peekIndex;
17752
+ node2.resolvedKey.push(peekIndex);
17753
+ keyStore = keyStore.keys.get(peekIndex);
17754
+ }
17755
+ keys = keyStore.keys;
17756
+ }
17757
+ const lastKeyNode = node2.key.keys[peekKeyIndex];
17758
+ const lastKeyName = toKeyName(lastKeyNode);
17759
+ node2.resolvedKey.push(lastKeyName);
17760
+ const lastKeyStore = keys.get(lastKeyName);
17761
+ if (!lastKeyStore)
17762
+ if (node2.kind === "array") {
17763
+ node2.resolvedKey.push(0);
17764
+ const newKeyStore = {
17765
+ node: lastKeyNode,
17766
+ keys: /* @__PURE__ */ new Map
17767
+ };
17768
+ keys.set(lastKeyName, {
17769
+ table: node2.kind,
17770
+ node: lastKeyNode,
17771
+ keys: new Map([[0, newKeyStore]]),
17772
+ peekIndex: 0
17773
+ });
17774
+ this.tables.push({
17775
+ node: node2,
17776
+ keys: newKeyStore.keys
17777
+ });
17778
+ } else {
17779
+ const newKeyStore = {
17780
+ table: node2.kind,
17781
+ node: lastKeyNode,
17782
+ keys: /* @__PURE__ */ new Map
17783
+ };
17784
+ keys.set(lastKeyName, newKeyStore);
17785
+ this.tables.push({
17786
+ node: node2,
17787
+ keys: newKeyStore.keys
17788
+ });
17789
+ }
17790
+ else if (!lastKeyStore.table)
17791
+ if (node2.kind === "array")
17792
+ this.ctx.reportParseError("dupe-keys", lastKeyNode);
17793
+ else {
17794
+ const transformKey = {
17795
+ table: node2.kind,
17796
+ node: lastKeyNode,
17797
+ keys: lastKeyStore.keys
17798
+ };
17799
+ keys.set(lastKeyName, transformKey);
17800
+ this.tables.push({
17801
+ node: node2,
17802
+ keys: transformKey.keys
17803
+ });
17804
+ }
17805
+ else if (lastKeyStore.table === "array")
17806
+ if (node2.kind === "array") {
17807
+ const newKeyStore = {
17808
+ node: lastKeyNode,
17809
+ keys: /* @__PURE__ */ new Map
17810
+ };
17811
+ const newIndex = lastKeyStore.peekIndex + 1;
17812
+ node2.resolvedKey.push(newIndex);
17813
+ lastKeyStore.keys.set(newIndex, newKeyStore);
17814
+ lastKeyStore.peekIndex = newIndex;
17815
+ this.tables.push({
17816
+ node: node2,
17817
+ keys: newKeyStore.keys
17818
+ });
17819
+ } else
17820
+ this.ctx.reportParseError("dupe-keys", lastKeyNode);
17821
+ else
17822
+ this.ctx.reportParseError("dupe-keys", lastKeyNode);
17823
+ }
17824
+ verifyDuplicateKeys(node2) {
17825
+ for (const body of node2.body)
17826
+ if (body.type === "TOMLKeyValue")
17827
+ verifyDuplicateKeysForKeyValue(this.ctx, this.rootKeys, body);
17828
+ for (const { node: tableNode, keys } of this.tables)
17829
+ for (const body of tableNode.body)
17830
+ verifyDuplicateKeysForKeyValue(this.ctx, keys, body);
17831
+ }
17832
+ };
17833
+ function verifyDuplicateKeysForKeyValue(ctx, defineKeys, node2) {
17834
+ let keys = defineKeys;
17835
+ const lastKey = last(node2.key.keys);
17836
+ for (const keyNode of node2.key.keys) {
17837
+ const key = toKeyName(keyNode);
17838
+ let defineKey = keys.get(key);
17839
+ if (defineKey) {
17840
+ if (defineKey.value === VALUE_KIND_VALUE)
17841
+ ctx.reportParseError("dupe-keys", getAfterNode(keyNode, defineKey.node));
17842
+ else if (lastKey === keyNode)
17843
+ ctx.reportParseError("dupe-keys", getAfterNode(keyNode, defineKey.node));
17844
+ else if (defineKey.table)
17845
+ ctx.reportParseError("dupe-keys", getAfterNode(keyNode, defineKey.node));
17846
+ defineKey.value = VALUE_KIND_INTERMEDIATE;
17847
+ } else {
17848
+ if (lastKey === keyNode)
17849
+ defineKey = {
17850
+ value: VALUE_KIND_VALUE,
17851
+ node: keyNode,
17852
+ keys: /* @__PURE__ */ new Map
17853
+ };
17854
+ else
17855
+ defineKey = {
17856
+ value: VALUE_KIND_INTERMEDIATE,
17857
+ node: keyNode,
17858
+ keys: /* @__PURE__ */ new Map
17859
+ };
17860
+ keys.set(key, defineKey);
17861
+ }
17862
+ keys = defineKey.keys;
17863
+ }
17864
+ if (node2.value.type === "TOMLInlineTable")
17865
+ verifyDuplicateKeysForInlineTable(ctx, keys, node2.value);
17866
+ else if (node2.value.type === "TOMLArray")
17867
+ verifyDuplicateKeysForArray(ctx, keys, node2.value);
17868
+ }
17869
+ function verifyDuplicateKeysForInlineTable(ctx, defineKeys, node2) {
17870
+ for (const body of node2.body)
17871
+ verifyDuplicateKeysForKeyValue(ctx, defineKeys, body);
17872
+ }
17873
+ function verifyDuplicateKeysForArray(ctx, defineKeys, node2) {
17874
+ const keys = defineKeys;
17875
+ for (let index = 0;index < node2.elements.length; index++) {
17876
+ const element = node2.elements[index];
17877
+ let defineKey = keys.get(index);
17878
+ if (defineKey)
17879
+ ctx.reportParseError("dupe-keys", getAfterNode(element, defineKey.node));
17880
+ else {
17881
+ defineKey = {
17882
+ value: VALUE_KIND_VALUE,
17883
+ node: element,
17884
+ keys: /* @__PURE__ */ new Map
17885
+ };
17886
+ defineKeys.set(index, defineKey);
17887
+ if (element.type === "TOMLInlineTable")
17888
+ verifyDuplicateKeysForInlineTable(ctx, defineKey.keys, element);
17889
+ else if (element.type === "TOMLArray")
17890
+ verifyDuplicateKeysForArray(ctx, defineKey.keys, element);
17891
+ }
17892
+ }
17893
+ }
17894
+ function getAfterNode(a, b) {
17895
+ return a.range[0] <= b.range[0] ? b : a;
17896
+ }
17897
+ var Context = class {
17898
+ constructor(data) {
17899
+ this.tokens = [];
17900
+ this.comments = [];
17901
+ this.back = null;
17902
+ this.stateStack = [];
17903
+ this.needNewLine = false;
17904
+ this.needSameLine = false;
17905
+ this.currToken = null;
17906
+ this.prevToken = null;
17907
+ this.valueContainerStack = [];
17908
+ this.tokenizer = new Tokenizer(data.text, data.parserOptions);
17909
+ this.topLevelTable = data.topLevelTable;
17910
+ this.table = data.topLevelTable;
17911
+ this.keysResolver = new KeysResolver(this);
17912
+ }
17913
+ nextToken(option) {
17914
+ this.prevToken = this.currToken;
17915
+ if (this.back) {
17916
+ this.currToken = this.back;
17917
+ this.back = null;
17918
+ } else
17919
+ this.currToken = this._nextTokenFromTokenizer(option);
17920
+ if ((this.needNewLine || this.needSameLine || option?.needSameLine) && this.prevToken && this.currToken)
17921
+ if (this.prevToken.loc.end.line === this.currToken.loc.start.line) {
17922
+ if (this.needNewLine)
17923
+ return this.reportParseError("missing-newline", this.currToken);
17924
+ } else {
17925
+ const needSameLine = this.needSameLine || option?.needSameLine;
17926
+ if (needSameLine)
17927
+ return this.reportParseError(needSameLine, this.currToken);
17928
+ }
17929
+ this.needNewLine = false;
17930
+ this.needSameLine = false;
17931
+ return this.currToken;
17932
+ }
17933
+ _nextTokenFromTokenizer(option) {
17934
+ const valuesEnabled = this.tokenizer.valuesEnabled;
17935
+ if (option?.valuesEnabled)
17936
+ this.tokenizer.valuesEnabled = option.valuesEnabled;
17937
+ let token = this.tokenizer.nextToken();
17938
+ while (token && token.type === "Block") {
17939
+ this.comments.push(token);
17940
+ token = this.tokenizer.nextToken();
17941
+ }
17942
+ if (token)
17943
+ this.tokens.push(token);
17944
+ this.tokenizer.valuesEnabled = valuesEnabled;
17945
+ return token;
17946
+ }
17947
+ backToken() {
17948
+ if (this.back)
17949
+ throw new Error("Illegal state");
17950
+ this.back = this.currToken;
17951
+ this.currToken = this.prevToken;
17952
+ }
17953
+ addValueContainer(valueContainer) {
17954
+ this.valueContainerStack.push(valueContainer);
17955
+ this.tokenizer.valuesEnabled = true;
17956
+ }
17957
+ consumeValueContainer() {
17958
+ const valueContainer = this.valueContainerStack.pop();
17959
+ this.tokenizer.valuesEnabled = this.valueContainerStack.length > 0;
17960
+ return valueContainer;
17961
+ }
17962
+ applyResolveKeyForTable(node2) {
17963
+ this.keysResolver.applyResolveKeyForTable(node2);
17964
+ }
17965
+ verifyDuplicateKeys() {
17966
+ this.keysResolver.verifyDuplicateKeys(this.topLevelTable);
17967
+ }
17968
+ reportParseError(code, token) {
17969
+ let offset, line, column;
17970
+ if (token) {
17971
+ offset = token.range[0];
17972
+ line = token.loc.start.line;
17973
+ column = token.loc.start.column;
17974
+ } else {
17975
+ offset = this.tokenizer.start;
17976
+ const startPos = this.tokenizer.getLocFromIndex(offset);
17977
+ line = startPos.line;
17978
+ column = startPos.column;
17979
+ }
17980
+ throw new ParseError(code, offset, line, column);
17981
+ }
17982
+ };
17983
+ var STATE_FOR_ERROR = { VALUE: "missing-value" };
17984
+ var STRING_VALUE_STYLE_MAP = {
17985
+ BasicString: "basic",
17986
+ MultiLineBasicString: "basic",
17987
+ LiteralString: "literal",
17988
+ MultiLineLiteralString: "literal"
17989
+ };
17990
+ var STRING_KEY_STYLE_MAP = {
17991
+ BasicString: "basic",
17992
+ LiteralString: "literal"
17993
+ };
17994
+ var DATETIME_VALUE_KIND_MAP = {
17995
+ OffsetDateTime: "offset-date-time",
17996
+ LocalDateTime: "local-date-time",
17997
+ LocalDate: "local-date",
17998
+ LocalTime: "local-time"
17999
+ };
18000
+ var TOMLParser = class {
18001
+ constructor(text, parserOptions) {
18002
+ this.text = text;
18003
+ this.parserOptions = parserOptions || {};
18004
+ this.tomlVersion = getTOMLVer(this.parserOptions.tomlVersion);
18005
+ }
18006
+ parse() {
18007
+ const ast = {
18008
+ type: "Program",
18009
+ body: [],
18010
+ sourceType: "module",
18011
+ tokens: [],
18012
+ comments: [],
18013
+ parent: null,
18014
+ range: [0, 0],
18015
+ loc: {
18016
+ start: {
18017
+ line: 1,
18018
+ column: 0
18019
+ },
18020
+ end: {
18021
+ line: 1,
18022
+ column: 0
18023
+ }
18024
+ }
18025
+ };
18026
+ const node2 = {
18027
+ type: "TOMLTopLevelTable",
18028
+ body: [],
18029
+ parent: ast,
18030
+ range: cloneRange(ast.range),
18031
+ loc: cloneLoc(ast.loc)
18032
+ };
18033
+ ast.body = [node2];
18034
+ const ctx = new Context({
18035
+ text: this.text,
18036
+ parserOptions: this.parserOptions,
18037
+ topLevelTable: node2
18038
+ });
18039
+ let token = ctx.nextToken();
18040
+ if (token) {
18041
+ node2.range[0] = token.range[0];
18042
+ node2.loc.start = clonePos(token.loc.start);
18043
+ while (token) {
18044
+ const state$1 = ctx.stateStack.pop() || "TABLE";
18045
+ ctx.stateStack.push(...this[state$1](token, ctx));
18046
+ token = ctx.nextToken();
18047
+ }
18048
+ const state = ctx.stateStack.pop() || "TABLE";
18049
+ if (state in STATE_FOR_ERROR)
18050
+ return ctx.reportParseError(STATE_FOR_ERROR[state], null);
18051
+ if (ctx.table.type === "TOMLTable")
18052
+ applyEndLoc(ctx.table, last(ctx.table.body));
18053
+ applyEndLoc(node2, last(node2.body));
18054
+ }
18055
+ ctx.verifyDuplicateKeys();
18056
+ ast.tokens = ctx.tokens;
18057
+ ast.comments = ctx.comments;
18058
+ const endOffset = ctx.tokenizer.end;
18059
+ const endPos = ctx.tokenizer.getLocFromIndex(endOffset);
18060
+ ast.range[1] = endOffset;
18061
+ ast.loc.end = {
18062
+ line: endPos.line,
18063
+ column: endPos.column
18064
+ };
18065
+ return ast;
18066
+ }
18067
+ TABLE(token, ctx) {
18068
+ if (isBare(token) || isString(token))
18069
+ return this.processKeyValue(token, ctx.table, ctx);
18070
+ if (isLeftBracket(token))
18071
+ return this.processTable(token, ctx.topLevelTable, ctx);
18072
+ return ctx.reportParseError("unexpected-token", token);
18073
+ }
18074
+ VALUE(token, ctx) {
18075
+ if (isString(token) || isMultiLineString(token))
18076
+ return this.processStringValue(token, ctx);
18077
+ if (isNumber(token))
18078
+ return this.processNumberValue(token, ctx);
18079
+ if (isBoolean(token))
18080
+ return this.processBooleanValue(token, ctx);
18081
+ if (isDateTime(token))
18082
+ return this.processDateTimeValue(token, ctx);
18083
+ if (isLeftBracket(token))
18084
+ return this.processArray(token, ctx);
18085
+ if (isLeftBrace(token))
18086
+ return this.processInlineTable(token, ctx);
18087
+ return ctx.reportParseError("unexpected-token", token);
18088
+ }
18089
+ processTable(token, topLevelTableNode, ctx) {
18090
+ const tableNode = {
18091
+ type: "TOMLTable",
18092
+ kind: "standard",
18093
+ key: null,
18094
+ resolvedKey: [],
18095
+ body: [],
18096
+ parent: topLevelTableNode,
18097
+ range: cloneRange(token.range),
18098
+ loc: cloneLoc(token.loc)
18099
+ };
18100
+ if (ctx.table.type === "TOMLTable")
18101
+ applyEndLoc(ctx.table, last(ctx.table.body));
18102
+ topLevelTableNode.body.push(tableNode);
18103
+ ctx.table = tableNode;
18104
+ let targetToken = ctx.nextToken({ needSameLine: "invalid-key-value-newline" });
18105
+ if (isLeftBracket(targetToken)) {
18106
+ if (token.range[1] < targetToken.range[0])
18107
+ return ctx.reportParseError("invalid-space", targetToken);
18108
+ tableNode.kind = "array";
18109
+ targetToken = ctx.nextToken({ needSameLine: "invalid-key-value-newline" });
18110
+ }
18111
+ if (isRightBracket(targetToken))
18112
+ return ctx.reportParseError("missing-key", targetToken);
18113
+ if (!targetToken)
18114
+ return ctx.reportParseError("unterminated-table-key", null);
18115
+ targetToken = this.processKeyNode(targetToken, tableNode, ctx).nextToken;
18116
+ if (!isRightBracket(targetToken))
18117
+ return ctx.reportParseError("unterminated-table-key", targetToken);
18118
+ if (tableNode.kind === "array") {
18119
+ const rightBracket = targetToken;
18120
+ targetToken = ctx.nextToken({ needSameLine: "invalid-key-value-newline" });
18121
+ if (!isRightBracket(targetToken))
18122
+ return ctx.reportParseError("unterminated-table-key", targetToken);
18123
+ if (rightBracket.range[1] < targetToken.range[0])
18124
+ return ctx.reportParseError("invalid-space", targetToken);
18125
+ }
18126
+ applyEndLoc(tableNode, targetToken);
18127
+ ctx.applyResolveKeyForTable(tableNode);
18128
+ ctx.needNewLine = true;
18129
+ return [];
18130
+ }
18131
+ processKeyValue(token, tableNode, ctx) {
18132
+ const keyValueNode = {
18133
+ type: "TOMLKeyValue",
18134
+ key: null,
18135
+ value: null,
18136
+ parent: tableNode,
18137
+ range: cloneRange(token.range),
18138
+ loc: cloneLoc(token.loc)
18139
+ };
18140
+ tableNode.body.push(keyValueNode);
18141
+ const { nextToken: targetToken } = this.processKeyNode(token, keyValueNode, ctx);
18142
+ if (!isEq(targetToken))
18143
+ return ctx.reportParseError("missing-equals-sign", targetToken);
18144
+ ctx.addValueContainer({
18145
+ parent: keyValueNode,
18146
+ set: (valNode) => {
18147
+ keyValueNode.value = valNode;
18148
+ applyEndLoc(keyValueNode, valNode);
18149
+ ctx.needNewLine = true;
18150
+ return [];
18151
+ }
18152
+ });
18153
+ ctx.needSameLine = "invalid-key-value-newline";
18154
+ return ["VALUE"];
18155
+ }
18156
+ processKeyNode(token, parent, ctx) {
18157
+ if (isDot(token))
18158
+ ctx.reportParseError("invalid-leading-dot-in-key", token);
18159
+ const keyNode = {
18160
+ type: "TOMLKey",
18161
+ keys: [],
18162
+ parent,
18163
+ range: cloneRange(token.range),
18164
+ loc: cloneLoc(token.loc)
18165
+ };
18166
+ parent.key = keyNode;
18167
+ let targetToken = token;
18168
+ let dotToken = null;
18169
+ do {
18170
+ if (isBare(targetToken))
18171
+ this.processBareKey(targetToken, keyNode);
18172
+ else if (isString(targetToken))
18173
+ this.processStringKey(targetToken, keyNode);
18174
+ else
18175
+ break;
18176
+ dotToken = null;
18177
+ targetToken = ctx.nextToken({ needSameLine: "invalid-key-value-newline" });
18178
+ if (!isDot(targetToken))
18179
+ break;
18180
+ dotToken = targetToken;
18181
+ targetToken = ctx.nextToken({ needSameLine: "invalid-key-value-newline" });
18182
+ } while (targetToken);
18183
+ if (dotToken)
18184
+ ctx.reportParseError(isDot(targetToken) ? "invalid-consecutive-dots-in-key" : "invalid-trailing-dot-in-key", dotToken);
18185
+ applyEndLoc(keyNode, last(keyNode.keys));
18186
+ return {
18187
+ keyNode,
18188
+ nextToken: targetToken
18189
+ };
18190
+ }
18191
+ processBareKey(token, keyNode) {
18192
+ const node2 = {
18193
+ type: "TOMLBare",
18194
+ name: token.value,
18195
+ parent: keyNode,
18196
+ range: cloneRange(token.range),
18197
+ loc: cloneLoc(token.loc)
18198
+ };
18199
+ keyNode.keys.push(node2);
18200
+ }
18201
+ processStringKey(token, keyNode) {
18202
+ const node2 = {
18203
+ type: "TOMLQuoted",
18204
+ kind: "string",
18205
+ value: token.string,
18206
+ style: STRING_KEY_STYLE_MAP[token.type],
18207
+ multiline: false,
18208
+ parent: keyNode,
18209
+ range: cloneRange(token.range),
18210
+ loc: cloneLoc(token.loc)
18211
+ };
18212
+ keyNode.keys.push(node2);
18213
+ }
18214
+ processStringValue(token, ctx) {
18215
+ const valueContainer = ctx.consumeValueContainer();
18216
+ const node2 = {
18217
+ type: "TOMLValue",
18218
+ kind: "string",
18219
+ value: token.string,
18220
+ style: STRING_VALUE_STYLE_MAP[token.type],
18221
+ multiline: isMultiLineString(token),
18222
+ parent: valueContainer.parent,
18223
+ range: cloneRange(token.range),
18224
+ loc: cloneLoc(token.loc)
18225
+ };
18226
+ return valueContainer.set(node2);
18227
+ }
18228
+ processNumberValue(token, ctx) {
18229
+ const valueContainer = ctx.consumeValueContainer();
18230
+ const text = this.text;
18231
+ const [startRange, endRange] = token.range;
18232
+ let numberString = null;
18233
+ const getNumberText = () => {
18234
+ return numberString ?? (numberString = text.slice(startRange, endRange).replace(/_/g, ""));
18235
+ };
18236
+ let node2;
18237
+ if (token.type === "Integer")
18238
+ node2 = {
18239
+ type: "TOMLValue",
18240
+ kind: "integer",
18241
+ value: token.number,
18242
+ bigint: token.bigint,
18243
+ get number() {
18244
+ return getNumberText();
18245
+ },
18246
+ parent: valueContainer.parent,
18247
+ range: cloneRange(token.range),
18248
+ loc: cloneLoc(token.loc)
18249
+ };
18250
+ else
18251
+ node2 = {
18252
+ type: "TOMLValue",
18253
+ kind: "float",
18254
+ value: token.number,
18255
+ get number() {
18256
+ return getNumberText();
18257
+ },
18258
+ parent: valueContainer.parent,
18259
+ range: cloneRange(token.range),
18260
+ loc: cloneLoc(token.loc)
18261
+ };
18262
+ return valueContainer.set(node2);
18263
+ }
18264
+ processBooleanValue(token, ctx) {
18265
+ const valueContainer = ctx.consumeValueContainer();
18266
+ const node2 = {
18267
+ type: "TOMLValue",
18268
+ kind: "boolean",
18269
+ value: token.boolean,
18270
+ parent: valueContainer.parent,
18271
+ range: cloneRange(token.range),
18272
+ loc: cloneLoc(token.loc)
18273
+ };
18274
+ return valueContainer.set(node2);
18275
+ }
18276
+ processDateTimeValue(token, ctx) {
18277
+ const valueContainer = ctx.consumeValueContainer();
18278
+ const node2 = {
18279
+ type: "TOMLValue",
18280
+ kind: DATETIME_VALUE_KIND_MAP[token.type],
18281
+ value: token.date,
18282
+ datetime: token.value,
18283
+ parent: valueContainer.parent,
18284
+ range: cloneRange(token.range),
18285
+ loc: cloneLoc(token.loc)
18286
+ };
18287
+ return valueContainer.set(node2);
18288
+ }
18289
+ processArray(token, ctx) {
18290
+ const valueContainer = ctx.consumeValueContainer();
18291
+ const node2 = {
18292
+ type: "TOMLArray",
18293
+ elements: [],
18294
+ parent: valueContainer.parent,
18295
+ range: cloneRange(token.range),
18296
+ loc: cloneLoc(token.loc)
18297
+ };
18298
+ const nextToken = ctx.nextToken({ valuesEnabled: true });
18299
+ if (isRightBracket(nextToken)) {
18300
+ applyEndLoc(node2, nextToken);
18301
+ return valueContainer.set(node2);
18302
+ }
18303
+ ctx.backToken();
18304
+ return this.processArrayValue(node2, valueContainer, ctx);
18305
+ }
18306
+ processArrayValue(node2, valueContainer, ctx) {
18307
+ ctx.addValueContainer({
18308
+ parent: node2,
18309
+ set: (valNode) => {
18310
+ node2.elements.push(valNode);
18311
+ let nextToken = ctx.nextToken({ valuesEnabled: true });
18312
+ const hasComma = isComma(nextToken);
18313
+ if (hasComma)
18314
+ nextToken = ctx.nextToken({ valuesEnabled: true });
18315
+ if (isRightBracket(nextToken)) {
18316
+ applyEndLoc(node2, nextToken);
18317
+ return valueContainer.set(node2);
18318
+ }
18319
+ if (hasComma) {
18320
+ ctx.backToken();
18321
+ return this.processArrayValue(node2, valueContainer, ctx);
18322
+ }
18323
+ return ctx.reportParseError(nextToken ? "missing-comma" : "unterminated-array", nextToken);
18324
+ }
18325
+ });
18326
+ return ["VALUE"];
18327
+ }
18328
+ processInlineTable(token, ctx) {
18329
+ const valueContainer = ctx.consumeValueContainer();
18330
+ const node2 = {
18331
+ type: "TOMLInlineTable",
18332
+ body: [],
18333
+ parent: valueContainer.parent,
18334
+ range: cloneRange(token.range),
18335
+ loc: cloneLoc(token.loc)
18336
+ };
18337
+ const needSameLine = this.tomlVersion.gte(1, 1) ? undefined : "invalid-inline-table-newline";
18338
+ const nextToken = ctx.nextToken({ needSameLine });
18339
+ if (nextToken) {
18340
+ if (isBare(nextToken) || isString(nextToken))
18341
+ return this.processInlineTableKeyValue(nextToken, node2, valueContainer, ctx);
18342
+ if (isRightBrace(nextToken)) {
18343
+ applyEndLoc(node2, nextToken);
18344
+ return valueContainer.set(node2);
18345
+ }
18346
+ }
18347
+ return ctx.reportParseError("unexpected-token", nextToken);
18348
+ }
18349
+ processInlineTableKeyValue(token, inlineTableNode, valueContainer, ctx) {
18350
+ const keyValueNode = {
18351
+ type: "TOMLKeyValue",
18352
+ key: null,
18353
+ value: null,
18354
+ parent: inlineTableNode,
18355
+ range: cloneRange(token.range),
18356
+ loc: cloneLoc(token.loc)
18357
+ };
18358
+ inlineTableNode.body.push(keyValueNode);
18359
+ const { nextToken: targetToken } = this.processKeyNode(token, keyValueNode, ctx);
18360
+ if (!isEq(targetToken))
18361
+ return ctx.reportParseError("missing-equals-sign", targetToken);
18362
+ const needSameLine = this.tomlVersion.gte(1, 1) ? undefined : "invalid-inline-table-newline";
18363
+ ctx.addValueContainer({
18364
+ parent: keyValueNode,
18365
+ set: (valNode) => {
18366
+ keyValueNode.value = valNode;
18367
+ applyEndLoc(keyValueNode, valNode);
18368
+ let nextToken = ctx.nextToken({ needSameLine });
18369
+ if (isComma(nextToken)) {
18370
+ nextToken = ctx.nextToken({ needSameLine });
18371
+ if (nextToken && (isBare(nextToken) || isString(nextToken)))
18372
+ return this.processInlineTableKeyValue(nextToken, inlineTableNode, valueContainer, ctx);
18373
+ if (isRightBrace(nextToken)) {
18374
+ if (this.tomlVersion.lt(1, 1))
18375
+ return ctx.reportParseError("invalid-trailing-comma-in-inline-table", nextToken);
18376
+ } else
18377
+ return ctx.reportParseError(nextToken ? "unexpected-token" : "unterminated-inline-table", nextToken);
18378
+ }
18379
+ if (isRightBrace(nextToken)) {
18380
+ applyEndLoc(inlineTableNode, nextToken);
18381
+ return valueContainer.set(inlineTableNode);
18382
+ }
18383
+ return ctx.reportParseError(nextToken ? "missing-comma" : "unterminated-inline-table", nextToken);
18384
+ }
18385
+ });
18386
+ ctx.needSameLine = "invalid-key-value-newline";
18387
+ return ["VALUE"];
18388
+ }
18389
+ };
18390
+ function isDot(token) {
18391
+ return isPunctuator(token) && token.value === ".";
18392
+ }
18393
+ function isEq(token) {
18394
+ return isPunctuator(token) && token.value === "=";
18395
+ }
18396
+ function isLeftBracket(token) {
18397
+ return isPunctuator(token) && token.value === "[";
18398
+ }
18399
+ function isRightBracket(token) {
18400
+ return isPunctuator(token) && token.value === "]";
18401
+ }
18402
+ function isLeftBrace(token) {
18403
+ return isPunctuator(token) && token.value === "{";
18404
+ }
18405
+ function isRightBrace(token) {
18406
+ return isPunctuator(token) && token.value === "}";
18407
+ }
18408
+ function isComma(token) {
18409
+ return isPunctuator(token) && token.value === ",";
18410
+ }
18411
+ function isPunctuator(token) {
18412
+ return Boolean(token && token.type === "Punctuator");
18413
+ }
18414
+ function isBare(token) {
18415
+ return token.type === "Bare";
18416
+ }
18417
+ function isString(token) {
18418
+ return token.type === "BasicString" || token.type === "LiteralString";
18419
+ }
18420
+ function isMultiLineString(token) {
18421
+ return token.type === "MultiLineBasicString" || token.type === "MultiLineLiteralString";
18422
+ }
18423
+ function isNumber(token) {
18424
+ return token.type === "Integer" || token.type === "Float";
18425
+ }
18426
+ function isBoolean(token) {
18427
+ return token.type === "Boolean";
18428
+ }
18429
+ function isDateTime(token) {
18430
+ return token.type === "OffsetDateTime" || token.type === "LocalDateTime" || token.type === "LocalDate" || token.type === "LocalTime";
18431
+ }
18432
+ function applyEndLoc(node2, child) {
18433
+ if (child) {
18434
+ node2.range[1] = child.range[1];
18435
+ node2.loc.end = clonePos(child.loc.end);
18436
+ }
18437
+ }
18438
+ function cloneRange(range) {
18439
+ return [range[0], range[1]];
18440
+ }
18441
+ function cloneLoc(loc) {
18442
+ return {
18443
+ start: clonePos(loc.start),
18444
+ end: clonePos(loc.end)
18445
+ };
18446
+ }
18447
+ function clonePos(pos) {
18448
+ return {
18449
+ line: pos.line,
18450
+ column: pos.column
18451
+ };
18452
+ }
18453
+ var tomlKeys = {
18454
+ Program: ["body"],
18455
+ TOMLTopLevelTable: ["body"],
18456
+ TOMLTable: ["key", "body"],
18457
+ TOMLKeyValue: ["key", "value"],
18458
+ TOMLKey: ["keys"],
18459
+ TOMLArray: ["elements"],
18460
+ TOMLInlineTable: ["body"],
18461
+ TOMLBare: [],
18462
+ TOMLQuoted: [],
18463
+ TOMLValue: []
18464
+ };
18465
+ var KEYS2 = unionWith(tomlKeys);
18466
+ function parseForESLint(code, options) {
18467
+ return {
18468
+ ast: new TOMLParser(code, options).parse(),
18469
+ visitorKeys: KEYS2,
18470
+ services: { isTOML: true }
18471
+ };
18472
+ }
18473
+ var getStaticTOMLValue = generateConvertTOMLValue((node2) => node2.value);
18474
+ function generateConvertTOMLValue(convertValue) {
18475
+ function resolveValue(node2, baseTable) {
18476
+ return resolver[node2.type](node2, baseTable);
18477
+ }
18478
+ const resolver = {
18479
+ Program(node2, baseTable = {}) {
18480
+ return resolveValue(node2.body[0], baseTable);
18481
+ },
18482
+ TOMLTopLevelTable(node2, baseTable = {}) {
18483
+ for (const body of node2.body)
18484
+ resolveValue(body, baseTable);
18485
+ return baseTable;
18486
+ },
18487
+ TOMLKeyValue(node2, baseTable = {}) {
18488
+ const value = resolveValue(node2.value);
18489
+ set(baseTable, resolveValue(node2.key), value);
18490
+ return baseTable;
18491
+ },
18492
+ TOMLTable(node2, baseTable = {}) {
18493
+ const table = getTable(baseTable, resolveValue(node2.key), node2.kind === "array");
18494
+ for (const body of node2.body)
18495
+ resolveValue(body, table);
18496
+ return baseTable;
18497
+ },
18498
+ TOMLArray(node2) {
18499
+ return node2.elements.map((e) => resolveValue(e));
18500
+ },
18501
+ TOMLInlineTable(node2) {
18502
+ const table = {};
18503
+ for (const body of node2.body)
18504
+ resolveValue(body, table);
18505
+ return table;
18506
+ },
18507
+ TOMLKey(node2) {
18508
+ return node2.keys.map((key) => resolveValue(key));
18509
+ },
18510
+ TOMLBare(node2) {
18511
+ return node2.name;
18512
+ },
18513
+ TOMLQuoted(node2) {
18514
+ return node2.value;
18515
+ },
18516
+ TOMLValue(node2) {
18517
+ return convertValue(node2);
18518
+ }
18519
+ };
18520
+ return (node2) => resolveValue(node2);
18521
+ }
18522
+ function getTable(baseTable, keys, array) {
18523
+ let target = baseTable;
18524
+ for (let index = 0;index < keys.length - 1; index++) {
18525
+ const key = keys[index];
18526
+ target = getNextTargetFromKey(target, key);
18527
+ }
18528
+ const lastKey = last(keys);
18529
+ const lastTarget = target[lastKey];
18530
+ if (lastTarget == null) {
18531
+ const tableValue$1 = {};
18532
+ target[lastKey] = array ? [tableValue$1] : tableValue$1;
18533
+ return tableValue$1;
18534
+ }
18535
+ if (isValue(lastTarget)) {
18536
+ const tableValue$1 = {};
18537
+ target[lastKey] = array ? [tableValue$1] : tableValue$1;
18538
+ return tableValue$1;
18539
+ }
18540
+ if (!array) {
18541
+ if (Array.isArray(lastTarget)) {
18542
+ const tableValue$1 = {};
18543
+ target[lastKey] = tableValue$1;
18544
+ return tableValue$1;
18545
+ }
18546
+ return lastTarget;
18547
+ }
18548
+ if (Array.isArray(lastTarget)) {
18549
+ const tableValue$1 = {};
18550
+ lastTarget.push(tableValue$1);
18551
+ return tableValue$1;
18552
+ }
18553
+ const tableValue = {};
18554
+ target[lastKey] = [tableValue];
18555
+ return tableValue;
18556
+ function getNextTargetFromKey(currTarget, key) {
18557
+ const nextTarget = currTarget[key];
18558
+ if (nextTarget == null) {
18559
+ const val = {};
18560
+ currTarget[key] = val;
18561
+ return val;
18562
+ }
18563
+ if (isValue(nextTarget)) {
18564
+ const val = {};
18565
+ currTarget[key] = val;
18566
+ return val;
18567
+ }
18568
+ let resultTarget = nextTarget;
18569
+ while (Array.isArray(resultTarget)) {
18570
+ const lastIndex = resultTarget.length - 1;
18571
+ const nextElement = resultTarget[lastIndex];
18572
+ if (isValue(nextElement)) {
18573
+ const val = {};
18574
+ resultTarget[lastIndex] = val;
18575
+ return val;
18576
+ }
18577
+ resultTarget = nextElement;
18578
+ }
18579
+ return resultTarget;
18580
+ }
18581
+ }
18582
+ function set(baseTable, keys, value) {
18583
+ let target = baseTable;
18584
+ for (let index = 0;index < keys.length - 1; index++) {
18585
+ const key = keys[index];
18586
+ const nextTarget = target[key];
18587
+ if (nextTarget == null) {
18588
+ const val = {};
18589
+ target[key] = val;
18590
+ target = val;
18591
+ } else if (isValue(nextTarget) || Array.isArray(nextTarget)) {
18592
+ const val = {};
18593
+ target[key] = val;
18594
+ target = val;
18595
+ } else
18596
+ target = nextTarget;
18597
+ }
18598
+ target[last(keys)] = value;
18599
+ }
18600
+ function isValue(value) {
18601
+ return typeof value !== "object" || value instanceof Date;
18602
+ }
18603
+ function parseTOML(code, options) {
18604
+ return parseForESLint(code, options).ast;
18605
+ }
18606
+
18607
+ // src/configEvidenceParser.ts
18608
+ var import_yaml2 = __toESM(require_dist(), 1);
18609
+ var SECRET_TOKEN2 = /^(?:password|passwd|pwd|secret|token|credential|credentials|authorization|cookie)$/u;
18610
+ var SECRET_COMPOUND2 = /^(?:api-key|access-key|private-key|client-secret|access-token|refresh-token)$/u;
18611
+ var SECRET_VALUE = /^(?:[a-z][a-z0-9+.-]*:\/\/[^\s/@:]+:[^\s/@]+@)|[?&](?:access_token|refresh_token|api_key|password|secret)=/iu;
18612
+ var REFERENCE_KEY = /(?:path|file|url|uri|endpoint|module|package|import|include|extends|schema|ref)$/iu;
18613
+ var REFERENCE_VALUE = /^(?:[a-z][a-z0-9+.-]*:\/\/|\.\.?(?:\/|$)|[~@]?[a-z0-9_.-]+\/[a-z0-9_./-]+|[a-z0-9_.-]+\.(?:json|ya?ml|toml|js|mjs|cjs|ts|tsx|css|scss))$/iu;
18614
+ var BOUNDARY_PATTERNS = [
18615
+ ["entry", /^(?:entry|entries|main|bootstrap|startup)$/iu],
18616
+ ["route", /^(?:route|routes|router|routing|path)$/iu],
18617
+ ["build", /^(?:build|bundle|bundler|compiler|compile|output|outdir|target)$/iu],
18618
+ ["protocol", /^(?:protocol|schema|schemas|api|rpc|openapi|graphql|protobuf|thrift)$/iu],
18619
+ ["runtime", /^(?:runtime|host|port|server|environment|env|command|args)$/iu],
18620
+ ["dependency", /^(?:dependencies|dependency|imports|includes|extends|plugins)$/iu]
18621
+ ];
18622
+ function pathIdentity(path5) {
18623
+ return JSON.stringify(path5);
18624
+ }
18625
+ function qualifiedItemPath(path5) {
18626
+ if (path5.length === 0)
18627
+ return "config:/";
18628
+ return `config:/${path5.map((segment) => segment.replace(/~/gu, "~0").replace(/\//gu, "~1")).join("/")}`;
18629
+ }
18630
+ function locator(filePath, keyPath, location) {
18631
+ return {
18632
+ path: filePath,
18633
+ line: Math.max(1, location.line),
18634
+ column: Math.max(1, location.column),
18635
+ qualified_item_path: qualifiedItemPath(keyPath)
18636
+ };
18637
+ }
18638
+ function normalizedKeySegment(segment) {
18639
+ return segment.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").replace(/[^A-Za-z0-9]+/gu, "-").toLowerCase();
18640
+ }
18641
+ function secretLike(keyPath, value) {
18642
+ const keySecret = keyPath.some((segment) => {
18643
+ const normalized = normalizedKeySegment(segment);
18644
+ return SECRET_COMPOUND2.test(normalized) || normalized.split("-").some((token) => SECRET_TOKEN2.test(token));
18645
+ });
18646
+ return keySecret || typeof value === "string" && SECRET_VALUE.test(value);
18647
+ }
18648
+ function boundaryCandidate(keyPath) {
18649
+ for (let index = keyPath.length - 1;index >= 0; index -= 1) {
18650
+ const segment = keyPath[index];
18651
+ for (const [candidate, pattern] of BOUNDARY_PATTERNS) {
18652
+ if (pattern.test(segment))
18653
+ return candidate;
18654
+ }
18655
+ }
18656
+ return null;
18657
+ }
18658
+ function valueType(value) {
18659
+ if (value === null)
18660
+ return "null";
18661
+ if (value instanceof Date)
18662
+ return "datetime";
18663
+ if (Array.isArray(value))
18664
+ return "array";
18665
+ if (typeof value === "object")
18666
+ return "object";
18667
+ if (typeof value === "string")
18668
+ return "string";
18669
+ if (typeof value === "boolean")
18670
+ return "boolean";
18671
+ return "number";
18672
+ }
18673
+ function digestableScalar(value) {
18674
+ if (typeof value === "bigint")
18675
+ return { integer: value.toString() };
18676
+ if (value instanceof Date)
18677
+ return { datetime: value.toISOString() };
18678
+ return value;
18679
+ }
18680
+ function allowlistedScalar(value) {
18681
+ if (value === null || typeof value === "string" || typeof value === "boolean")
18682
+ return value;
18683
+ if (typeof value === "number" && Number.isFinite(value) && (!Number.isInteger(value) || Number.isSafeInteger(value)))
18684
+ return value;
18685
+ return;
18686
+ }
18687
+ function scalarEqual(left, right) {
18688
+ return Object.is(left, right);
18689
+ }
18690
+ function classify(keyPath, value, isContainer, isSecret, exposed) {
18691
+ if (isContainer)
18692
+ return "container";
18693
+ if (isSecret)
18694
+ return "secret-like";
18695
+ if (exposed)
18696
+ return "enum-allowlisted";
18697
+ const finalKey = keyPath.at(-1) ?? "";
18698
+ if (typeof value === "string" && (REFERENCE_KEY.test(finalKey) || REFERENCE_VALUE.test(value))) {
18699
+ return "reference-like";
18700
+ }
18701
+ return "scalar";
18702
+ }
18703
+ function addValue(context, keyPath, value, location) {
18704
+ const type = valueType(value);
18705
+ const isContainer = type === "object" || type === "array";
18706
+ const allowlist = context.allowlist.get(pathIdentity(keyPath));
18707
+ const scalar = allowlistedScalar(value);
18708
+ const isSecret = secretLike(keyPath, value);
18709
+ const exposed = !isSecret && scalar !== undefined && allowlist !== undefined && allowlist.allowed_values.some((allowed) => scalarEqual(allowed, scalar));
18710
+ if (allowlist && scalar !== undefined && !exposed && !isSecret) {
18711
+ context.diagnostics.push({
18712
+ code: "config-enum-value-not-allowlisted",
18713
+ severity: "warning",
18714
+ locator: locator(context.path, keyPath, location),
18715
+ detail: "configured enum allowlist does not include the parsed scalar"
18716
+ });
18717
+ }
18718
+ const classification = classify(keyPath, value, isContainer, isSecret, exposed);
18719
+ const digestSafe = !(typeof value === "number" && (!Number.isFinite(value) || Number.isInteger(value) && !Number.isSafeInteger(value)));
18720
+ context.values.push({
18721
+ config_ref: context.configRef,
18722
+ key_path: keyPath,
18723
+ value_type: type,
18724
+ classification,
18725
+ boundary_candidate: boundaryCandidate(keyPath),
18726
+ value_digest: isContainer || classification === "secret-like" || !digestSafe ? null : indexerEvidenceAdapterProtocolDigest({ type, value: digestableScalar(value) }),
18727
+ ...exposed ? { normalized_value: scalar } : {},
18728
+ locator: locator(context.path, keyPath, location)
18729
+ });
18730
+ }
18731
+ function walkValue(context, value, keyPath, locate) {
18732
+ addValue(context, keyPath, value, locate(keyPath));
18733
+ if (Array.isArray(value)) {
18734
+ value.forEach((item, index) => walkValue(context, item, [...keyPath, String(index)], locate));
18735
+ return;
18736
+ }
18737
+ if (value !== null && typeof value === "object" && !(value instanceof Date)) {
18738
+ for (const [key, item] of Object.entries(value)) {
18739
+ walkValue(context, item, [...keyPath, key], locate);
18740
+ }
18741
+ }
18742
+ }
18743
+ function validateYamlKeys(node2) {
18744
+ if (!node2)
18745
+ return;
18746
+ if (import_yaml2.isMap(node2)) {
18747
+ for (const pair of node2.items) {
18748
+ if (!import_yaml2.isScalar(pair.key) || typeof pair.key.value !== "string") {
18749
+ throw new TypeError("YAML mapping keys must be scalar strings");
18750
+ }
18751
+ validateYamlKeys(pair.value);
18752
+ }
18753
+ } else if (import_yaml2.isSeq(node2)) {
18754
+ for (const item of node2.items)
18755
+ validateYamlKeys(item);
18756
+ }
18757
+ }
18758
+ function yamlLocation(document, lineCounter, logicalPath, documentPrefixLength) {
18759
+ const yamlPath = logicalPath.slice(documentPrefixLength).map((segment) => /^\d+$/u.test(segment) ? Number(segment) : segment);
18760
+ const node2 = document.getIn(yamlPath, true);
18761
+ const offset = node2?.range?.[0] ?? document.contents?.range?.[0] ?? 0;
18762
+ const position = lineCounter.linePos(offset);
18763
+ return { line: position.line, column: position.col };
18764
+ }
18765
+ function parseYamlLike(context, source, strictJson) {
18766
+ if (strictJson)
18767
+ JSON.parse(source);
18768
+ const lineCounter = new import_yaml2.LineCounter;
18769
+ const documents = strictJson ? [import_yaml2.parseDocument(source, { lineCounter, schema: "json", strict: true, uniqueKeys: true })] : import_yaml2.parseAllDocuments(source, { lineCounter, strict: true, uniqueKeys: true });
18770
+ if (documents.length === 0)
18771
+ throw new TypeError("configuration document is empty");
18772
+ for (const [documentIndex, document] of documents.entries()) {
18773
+ if (document.errors.length > 0)
18774
+ throw new TypeError("configuration syntax is invalid");
18775
+ validateYamlKeys(document.contents);
18776
+ const value = document.toJS({ maxAliasCount: 100 });
18777
+ const prefix = documents.length > 1 ? ["$document", String(documentIndex)] : [];
18778
+ walkValue(context, value, prefix, (path5) => yamlLocation(document, lineCounter, path5, prefix.length));
18779
+ }
18780
+ }
18781
+ function tomlKey(node2) {
18782
+ return node2.keys.map((item) => item.type === "TOMLBare" ? item.name : item.value);
18783
+ }
18784
+ function tomlLocations(ast) {
18785
+ const locations = new Map;
18786
+ const remember = (path5, node2) => {
18787
+ locations.set(pathIdentity(path5), { line: node2.loc.start.line, column: node2.loc.start.column + 1 });
18788
+ };
18789
+ const walkContent = (node2, path5) => {
18790
+ remember(path5, node2);
18791
+ if (node2.type === "TOMLArray") {
18792
+ node2.elements.forEach((element, index) => walkContent(element, [...path5, String(index)]));
18793
+ } else if (node2.type === "TOMLInlineTable") {
18794
+ for (const item of node2.body) {
18795
+ const itemPath = [...path5, ...tomlKey(item.key)];
18796
+ remember(itemPath, item.key);
18797
+ walkContent(item.value, itemPath);
18798
+ }
18799
+ }
18800
+ };
18801
+ remember([], ast);
18802
+ for (const item of ast.body[0].body) {
18803
+ if (item.type === "TOMLKeyValue") {
18804
+ const itemPath = tomlKey(item.key);
18805
+ remember(itemPath, item.key);
18806
+ walkContent(item.value, itemPath);
18807
+ continue;
18808
+ }
18809
+ const tablePath = item.resolvedKey.map(String);
18810
+ remember(tablePath, item.key);
18811
+ for (const entry of item.body) {
18812
+ const entryPath = [...tablePath, ...tomlKey(entry.key)];
18813
+ remember(entryPath, entry.key);
18814
+ walkContent(entry.value, entryPath);
18815
+ }
18816
+ }
18817
+ return locations;
18818
+ }
18819
+ function parseToml(context, source) {
18820
+ const ast = parseTOML(source, { tomlVersion: "1.0.0" });
18821
+ const value = getStaticTOMLValue(ast);
18822
+ const locations = tomlLocations(ast);
18823
+ walkValue(context, value, [], (path5) => locations.get(pathIdentity(path5)) ?? { line: 1, column: 1 });
18824
+ }
18825
+ function detectFormat(path5) {
18826
+ const lower = path5.toLowerCase();
18827
+ if (lower.endsWith(".json"))
18828
+ return "json";
18829
+ if (lower.endsWith(".yaml") || lower.endsWith(".yml"))
18830
+ return "yaml";
18831
+ if (lower.endsWith(".toml"))
18832
+ return "toml";
18833
+ return "excluded";
18834
+ }
18835
+ function validatePath(path5) {
18836
+ const segments = path5.split("/");
18837
+ if (!path5 || path5.includes("\\") || path5.startsWith("/") || segments.some((segment) => !segment || segment === "." || segment === "..")) {
18838
+ throw new TypeError(`config path must be a portable relative path: ${path5}`);
18839
+ }
18840
+ }
18841
+ function validatedAllowlists(options) {
18842
+ const byFile = new Map;
18843
+ for (const entry of options.non_sensitive_enums ?? []) {
18844
+ validatePath(entry.path);
18845
+ if (entry.key_path.length === 0)
18846
+ throw new TypeError("config enum allowlist cannot target the document root");
18847
+ if (secretLike(entry.key_path))
18848
+ throw new TypeError("config enum allowlist cannot target a secret-like key path");
18849
+ if (entry.allowed_values.length === 0)
18850
+ throw new TypeError("config enum allowlist must declare at least one value");
18851
+ const identities = entry.allowed_values.map((value) => JSON.stringify([typeof value, value]));
18852
+ if (new Set(identities).size !== identities.length)
18853
+ throw new TypeError("config enum allowlist contains duplicate values");
18854
+ const fileEntries = byFile.get(entry.path) ?? new Map;
18855
+ const identity = pathIdentity(entry.key_path);
18856
+ if (fileEntries.has(identity))
18857
+ throw new TypeError("config enum allowlist contains a duplicate file and key path");
18858
+ fileEntries.set(identity, entry);
18859
+ byFile.set(entry.path, fileEntries);
18860
+ }
18861
+ return byFile;
18862
+ }
18863
+ function parseOne(path5, source, format, allowlist) {
18864
+ if (format === "excluded")
18865
+ return { path: path5, format, disposition: "excluded", values: [], diagnostics: [] };
18866
+ const context = {
18867
+ path: path5,
18868
+ format,
18869
+ configRef: `config:${indexerEvidenceAdapterProtocolDigest({ path: path5, format })}`,
18870
+ allowlist,
18871
+ diagnostics: [],
18872
+ values: []
18873
+ };
18874
+ try {
18875
+ if (format === "toml")
18876
+ parseToml(context, source);
18877
+ else
18878
+ parseYamlLike(context, source, format === "json");
18879
+ return { path: path5, format, disposition: "analyzed", values: context.values, diagnostics: context.diagnostics };
18880
+ } catch {
18881
+ const root = locator(path5, [], { line: 1, column: 1 });
18882
+ return {
18883
+ path: path5,
18884
+ format,
18885
+ disposition: "unsupported",
18886
+ values: [],
18887
+ diagnostics: [{ code: "config-source-unsupported", severity: "error", locator: root, detail: `${format} configuration could not be analyzed` }]
18888
+ };
18889
+ }
18890
+ }
18891
+ function parseConfigSources(files, options = {}) {
18892
+ const allowlists = validatedAllowlists(options);
18893
+ return Object.entries(files).sort(([left], [right]) => left.localeCompare(right)).map(([path5, source]) => {
18894
+ validatePath(path5);
18895
+ return parseOne(path5, source, detectFormat(path5), allowlists.get(path5) ?? new Map);
18896
+ });
18897
+ }
18898
+ // src/configEvidenceAdapter.ts
18899
+ function assertModuleAuthorized(moduleRef, invocation) {
18900
+ if (moduleRef !== null && !invocation.authorized_scope.module_refs.includes(moduleRef)) {
18901
+ throw new TypeError(`config module ${moduleRef} escapes authorized scope`);
18902
+ }
18903
+ }
18904
+ function fact3(document, value, invocation, moduleRef) {
18905
+ const semantic = {
18906
+ config_ref: value.config_ref,
18907
+ key_path: value.key_path,
18908
+ value_type: value.value_type,
18909
+ classification: value.classification,
18910
+ boundary_candidate: value.boundary_candidate,
18911
+ value_digest: value.value_digest,
18912
+ ...value.normalized_value !== undefined ? { normalized_value: value.normalized_value } : {},
18913
+ locator: value.locator
18914
+ };
18915
+ return createIndexerEvidenceAdapterFact({
18916
+ source_ref: invocation.authorized_scope.source_ref,
18917
+ module_ref: moduleRef,
18918
+ normalized_path: document.path,
18919
+ qualified_item_path: value.locator.qualified_item_path,
18920
+ kind: "config-value",
18921
+ signature: semantic,
18922
+ payload: semantic,
18923
+ denominator: "none"
18924
+ });
18925
+ }
18926
+ function configSourcesToEvidenceAdapterResult(files, invocation, options = {}) {
18927
+ const role = invocation.role ?? "primary-owner";
18928
+ const documents = parseConfigSources(files, options);
18929
+ const diagnostics = [];
18930
+ const evidenceFiles = documents.map((document) => {
18931
+ const moduleRef = invocation.module_refs?.[document.path] ?? null;
18932
+ assertModuleAuthorized(moduleRef, invocation);
18933
+ const fileRef = indexerEvidenceAdapterFileRef({
18934
+ source_ref: invocation.authorized_scope.source_ref,
18935
+ module_ref: moduleRef,
18936
+ normalized_path: document.path
18937
+ });
18938
+ for (const diagnostic of document.diagnostics) {
18939
+ diagnostics.push({
18940
+ code: diagnostic.code,
18941
+ severity: diagnostic.severity,
18942
+ fact_ref: fileRef,
18943
+ detail_digest: indexerEvidenceAdapterProtocolDigest({
18944
+ locator: diagnostic.locator,
18945
+ detail: diagnostic.detail
18946
+ })
18947
+ });
18948
+ }
18949
+ const sourceFact = document.disposition === "analyzed" ? createIndexerEvidenceAdapterFact({
18950
+ source_ref: invocation.authorized_scope.source_ref,
18951
+ module_ref: moduleRef,
18952
+ normalized_path: document.path,
18953
+ qualified_item_path: "file",
18954
+ kind: "source-file",
18955
+ signature: { catalog: "config", format: document.format, tier: "lightweight-evidence" },
18956
+ payload: { path: document.path, format: document.format },
18957
+ denominator: "none"
18958
+ }) : null;
18959
+ return {
18960
+ file_ref: fileRef,
18961
+ source_ref: invocation.authorized_scope.source_ref,
18962
+ module_ref: moduleRef,
18963
+ normalized_path: document.path,
18964
+ role,
18965
+ coverage_tier: "lightweight-evidence",
18966
+ disposition: document.disposition,
18967
+ facts: sourceFact === null ? [] : [sourceFact, ...document.values.map((value) => fact3(document, value, invocation, moduleRef))]
18968
+ };
18969
+ });
18970
+ return buildIndexerEvidenceAdapterResult({
18971
+ protocol: "context.indexer.evidence-adapter-result/v1",
18972
+ adapter: invocation.adapter,
18973
+ authorized_scope: invocation.authorized_scope,
18974
+ input_digest: invocation.input_digest,
18975
+ precedence: invocation.precedence,
18976
+ files: evidenceFiles,
18977
+ diagnostics,
18978
+ toolchain: [{
18979
+ step: "parse-config-evidence",
18980
+ package: invocation.adapter.package,
18981
+ export: invocation.adapter.export,
18982
+ version: invocation.adapter.version,
18983
+ digest: invocation.adapter.digest,
18984
+ capabilities: ["config-boundary-candidates", "config-schema-neutral", "parser.json", "parser.toml", "parser.yaml"],
18985
+ input_digest: invocation.input_digest,
18986
+ output_digest: indexerEvidenceAdapterProtocolDigest(documents)
18987
+ }]
18988
+ });
18989
+ }
18990
+ function configSourcesToEvidenceAdapterMaterialization(files, invocation, options = {}) {
18991
+ return materializeIndexerEvidenceAdapterResult(configSourcesToEvidenceAdapterResult(files, invocation, options));
18992
+ }
18993
+ // src/parser.ts
18994
+ import * as WebTreeSitter from "web-tree-sitter";
18995
+ import { existsSync } from "node:fs";
18996
+ import { fileURLToPath } from "node:url";
18997
+ var treeSitterRuntime = WebTreeSitter;
18998
+ var Parser = treeSitterRuntime.default ?? treeSitterRuntime.Parser;
18999
+ if (!Parser) {
19000
+ throw new TypeError("web-tree-sitter runtime does not expose Parser");
19001
+ }
19002
+ var parserInitPromise = null;
19003
+ var parsedBytesSinceReset = 0;
19004
+ var parserDead = false;
19005
+ var PARSER_RESET_THRESHOLD = 16 * 1024 * 1024;
19006
+ var resolveWasmPath = (relativePath) => fileURLToPath(new URL(relativePath, import.meta.url));
19007
+ var createParserInstance = async () => {
19008
+ const localWasm = resolveWasmPath("./wasm/tree-sitter.wasm");
19009
+ const initOptions = existsSync(localWasm) ? { locateFile: (scriptName) => resolveWasmPath(`./wasm/${scriptName}`) } : undefined;
19010
+ await Parser.init(initOptions);
19011
+ const LanguageRuntime = treeSitterRuntime.default?.Language ?? treeSitterRuntime.Language;
19012
+ if (!LanguageRuntime) {
19013
+ throw new TypeError("web-tree-sitter runtime does not expose Language after initialization");
19014
+ }
19015
+ const parser = new Parser;
19016
+ const tsLanguage = await LanguageRuntime.load(resolveWasmPath("./wasm/tree-sitter-typescript.wasm"));
19017
+ const tsxLanguage = await LanguageRuntime.load(resolveWasmPath("./wasm/tree-sitter-tsx.wasm"));
19018
+ return { parser, tsLanguage, tsxLanguage };
19019
+ };
19020
+ var initParser = async () => {
19021
+ if (!parserInitPromise) {
19022
+ parserInitPromise = (async () => {
19023
+ try {
19024
+ parsedBytesSinceReset = 0;
19025
+ return await createParserInstance();
19026
+ } catch (error) {
19027
+ parserInitPromise = null;
19028
+ throw error;
19029
+ }
19030
+ })();
19031
+ }
19032
+ return parserInitPromise;
19033
+ };
19034
+ var resetParser = () => {
19035
+ parserInitPromise = null;
19036
+ parsedBytesSinceReset = 0;
19037
+ parserDead = false;
19038
+ };
19039
+ var tryParse = async (source, isTsx) => {
19040
+ const { parser, tsLanguage, tsxLanguage } = await initParser();
19041
+ parser.setLanguage(isTsx ? tsxLanguage : tsLanguage);
19042
+ const tree = parser.parse(source);
19043
+ parsedBytesSinceReset += source.length;
19044
+ if (tree.rootNode.hasError()) {
19045
+ return null;
19046
+ }
19047
+ return tree;
19048
+ };
19049
+ var parseFile = async (source, isTsx) => {
19050
+ if (parserDead)
19051
+ return null;
19052
+ if (parsedBytesSinceReset > PARSER_RESET_THRESHOLD) {
19053
+ resetParser();
19054
+ }
19055
+ try {
15559
19056
  return await tryParse(source, isTsx);
15560
19057
  } catch {
15561
19058
  resetParser();
@@ -15620,95 +19117,226 @@ var detectTechStack = async (repoPath) => {
15620
19117
  }
15621
19118
  return labels;
15622
19119
  };
19120
+
19121
+ // src/index.ts
19122
+ var CONFIG_EVIDENCE_ADAPTER_EXPORT = "configSourcesToEvidenceAdapterResult";
15623
19123
  export {
19124
+ visibilitySchema,
15624
19125
  truncateSourceSpanHash,
19126
+ transitionAtomSchema,
15625
19127
  symbolParamSchema,
19128
+ symbolKindSchema,
15626
19129
  symbolInfoSchema,
15627
19130
  symbolDiffSchema,
19131
+ stripSearchPrefix,
19132
+ stateAtomSchema,
15628
19133
  stableStringify,
19134
+ sourceSpanSchema,
15629
19135
  sourceSpanHashMatches,
19136
+ sourceRefSpanSchema,
19137
+ sourceRefSchema,
15630
19138
  sourceInfoSchema,
19139
+ serializeYaml,
19140
+ sectionSchema,
15631
19141
  scanSourceFiles,
15632
19142
  runRepositoryExtraction,
15633
19143
  runCodeExtractRunner,
15634
19144
  runCodeExtractCliFromFile,
15635
19145
  runCodeExtractCli,
19146
+ ruleAtomSchema,
19147
+ roleAtomSchema,
15636
19148
  resolveRepoRelativePath,
19149
+ resolvePathFilter,
15637
19150
  resolveModuleFsPath,
15638
19151
  resolveModuleDir,
15639
19152
  relationInfoSchema,
19153
+ relationAtomSchema,
19154
+ relatedFactSchema,
19155
+ redactIndexerOutputText,
19156
+ redactIndexerOutput,
19157
+ productKindSchema,
15640
19158
  prefixSymbolPaths,
15641
19159
  prefixExtractionPaths,
15642
19160
  prefixEntryDetectionPaths,
15643
19161
  patternDetectionResultSchema,
19162
+ parseYaml,
15644
19163
  parseSpanSourceRef,
19164
+ parseRef,
15645
19165
  parseFile,
15646
19166
  parseDocumentSourceLocator,
15647
19167
  parseDocumentSnapshotManifest,
15648
19168
  parseDocumentResourceMaterialization,
15649
19169
  parseDocumentCaptureFidelity,
19170
+ parseConfigSources,
19171
+ paragraphAtomSchema,
19172
+ packageKindSchema,
15650
19173
  normalizeSnapshotRelativePath,
15651
19174
  normalizeRelativePath,
15652
19175
  normalizeMarkdownDocument,
15653
19176
  normalizeExtractionPaths,
15654
19177
  normalizeDocumentSourceName,
19178
+ nodeTypeSchema,
19179
+ nodeSchema,
19180
+ metricMilestoneSchema,
19181
+ metricAtomSchema,
15655
19182
  metaText,
19183
+ mergeDefaults,
19184
+ materializeIndexerEvidenceAdapterResult,
19185
+ matchesPathFilter,
19186
+ mapErrorCodeToStatus,
15656
19187
  manifestTypeSchema,
15657
19188
  manifestText,
15658
19189
  manifestInfoSchema,
15659
19190
  loadSourceInfo,
15660
19191
  loadRunnerPlugins,
15661
19192
  jsonl,
19193
+ isVersionVisible,
15662
19194
  isScanExcludedDir,
19195
+ isRefPointer,
19196
+ isPlainObject,
19197
+ isPathSafe,
15663
19198
  isNonBlockingDocumentResourceFailureReasonCode,
19199
+ isIndexableFile,
15664
19200
  initParser,
19201
+ indexerEvidenceAdapterResultSchema,
19202
+ indexerEvidenceAdapterProtocolDigest,
19203
+ indexerEvidenceAdapterOutputDigest,
19204
+ indexerEvidenceAdapterFileSchema,
19205
+ indexerEvidenceAdapterFileRef,
19206
+ indexerEvidenceAdapterFactSchema,
19207
+ indexerEvidenceAdapterFactRef,
19208
+ indexerEvidenceAdapterFactPayloads,
15665
19209
  hashStable,
19210
+ hasExcludedSegment,
19211
+ groundingSchema,
19212
+ globToRegex,
15666
19213
  getGitCommitHash,
19214
+ getFileExtension,
19215
+ generateUUID,
15667
19216
  generateSymbolDiff,
19217
+ generateId,
15668
19218
  generateDigest,
15669
19219
  formatSpanSourceRef,
15670
19220
  formatCanonicalProseSourceRef,
15671
19221
  flattenSymbols,
15672
19222
  fileInfoSchema,
19223
+ factStatusSchema,
19224
+ factSourceTypeSchema,
19225
+ factSchemaBase,
19226
+ factSchema,
19227
+ factRelationSchema,
19228
+ factKindSchema,
19229
+ factConfidenceSchema,
15673
19230
  extractionStatsSchema,
19231
+ extractionResultToEvidenceAdapterResult,
19232
+ extractionResultToEvidenceAdapterMaterialization,
15674
19233
  extractionResultSchema,
15675
19234
  extractionPackageSchema,
15676
19235
  extractionMetaSchema,
19236
+ extractionDiagnosticSchema,
19237
+ extractionCoverageSchema,
19238
+ extractAllRefs,
19239
+ eventAtomSchema,
15677
19240
  entryFileSchema,
15678
19241
  entryDetectionResultSchema,
19242
+ entityAtomSchema,
19243
+ encodeVersionLabel,
15679
19244
  encodeSnapshotLocatorPath,
19245
+ embeddingEntrySchema,
19246
+ edgeTypeSchema,
19247
+ edgeSourceSchema,
19248
+ edgeSchema,
19249
+ docDigestSchema,
19250
+ docChunkResultSchema,
19251
+ docChunkParagraphSchema,
15680
19252
  digestStatsSchema,
15681
19253
  digestDataSchema,
15682
19254
  detectTechStack,
15683
19255
  detectModules,
15684
19256
  detectModuleBoundaries,
15685
19257
  detectModuleAt,
19258
+ defaultRegistry,
15686
19259
  decodeSnapshotLocatorPath,
19260
+ decisionPhaseSchema,
19261
+ decisionAtomSchema,
19262
+ createPathMatcher,
15687
19263
  createModuleFileSystem,
19264
+ createIndexerEvidenceAdapterFact,
15688
19265
  createDocumentSourceSpan,
15689
19266
  createDocumentSnapshotManifest,
15690
19267
  createDocumentSnapshotFileEntry,
15691
19268
  countMarkdownLines,
19269
+ contentHash,
19270
+ constraintAtomSchema,
19271
+ configSourcesToEvidenceAdapterResult,
19272
+ configSourcesToEvidenceAdapterMaterialization,
15692
19273
  computeLogicalRawHash,
15693
19274
  computeDocumentContentHash,
19275
+ comparisonDimensionValueSchema,
19276
+ comparisonDimensionSchema,
19277
+ comparisonAtomSchema,
15694
19278
  codeExtractRunnerInputSchema,
15695
19279
  canonicalizeCodeVersionLabel,
15696
19280
  buildSourceFileHashId,
19281
+ buildSearchPrefix,
19282
+ buildRef,
15697
19283
  buildPackageHashId,
19284
+ buildIndexerEvidenceAdapterResult,
15698
19285
  buildHashId,
15699
19286
  buildEdgeHashId,
15700
19287
  buildDigestData,
15701
19288
  buildCodeSnapshot,
19289
+ boundaryAtomSchema,
19290
+ behaviorAtomSchema,
19291
+ attributeAtomSchema,
19292
+ assertIndexerOutputSafe,
19293
+ Visibility,
19294
+ UPLOAD_MAX_FILE_SIZE,
19295
+ UPLOAD_MAX_FILES,
19296
+ UPLOAD_ALLOWED_EXTENSIONS,
19297
+ TEXT_EXTENSIONS,
19298
+ SymbolKind,
19299
+ SUPERTEST_USER_NAME,
19300
+ SUPERTEST_EMAIL,
15702
19301
  SCAN_EXCLUDED_DIRS,
19302
+ RESERVED_USER_NAMES,
19303
+ ProductKind,
19304
+ PathFilterConfigSchema,
19305
+ PackageKind,
15703
19306
  PACKAGE_JSON,
19307
+ NodeType,
15704
19308
  NO_ENTRY_DETECTED,
19309
+ INDEXER_OUTPUT_REDACTION_MARKER,
19310
+ INDEXABLE_EXTENSIONS,
19311
+ INDEXABLE_DOC_EXTENSIONS,
19312
+ INDEXABLE_CODE_EXTENSIONS,
19313
+ Grounding,
15705
19314
  GO_MOD,
19315
+ FactStatus,
19316
+ FactSourceType,
19317
+ FactRelation,
19318
+ FactKind,
19319
+ FactConfidence,
15706
19320
  ExtractionPluginRegistry,
15707
19321
  ExtractionInputError,
19322
+ ErrorCode,
19323
+ EdgeType,
19324
+ EdgeSource,
15708
19325
  DOCUMENT_SNAPSHOT_MANIFEST_SCHEMA_VERSION,
15709
19326
  DOCUMENT_RESOURCE_SOURCE_MISSING_REASON_CODE,
15710
19327
  DOCUMENT_RESOURCE_PERMISSION_DENIED_REASON_CODE,
15711
19328
  DOCUMENT_EVIDENCE_NORMALIZER_VERSION,
19329
+ DEFAULT_WORKSPACE_NAME,
15712
19330
  DEFAULT_SOURCE_SPAN_HASH_LENGTH,
15713
- CODE_SNAPSHOT_META_SCHEMA_VERSION
19331
+ DEFAULT_PATH_FILTER,
19332
+ DEFAULT_CONTENT_TYPE_DEFINITIONS,
19333
+ DEFAULT_CLOUD_LIBRARY_NAME,
19334
+ DAEMON_OFFLINE_THRESHOLD,
19335
+ DAEMON_HEARTBEAT_INTERVAL,
19336
+ ContentTypeRegistry,
19337
+ CONFIG_EVIDENCE_ADAPTER_EXPORT,
19338
+ CODE_SNAPSHOT_META_SCHEMA_VERSION,
19339
+ CODE_DIGEST_TYPE,
19340
+ CLOUD_DAEMON_IDLE_TIMEOUT,
19341
+ C4AError
15714
19342
  };