@forzalabs/remora 2.0.0 → 2.0.1

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
@@ -11009,9 +11009,20 @@ var init_FileLogService = __esm({
11009
11009
  FileLogServiceClass = class {
11010
11010
  constructor() {
11011
11011
  this._enabled = false;
11012
+ /**
11013
+ * Points the sink at a file, once per target.
11014
+ *
11015
+ * Idempotent on purpose: the executor worker re-applies the parent's logger config at the START
11016
+ * OF EVERY TASK, and a thread under the run-long pool handles many tasks. Building a transport
11017
+ * per call left one open append stream per task on the same file.
11018
+ */
11012
11019
  this.enable = (folder = "./remora/.temp/logs", file = "remora.log") => {
11020
+ if (this._enabled && this._folder === folder && this._file === file)
11021
+ return;
11013
11022
  if (!(0, import_fs.existsSync)(folder))
11014
11023
  (0, import_fs.mkdirSync)(folder, { recursive: true });
11024
+ if (this._logger)
11025
+ this._logger.end();
11015
11026
  this._folder = folder;
11016
11027
  this._file = file;
11017
11028
  this._logger = import_winston.default.createLogger({
@@ -11025,6 +11036,9 @@ ${stack}` : base;
11025
11036
  })
11026
11037
  ),
11027
11038
  transports: [
11039
+ // Rotation is the transport's job. A run writes this file from the main process and
11040
+ // from every executor thread, so a rotation renames a file others hold open — the
11041
+ // 'error' handler below is what keeps that a logged line rather than a dead thread.
11028
11042
  new import_winston.default.transports.File({
11029
11043
  filename: import_path.default.join(folder, file),
11030
11044
  maxsize: 10 * 1024 * 1024,
@@ -11034,6 +11048,7 @@ ${stack}` : base;
11034
11048
  })
11035
11049
  ]
11036
11050
  });
11051
+ this._logger.on("error", (error) => console.error(`File logger error: ${error?.message ?? String(error)}`));
11037
11052
  this._enabled = true;
11038
11053
  };
11039
11054
  /**
@@ -11075,11 +11090,22 @@ ${stack}` : base;
11075
11090
  }
11076
11091
  });
11077
11092
  };
11093
+ /**
11094
+ * Ends the sink. The state goes with it, so the next write re-enables a fresh one.
11095
+ *
11096
+ * That reset is the point: a closed winston logger still accepts `log()` calls and writes them
11097
+ * into an ended stream, which throws ERR_STREAM_WRITE_AFTER_END from a stream nothing is
11098
+ * listening to. Leaving `_enabled` true after a close is what turned "someone logged after
11099
+ * close" into "the process died". Use `flush()` when the sink is still needed afterwards.
11100
+ */
11078
11101
  this.close = () => {
11079
11102
  if (!this._enabled || !this._logger) return Promise.resolve();
11103
+ const closing = this._logger;
11104
+ this._enabled = false;
11105
+ this._logger = null;
11080
11106
  return new Promise((resolve) => {
11081
- this._logger.on("finish", resolve);
11082
- this._logger.end();
11107
+ closing.on("finish", resolve);
11108
+ closing.end();
11083
11109
  });
11084
11110
  };
11085
11111
  }
