electric-ax 0.1.5 → 0.1.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.
@@ -1,4 +1,4 @@
1
- import { ElectricCliEnv } from "./index-CQaCUw1k.cjs";
1
+ import { ElectricCliEnv } from "./index-Bx8g95OI.cjs";
2
2
 
3
3
  //#region src/completions.d.ts
4
4
  declare function fetchEntityTypeNames(env: ElectricCliEnv): Promise<Array<string>>;
@@ -1,4 +1,4 @@
1
- import { ElectricCliEnv } from "./index-CrW6PmwB.js";
1
+ import { ElectricCliEnv } from "./index-Co_ocoIu.js";
2
2
 
3
3
  //#region src/completions.d.ts
4
4
  declare function fetchEntityTypeNames(env: ElectricCliEnv): Promise<Array<string>>;
@@ -1,2 +1,2 @@
1
- import { EntityStreamDB, createEntityStreamDB$1 as createEntityStreamDB } from "./entity-stream-db-BzuIvhSy.js";
1
+ import { EntityStreamDB, createEntityStreamDB$1 as createEntityStreamDB } from "./entity-stream-db-BRwzIuHl.js";
2
2
  export { EntityStreamDB, createEntityStreamDB };
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ const require_chunk = require('./chunk-BCwAaXi7.cjs');
3
+ const node_fs = require_chunk.__toESM(require("node:fs"));
4
+ const node_path = require_chunk.__toESM(require("node:path"));
5
+
6
+ //#region src/env.ts
7
+ function parseDotEnvValue(raw) {
8
+ const trimmed = raw.trim();
9
+ if (trimmed.startsWith(`"`) && trimmed.endsWith(`"`) || trimmed.startsWith(`'`) && trimmed.endsWith(`'`)) return trimmed.slice(1, -1);
10
+ const hashIndex = trimmed.indexOf(`#`);
11
+ return hashIndex === -1 ? trimmed : trimmed.slice(0, hashIndex).trim();
12
+ }
13
+ function readDotEnvFile(cwd = process.cwd()) {
14
+ const envPath = (0, node_path.resolve)(cwd, `.env`);
15
+ try {
16
+ const content = (0, node_fs.readFileSync)(envPath, `utf8`);
17
+ const values = {};
18
+ for (const line of content.split(/\r?\n/)) {
19
+ const trimmed = line.trim();
20
+ if (!trimmed || trimmed.startsWith(`#`)) continue;
21
+ const equalsIndex = trimmed.indexOf(`=`);
22
+ if (equalsIndex <= 0) continue;
23
+ const key = trimmed.slice(0, equalsIndex).trim();
24
+ const value = parseDotEnvValue(trimmed.slice(equalsIndex + 1));
25
+ values[key] = value;
26
+ }
27
+ return values;
28
+ } catch (error) {
29
+ if (error.code === `ENOENT`) return {};
30
+ throw error;
31
+ }
32
+ }
33
+ function resolveAnthropicApiKey(options, env = process.env, fileEnv = readDotEnvFile()) {
34
+ const candidate = options.anthropicApiKey?.trim() || env.ANTHROPIC_API_KEY?.trim() || fileEnv.ANTHROPIC_API_KEY?.trim();
35
+ if (!candidate) throw new Error(`ANTHROPIC_API_KEY is required. Pass --anthropic-api-key, export it in your shell, or set it in .env.`);
36
+ return candidate;
37
+ }
38
+
39
+ //#endregion
40
+ Object.defineProperty(exports, 'readDotEnvFile', {
41
+ enumerable: true,
42
+ get: function () {
43
+ return readDotEnvFile;
44
+ }
45
+ });
46
+ Object.defineProperty(exports, 'resolveAnthropicApiKey', {
47
+ enumerable: true,
48
+ get: function () {
49
+ return resolveAnthropicApiKey;
50
+ }
51
+ });
@@ -0,0 +1,38 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+
4
+ //#region src/env.ts
5
+ function parseDotEnvValue(raw) {
6
+ const trimmed = raw.trim();
7
+ if (trimmed.startsWith(`"`) && trimmed.endsWith(`"`) || trimmed.startsWith(`'`) && trimmed.endsWith(`'`)) return trimmed.slice(1, -1);
8
+ const hashIndex = trimmed.indexOf(`#`);
9
+ return hashIndex === -1 ? trimmed : trimmed.slice(0, hashIndex).trim();
10
+ }
11
+ function readDotEnvFile(cwd = process.cwd()) {
12
+ const envPath = resolve(cwd, `.env`);
13
+ try {
14
+ const content = readFileSync(envPath, `utf8`);
15
+ const values = {};
16
+ for (const line of content.split(/\r?\n/)) {
17
+ const trimmed = line.trim();
18
+ if (!trimmed || trimmed.startsWith(`#`)) continue;
19
+ const equalsIndex = trimmed.indexOf(`=`);
20
+ if (equalsIndex <= 0) continue;
21
+ const key = trimmed.slice(0, equalsIndex).trim();
22
+ const value = parseDotEnvValue(trimmed.slice(equalsIndex + 1));
23
+ values[key] = value;
24
+ }
25
+ return values;
26
+ } catch (error) {
27
+ if (error.code === `ENOENT`) return {};
28
+ throw error;
29
+ }
30
+ }
31
+ function resolveAnthropicApiKey(options, env = process.env, fileEnv = readDotEnvFile()) {
32
+ const candidate = options.anthropicApiKey?.trim() || env.ANTHROPIC_API_KEY?.trim() || fileEnv.ANTHROPIC_API_KEY?.trim();
33
+ if (!candidate) throw new Error(`ANTHROPIC_API_KEY is required. Pass --anthropic-api-key, export it in your shell, or set it in .env.`);
34
+ return candidate;
35
+ }
36
+
37
+ //#endregion
38
+ export { readDotEnvFile as readDotEnvFile$1, resolveAnthropicApiKey as resolveAnthropicApiKey$1 };
@@ -1,5 +1,13 @@
1
1
  import { Command } from "commander";
