@xera-ai/core 0.9.6 → 0.9.7

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/bin/internal.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  #!/usr/bin/env bun
2
+ import { config } from 'dotenv';
2
3
  import { run } from '../src/bin-internal/index';
3
4
 
5
+ // Load .env.local (secrets, gitignored) then .env (defaults) so every
6
+ // xera-internal subcommand has access to credentials without requiring
7
+ // the caller to pre-load env.
8
+ config({ path: '.env.local' });
9
+ config();
10
+
4
11
  const code = await run(process.argv.slice(2));
5
12
  process.exit(code);
@@ -1,6 +1,35 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
+ var __create = Object.create;
4
+ var __getProtoOf = Object.getPrototypeOf;
3
5
  var __defProp = Object.defineProperty;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
13
+ var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
21
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
22
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
+ for (let key of __getOwnPropNames(mod))
24
+ if (!__hasOwnProp.call(to, key))
25
+ __defProp(to, key, {
26
+ get: __accessProp.bind(mod, key),
27
+ enumerable: true
28
+ });
29
+ if (canCache)
30
+ cache.set(mod, to);
31
+ return to;
32
+ };
4
33
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
5
34
  var __returnValue = (v) => v;
6
35
  function __exportSetter(name, newValue) {
@@ -18,6 +47,362 @@ var __export = (target, all) => {
18
47
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
19
48
  var __require = import.meta.require;
20
49
 
50
+ // ../../node_modules/dotenv/package.json
51
+ var require_package = __commonJS((exports, module) => {
52
+ module.exports = {
53
+ name: "dotenv",
54
+ version: "16.6.1",
55
+ description: "Loads environment variables from .env file",
56
+ main: "lib/main.js",
57
+ types: "lib/main.d.ts",
58
+ exports: {
59
+ ".": {
60
+ types: "./lib/main.d.ts",
61
+ require: "./lib/main.js",
62
+ default: "./lib/main.js"
63
+ },
64
+ "./config": "./config.js",
65
+ "./config.js": "./config.js",
66
+ "./lib/env-options": "./lib/env-options.js",
67
+ "./lib/env-options.js": "./lib/env-options.js",
68
+ "./lib/cli-options": "./lib/cli-options.js",
69
+ "./lib/cli-options.js": "./lib/cli-options.js",
70
+ "./package.json": "./package.json"
71
+ },
72
+ scripts: {
73
+ "dts-check": "tsc --project tests/types/tsconfig.json",
74
+ lint: "standard",
75
+ pretest: "npm run lint && npm run dts-check",
76
+ test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
77
+ "test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
78
+ prerelease: "npm test",
79
+ release: "standard-version"
80
+ },
81
+ repository: {
82
+ type: "git",
83
+ url: "git://github.com/motdotla/dotenv.git"
84
+ },
85
+ homepage: "https://github.com/motdotla/dotenv#readme",
86
+ funding: "https://dotenvx.com",
87
+ keywords: [
88
+ "dotenv",
89
+ "env",
90
+ ".env",
91
+ "environment",
92
+ "variables",
93
+ "config",
94
+ "settings"
95
+ ],
96
+ readmeFilename: "README.md",
97
+ license: "BSD-2-Clause",
98
+ devDependencies: {
99
+ "@types/node": "^18.11.3",
100
+ decache: "^4.6.2",
101
+ sinon: "^14.0.1",
102
+ standard: "^17.0.0",
103
+ "standard-version": "^9.5.0",
104
+ tap: "^19.2.0",
105
+ typescript: "^4.8.4"
106
+ },
107
+ engines: {
108
+ node: ">=12"
109
+ },
110
+ browser: {
111
+ fs: false
112
+ }
113
+ };
114
+ });
115
+
116
+ // ../../node_modules/dotenv/lib/main.js
117
+ var require_main = __commonJS((exports, module) => {
118
+ var fs = __require("fs");
119
+ var path = __require("path");
120
+ var os = __require("os");
121
+ var crypto2 = __require("crypto");
122
+ var packageJson = require_package();
123
+ var version = packageJson.version;
124
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
125
+ function parse(src) {
126
+ const obj = {};
127
+ let lines = src.toString();
128
+ lines = lines.replace(/\r\n?/mg, `
129
+ `);
130
+ let match;
131
+ while ((match = LINE.exec(lines)) != null) {
132
+ const key = match[1];
133
+ let value = match[2] || "";
134
+ value = value.trim();
135
+ const maybeQuote = value[0];
136
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
137
+ if (maybeQuote === '"') {
138
+ value = value.replace(/\\n/g, `
139
+ `);
140
+ value = value.replace(/\\r/g, "\r");
141
+ }
142
+ obj[key] = value;
143
+ }
144
+ return obj;
145
+ }
146
+ function _parseVault(options) {
147
+ options = options || {};
148
+ const vaultPath = _vaultPath(options);
149
+ options.path = vaultPath;
150
+ const result = DotenvModule.configDotenv(options);
151
+ if (!result.parsed) {
152
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
153
+ err.code = "MISSING_DATA";
154
+ throw err;
155
+ }
156
+ const keys = _dotenvKey(options).split(",");
157
+ const length = keys.length;
158
+ let decrypted;
159
+ for (let i = 0;i < length; i++) {
160
+ try {
161
+ const key = keys[i].trim();
162
+ const attrs = _instructions(result, key);
163
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
164
+ break;
165
+ } catch (error) {
166
+ if (i + 1 >= length) {
167
+ throw error;
168
+ }
169
+ }
170
+ }
171
+ return DotenvModule.parse(decrypted);
172
+ }
173
+ function _warn(message) {
174
+ console.log(`[dotenv@${version}][WARN] ${message}`);
175
+ }
176
+ function _debug(message) {
177
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
178
+ }
179
+ function _log(message) {
180
+ console.log(`[dotenv@${version}] ${message}`);
181
+ }
182
+ function _dotenvKey(options) {
183
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
184
+ return options.DOTENV_KEY;
185
+ }
186
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
187
+ return process.env.DOTENV_KEY;
188
+ }
189
+ return "";
190
+ }
191
+ function _instructions(result, dotenvKey) {
192
+ let uri;
193
+ try {
194
+ uri = new URL(dotenvKey);
195
+ } catch (error) {
196
+ if (error.code === "ERR_INVALID_URL") {
197
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
198
+ err.code = "INVALID_DOTENV_KEY";
199
+ throw err;
200
+ }
201
+ throw error;
202
+ }
203
+ const key = uri.password;
204
+ if (!key) {
205
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
206
+ err.code = "INVALID_DOTENV_KEY";
207
+ throw err;
208
+ }
209
+ const environment = uri.searchParams.get("environment");
210
+ if (!environment) {
211
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
212
+ err.code = "INVALID_DOTENV_KEY";
213
+ throw err;
214
+ }
215
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
216
+ const ciphertext = result.parsed[environmentKey];
217
+ if (!ciphertext) {
218
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
219
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
220
+ throw err;
221
+ }
222
+ return { ciphertext, key };
223
+ }
224
+ function _vaultPath(options) {
225
+ let possibleVaultPath = null;
226
+ if (options && options.path && options.path.length > 0) {
227
+ if (Array.isArray(options.path)) {
228
+ for (const filepath of options.path) {
229
+ if (fs.existsSync(filepath)) {
230
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
231
+ }
232
+ }
233
+ } else {
234
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
235
+ }
236
+ } else {
237
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
238
+ }
239
+ if (fs.existsSync(possibleVaultPath)) {
240
+ return possibleVaultPath;
241
+ }
242
+ return null;
243
+ }
244
+ function _resolveHome(envPath) {
245
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
246
+ }
247
+ function _configVault(options) {
248
+ const debug = Boolean(options && options.debug);
249
+ const quiet = options && "quiet" in options ? options.quiet : true;
250
+ if (debug || !quiet) {
251
+ _log("Loading env from encrypted .env.vault");
252
+ }
253
+ const parsed = DotenvModule._parseVault(options);
254
+ let processEnv = process.env;
255
+ if (options && options.processEnv != null) {
256
+ processEnv = options.processEnv;
257
+ }
258
+ DotenvModule.populate(processEnv, parsed, options);
259
+ return { parsed };
260
+ }
261
+ function configDotenv(options) {
262
+ const dotenvPath = path.resolve(process.cwd(), ".env");
263
+ let encoding = "utf8";
264
+ const debug = Boolean(options && options.debug);
265
+ const quiet = options && "quiet" in options ? options.quiet : true;
266
+ if (options && options.encoding) {
267
+ encoding = options.encoding;
268
+ } else {
269
+ if (debug) {
270
+ _debug("No encoding is specified. UTF-8 is used by default");
271
+ }
272
+ }
273
+ let optionPaths = [dotenvPath];
274
+ if (options && options.path) {
275
+ if (!Array.isArray(options.path)) {
276
+ optionPaths = [_resolveHome(options.path)];
277
+ } else {
278
+ optionPaths = [];
279
+ for (const filepath of options.path) {
280
+ optionPaths.push(_resolveHome(filepath));
281
+ }
282
+ }
283
+ }
284
+ let lastError;
285
+ const parsedAll = {};
286
+ for (const path2 of optionPaths) {
287
+ try {
288
+ const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
289
+ DotenvModule.populate(parsedAll, parsed, options);
290
+ } catch (e) {
291
+ if (debug) {
292
+ _debug(`Failed to load ${path2} ${e.message}`);
293
+ }
294
+ lastError = e;
295
+ }
296
+ }
297
+ let processEnv = process.env;
298
+ if (options && options.processEnv != null) {
299
+ processEnv = options.processEnv;
300
+ }
301
+ DotenvModule.populate(processEnv, parsedAll, options);
302
+ if (debug || !quiet) {
303
+ const keysCount = Object.keys(parsedAll).length;
304
+ const shortPaths = [];
305
+ for (const filePath of optionPaths) {
306
+ try {
307
+ const relative = path.relative(process.cwd(), filePath);
308
+ shortPaths.push(relative);
309
+ } catch (e) {
310
+ if (debug) {
311
+ _debug(`Failed to load ${filePath} ${e.message}`);
312
+ }
313
+ lastError = e;
314
+ }
315
+ }
316
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(",")}`);
317
+ }
318
+ if (lastError) {
319
+ return { parsed: parsedAll, error: lastError };
320
+ } else {
321
+ return { parsed: parsedAll };
322
+ }
323
+ }
324
+ function config(options) {
325
+ if (_dotenvKey(options).length === 0) {
326
+ return DotenvModule.configDotenv(options);
327
+ }
328
+ const vaultPath = _vaultPath(options);
329
+ if (!vaultPath) {
330
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
331
+ return DotenvModule.configDotenv(options);
332
+ }
333
+ return DotenvModule._configVault(options);
334
+ }
335
+ function decrypt(encrypted, keyStr) {
336
+ const key = Buffer.from(keyStr.slice(-64), "hex");
337
+ let ciphertext = Buffer.from(encrypted, "base64");
338
+ const nonce = ciphertext.subarray(0, 12);
339
+ const authTag = ciphertext.subarray(-16);
340
+ ciphertext = ciphertext.subarray(12, -16);
341
+ try {
342
+ const aesgcm = crypto2.createDecipheriv("aes-256-gcm", key, nonce);
343
+ aesgcm.setAuthTag(authTag);
344
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
345
+ } catch (error) {
346
+ const isRange = error instanceof RangeError;
347
+ const invalidKeyLength = error.message === "Invalid key length";
348
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
349
+ if (isRange || invalidKeyLength) {
350
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
351
+ err.code = "INVALID_DOTENV_KEY";
352
+ throw err;
353
+ } else if (decryptionFailed) {
354
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
355
+ err.code = "DECRYPTION_FAILED";
356
+ throw err;
357
+ } else {
358
+ throw error;
359
+ }
360
+ }
361
+ }
362
+ function populate(processEnv, parsed, options = {}) {
363
+ const debug = Boolean(options && options.debug);
364
+ const override = Boolean(options && options.override);
365
+ if (typeof parsed !== "object") {
366
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
367
+ err.code = "OBJECT_REQUIRED";
368
+ throw err;
369
+ }
370
+ for (const key of Object.keys(parsed)) {
371
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
372
+ if (override === true) {
373
+ processEnv[key] = parsed[key];
374
+ }
375
+ if (debug) {
376
+ if (override === true) {
377
+ _debug(`"${key}" is already defined and WAS overwritten`);
378
+ } else {
379
+ _debug(`"${key}" is already defined and was NOT overwritten`);
380
+ }
381
+ }
382
+ } else {
383
+ processEnv[key] = parsed[key];
384
+ }
385
+ }
386
+ }
387
+ var DotenvModule = {
388
+ configDotenv,
389
+ _configVault,
390
+ _parseVault,
391
+ config,
392
+ decrypt,
393
+ parse,
394
+ populate
395
+ };
396
+ exports.configDotenv = DotenvModule.configDotenv;
397
+ exports._configVault = DotenvModule._configVault;
398
+ exports._parseVault = DotenvModule._parseVault;
399
+ exports.config = DotenvModule.config;
400
+ exports.decrypt = DotenvModule.decrypt;
401
+ exports.parse = DotenvModule.parse;
402
+ exports.populate = DotenvModule.populate;
403
+ module.exports = DotenvModule;
404
+ });
405
+
21
406
  // src/graph/paths.ts
22
407
  import { join as join3 } from "path";
23
408
  function graphPaths(repoRoot) {
@@ -7962,6 +8347,9 @@ var init_graph_backfill = __esm(() => {
7962
8347
  init_graph_record_script();
7963
8348
  });
7964
8349
 
8350
+ // bin/internal.ts
8351
+ var import_dotenv = __toESM(require_main(), 1);
8352
+
7965
8353
  // src/bin-internal/auth-setup.ts
7966
8354
  import { existsSync as existsSync2 } from "fs";
7967
8355
  import { join as join2 } from "path";
@@ -11688,5 +12076,7 @@ Commands: ${Object.keys(COMMANDS).join(", ")}`);
11688
12076
  }
11689
12077
 
11690
12078
  // bin/internal.ts
12079
+ import_dotenv.config({ path: ".env.local" });
12080
+ import_dotenv.config();
11691
12081
  var code = await run(process.argv.slice(2));
11692
12082
  process.exit(code);
package/dist/src/index.js CHANGED
@@ -1,5 +1,34 @@
1
1
  // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
2
4
  var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
3
32
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
4
33
  var __returnValue = (v) => v;
5
34
  function __exportSetter(name, newValue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xera-ai/core",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -31,9 +31,10 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "zod": "4.4.3",
34
- "@xera-ai/web": "^0.9.6",
35
- "@xera-ai/http": "^0.9.6",
34
+ "@xera-ai/web": "^0.9.7",
35
+ "@xera-ai/http": "^0.9.7",
36
36
  "@playwright/test": "1.60.0",
37
+ "dotenv": "^16.0.0",
37
38
  "fflate": "0.8.3",
38
39
  "yaml": "2.9.0"
39
40
  }