@@ -11501,7 +11527,7 @@ var CONSTANTS, Constants_default;
11501
11527
  var init_Constants = __esm({
11502
11528
  "../../packages/constants/src/Constants.ts"() {
11503
11529
  CONSTANTS = {
11504
- cliVersion: "2.0.0",
11530
+ cliVersion: "2.0.1",
11505
11531
  backendVersion: 1,
11506
11532
  backendPort: 5088,
11507
11533
  workerVersion: 2,
@@ -11787,6 +11813,132 @@ var init_SecretManager = __esm({
11787
11813
  }
11788
11814
  });
11789
11815
 
11816
+ // ../../packages/common/src/schema/SchemaErrorReporter.ts
11817
+ var MAX_REPORTED_ERRORS, MAX_LISTED_VALUES, MAX_QUOTED_LENGTH, VALUE_KEYWORDS, ITEM_NAME_KEYS, SchemaErrorReporterClass, SchemaErrorReporter, SchemaErrorReporter_default;
11818
+ var init_SchemaErrorReporter = __esm({
11819
+ "../../packages/common/src/schema/SchemaErrorReporter.ts"() {
11820
+ MAX_REPORTED_ERRORS = 3;
11821
+ MAX_LISTED_VALUES = 30;
11822
+ MAX_QUOTED_LENGTH = 40;
11823
+ VALUE_KEYWORDS = ["type", "pattern", "format", "maxLength", "minLength", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "multipleOf", "const"];
11824
+ ITEM_NAME_KEYS = ["name", "alias", "key", "title"];
11825
+ SchemaErrorReporterClass = class {
11826
+ constructor() {
11827
+ /**
11828
+ * One human-readable line for a failed validation. `data` is the value that was validated, and is
11829
+ * read to quote the offending value back and to name the resource's own parts.
11830
+ */
11831
+ this.describe = (errors, data) => {
11832
+ const relevant = this._prune(errors ?? []);
11833
+ const shown = relevant.slice(0, MAX_REPORTED_ERRORS).map((x2) => this._explain(x2, data));
11834
+ const hidden = relevant.length - shown.length;
11835
+ return [shown.join("; "), hidden > 0 ? `+${hidden} more` : null].filter(Boolean).join(", ");
11836
+ };
11837
+ /**
11838
+ * Drops the alternatives' complaints from every failed `oneOf`/`anyOf`, because they are one
11839
+ * rejection per alternative rather than one problem. What survives is whatever an alternative
11840
+ * said about a value BELOW the branch point — the alternative that got far enough in to find the
11841
+ * real mistake — and when no alternative got that far, the branch point itself, which then reads
11842
+ * as the list of what was allowed there.
11843
+ */
11844
+ this._prune = (errors) => {
11845
+ const branchPoints = errors.filter((x2) => x2.keyword === "oneOf" || x2.keyword === "anyOf");
11846
+ const kept = branchPoints.reduce((remaining, branch) => this._resolveBranch(remaining, branch), errors);
11847
+ return this._dedupe(kept);
11848
+ };
11849
+ /** Keeps, of everything reported at one branch point, only what says where the mistake actually is. */
11850
+ this._resolveBranch = (kept, branch) => {
11851
+ if (!kept.includes(branch)) return kept;
11852
+ const isAtBranch = (x2) => x2.instancePath === branch.instancePath;
11853
+ const hasDeeper = kept.some((x2) => x2.instancePath.startsWith(branch.instancePath + "/"));
11854
+ return hasDeeper ? kept.filter((x2) => !isAtBranch(x2)) : kept.filter((x2) => !isAtBranch(x2) || x2 === branch);
11855
+ };
11856
+ /** The same complaint from several alternatives is still one complaint. */
11857
+ this._dedupe = (errors) => {
11858
+ const seen = /* @__PURE__ */ new Set();
11859
+ return errors.filter((x2) => {
11860
+ const signature = `${x2.instancePath}|${x2.keyword}|${x2.message}|${JSON.stringify(x2.params ?? {})}`;
11861
+ if (seen.has(signature)) return false;
11862
+ seen.add(signature);
11863
+ return true;
11864
+ });
11865
+ };
11866
+ this._explain = (error, data) => `${this._locate(error.instancePath, data)} ${this._reason(error, data)}`;
11867
+ /**
11868
+ * The JSON pointer to the offending value, followed by the name of the array item it sits in.
11869
+ * "/fields/2" is a position; "(field "created_at")" is what the author called it.
11870
+ */
11871
+ this._locate = (instancePath, data) => {
11872
+ const named = this._nameItem(instancePath, data);
11873
+ return [instancePath || "/", named].filter(Boolean).join(" ");
11874
+ };
11875
+ /** `/fields/2/transform/cast` in a consumer -> `(field "created_at")`, when the item carries a name. */
11876
+ this._nameItem = (instancePath, data) => {
11877
+ const segments = this._segments(instancePath);
11878
+ for (let index = segments.length - 1; index > 0; index--) {
11879
+ if (!/^\d+$/.test(segments[index])) continue;
11880
+ const item = this._valueAt(data, segments.slice(0, index + 1));
11881
+ const nameKey = ITEM_NAME_KEYS.find((key) => typeof item?.[key] === "string");
11882
+ if (!nameKey) continue;
11883
+ return `(${this._singular(segments[index - 1])} "${item[nameKey]}")`;
11884
+ }
11885
+ return null;
11886
+ };
11887
+ /** Reads the way a config author speaks about the collection: `fields` -> `field`. */
11888
+ this._singular = (collection) => collection.endsWith("s") ? collection.slice(0, -1) : collection;
11889
+ /**
11890
+ * What was wrong, in the terms the author wrote. Ajv's own message says what the schema wanted;
11891
+ * these add what was actually there, which is the half that names the typo.
11892
+ */
11893
+ this._reason = (error, data) => {
11894
+ const value = "data" in error ? error.data : this._valueAt(data, this._segments(error.instancePath));
11895
+ if (error.keyword === "enum")
11896
+ return `must be one of: ${this._list(error.params.allowedValues)} (got ${this._quote(value)})`;
11897
+ if (error.keyword === "additionalProperties")
11898
+ return `has unknown property "${error.params.additionalProperty}"`;
11899
+ if (error.keyword === "oneOf" || error.keyword === "anyOf")
11900
+ return this._describeAlternatives(error, value);
11901
+ if (VALUE_KEYWORDS.includes(error.keyword))
11902
+ return `${error.message} (got ${this._quote(value)})`;
11903
+ return error.message;
11904
+ };
11905
+ /**
11906
+ * A branch point no alternative matched, named by what the alternatives ARE — read off the schema
11907
+ * rather than off their rejections, because an alternative says nothing about the property it
11908
+ * requires when that property is present and the rest of it is what failed.
11909
+ */
11910
+ this._describeAlternatives = (error, value) => {
11911
+ const shapes = (error.schema ?? []).map((x2) => this._shape(x2)).filter(Boolean);
11912
+ if (shapes.length === 0) return error.message;
11913
+ if (value && typeof value === "object" && !Array.isArray(value))
11914
+ return `must have exactly one of: ${this._list(shapes)} (has: ${this._list(Object.keys(value))})`;
11915
+ return `must be one of: ${this._list(shapes)} (got ${this._quote(value)})`;
11916
+ };
11917
+ /** How one alternative would be described to whoever has to write it: a property, or a type. */
11918
+ this._shape = (alternative) => {
11919
+ if (alternative?.required?.length > 0) return alternative.required.join(" + ");
11920
+ if (alternative?.pattern) return `${alternative.type ?? "string"} matching "${alternative.pattern}"`;
11921
+ return alternative?.type ?? null;
11922
+ };
11923
+ /** `/fields/2/transform` -> ['fields', '2', 'transform'], undoing the pointer's escapes. */
11924
+ this._segments = (instancePath) => (instancePath || "").split("/").slice(1).map((x2) => x2.replace(/~1/g, "/").replace(/~0/g, "~"));
11925
+ this._valueAt = (data, segments) => segments.reduce((current, segment) => current?.[segment], data);
11926
+ this._list = (values) => {
11927
+ const shown = (values ?? []).slice(0, MAX_LISTED_VALUES).join(", ");
11928
+ const hidden = (values ?? []).length - MAX_LISTED_VALUES;
11929
+ return hidden > 0 ? `${shown}, +${hidden} more` : shown;
11930
+ };
11931
+ this._quote = (value) => {
11932
+ const text = value === void 0 ? "nothing" : JSON.stringify(value);
11933
+ return text.length > MAX_QUOTED_LENGTH ? `${text.slice(0, MAX_QUOTED_LENGTH)}\u2026` : text;
11934
+ };
11935
+ }
11936
+ };
11937
+ SchemaErrorReporter = new SchemaErrorReporterClass();
11938
+ SchemaErrorReporter_default = SchemaErrorReporter;
11939
+ }
11940
+ });
11941
+
11790
11942
  // ../../packages/common/src/schema/SchemaValidator.ts
11791
11943
  var import_ajv, import_ajv_formats, import_fs3, import_path3, SchemaValidatorClass, SchemaValidator, SchemaValidator_default;
11792
11944
  var init_SchemaValidator = __esm({
@@ -11796,11 +11948,12 @@ var init_SchemaValidator = __esm({
11796
11948
  import_fs3 = __toESM(require("fs"), 1);
11797
11949
  import_path3 = __toESM(require("path"), 1);
11798
11950
  init_src();
11951
+ init_SchemaErrorReporter();
11799
11952
  SchemaValidatorClass = class {
11800
11953
  constructor() {
11801
11954
  this.addSchema = (schema, schemaKey) => {
11802
11955
  const isValid = this.ajv.validateSchema(schema);
11803
- Affirm_default(isValid, `Invalid JSON Schema: ${JSON.stringify(this.ajv.errors)}`);
11956
+ Affirm_default(isValid, `Invalid JSON Schema: ${SchemaErrorReporter_default.describe(this.ajv.errors, schema)}`);
11804
11957
  this.ajv.addSchema(schema, schemaKey);
11805
11958
  };
11806
11959
  this.getSchema = (schemaKey) => {
@@ -11854,7 +12007,10 @@ var init_SchemaValidator = __esm({
11854
12007
  strictSchema: false,
11855
12008
  // Code values may be string | number | boolean, so schemas legitimately use union types.
11856
12009
  allowUnionTypes: true,
11857
- validateFormats: true
12010
+ validateFormats: true,
12011
+ // Carries the failing schema and value on each error, which is what lets
12012
+ // SchemaErrorReporter say what was allowed there and what was found instead.
12013
+ verbose: true
11858
12014
  });
11859
12015
  (0, import_ajv_formats.default)(this.ajv);
11860
12016
  this.loadInternalSchema();
@@ -13184,7 +13340,7 @@ ${errors.map((x2) => ` - ${x2}`).join("\n")}`);
13184
13340
  });
13185
13341
 
13186
13342
  // ../../packages/common/src/Environment.ts
13187
- var import_fs4, import_crypto, import_adm_zip, import_path4, import_client_s3, RESOURCE_SCHEMA_KEYS, INVALID_RESOURCE_MESSAGES, MAX_REPORTED_SCHEMA_ERRORS, EnvironmentClass, Environment, Environment_default;
13343
+ var import_fs4, import_crypto, import_adm_zip, import_path4, import_client_s3, RESOURCE_SCHEMA_KEYS, INVALID_RESOURCE_MESSAGES, EnvironmentClass, Environment, Environment_default;
13188
13344
  var init_Environment = __esm({
13189
13345
  "../../packages/common/src/Environment.ts"() {
13190
13346
  import_fs4 = __toESM(require("fs"), 1);
@@ -13193,6 +13349,7 @@ var init_Environment = __esm({
13193
13349
  init_src();
13194
13350
  import_path4 = __toESM(require("path"), 1);
13195
13351
  init_SchemaValidator();
13352
+ init_SchemaErrorReporter();
13196
13353
  init_Validator();
13197
13354
  init_ProducerExpander();
13198
13355
  init_src3();
@@ -13212,7 +13369,6 @@ var init_Environment = __esm({
13212
13369
  codeSet: "Invalid code set configuration",
13213
13370
  schema: "Invalid schema configuration"
13214
13371
  };
13215
- MAX_REPORTED_SCHEMA_ERRORS = 3;
13216
13372
  EnvironmentClass = class {
13217
13373
  constructor() {
13218
13374
  this._env = null;
@@ -13385,21 +13541,21 @@ var init_Environment = __esm({
13385
13541
  schemas.forEach((schema) => this._registerSchema(schema, problems));
13386
13542
  const sourceFiles = read(projectConfig.sources);
13387
13543
  const sources = sourceFiles.map((x2) => x2.config);
13388
- sources.forEach((source) => this._recordSchemaProblem(source, "source", problems));
13544
+ sourceFiles.forEach((source) => this._recordSchemaProblem(source, "source", problems));
13389
13545
  this._checkApiQueueSource(projectConfig, sources, problems);
13390
13546
  const producerFiles = read(projectConfig.producers);
13391
13547
  const producers = producerFiles.map((x2) => x2.config);
13392
- producers.forEach((producer) => {
13393
- const schemaProblem = this._schemaProblem(producer, "producer");
13548
+ producerFiles.forEach(({ config: producer, file }) => {
13549
+ const schemaProblem = this._schemaProblem(producer, "producer", file);
13394
13550
  this._expandProducer(producer, problems);
13395
13551
  if (schemaProblem) problems.push(schemaProblem);
13396
13552
  });
13397
13553
  const consumerFiles = read(projectConfig.consumers);
13398
13554
  const consumers = consumerFiles.map((x2) => x2.config);
13399
- consumers.forEach((consumer) => this._recordSchemaProblem(consumer, "consumer", problems));
13555
+ consumerFiles.forEach((consumer) => this._recordSchemaProblem(consumer, "consumer", problems));
13400
13556
  const codeSetFiles = read(projectConfig.codeSets ?? []);
13401
13557
  const codeSets = codeSetFiles.map((x2) => x2.config);
13402
- codeSets.forEach((codeSet) => this._recordSchemaProblem(codeSet, "codeSet", problems));
13558
+ codeSetFiles.forEach((codeSet) => this._recordSchemaProblem(codeSet, "codeSet", problems));
13403
13559
  this._checkCodeSetNames(codeSets, problems);
13404
13560
  return {
13405
13561
  env: { settings: this._readSettings(projectConfig), sources, producers, consumers, schemas, codeSets },
@@ -13479,7 +13635,7 @@ var init_Environment = __esm({
13479
13635
  severity: "error",
13480
13636
  scope: "project",
13481
13637
  file: projectPath,
13482
- message: `Invalid project configuration (${this._describeSchemaErrors(validation.errors)})`
13638
+ message: `Invalid project configuration - ${SchemaErrorReporter_default.describe(validation.errors, projectConfig)}`
13483
13639
  });
13484
13640
  }
13485
13641
  return projectConfig;
@@ -13535,8 +13691,8 @@ var init_Environment = __esm({
13535
13691
  }
13536
13692
  return results;
13537
13693
  };
13538
- this._recordSchemaProblem = (resource, kind, problems) => {
13539
- const problem = this._schemaProblem(resource, kind);
13694
+ this._recordSchemaProblem = (read, kind, problems) => {
13695
+ const problem = this._schemaProblem(read.config, kind, read.file);
13540
13696
  if (problem) problems.push(problem);
13541
13697
  };
13542
13698
  /**
@@ -13547,15 +13703,17 @@ var init_Environment = __esm({
13547
13703
  * Returns the problem instead of recording it, because a producer's is reported after its
13548
13704
  * expansion has had its say (see `inspect`).
13549
13705
  */
13550
- this._schemaProblem = (resource, kind) => {
13706
+ this._schemaProblem = (resource, kind, file) => {
13551
13707
  const name = resource?.name;
13552
13708
  const validation = SchemaValidator_default.validate(RESOURCE_SCHEMA_KEYS[kind], resource);
13553
13709
  if (validation.isValid) return null;
13710
+ const where = [name, file ? `(${file})` : null].filter(Boolean).join(" ");
13554
13711
  return {
13555
13712
  severity: "error",
13556
13713
  scope: "resource",
13714
+ file,
13557
13715
  resource: { kind, name },
13558
- message: `${INVALID_RESOURCE_MESSAGES[kind]}: ${name} (${this._describeSchemaErrors(validation.errors)})`
13716
+ message: `${INVALID_RESOURCE_MESSAGES[kind]}: ${where} - ${SchemaErrorReporter_default.describe(validation.errors, resource)}`
13559
13717
  };
13560
13718
  };
13561
13719
  this._registerSchema = (schema, problems) => {
@@ -13632,12 +13790,6 @@ var init_Environment = __esm({
13632
13790
  /** Kept verbatim from the batch loader this replaced, so `load()` still throws the same string. */
13633
13791
  this._loadFailureMessage = (remoraPath, configPath, error) => `Error loading from ${import_path4.default.resolve(remoraPath)} configuration from ${configPath}: ${this._messageOf(error)}`;
13634
13792
  this._messageOf = (error) => error instanceof Error ? error.message : String(error);
13635
- /** The first few Ajv complaints, so "Invalid producer configuration: p_x" says what is wrong with it. */
13636
- this._describeSchemaErrors = (errors) => {
13637
- const shown = (errors ?? []).slice(0, MAX_REPORTED_SCHEMA_ERRORS).map((item) => `${item.instancePath || "/"} ${item.message}`);
13638
- const hidden = (errors ?? []).length - shown.length;
13639
- return [shown.join("; "), hidden > 0 ? `+${hidden} more` : null].filter(Boolean).join(", ");
13640
- };
13641
13793
  /**
13642
13794
  * The loaded environment, flattened for transport to a worker thread.
13643
13795
  *
@@ -13897,6 +14049,220 @@ var init_src4 = __esm({
13897
14049
  }
13898
14050
  });
13899
14051
 
14052
+ // ../../packages/helper/src/Helper.ts
14053
+ var import_uuid, Helper, Helper_default;
14054
+ var init_Helper = __esm({
14055
+ "../../packages/helper/src/Helper.ts"() {
14056
+ import_uuid = require("uuid");
14057
+ init_src4();
14058
+ Helper = {
14059
+ uuid: () => (0, import_uuid.v4)(),
14060
+ isDev: () => ProcessENVManager_default.getEnvVariable("NODE_ENV") === "development",
14061
+ asError: (error) => error instanceof Error ? error : new Error(error),
14062
+ formatDateToYYYYMM(date2) {
14063
+ if (!date2) return "";
14064
+ const year2 = date2.getFullYear();
14065
+ const month = ("0" + (date2.getMonth() + 1)).slice(-2);
14066
+ return `${year2}-${month}`;
14067
+ },
14068
+ formatDuration: (milliseconds) => {
14069
+ if (!milliseconds || milliseconds < 0) return "0ms";
14070
+ if (milliseconds < 1e3) {
14071
+ return `${Math.round(milliseconds)}ms`;
14072
+ }
14073
+ const seconds = milliseconds / 1e3;
14074
+ if (seconds < 60) {
14075
+ return `${seconds.toFixed(1)}s`;
14076
+ }
14077
+ const minutes = Math.floor(seconds / 60);
14078
+ const remainingSeconds = seconds % 60;
14079
+ if (minutes < 60) {
14080
+ return `${minutes}m ${remainingSeconds.toFixed(1)}s`;
14081
+ }
14082
+ const hours = Math.floor(minutes / 60);
14083
+ const remainingMinutes = minutes % 60;
14084
+ return `${hours}h ${remainingMinutes}m`;
14085
+ },
14086
+ matchPattern: (pattern, items) => {
14087
+ let patternParts = [];
14088
+ let hasWildcard = false;
14089
+ let result = [...items];
14090
+ if (pattern) {
14091
+ if (pattern.includes("%")) {
14092
+ hasWildcard = true;
14093
+ const parts = pattern.split("%").filter((part) => part.length > 0);
14094
+ patternParts = parts;
14095
+ }
14096
+ }
14097
+ if (hasWildcard && patternParts.length > 0) {
14098
+ result = result.filter((key) => {
14099
+ const matchesPattern = (fileName, pattern2) => {
14100
+ if (!pattern2.includes("%")) {
14101
+ return fileName === pattern2;
14102
+ }
14103
+ const parts = pattern2.split("%");
14104
+ let currentIndex = 0;
14105
+ for (let i6 = 0; i6 < parts.length; i6++) {
14106
+ const part = parts[i6];
14107
+ if (part === "") continue;
14108
+ if (i6 === 0 && !pattern2.startsWith("%")) {
14109
+ if (!fileName.startsWith(part)) {
14110
+ return false;
14111
+ }
14112
+ currentIndex = part.length;
14113
+ } else if (i6 === parts.length - 1 && !pattern2.endsWith("%")) {
14114
+ if (!fileName.endsWith(part)) {
14115
+ return false;
14116
+ }
14117
+ } else {
14118
+ const foundIndex = fileName.indexOf(part, currentIndex);
14119
+ if (foundIndex === -1) {
14120
+ return false;
14121
+ }
14122
+ currentIndex = foundIndex + part.length;
14123
+ }
14124
+ }
14125
+ return true;
14126
+ };
14127
+ return matchesPattern(key, pattern);
14128
+ });
14129
+ }
14130
+ return result;
14131
+ }
14132
+ };
14133
+ Helper_default = Helper;
14134
+ }
14135
+ });
14136
+
14137
+ // ../../packages/helper/src/Formatter.ts
14138
+ var Formatter, Formatter_default;
14139
+ var init_Formatter = __esm({
14140
+ "../../packages/helper/src/Formatter.ts"() {
14141
+ Formatter = {
14142
+ bytes: (bytes, decimals = 2) => {
14143
+ if (!+bytes) return "0 Bytes";
14144
+ const k7 = 1024;
14145
+ const dm = decimals < 0 ? 0 : decimals;
14146
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
14147
+ const i6 = Math.floor(Math.log(bytes) / Math.log(k7));
14148
+ return `${parseFloat((bytes / Math.pow(k7, i6)).toFixed(dm))} ${sizes[i6]}`;
14149
+ }
14150
+ };
14151
+ Formatter_default = Formatter;
14152
+ }
14153
+ });
14154
+
14155
+ // ../../packages/helper/src/Settings.ts
14156
+ var SETTINGS, Settings_default;
14157
+ var init_Settings = __esm({
14158
+ "../../packages/helper/src/Settings.ts"() {
14159
+ SETTINGS = {
14160
+ db: {
14161
+ name: "remora-db",
14162
+ collections: {
14163
+ usage: "usage",
14164
+ users: "users",
14165
+ apiKeys: "apiKeys"
14166
+ }
14167
+ }
14168
+ };
14169
+ Settings_default = SETTINGS;
14170
+ }
14171
+ });
14172
+
14173
+ // ../../packages/helper/src/Runtime.ts
14174
+ var import_node_v8, RuntimeClass, Runtime, Runtime_default;
14175
+ var init_Runtime = __esm({
14176
+ "../../packages/helper/src/Runtime.ts"() {
14177
+ import_node_v8 = __toESM(require("v8"), 1);
14178
+ RuntimeClass = class {
14179
+ constructor() {
14180
+ this.getHeap = () => {
14181
+ const {
14182
+ heap_size_limit,
14183
+ used_heap_size
14184
+ } = import_node_v8.default.getHeapStatistics();
14185
+ return {
14186
+ heapSizeMB: this._toMB(heap_size_limit),
14187
+ usedHeapMB: this._toMB(used_heap_size)
14188
+ };
14189
+ };
14190
+ this._toMB = (bytes) => Math.round(bytes / (1024 * 1024) * 100) / 100;
14191
+ }
14192
+ };
14193
+ Runtime = new RuntimeClass();
14194
+ Runtime_default = Runtime;
14195
+ }
14196
+ });
14197
+
14198
+ // ../../packages/helper/src/HttpClient.ts
14199
+ var HttpClientClass, HttpClient;
14200
+ var init_HttpClient = __esm({
14201
+ "../../packages/helper/src/HttpClient.ts"() {
14202
+ init_src4();
14203
+ HttpClientClass = class {
14204
+ constructor() {
14205
+ this.post = async (url, body, headers) => {
14206
+ try {
14207
+ const response = await fetch(url, {
14208
+ method: "POST",
14209
+ body: JSON.stringify(body),
14210
+ headers: {
14211
+ "Content-Type": "application/json",
14212
+ ...headers
14213
+ }
14214
+ });
14215
+ if (!response.ok) {
14216
+ const errorData = await response.json().catch(() => ({}));
14217
+ throw new Error(errorData?.error || errorData?.message || "Request failed");
14218
+ }
14219
+ return await response.json();
14220
+ } catch (error) {
14221
+ const err2 = error;
14222
+ throw new Error(err2.message ?? "An error occurred on POST.");
14223
+ }
14224
+ };
14225
+ this.get = async (url, headers) => {
14226
+ try {
14227
+ const response = await fetch(url, {
14228
+ method: "GET",
14229
+ headers: {
14230
+ "Content-Type": "application/json",
14231
+ ...headers
14232
+ }
14233
+ });
14234
+ if (!response.ok) {
14235
+ const errorData = await response.json().catch(() => ({}));
14236
+ throw new Error(errorData?.error || errorData?.message || "Request failed");
14237
+ }
14238
+ return await response.json();
14239
+ } catch (error) {
14240
+ const err2 = error;
14241
+ throw new Error(err2.message ?? "An error occurred on GET.");
14242
+ }
14243
+ };
14244
+ this.getWorkerUrl = (path29) => {
14245
+ const cleanPath = path29.startsWith("/") ? path29.substring(1) : path29;
14246
+ return `${this.workerHost}/${cleanPath}`;
14247
+ };
14248
+ this.workerHost = ProcessENVManager_default.getEnvVariable("REMORA_WORKER_HOST") || "http://worker:5069";
14249
+ }
14250
+ };
14251
+ HttpClient = new HttpClientClass();
14252
+ }
14253
+ });
14254
+
14255
+ // ../../packages/helper/src/index.ts
14256
+ var init_src5 = __esm({
14257
+ "../../packages/helper/src/index.ts"() {
14258
+ init_Helper();
14259
+ init_Formatter();
14260
+ init_Settings();
14261
+ init_Runtime();
14262
+ init_HttpClient();
14263
+ }
14264
+ });
14265
+
13900
14266
  // ../../node_modules/@smithy/core/dist-es/submodules/config/property-provider/ProviderError.js
13901
14267
  var ProviderError;
13902
14268
  var init_ProviderError = __esm({
@@ -18677,7 +19043,7 @@ var init_sdk_stream_mixin = __esm({
18677
19043
  });
18678
19044
 
18679
19045
  // ../../node_modules/@smithy/core/dist-es/submodules/serde/index.js
18680
- var import_node_crypto2, Uint8ArrayBlobAdapter, _getRandomValues, v4, generateIdempotencyToken;
19046
+ var import_node_crypto2, Uint8ArrayBlobAdapter, _getRandomValues, v42, generateIdempotencyToken;
18681
19047
  var init_serde = __esm({
18682
19048
  "../../node_modules/@smithy/core/dist-es/submodules/serde/index.js"() {
18683
19049
  import_node_crypto2 = require("crypto");
@@ -18703,8 +19069,8 @@ var init_serde = __esm({
18703
19069
  Uint8ArrayBlobAdapter = class extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) {
18704
19070
  };
18705
19071
  _getRandomValues = import_node_crypto2.getRandomValues;
18706
- v4 = bindV4(_getRandomValues);
18707
- generateIdempotencyToken = v4;
19072
+ v42 = bindV4(_getRandomValues);
19073
+ generateIdempotencyToken = v42;
18708
19074
  }
18709
19075
  });
18710
19076
 
@@ -21221,7 +21587,7 @@ function bindRetryMiddleware(isStreamingPayload2) {
21221
21587
  const { request } = args;
21222
21588
  const isRequest = HttpRequest.isInstance(request);
21223
21589
  if (isRequest) {
21224
- request.headers[INVOCATION_ID_HEADER] = v4();
21590
+ request.headers[INVOCATION_ID_HEADER] = v42();
21225
21591
  }
21226
21592
  while (true) {
21227
21593
  try {
@@ -35858,7 +36224,7 @@ var init_XMLParser = __esm({
35858
36224
  });
35859
36225
 
35860
36226
  // ../../packages/parsing/src/index.ts
35861
- var init_src5 = __esm({
36227
+ var init_src6 = __esm({
35862
36228
  "../../packages/parsing/src/index.ts"() {
35863
36229
  init_CSVParser();
35864
36230
  init_FixedWidthParser();
@@ -41344,7 +41710,7 @@ __export(src_exports, {
41344
41710
  function decompressGzip(input, outputLength) {
41345
41711
  return gunzip(input, new Uint8Array(outputLength));
41346
41712
  }
41347
- var init_src6 = __esm({
41713
+ var init_src7 = __esm({
41348
41714
  "../../node_modules/hyparquet-compressors/src/index.js"() {
41349
41715
  init_esm();
41350
41716
  init_hysnappy();
@@ -41364,7 +41730,7 @@ var init_DeltaShareDriver = __esm({
41364
41730
  init_src();
41365
41731
  init_src4();
41366
41732
  init_src2();
41367
- init_src5();
41733
+ init_src6();
41368
41734
  init_DeltaSharePredicate();
41369
41735
  init_OidcTokenProvider();
41370
41736
  MAX_LIMIT_HINT = 2147483647;
@@ -41613,7 +41979,7 @@ var init_DeltaShareDriver = __esm({
41613
41979
  };
41614
41980
  this._readParquetObjects = async (deltaFile) => {
41615
41981
  const hyparquet = await import("hyparquet");
41616
- const { compressors: compressors2 } = await Promise.resolve().then(() => (init_src6(), src_exports));
41982
+ const { compressors: compressors2 } = await Promise.resolve().then(() => (init_src7(), src_exports));
41617
41983
  const byteLength = deltaFile.file.deltaSingleAction.add?.size ?? deltaFile.file.deltaSingleAction.remove?.size;
41618
41984
  const startedMs = Date.now();
41619
41985
  let records;
@@ -42078,220 +42444,6 @@ var init_HttpApiDriver = __esm({
42078
42444
  }
42079
42445
  });
42080
42446
 
42081
- // ../../packages/helper/src/Helper.ts
42082
- var import_uuid, Helper, Helper_default;
42083
- var init_Helper = __esm({
42084
- "../../packages/helper/src/Helper.ts"() {
42085
- import_uuid = require("uuid");
42086
- init_src4();
42087
- Helper = {
42088
- uuid: () => (0, import_uuid.v4)(),
42089
- isDev: () => ProcessENVManager_default.getEnvVariable("NODE_ENV") === "development",
42090
- asError: (error) => error instanceof Error ? error : new Error(error),
42091
- formatDateToYYYYMM(date2) {
42092
- if (!date2) return "";
42093
- const year2 = date2.getFullYear();
42094
- const month = ("0" + (date2.getMonth() + 1)).slice(-2);
42095
- return `${year2}-${month}`;
42096
- },
42097
- formatDuration: (milliseconds) => {
42098
- if (!milliseconds || milliseconds < 0) return "0ms";
42099
- if (milliseconds < 1e3) {
42100
- return `${Math.round(milliseconds)}ms`;
42101
- }
42102
- const seconds = milliseconds / 1e3;
42103
- if (seconds < 60) {
42104
- return `${seconds.toFixed(1)}s`;
42105
- }
42106
- const minutes = Math.floor(seconds / 60);
42107
- const remainingSeconds = seconds % 60;
42108
- if (minutes < 60) {
42109
- return `${minutes}m ${remainingSeconds.toFixed(1)}s`;
42110
- }
42111
- const hours = Math.floor(minutes / 60);
42112
- const remainingMinutes = minutes % 60;
42113
- return `${hours}h ${remainingMinutes}m`;
42114
- },
42115
- matchPattern: (pattern, items) => {
42116
- let patternParts = [];
42117
- let hasWildcard = false;
42118
- let result = [...items];
42119
- if (pattern) {
42120
- if (pattern.includes("%")) {
42121
- hasWildcard = true;
42122
- const parts = pattern.split("%").filter((part) => part.length > 0);
42123
- patternParts = parts;
42124
- }
42125
- }
42126
- if (hasWildcard && patternParts.length > 0) {
42127
- result = result.filter((key) => {
42128
- const matchesPattern = (fileName, pattern2) => {
42129
- if (!pattern2.includes("%")) {
42130
- return fileName === pattern2;
42131
- }
42132
- const parts = pattern2.split("%");
42133
- let currentIndex = 0;
42134
- for (let i6 = 0; i6 < parts.length; i6++) {
42135
- const part = parts[i6];
42136
- if (part === "") continue;
42137
- if (i6 === 0 && !pattern2.startsWith("%")) {
42138
- if (!fileName.startsWith(part)) {
42139
- return false;
42140
- }
42141
- currentIndex = part.length;
42142
- } else if (i6 === parts.length - 1 && !pattern2.endsWith("%")) {
42143
- if (!fileName.endsWith(part)) {
42144
- return false;
42145
- }
42146
- } else {
42147
- const foundIndex = fileName.indexOf(part, currentIndex);
42148
- if (foundIndex === -1) {
42149
- return false;
42150
- }
42151
- currentIndex = foundIndex + part.length;
42152
- }
42153
- }
42154
- return true;
42155
- };
42156
- return matchesPattern(key, pattern);
42157
- });
42158
- }
42159
- return result;
42160
- }
42161
- };
42162
- Helper_default = Helper;
42163
- }
42164
- });
42165
-
42166
- // ../../packages/helper/src/Formatter.ts
42167
- var Formatter, Formatter_default;
42168
- var init_Formatter = __esm({
42169
- "../../packages/helper/src/Formatter.ts"() {
42170
- Formatter = {
42171
- bytes: (bytes, decimals = 2) => {
42172
- if (!+bytes) return "0 Bytes";
42173
- const k7 = 1024;
42174
- const dm = decimals < 0 ? 0 : decimals;
42175
- const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
42176
- const i6 = Math.floor(Math.log(bytes) / Math.log(k7));
42177
- return `${parseFloat((bytes / Math.pow(k7, i6)).toFixed(dm))} ${sizes[i6]}`;
42178
- }
42179
- };
42180
- Formatter_default = Formatter;
42181
- }
42182
- });
42183
-
42184
- // ../../packages/helper/src/Settings.ts
42185
- var SETTINGS, Settings_default;
42186
- var init_Settings = __esm({
42187
- "../../packages/helper/src/Settings.ts"() {
42188
- SETTINGS = {
42189
- db: {
42190
- name: "remora-db",
42191
- collections: {
42192
- usage: "usage",
42193
- users: "users",
42194
- apiKeys: "apiKeys"
42195
- }
42196
- }
42197
- };
42198
- Settings_default = SETTINGS;
42199
- }
42200
- });
42201
-
42202
- // ../../packages/helper/src/Runtime.ts
42203
- var import_node_v8, RuntimeClass, Runtime, Runtime_default;
42204
- var init_Runtime = __esm({
42205
- "../../packages/helper/src/Runtime.ts"() {
42206
- import_node_v8 = __toESM(require("v8"), 1);
42207
- RuntimeClass = class {
42208
- constructor() {
42209
- this.getHeap = () => {
42210
- const {
42211
- heap_size_limit,
42212
- used_heap_size
42213
- } = import_node_v8.default.getHeapStatistics();
42214
- return {
42215
- heapSizeMB: this._toMB(heap_size_limit),
42216
- usedHeapMB: this._toMB(used_heap_size)
42217
- };
42218
- };
42219
- this._toMB = (bytes) => Math.round(bytes / (1024 * 1024) * 100) / 100;
42220
- }
42221
- };
42222
- Runtime = new RuntimeClass();
42223
- Runtime_default = Runtime;
42224
- }
42225
- });
42226
-
42227
- // ../../packages/helper/src/HttpClient.ts
42228
- var HttpClientClass, HttpClient;
42229
- var init_HttpClient = __esm({
42230
- "../../packages/helper/src/HttpClient.ts"() {
42231
- init_src4();
42232
- HttpClientClass = class {
42233
- constructor() {
42234
- this.post = async (url, body, headers) => {
42235
- try {
42236
- const response = await fetch(url, {
42237
- method: "POST",
42238
- body: JSON.stringify(body),
42239
- headers: {
42240
- "Content-Type": "application/json",
42241
- ...headers
42242
- }
42243
- });
42244
- if (!response.ok) {
42245
- const errorData = await response.json().catch(() => ({}));
42246
- throw new Error(errorData?.error || errorData?.message || "Request failed");
42247
- }
42248
- return await response.json();
42249
- } catch (error) {
42250
- const err2 = error;
42251
- throw new Error(err2.message ?? "An error occurred on POST.");
42252
- }
42253
- };
42254
- this.get = async (url, headers) => {
42255
- try {
42256
- const response = await fetch(url, {
42257
- method: "GET",
42258
- headers: {
42259
- "Content-Type": "application/json",
42260
- ...headers
42261
- }
42262
- });
42263
- if (!response.ok) {
42264
- const errorData = await response.json().catch(() => ({}));
42265
- throw new Error(errorData?.error || errorData?.message || "Request failed");
42266
- }
42267
- return await response.json();
42268
- } catch (error) {
42269
- const err2 = error;
42270
- throw new Error(err2.message ?? "An error occurred on GET.");
42271
- }
42272
- };
42273
- this.getWorkerUrl = (path29) => {
42274
- const cleanPath = path29.startsWith("/") ? path29.substring(1) : path29;
42275
- return `${this.workerHost}/${cleanPath}`;
42276
- };
42277
- this.workerHost = ProcessENVManager_default.getEnvVariable("REMORA_WORKER_HOST") || "http://worker:5069";
42278
- }
42279
- };
42280
- HttpClient = new HttpClientClass();
42281
- }
42282
- });
42283
-
42284
- // ../../packages/helper/src/index.ts
42285
- var init_src7 = __esm({
42286
- "../../packages/helper/src/index.ts"() {
42287
- init_Helper();
42288
- init_Formatter();
42289
- init_Settings();
42290
- init_Runtime();
42291
- init_HttpClient();
42292
- }
42293
- });
42294
-
42295
42447
  // ../../packages/drivers/src/DriverHelper.ts
42296
42448
  var import_stream, import_readline, import_promises8, import_fs9, DriverHelper, DriverHelper_default;
42297
42449
  var init_DriverHelper = __esm({
@@ -42460,13 +42612,13 @@ var init_LocalSourceDriver = __esm({
42460
42612
  init_src();
42461
42613
  init_src();
42462
42614
  XLSX2 = __toESM(require("@e965/xlsx"), 1);
42615
+ init_src6();
42463
42616
  init_src5();
42464
- init_src7();
42465
- init_src5();
42617
+ init_src6();
42466
42618
  init_src2();
42467
42619
  init_DriverHelper();
42468
42620
  init_src4();
42469
- init_src5();
42621
+ init_src6();
42470
42622
  LocalSourceDriver = class {
42471
42623
  constructor() {
42472
42624
  this.init = async (source) => {
@@ -42790,9 +42942,9 @@ var init_S3SourceDriver = __esm({
42790
42942
  import_fs10 = __toESM(require("fs"), 1);
42791
42943
  init_src();
42792
42944
  import_xlsx2 = __toESM(require("@e965/xlsx"), 1);
42945
+ init_src6();
42793
42946
  init_src5();
42794
- init_src7();
42795
- init_src5();
42947
+ init_src6();
42796
42948
  init_src4();
42797
42949
  S3SourceDriver = class {
42798
42950
  constructor() {
@@ -43304,8 +43456,8 @@ var import_mongodb, DatabaseEngineClass, DatabaseEngine, DatabaseEngine_default;
43304
43456
  var init_DatabaseEngine = __esm({
43305
43457
  "../../packages/database/src/DatabaseEngine.ts"() {
43306
43458
  import_mongodb = require("mongodb");
43307
- init_src7();
43308
- init_src7();
43459
+ init_src5();
43460
+ init_src5();
43309
43461
  init_src4();
43310
43462
  DatabaseEngineClass = class {
43311
43463
  constructor() {
@@ -43443,8 +43595,8 @@ var UserManagerClass, UserManager, UserManager_default, DEV_USER, MOCK_USER;
43443
43595
  var init_UserManager = __esm({
43444
43596
  "../../packages/database/src/UserManager.ts"() {
43445
43597
  init_DatabaseEngine();
43446
- init_src7();
43447
- init_src7();
43598
+ init_src5();
43599
+ init_src5();
43448
43600
  UserManagerClass = class {
43449
43601
  constructor() {
43450
43602
  this.getUser = () => {
@@ -43483,7 +43635,7 @@ var init_UserManager = __esm({
43483
43635
  var DATABASE_STRUCTURE, DatabaseStructure_default;
43484
43636
  var init_DatabaseStructure = __esm({
43485
43637
  "../../packages/database/src/DatabaseStructure.ts"() {
43486
- init_src7();
43638
+ init_src5();
43487
43639
  DATABASE_STRUCTURE = {
43488
43640
  collections: [
43489
43641
  {
@@ -43515,7 +43667,7 @@ var init_DatabaseInitializer = __esm({
43515
43667
  init_src();
43516
43668
  init_src4();
43517
43669
  init_UserManager();
43518
- init_src7();
43670
+ init_src5();
43519
43671
  init_DatabaseEngine();
43520
43672
  init_DatabaseStructure();
43521
43673
  import_bcryptjs = __toESM(require("bcryptjs"), 1);
@@ -43979,7 +44131,7 @@ var init_ProducerManager = __esm({
43979
44131
  init_src();
43980
44132
  init_src4();
43981
44133
  init_src3();
43982
- init_src5();
44134
+ init_src6();
43983
44135
  ProducerManagerClass = class {
43984
44136
  constructor() {
43985
44137
  this.getColumns = (producer) => {
@@ -44214,7 +44366,7 @@ var LineParserClass, LineParser, LineParser_default;
44214
44366
  var init_LineParser = __esm({
44215
44367
  "../../packages/engines/src/parsing/LineParser.ts"() {
44216
44368
  init_TypeCaster();
44217
- init_src5();
44369
+ init_src6();
44218
44370
  LineParserClass = class {
44219
44371
  constructor() {
44220
44372
  /**
@@ -44335,7 +44487,7 @@ var init_ProducerEngine = __esm({
44335
44487
  init_src();
44336
44488
  init_src8();
44337
44489
  init_src4();
44338
- init_src5();
44490
+ init_src6();
44339
44491
  init_ProducerManager();
44340
44492
  init_LineParser();
44341
44493
  init_TypeCaster();
@@ -49274,7 +49426,7 @@ var init_OpsService = __esm({
49274
49426
  init_src3();
49275
49427
  init_src();
49276
49428
  init_src9();
49277
- init_src7();
49429
+ init_src5();
49278
49430
  init_RunRegistry();
49279
49431
  MAX_HISTORY_LIMIT = 200;
49280
49432
  DEFAULT_HISTORY_LIMIT = 20;
@@ -49795,8 +49947,8 @@ var init_UsageManager = __esm({
49795
49947
  init_src();
49796
49948
  init_src4();
49797
49949
  init_src9();
49798
- init_src7();
49799
- init_src7();
49950
+ init_src5();
49951
+ init_src5();
49800
49952
  init_src2();
49801
49953
  init_RunRegistry();
49802
49954
  init_LocalUsageDB();
@@ -50739,7 +50891,7 @@ var DataframeManagerClass, DataframeManager, DataframeManager_default;
50739
50891
  var init_DataframeManager = __esm({
50740
50892
  "../../packages/engines/src/usage/DataframeManager.ts"() {
50741
50893
  init_src();
50742
- init_src7();
50894
+ init_src5();
50743
50895
  DataframeManagerClass = class {
50744
50896
  fill(points, from, to2, onlyLastValue, maintainLastValue) {
50745
50897
  const min = from ?? this.getMinDate(points);
@@ -50963,7 +51115,7 @@ var init_OutputExecutor = __esm({
50963
51115
  init_src();
50964
51116
  init_src8();
50965
51117
  init_src4();
50966
- init_src5();
51118
+ init_src6();
50967
51119
  import_path22 = __toESM(require("path"));
50968
51120
  init_src2();
50969
51121
  OutputExecutorClass = class {
@@ -51897,7 +52049,7 @@ var import_os2, import_path25, OrchestratorHelper, OrchestratorHelper_default;
51897
52049
  var init_OrchestratorHelper = __esm({
51898
52050
  "../../packages/executors/src/OrchestratorHelper.ts"() {
51899
52051
  init_src();
51900
- init_src7();
52052
+ init_src5();
51901
52053
  import_os2 = __toESM(require("os"));
51902
52054
  init_src4();
51903
52055
  import_path25 = __toESM(require("path"));
@@ -52245,7 +52397,7 @@ var init_ExecutorOrchestrator = __esm({
52245
52397
  import_workerpool = __toESM(require("workerpool"));
52246
52398
  init_src();
52247
52399
  init_src10();
52248
- init_src7();
52400
+ init_src5();
52249
52401
  init_src4();
52250
52402
  init_ProducerExecutor();
52251
52403
  init_src3();
@@ -52260,7 +52412,7 @@ var init_ExecutorOrchestrator = __esm({
52260
52412
  import_promises17 = require("stream/promises");
52261
52413
  init_src2();
52262
52414
  init_ExecutorProgress2();
52263
- init_src5();
52415
+ init_src6();
52264
52416
  init_OrchestratorHelper();
52265
52417
  init_LookupResolver();
52266
52418
  init_ConsumerInputResolver();
@@ -52271,8 +52423,9 @@ var init_ExecutorOrchestrator = __esm({
52271
52423
  *
52272
52424
  * `maxWorkers` must come from getParallelWorkerCount(), never from the amount of work: that count
52273
52425
  * is memory-aware and is what stops a low-end machine oversubscribing itself. Surplus work queues
52274
- * instead of spawning threads. `census` counts threads as workerpool creates them, which is the
52275
- * only way to know the peak — they spawn lazily, on first exec.
52426
+ * instead of spawning threads. `census.created` counts every thread workerpool spawns — they
52427
+ * spawn lazily, on first exec, and a thread that dies mid-run is replaced by another, so this is
52428
+ * a count of spawns and NOT a concurrency figure (see IWorkerCensus).
52276
52429
  *
52277
52430
  * `workerData` carries the loaded environment, so it is cloned once per THREAD at spawn rather
52278
52431
  * than read and validated from disk once per chunk. Only run-constant data belongs there; per-task
@@ -52289,12 +52442,8 @@ var init_ExecutorOrchestrator = __esm({
52289
52442
  }
52290
52443
  },
52291
52444
  onCreateWorker: () => {
52292
- census.alive++;
52293
- census.peak = Math.max(census.peak, census.alive);
52445
+ census.created++;
52294
52446
  return void 0;
52295
- },
52296
- onTerminateWorker: () => {
52297
- census.alive--;
52298
52447
  }
52299
52448
  };
52300
52449
  const workerPath = OrchestratorHelper_default.getPhysicalWorkerPath();
@@ -52313,7 +52462,7 @@ var init_ExecutorOrchestrator = __esm({
52313
52462
  const { usageId } = UsageManager_default.startUsage(consumer, details);
52314
52463
  const scope = { id: usageId, folder: `${consumer.name}_${usageId}`, workersId: [], limitFileSize: consumer.maximumFileSize };
52315
52464
  const expandedFields = ConsumerManager_default.getExpandedFields(consumer);
52316
- const census = { alive: 0, peak: 0 };
52465
+ const census = { created: 0, peak: 0 };
52317
52466
  try {
52318
52467
  const start = performance.now();
52319
52468
  const executorResults = [];
@@ -52552,6 +52701,7 @@ var init_ExecutorOrchestrator = __esm({
52552
52701
  const context = {
52553
52702
  consumer: request.consumer,
52554
52703
  scope,
52704
+ census,
52555
52705
  options: request.options,
52556
52706
  lookups: request.lookups,
52557
52707
  progress: request.progress,
@@ -52566,8 +52716,12 @@ var init_ExecutorOrchestrator = __esm({
52566
52716
  phase = performance.now();
52567
52717
  const resultsByFile = await Promise.all(pendingByFile.map((file) => Promise.all(file)));
52568
52718
  tracker.measure("worker-wait", performance.now() - phase);
52719
+ census.peak = Math.max(census.peak, pool.stats().totalWorkers);
52569
52720
  Affirm_default(census.peak <= poolSize, `The worker pool ran ${census.peak} thread(s) at once but was sized ${poolSize}`);
52570
52721
  const results = resultsByFile.flat();
52722
+ const failures = results.filter((x2) => !Algo_default.hasVal(x2)).length;
52723
+ if (failures > 0 || census.created > poolSize)
52724
+ Logger_default.warn(`[${scope.id}] ${failures} of ${chunkCount} chunk(s) failed and ${census.created} thread(s) were spawned for a pool of ${poolSize} \u2014 a thread that dies is replaced, so the chunk error(s) logged above are the cause`);
52571
52725
  this.recordWorkerBoot(results, context.requestedAtByWorker, tracker);
52572
52726
  for (const [index, fileResults] of resultsByFile.entries())
52573
52727
  this._assignChunkRowMetadata(workFiles[index].chunks, fileResults);
@@ -52598,7 +52752,12 @@ var init_ExecutorOrchestrator = __esm({
52598
52752
  context.requestedAtByWorker.set(workerId, performance.timeOrigin + performance.now());
52599
52753
  Logger_default.log(`[${scope.id}] Queued worker ${workerId} for ${file.label} \u2014 chunk ${chunk.start}-${chunk.end} (${Math.round((chunk.end - chunk.start) / 1024)}KB)`);
52600
52754
  return pool.exec("executor", [workerData], {
52601
- on: (payload) => this.onWorkAdvanced(payload, workerId, context)
52755
+ // Progress packets are the run's only regular tick on the main thread, which makes them
52756
+ // the cheapest place to sample how many threads are actually alive at once.
52757
+ on: (payload) => {
52758
+ context.census.peak = Math.max(context.census.peak, pool.stats().totalWorkers);
52759
+ this.onWorkAdvanced(payload, workerId, context);
52760
+ }
52602
52761
  }).catch((error) => {
52603
52762
  Logger_default.error(error);
52604
52763
  return null;
@@ -52977,24 +53136,20 @@ var import_chalk2 = __toESM(require("chalk"));
52977
53136
  var import_fs_extra = __toESM(require("fs-extra"));
52978
53137
  var import_ora = __toESM(require("ora"));
52979
53138
  init_src4();
53139
+ init_src5();
52980
53140
  init_src2();
53141
+ var REQUIRED_DIRECTORIES = ["./remora", "./remora/consumers", "./remora/producers", "./remora/sources"];
52981
53142
  var compile = async () => {
52982
53143
  let errors = [];
52983
53144
  try {
52984
53145
  const spinner = (0, import_ora.default)(import_chalk2.default.blue("Validating project structure...")).start();
52985
- Environment_default.load("");
52986
- if (!import_fs_extra.default.existsSync("./remora"))
52987
- errors.push(import_chalk2.default.red("Missing directory: ") + import_chalk2.default.yellow("./remora"));
52988
- if (!import_fs_extra.default.existsSync("./remora/consumers"))
52989
- errors.push(import_chalk2.default.red("Missing directory: ") + import_chalk2.default.yellow("./remora/consumers"));
52990
- if (!import_fs_extra.default.existsSync("./remora/producers"))
52991
- errors.push(import_chalk2.default.red("Missing directory: ") + import_chalk2.default.yellow("./remora/producers"));
52992
- if (!import_fs_extra.default.existsSync("./remora/producers"))
52993
- errors.push(import_chalk2.default.red("Missing directory: ") + import_chalk2.default.yellow("./remora/producers"));
52994
- if (!import_fs_extra.default.existsSync("./remora/sources"))
52995
- errors.push(import_chalk2.default.red("Missing directory: ") + import_chalk2.default.yellow("./remora/sources"));
52996
- const envErrors = Environment_default.validate();
52997
- errors = [...errors, ...envErrors];
53146
+ REQUIRED_DIRECTORIES.filter((dir) => !import_fs_extra.default.existsSync(dir)).forEach((dir) => errors.push(import_chalk2.default.red("Missing directory: ") + import_chalk2.default.yellow(dir)));
53147
+ try {
53148
+ Environment_default.load("");
53149
+ errors = [...errors, ...Environment_default.validate()];
53150
+ } catch (err2) {
53151
+ errors.push(Helper_default.asError(err2).message);
53152
+ }
52998
53153
  if (errors.length === 0) {
52999
53154
  spinner.succeed(import_chalk2.default.green("Project structure validated successfully"));
53000
53155
  console.log(import_chalk2.default.blueBright.bold("\u2705 Compilation complete!"));
@@ -53006,7 +53161,7 @@ var compile = async () => {
53006
53161
  process.exit(1);
53007
53162
  }
53008
53163
  } catch (err2) {
53009
- console.error(import_chalk2.default.red.bold("\n\u274C Unexpected error during validation:"), err2 instanceof Error ? err2.message : String(err2));
53164
+ console.error(import_chalk2.default.red.bold("\n\u274C Unexpected error during validation:"), Helper_default.asError(err2).message);
53010
53165
  Logger_default.error(err2);
53011
53166
  process.exit(1);
53012
53167
  }
@@ -53328,13 +53483,13 @@ var init = async () => {
53328
53483
  // src/actions/run.ts
53329
53484
  var import_chalk7 = __toESM(require("chalk"));
53330
53485
  init_src4();
53331
- init_src7();
53486
+ init_src5();
53332
53487
 
53333
53488
  // ../../packages/auth/src/AdminManager.ts
53334
53489
  init_src();
53335
53490
  init_src9();
53336
53491
  init_src9();
53337
- init_src7();
53492
+ init_src5();
53338
53493
  var import_bcryptjs2 = __toESM(require("bcryptjs"), 1);
53339
53494
 
53340
53495
  // ../../packages/auth/src/JWTManager.ts
@@ -53416,8 +53571,8 @@ var AdminManager = new AdminManagerClass();
53416
53571
  // ../../packages/auth/src/ApiKeysManager.ts
53417
53572
  init_src();
53418
53573
  init_src9();
53419
- init_src7();
53420
- init_src7();
53574
+ init_src5();
53575
+ init_src5();
53421
53576
  var ApiKeysManagerClass = class {
53422
53577
  constructor() {
53423
53578
  this.COLLECTION = Settings_default.db.collections.apiKeys;
@@ -53648,7 +53803,7 @@ init_src();
53648
53803
  init_OutputExecutor();
53649
53804
  init_src4();
53650
53805
  init_src10();
53651
- init_src5();
53806
+ init_src6();
53652
53807
  init_ExecutorPerformance();
53653
53808
  init_src2();
53654
53809
 
@@ -53807,7 +53962,7 @@ var import_chalk9 = __toESM(require("chalk"));
53807
53962
  init_src4();
53808
53963
  init_src3();
53809
53964
  init_src10();
53810
- init_src7();
53965
+ init_src5();
53811
53966
  init_src2();
53812
53967
  var FORMATS = ["mermaid", "dot", "json"];
53813
53968
  var graph = async (options) => {
@@ -53859,7 +54014,7 @@ var import_node_path16 = __toESM(require("path"));
53859
54014
  init_src4();
53860
54015
  init_src3();
53861
54016
  init_src10();
53862
- init_src7();
54017
+ init_src5();
53863
54018
  init_src2();
53864
54019
  var WATCH_INTERVAL_MS = 1e3;
53865
54020
  var SAMPLEABLE_KINDS = ["producer", "consumer"];
@@ -54187,7 +54342,7 @@ var create_consumer = async (name, producerName) => {
54187
54342
 
54188
54343
  // src/index.ts
54189
54344
  init_src3();
54190
- init_src7();
54345
+ init_src5();
54191
54346
 
54192
54347
  // src/actions/automap.ts
54193
54348
  var import_chalk13 = __toESM(require("chalk"));
@@ -54251,7 +54406,7 @@ var automap = async (producerName, schemaNames) => {
54251
54406
  var import_chalk14 = __toESM(require("chalk"));
54252
54407
  var import_ora6 = __toESM(require("ora"));
54253
54408
  init_src10();
54254
- init_src7();
54409
+ init_src5();
54255
54410
  init_src2();
54256
54411
  var sample = async (resourceName, sampleSize = 10) => {
54257
54412
  try {
@@ -54344,7 +54499,7 @@ var formatValue = (value) => {
54344
54499
  // src/actions/synth.ts
54345
54500
  var import_chalk15 = __toESM(require("chalk"));
54346
54501
  init_src4();
54347
- init_src7();
54502
+ init_src5();
54348
54503
  init_src10();
54349
54504
  init_src2();
54350
54505
  var synth = async (consumerName, args) => {