2
2
 
3
+ //#region src/env.d.ts
4
+ interface AnthropicApiKeyOptions {
5
+ anthropicApiKey?: string;
6
+ }
7
+ declare function readDotEnvFile(cwd?: string): Record<string, string>;
8
+ declare function resolveAnthropicApiKey(options: AnthropicApiKeyOptions, env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): string;
9
+
10
+ //#endregion
3
11
  //#region src/start.d.ts
4
12
  interface StartedDevEnvironment {
5
13
  port: number;
@@ -21,8 +29,6 @@ interface WaitForServerOptions {
21
29
  timeoutMs?: number;
22
30
  intervalMs?: number;
23
31
  }
24
- declare function readDotEnvFile(cwd?: string): Record<string, string>;
25
- declare function resolveAnthropicApiKey(options: StartBuiltinCommandOptions, env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): string;
26
32
  declare function resolveBuiltinAgentsPort(env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): number;
27
33
  declare function resolveElectricAgentsPort(env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): number;
28
34
  declare function getStartedEnvironmentMessage(started: StartedDevEnvironment): string;
@@ -1,5 +1,13 @@
1
1
  import { Command } from "commander";
2
2
 
3
+ //#region src/env.d.ts
4
+ interface AnthropicApiKeyOptions {
5
+ anthropicApiKey?: string;
6
+ }
7
+ declare function readDotEnvFile(cwd?: string): Record<string, string>;
8
+ declare function resolveAnthropicApiKey(options: AnthropicApiKeyOptions, env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): string;
9
+
10
+ //#endregion
3
11
  //#region src/start.d.ts
4
12
  interface StartedDevEnvironment {
5
13
  port: number;
@@ -21,8 +29,6 @@ interface WaitForServerOptions {
21
29
  timeoutMs?: number;
22
30
  intervalMs?: number;
23
31
  }
24
- declare function readDotEnvFile(cwd?: string): Record<string, string>;
25
- declare function resolveAnthropicApiKey(options: StartBuiltinCommandOptions, env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): string;
26
32
  declare function resolveBuiltinAgentsPort(env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): number;
27
33
  declare function resolveElectricAgentsPort(env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): number;
28
34
  declare function getStartedEnvironmentMessage(started: StartedDevEnvironment): string;
package/dist/index.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
  "use strict";
3
3
  const require_chunk = require('./chunk-BCwAaXi7.cjs');
4
4
  const require_completions = require('./completions-CO5UBiNh.cjs');
5
+ const require_env = require('./env-BXUgom_C.cjs');
5
6
  const node_fs = require_chunk.__toESM(require("node:fs"));
6
7
  const node_os = require_chunk.__toESM(require("node:os"));
7
8
  const node_path = require_chunk.__toESM(require("node:path"));
@@ -266,6 +267,7 @@ function createElectricCliHandlers(env, commandPrefix = commandExample(`electric
266
267
  return stopped;
267
268
  },
268
269
  quickstart: async (options) => {
270
+ require_env.resolveAnthropicApiKey(options);
269
271
  const { startBuiltinAgentsServer, startElectricAgentsDevEnvironment } = await loadStartModule();
270
272
  const started = await startElectricAgentsDevEnvironment();
271
273
  printStartedEnvironment(started);
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, getElectricCliEnv, resolveCommandPrefix, run } from "./index-CQaCUw1k.cjs";
2
+ import { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, getElectricCliEnv, resolveCommandPrefix, run } from "./index-Bx8g95OI.cjs";
3
3
  export { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, getElectricCliEnv, resolveCommandPrefix, run };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, getElectricCliEnv, resolveCommandPrefix, run } from "./index-CrW6PmwB.js";
2
+ import { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, getElectricCliEnv, resolveCommandPrefix, run } from "./index-Co_ocoIu.js";
3
3
  export { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, getElectricCliEnv, resolveCommandPrefix, run };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { installCompletions, setupCompletions } from "./completions-BHILvHgZ.js";
3
+ import { resolveAnthropicApiKey$1 as resolveAnthropicApiKey } from "./env-LZtIfFz1.js";
3
4
  import { realpathSync } from "node:fs";
4
5
  import { hostname, userInfo } from "node:os";
5
6
  import { basename, resolve } from "node:path";
@@ -264,6 +265,7 @@ function createElectricCliHandlers(env, commandPrefix = commandExample(`electric
264
265
  return stopped;
265
266
  },
266
267
  quickstart: async (options) => {
268
+ resolveAnthropicApiKey(options);
267
269
  const { startBuiltinAgentsServer, startElectricAgentsDevEnvironment } = await loadStartModule();
268
270
  const started = await startElectricAgentsDevEnvironment();
269
271
  printStartedEnvironment(started);
@@ -1,4 +1,4 @@
1
- import { EntityStreamDB } from "./entity-stream-db-BzuIvhSy.js";
1
+ import { EntityStreamDB } from "./entity-stream-db-BRwzIuHl.js";
2
2
  import { EntityTimelineContentItem, MessageReceived } from "@electric-ax/agents-runtime";
3
3
  import React from "react";
4
4
 
package/dist/start.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  const require_chunk = require('./chunk-BCwAaXi7.cjs');
3
- const node_fs = require_chunk.__toESM(require("node:fs"));
4
- const node_path = require_chunk.__toESM(require("node:path"));
3
+ const require_env = require('./env-BXUgom_C.cjs');
5
4
  const node_url = require_chunk.__toESM(require("node:url"));
6
5
  const node_child_process = require_chunk.__toESM(require("node:child_process"));
7
6
  const __electric_ax_agents = require_chunk.__toESM(require("@electric-ax/agents"));
@@ -11,44 +10,13 @@ const DEFAULT_ELECTRIC_AGENTS_PORT = 4437;
11
10
  const DEFAULT_BUILTIN_AGENTS_PORT = 4448;
12
11
  const DEFAULT_COMPOSE_PROJECT_NAME = `electric-agents`;
13
12
  const DOCKER_COMPOSE_FILE = (0, node_url.fileURLToPath)(new URL(`../docker-compose.full.yml`, require("url").pathToFileURL(__filename).href));
14
- function parseDotEnvValue(raw) {
15
- const trimmed = raw.trim();
16
- if (trimmed.startsWith(`"`) && trimmed.endsWith(`"`) || trimmed.startsWith(`'`) && trimmed.endsWith(`'`)) return trimmed.slice(1, -1);
17
- const hashIndex = trimmed.indexOf(`#`);
18
- return hashIndex === -1 ? trimmed : trimmed.slice(0, hashIndex).trim();
19
- }
20
- function readDotEnvFile(cwd = process.cwd()) {
21
- const envPath = (0, node_path.resolve)(cwd, `.env`);
22
- try {
23
- const content = (0, node_fs.readFileSync)(envPath, `utf8`);
24
- const values = {};
25
- for (const line of content.split(/\r?\n/)) {
26
- const trimmed = line.trim();
27
- if (!trimmed || trimmed.startsWith(`#`)) continue;
28
- const equalsIndex = trimmed.indexOf(`=`);
29
- if (equalsIndex <= 0) continue;
30
- const key = trimmed.slice(0, equalsIndex).trim();
31
- const value = parseDotEnvValue(trimmed.slice(equalsIndex + 1));
32
- values[key] = value;
33
- }
34
- return values;
35
- } catch (error) {
36
- if (error.code === `ENOENT`) return {};
37
- throw error;
38
- }
39
- }
40
- function resolveAnthropicApiKey(options, env = process.env, fileEnv = readDotEnvFile()) {
41
- const candidate = options.anthropicApiKey?.trim() || env.ANTHROPIC_API_KEY?.trim() || fileEnv.ANTHROPIC_API_KEY?.trim();
42
- if (!candidate) throw new Error(`ANTHROPIC_API_KEY is required. Pass --anthropic-api-key, export it in your shell, or set it in .env.`);
43
- return candidate;
44
- }
45
- function resolveBuiltinAgentsPort(env = process.env, fileEnv = readDotEnvFile()) {
13
+ function resolveBuiltinAgentsPort(env = process.env, fileEnv = require_env.readDotEnvFile()) {
46
14
  const raw = env.ELECTRIC_AGENTS_BUILTIN_PORT?.trim() || fileEnv.ELECTRIC_AGENTS_BUILTIN_PORT?.trim();
47
15
  const parsed = raw ? Number(raw) : DEFAULT_BUILTIN_AGENTS_PORT;
48
16
  if (!Number.isInteger(parsed) || parsed <= 0) throw new Error(`ELECTRIC_AGENTS_BUILTIN_PORT must be a positive integer`);
49
17
  return parsed;
50
18
  }
51
- function resolveElectricAgentsPort(env = process.env, fileEnv = readDotEnvFile()) {
19
+ function resolveElectricAgentsPort(env = process.env, fileEnv = require_env.readDotEnvFile()) {
52
20
  const raw = env.ELECTRIC_AGENTS_PORT?.trim() || fileEnv.ELECTRIC_AGENTS_PORT?.trim();
53
21
  const parsed = raw ? Number(raw) : DEFAULT_ELECTRIC_AGENTS_PORT;
54
22
  if (!Number.isInteger(parsed) || parsed <= 0) throw new Error(`ELECTRIC_AGENTS_PORT must be a positive integer`);
@@ -125,7 +93,7 @@ async function waitForElectricAgentsServer(baseUrl, options = {}) {
125
93
  throw new Error(`Timed out waiting for Electric Agents server at ${healthUrl}${lastError ? `: ${lastError}` : ``}`);
126
94
  }
127
95
  async function startElectricAgentsDevEnvironment(_options = {}, env = process.env, cwd = process.cwd()) {
128
- const fileEnv = readDotEnvFile(cwd);
96
+ const fileEnv = require_env.readDotEnvFile(cwd);
129
97
  const port = resolveElectricAgentsPort(env, fileEnv);
130
98
  const composeProjectName = resolveComposeProjectName(cwd, env);
131
99
  await runDockerCompose([
@@ -193,8 +161,8 @@ function waitForShutdown(stop, signalSource = process) {
193
161
  async function startBuiltinAgentsServer(options, params = {}) {
194
162
  const env = params.env ?? process.env;
195
163
  const cwd = params.cwd ?? process.cwd();
196
- const fileEnv = readDotEnvFile(cwd);
197
- const anthropicApiKey = resolveAnthropicApiKey(options, env, fileEnv);
164
+ const fileEnv = require_env.readDotEnvFile(cwd);
165
+ const anthropicApiKey = require_env.resolveAnthropicApiKey(options, env, fileEnv);
198
166
  const port = resolveBuiltinAgentsPort(env, fileEnv);
199
167
  const agentServerUrl = params.agentServerUrl ?? env.ELECTRIC_AGENTS_URL?.trim() ?? `http://localhost:${resolveElectricAgentsPort(env, fileEnv)}`;
200
168
  process.env.ANTHROPIC_API_KEY = anthropicApiKey;
@@ -220,8 +188,8 @@ async function startBuiltinAgentsServer(options, params = {}) {
220
188
  exports.getStartedBuiltinAgentsMessage = getStartedBuiltinAgentsMessage
221
189
  exports.getStartedEnvironmentMessage = getStartedEnvironmentMessage
222
190
  exports.getStoppedEnvironmentMessage = getStoppedEnvironmentMessage
223
- exports.readDotEnvFile = readDotEnvFile
224
- exports.resolveAnthropicApiKey = resolveAnthropicApiKey
191
+ exports.readDotEnvFile = require_env.readDotEnvFile
192
+ exports.resolveAnthropicApiKey = require_env.resolveAnthropicApiKey
225
193
  exports.resolveBuiltinAgentsPort = resolveBuiltinAgentsPort
226
194
  exports.resolveComposeProjectName = resolveComposeProjectName
227
195
  exports.resolveElectricAgentsPort = resolveElectricAgentsPort
package/dist/start.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StoppedDevEnvironment, getStartedBuiltinAgentsMessage, getStartedEnvironmentMessage, getStoppedEnvironmentMessage, readDotEnvFile, resolveAnthropicApiKey, resolveBuiltinAgentsPort, resolveComposeProjectName, resolveElectricAgentsPort, startBuiltinAgentsServer, startElectricAgentsDevEnvironment, stopElectricAgentsDevEnvironment, waitForElectricAgentsServer } from "./index-CQaCUw1k.cjs";
1
+ import { StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StoppedDevEnvironment, getStartedBuiltinAgentsMessage, getStartedEnvironmentMessage, getStoppedEnvironmentMessage, readDotEnvFile, resolveAnthropicApiKey, resolveBuiltinAgentsPort, resolveComposeProjectName, resolveElectricAgentsPort, startBuiltinAgentsServer, startElectricAgentsDevEnvironment, stopElectricAgentsDevEnvironment, waitForElectricAgentsServer } from "./index-Bx8g95OI.cjs";
2
2
  export { StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StoppedDevEnvironment, getStartedBuiltinAgentsMessage, getStartedEnvironmentMessage, getStoppedEnvironmentMessage, readDotEnvFile, resolveAnthropicApiKey, resolveBuiltinAgentsPort, resolveComposeProjectName, resolveElectricAgentsPort, startBuiltinAgentsServer, startElectricAgentsDevEnvironment, stopElectricAgentsDevEnvironment, waitForElectricAgentsServer };
package/dist/start.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StoppedDevEnvironment, getStartedBuiltinAgentsMessage, getStartedEnvironmentMessage, getStoppedEnvironmentMessage, readDotEnvFile, resolveAnthropicApiKey, resolveBuiltinAgentsPort, resolveComposeProjectName, resolveElectricAgentsPort, startBuiltinAgentsServer, startElectricAgentsDevEnvironment, stopElectricAgentsDevEnvironment, waitForElectricAgentsServer } from "./index-CrW6PmwB.js";
1
+ import { StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StoppedDevEnvironment, getStartedBuiltinAgentsMessage, getStartedEnvironmentMessage, getStoppedEnvironmentMessage, readDotEnvFile, resolveAnthropicApiKey, resolveBuiltinAgentsPort, resolveComposeProjectName, resolveElectricAgentsPort, startBuiltinAgentsServer, startElectricAgentsDevEnvironment, stopElectricAgentsDevEnvironment, waitForElectricAgentsServer } from "./index-Co_ocoIu.js";
2
2
  export { StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StoppedDevEnvironment, getStartedBuiltinAgentsMessage, getStartedEnvironmentMessage, getStoppedEnvironmentMessage, readDotEnvFile, resolveAnthropicApiKey, resolveBuiltinAgentsPort, resolveComposeProjectName, resolveElectricAgentsPort, startBuiltinAgentsServer, startElectricAgentsDevEnvironment, stopElectricAgentsDevEnvironment, waitForElectricAgentsServer };
package/dist/start.js CHANGED
@@ -1,5 +1,4 @@
1
- import { readFileSync } from "node:fs";
2
- import { resolve } from "node:path";
1
+ import { readDotEnvFile$1 as readDotEnvFile, resolveAnthropicApiKey$1 as resolveAnthropicApiKey } from "./env-LZtIfFz1.js";
3
2
  import { fileURLToPath } from "node:url";
4
3
  import { spawn } from "node:child_process";
5
4
  import { BuiltinAgentsServer } from "@electric-ax/agents";
@@ -9,37 +8,6 @@ const DEFAULT_ELECTRIC_AGENTS_PORT = 4437;
9
8
  const DEFAULT_BUILTIN_AGENTS_PORT = 4448;
10
9
  const DEFAULT_COMPOSE_PROJECT_NAME = `electric-agents`;
11
10
  const DOCKER_COMPOSE_FILE = fileURLToPath(new URL(`../docker-compose.full.yml`, import.meta.url));
12
- function parseDotEnvValue(raw) {
13
- const trimmed = raw.trim();
14
- if (trimmed.startsWith(`"`) && trimmed.endsWith(`"`) || trimmed.startsWith(`'`) && trimmed.endsWith(`'`)) return trimmed.slice(1, -1);
15
- const hashIndex = trimmed.indexOf(`#`);
16
- return hashIndex === -1 ? trimmed : trimmed.slice(0, hashIndex).trim();
17
- }
18
- function readDotEnvFile(cwd = process.cwd()) {
19
- const envPath = resolve(cwd, `.env`);
20
- try {
21
- const content = readFileSync(envPath, `utf8`);
22
- const values = {};
23
- for (const line of content.split(/\r?\n/)) {
24
- const trimmed = line.trim();
25
- if (!trimmed || trimmed.startsWith(`#`)) continue;
26
- const equalsIndex = trimmed.indexOf(`=`);
27
- if (equalsIndex <= 0) continue;
28
- const key = trimmed.slice(0, equalsIndex).trim();
29
- const value = parseDotEnvValue(trimmed.slice(equalsIndex + 1));
30
- values[key] = value;
31
- }
32
- return values;
33
- } catch (error) {
34
- if (error.code === `ENOENT`) return {};
35
- throw error;
36
- }
37
- }
38
- function resolveAnthropicApiKey(options, env = process.env, fileEnv = readDotEnvFile()) {
39
- const candidate = options.anthropicApiKey?.trim() || env.ANTHROPIC_API_KEY?.trim() || fileEnv.ANTHROPIC_API_KEY?.trim();
40
- if (!candidate) throw new Error(`ANTHROPIC_API_KEY is required. Pass --anthropic-api-key, export it in your shell, or set it in .env.`);
41
- return candidate;
42
- }
43
11
  function resolveBuiltinAgentsPort(env = process.env, fileEnv = readDotEnvFile()) {
44
12
  const raw = env.ELECTRIC_AGENTS_BUILTIN_PORT?.trim() || fileEnv.ELECTRIC_AGENTS_BUILTIN_PORT?.trim();
45
13
  const parsed = raw ? Number(raw) : DEFAULT_BUILTIN_AGENTS_PORT;
@@ -80,7 +48,7 @@ function resolveComposeProjectName(_cwd = process.cwd(), env = process.env) {
80
48
  return DEFAULT_COMPOSE_PROJECT_NAME;
81
49
  }
82
50
  async function runDockerCompose(args, env) {
83
- await new Promise((resolve$1, reject) => {
51
+ await new Promise((resolve, reject) => {
84
52
  const child = spawn(`docker`, args, {
85
53
  cwd: process.cwd(),
86
54
  env,
@@ -91,7 +59,7 @@ async function runDockerCompose(args, env) {
91
59
  });
92
60
  child.on(`exit`, (code) => {
93
61
  if (code === 0) {
94
- resolve$1();
62
+ resolve();
95
63
  return;
96
64
  }
97
65
  reject(new Error(`docker compose exited with code ${code ?? `unknown`}`));
@@ -99,8 +67,8 @@ async function runDockerCompose(args, env) {
99
67
  });
100
68
  }
101
69
  function delay(ms) {
102
- return new Promise((resolve$1) => {
103
- setTimeout(resolve$1, ms);
70
+ return new Promise((resolve) => {
71
+ setTimeout(resolve, ms);
104
72
  });
105
73
  }
106
74
  async function waitForElectricAgentsServer(baseUrl, options = {}) {
@@ -164,7 +132,7 @@ async function stopElectricAgentsDevEnvironment(options, env = process.env, cwd
164
132
  };
165
133
  }
166
134
  function waitForShutdown(stop, signalSource = process) {
167
- return new Promise((resolve$1, reject) => {
135
+ return new Promise((resolve, reject) => {
168
136
  let stopping = false;
169
137
  const cleanup = () => {
170
138
  signalSource.off(`SIGINT`, onSigint);
@@ -174,7 +142,7 @@ function waitForShutdown(stop, signalSource = process) {
174
142
  if (stopping) return;
175
143
  stopping = true;
176
144
  cleanup();
177
- stop().then(resolve$1).catch((error) => {
145
+ stop().then(resolve).catch((error) => {
178
146
  reject(new Error(`Failed to stop builtin agents server after ${signal}: ${error instanceof Error ? error.message : String(error)}`));
179
147
  });
180
148
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electric-ax",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "CLI for Electric Agents",
5
5
  "author": "ElectricSQL team and contributors",
6
6
  "license": "Apache-2.0",
@@ -46,8 +46,8 @@
46
46
  "ink": "^6.8.0",
47
47
  "omelette": "^0.4.17",
48
48
  "react": "^19.2.0",
49
- "@electric-ax/agents": "0.1.2",
50
- "@electric-ax/agents-runtime": "0.0.2"
49
+ "@electric-ax/agents": "0.1.3",
50
+ "@electric-ax/agents-runtime": "0.0.3"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@vitest/coverage-v8": "^4.1.0",