@electric-ax/agents 0.4.10 → 0.4.11

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.
@@ -16,28 +16,47 @@ import { getModels } from "@mariozechner/pi-ai";
16
16
  import { bridgeMcpTool, buildPromptTools, buildResourceTools, createRegistry, keychainPersistence, loadConfig, mcp, watchConfig } from "@electric-ax/agents-mcp";
17
17
 
18
18
  //#region src/log.ts
19
- const LOG_DIR = process.env.ELECTRIC_AGENTS_LOG_DIR ?? path.resolve(process.cwd(), `logs`);
20
- fs.mkdirSync(LOG_DIR, { recursive: true });
21
- const LOG_FILE = path.join(LOG_DIR, `builtin-agents-${Date.now()}.jsonl`);
22
19
  const LOG_LEVEL = process.env.ELECTRIC_AGENTS_LOG_LEVEL ?? `info`;
23
20
  const IS_ELECTRON_MAIN = Boolean(process.versions.electron);
21
+ const USE_FILE_LOGS = process.env.ELECTRIC_AGENTS_LOG_FILE !== `false`;
24
22
  const USE_PRETTY_LOGS = LOG_LEVEL !== `silent` && !process.env.VITEST && !IS_ELECTRON_MAIN;
25
- const streams = [{ stream: pino.destination({
26
- dest: LOG_FILE,
27
- sync: IS_ELECTRON_MAIN
28
- }) }];
29
- if (USE_PRETTY_LOGS) streams.push({ stream: pino.transport({
30
- target: `pino-pretty`,
31
- options: {
32
- colorize: true,
33
- ignore: `pid,hostname,name`,
34
- translateTime: `SYS:HH:MM:ss`
23
+ let _logger;
24
+ function getLogger() {
25
+ if (_logger) return _logger;
26
+ const streams = [];
27
+ try {
28
+ if (USE_FILE_LOGS) {
29
+ const logDir = process.env.ELECTRIC_AGENTS_LOG_DIR ?? path.resolve(process.cwd(), `logs`);
30
+ fs.mkdirSync(logDir, { recursive: true });
31
+ const logFile = path.join(logDir, `builtin-agents-${Date.now()}.jsonl`);
32
+ streams.push({ stream: pino.destination({
33
+ dest: logFile,
34
+ sync: IS_ELECTRON_MAIN
35
+ }) });
36
+ }
37
+ } catch (err) {
38
+ process.stderr.write(`[agents] Failed to initialize file logging: ${err instanceof Error ? err.message : err}\n`);
35
39
  }
36
- }) });
37
- const logger = pino({
38
- base: void 0,
39
- level: LOG_LEVEL
40
- }, pino.multistream(streams));
40
+ try {
41
+ if (USE_PRETTY_LOGS) streams.push({ stream: pino.transport({
42
+ target: `pino-pretty`,
43
+ options: {
44
+ colorize: true,
45
+ ignore: `pid,hostname,name`,
46
+ translateTime: `SYS:HH:MM:ss`
47
+ }
48
+ }) });
49
+ } catch {}
50
+ _logger = streams.length > 0 ? pino({
51
+ base: void 0,
52
+ level: LOG_LEVEL
53
+ }, pino.multistream(streams)) : pino({
54
+ base: void 0,
55
+ enabled: false,
56
+ level: LOG_LEVEL
57
+ });
58
+ return _logger;
59
+ }
41
60
  function formatArgs(args) {
42
61
  const errors = [];
43
62
  const parts = [];
@@ -51,24 +70,24 @@ function formatArgs(args) {
51
70
  const serverLog = {
52
71
  debug(...args) {
53
72
  const { msg } = formatArgs(args);
54
- logger.debug(msg);
73
+ getLogger().debug(msg);
55
74
  },
56
75
  info(...args) {
57
76
  const { msg } = formatArgs(args);
58
- logger.info(msg);
77
+ getLogger().info(msg);
59
78
  },
60
79
  warn(...args) {
61
80
  const { err, msg } = formatArgs(args);
62
- if (err) logger.warn({ err }, msg);
63
- else logger.warn(msg);
81
+ if (err) getLogger().warn({ err }, msg);
82
+ else getLogger().warn(msg);
64
83
  },
65
84
  error(...args) {
66
85
  const { err, msg } = formatArgs(args);
67
- if (err) logger.error({ err }, msg);
68
- else logger.error(msg);
86
+ if (err) getLogger().error({ err }, msg);
87
+ else getLogger().error(msg);
69
88
  },
70
89
  event(obj, msg) {
71
- logger.info(obj, msg);
90
+ getLogger().info(obj, msg);
72
91
  }
73
92
  };
74
93
 
package/dist/index.cjs CHANGED
@@ -40,28 +40,47 @@ const __mariozechner_pi_ai = __toESM(require("@mariozechner/pi-ai"));
40
40
  const __electric_ax_agents_mcp = __toESM(require("@electric-ax/agents-mcp"));
41
41
 
42
42
  //#region src/log.ts
43
- const LOG_DIR = process.env.ELECTRIC_AGENTS_LOG_DIR ?? node_path.default.resolve(process.cwd(), `logs`);
44
- node_fs.default.mkdirSync(LOG_DIR, { recursive: true });
45
- const LOG_FILE = node_path.default.join(LOG_DIR, `builtin-agents-${Date.now()}.jsonl`);
46
43
  const LOG_LEVEL = process.env.ELECTRIC_AGENTS_LOG_LEVEL ?? `info`;
47
44
  const IS_ELECTRON_MAIN = Boolean(process.versions.electron);
45
+ const USE_FILE_LOGS = process.env.ELECTRIC_AGENTS_LOG_FILE !== `false`;
48
46
  const USE_PRETTY_LOGS = LOG_LEVEL !== `silent` && !process.env.VITEST && !IS_ELECTRON_MAIN;
49
- const streams = [{ stream: pino.default.destination({
50
- dest: LOG_FILE,
51
- sync: IS_ELECTRON_MAIN
52
- }) }];
53
- if (USE_PRETTY_LOGS) streams.push({ stream: pino.default.transport({
54
- target: `pino-pretty`,
55
- options: {
56
- colorize: true,
57
- ignore: `pid,hostname,name`,
58
- translateTime: `SYS:HH:MM:ss`
47
+ let _logger;
48
+ function getLogger() {
49
+ if (_logger) return _logger;
50
+ const streams = [];
51
+ try {
52
+ if (USE_FILE_LOGS) {
53
+ const logDir = process.env.ELECTRIC_AGENTS_LOG_DIR ?? node_path.default.resolve(process.cwd(), `logs`);
54
+ node_fs.default.mkdirSync(logDir, { recursive: true });
55
+ const logFile = node_path.default.join(logDir, `builtin-agents-${Date.now()}.jsonl`);
56
+ streams.push({ stream: pino.default.destination({
57
+ dest: logFile,
58
+ sync: IS_ELECTRON_MAIN
59
+ }) });
60
+ }
61
+ } catch (err) {
62
+ process.stderr.write(`[agents] Failed to initialize file logging: ${err instanceof Error ? err.message : err}\n`);
59
63
  }
60
- }) });
61
- const logger = (0, pino.default)({
62
- base: void 0,
63
- level: LOG_LEVEL
64
- }, pino.default.multistream(streams));
64
+ try {
65
+ if (USE_PRETTY_LOGS) streams.push({ stream: pino.default.transport({
66
+ target: `pino-pretty`,
67
+ options: {
68
+ colorize: true,
69
+ ignore: `pid,hostname,name`,
70
+ translateTime: `SYS:HH:MM:ss`
71
+ }
72
+ }) });
73
+ } catch {}
74
+ _logger = streams.length > 0 ? (0, pino.default)({
75
+ base: void 0,
76
+ level: LOG_LEVEL
77
+ }, pino.default.multistream(streams)) : (0, pino.default)({
78
+ base: void 0,
79
+ enabled: false,
80
+ level: LOG_LEVEL
81
+ });
82
+ return _logger;
83
+ }
65
84
  function formatArgs(args) {
66
85
  const errors = [];
67
86
  const parts = [];
@@ -75,24 +94,24 @@ function formatArgs(args) {
75
94
  const serverLog = {
76
95
  debug(...args) {
77
96
  const { msg } = formatArgs(args);
78
- logger.debug(msg);
97
+ getLogger().debug(msg);
79
98
  },
80
99
  info(...args) {
81
100
  const { msg } = formatArgs(args);
82
- logger.info(msg);
101
+ getLogger().info(msg);
83
102
  },
84
103
  warn(...args) {
85
104
  const { err, msg } = formatArgs(args);
86
- if (err) logger.warn({ err }, msg);
87
- else logger.warn(msg);
105
+ if (err) getLogger().warn({ err }, msg);
106
+ else getLogger().warn(msg);
88
107
  },
89
108
  error(...args) {
90
109
  const { err, msg } = formatArgs(args);
91
- if (err) logger.error({ err }, msg);
92
- else logger.error(msg);
110
+ if (err) getLogger().error({ err }, msg);
111
+ else getLogger().error(msg);
93
112
  },
94
113
  event(obj, msg) {
95
- logger.info(obj, msg);
114
+ getLogger().info(obj, msg);
96
115
  }
97
116
  };
98
117
 
package/dist/index.js CHANGED
@@ -16,28 +16,47 @@ import { getModels } from "@mariozechner/pi-ai";
16
16
  import { bridgeMcpTool, buildPromptTools, buildResourceTools, createRegistry, keychainPersistence, loadConfig, mcp, watchConfig } from "@electric-ax/agents-mcp";
17
17
 
18
18
  //#region src/log.ts
19
- const LOG_DIR = process.env.ELECTRIC_AGENTS_LOG_DIR ?? path.resolve(process.cwd(), `logs`);
20
- fs.mkdirSync(LOG_DIR, { recursive: true });
21
- const LOG_FILE = path.join(LOG_DIR, `builtin-agents-${Date.now()}.jsonl`);
22
19
  const LOG_LEVEL = process.env.ELECTRIC_AGENTS_LOG_LEVEL ?? `info`;
23
20
  const IS_ELECTRON_MAIN = Boolean(process.versions.electron);
21
+ const USE_FILE_LOGS = process.env.ELECTRIC_AGENTS_LOG_FILE !== `false`;
24
22
  const USE_PRETTY_LOGS = LOG_LEVEL !== `silent` && !process.env.VITEST && !IS_ELECTRON_MAIN;
25
- const streams = [{ stream: pino.destination({
26
- dest: LOG_FILE,
27
- sync: IS_ELECTRON_MAIN
28
- }) }];
29
- if (USE_PRETTY_LOGS) streams.push({ stream: pino.transport({
30
- target: `pino-pretty`,
31
- options: {
32
- colorize: true,
33
- ignore: `pid,hostname,name`,
34
- translateTime: `SYS:HH:MM:ss`
23
+ let _logger;
24
+ function getLogger() {
25
+ if (_logger) return _logger;
26
+ const streams = [];
27
+ try {
28
+ if (USE_FILE_LOGS) {
29
+ const logDir = process.env.ELECTRIC_AGENTS_LOG_DIR ?? path.resolve(process.cwd(), `logs`);
30
+ fs.mkdirSync(logDir, { recursive: true });
31
+ const logFile = path.join(logDir, `builtin-agents-${Date.now()}.jsonl`);
32
+ streams.push({ stream: pino.destination({
33
+ dest: logFile,
34
+ sync: IS_ELECTRON_MAIN
35
+ }) });
36
+ }
37
+ } catch (err) {
38
+ process.stderr.write(`[agents] Failed to initialize file logging: ${err instanceof Error ? err.message : err}\n`);
35
39
  }
36
- }) });
37
- const logger = pino({
38
- base: void 0,
39
- level: LOG_LEVEL
40
- }, pino.multistream(streams));
40
+ try {
41
+ if (USE_PRETTY_LOGS) streams.push({ stream: pino.transport({
42
+ target: `pino-pretty`,
43
+ options: {
44
+ colorize: true,
45
+ ignore: `pid,hostname,name`,
46
+ translateTime: `SYS:HH:MM:ss`
47
+ }
48
+ }) });
49
+ } catch {}
50
+ _logger = streams.length > 0 ? pino({
51
+ base: void 0,
52
+ level: LOG_LEVEL
53
+ }, pino.multistream(streams)) : pino({
54
+ base: void 0,
55
+ enabled: false,
56
+ level: LOG_LEVEL
57
+ });
58
+ return _logger;
59
+ }
41
60
  function formatArgs(args) {
42
61
  const errors = [];
43
62
  const parts = [];
@@ -51,24 +70,24 @@ function formatArgs(args) {
51
70
  const serverLog = {
52
71
  debug(...args) {
53
72
  const { msg } = formatArgs(args);
54
- logger.debug(msg);
73
+ getLogger().debug(msg);
55
74
  },
56
75
  info(...args) {
57
76
  const { msg } = formatArgs(args);
58
- logger.info(msg);
77
+ getLogger().info(msg);
59
78
  },
60
79
  warn(...args) {
61
80
  const { err, msg } = formatArgs(args);
62
- if (err) logger.warn({ err }, msg);
63
- else logger.warn(msg);
81
+ if (err) getLogger().warn({ err }, msg);
82
+ else getLogger().warn(msg);
64
83
  },
65
84
  error(...args) {
66
85
  const { err, msg } = formatArgs(args);
67
- if (err) logger.error({ err }, msg);
68
- else logger.error(msg);
86
+ if (err) getLogger().error({ err }, msg);
87
+ else getLogger().error(msg);
69
88
  },
70
89
  event(obj, msg) {
71
- logger.info(obj, msg);
90
+ getLogger().info(obj, msg);
72
91
  }
73
92
  };
74
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electric-ax/agents",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "description": "Built-in Electric Agents runtimes such as Horton and worker",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,7 +49,7 @@
49
49
  "sqlite-vec": "^0.1.9",
50
50
  "zod": "^4.3.6",
51
51
  "@electric-ax/agents-mcp": "0.2.2",
52
- "@electric-ax/agents-runtime": "0.3.6"
52
+ "@electric-ax/agents-runtime": "0.3.7"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/better-sqlite3": "^7.6.13",