agent-tail-core 0.3.1 → 0.3.2

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/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as cmd_run, r as cmd_wrap, t as cmd_init } from "./commands-LpvDep8T.mjs";
2
+ import { n as cmd_run, r as cmd_wrap, t as cmd_init } from "./commands-BGQ-_7t4.mjs";
3
3
  import { parseArgs } from "node:util";
4
4
 
5
5
  //#region src/cli.ts
@@ -17,6 +17,7 @@ function should_exclude(message, excludes) {
17
17
  //#endregion
18
18
  //#region src/log-manager.ts
19
19
  const PLUGIN_PREFIX = "\x1B[36m[agent-tail]\x1B[0m";
20
+ const SESSION_ENV_VAR = "AGENT_TAIL_SESSION";
20
21
  let session_counter = 0;
21
22
  var LogManager = class {
22
23
  constructor(options) {
@@ -70,6 +71,17 @@ var LogManager = class {
70
71
  } catch {}
71
72
  }
72
73
  /**
74
+ * Join an existing session directory. Creates the log file if it doesn't
75
+ * exist. Use this when a parent process (e.g. `agent-tail run`) has
76
+ * already created the session and passed its path via AGENT_TAIL_SESSION.
77
+ */
78
+ join_session(session_dir) {
79
+ const log_file = path.join(session_dir, this.options.logFileName);
80
+ if (!fs.existsSync(log_file)) fs.writeFileSync(log_file, "");
81
+ console.log(`${PLUGIN_PREFIX} Writing to ${log_file}`);
82
+ return log_file;
83
+ }
84
+ /**
73
85
  * Resolve the current session directory. If a `latest` symlink exists and
74
86
  * points to a valid directory, return it. Otherwise create a new session.
75
87
  */
@@ -276,7 +288,10 @@ function cmd_run(project_root, service_args, options = DEFAULT_CLI_OPTIONS) {
276
288
  "pipe",
277
289
  "pipe"
278
290
  ],
279
- env: { ...process.env },
291
+ env: {
292
+ ...process.env,
293
+ [SESSION_ENV_VAR]: session_dir
294
+ },
280
295
  shell: true
281
296
  });
282
297
  function handle(target, chunk) {
@@ -317,4 +332,4 @@ function cmd_run(project_root, service_args, options = DEFAULT_CLI_OPTIONS) {
317
332
  }
318
333
 
319
334
  //#endregion
320
- export { resolve_session_dir as a, LogManager as c, parse_service_configs as i, should_exclude as l, cmd_run as n, DEFAULT_OPTIONS as o, cmd_wrap as r, resolve_options as s, cmd_init as t };
335
+ export { resolve_session_dir as a, LogManager as c, parse_service_configs as i, SESSION_ENV_VAR as l, cmd_run as n, DEFAULT_OPTIONS as o, cmd_wrap as r, resolve_options as s, cmd_init as t, should_exclude as u };
package/dist/index.d.mts CHANGED
@@ -46,6 +46,7 @@ declare function should_exclude(message: string, excludes: string[]): boolean;
46
46
  declare function generate_client_script(options: ResolvedOptions): string;
47
47
  //#endregion
48
48
  //#region src/log-manager.d.ts
49
+ declare const SESSION_ENV_VAR = "AGENT_TAIL_SESSION";
49
50
  declare class LogManager {
50
51
  private options;
51
52
  constructor(options: ResolvedOptions);
@@ -53,6 +54,12 @@ declare class LogManager {
53
54
  create_session_name(): string;
54
55
  update_latest_symlink(log_dir: string, session_dir: string): void;
55
56
  prune_sessions(log_dir: string): void;
57
+ /**
58
+ * Join an existing session directory. Creates the log file if it doesn't
59
+ * exist. Use this when a parent process (e.g. `agent-tail run`) has
60
+ * already created the session and passed its path via AGENT_TAIL_SESSION.
61
+ */
62
+ join_session(session_dir: string): string;
56
63
  /**
57
64
  * Resolve the current session directory. If a `latest` symlink exists and
58
65
  * points to a valid directory, return it. Otherwise create a new session.
@@ -92,4 +99,4 @@ declare function cmd_wrap(project_root: string, name: string, command: string[],
92
99
  */
93
100
  declare function cmd_run(project_root: string, service_args: string[], options?: CliOptions): Promise<void>;
94
101
  //#endregion
95
- export { type BrowserLogsOptions, type CliOptions, DEFAULT_OPTIONS, type LogEntry, LogManager, type ResolvedOptions, type ServiceConfig, cmd_init, cmd_run, cmd_wrap, format_log_line, generate_client_script, parse_service_configs, resolve_options, resolve_session_dir, should_exclude };
102
+ export { type BrowserLogsOptions, type CliOptions, DEFAULT_OPTIONS, type LogEntry, LogManager, type ResolvedOptions, SESSION_ENV_VAR, type ServiceConfig, cmd_init, cmd_run, cmd_wrap, format_log_line, generate_client_script, parse_service_configs, resolve_options, resolve_session_dir, should_exclude };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as resolve_session_dir, c as LogManager, i as parse_service_configs, l as should_exclude, n as cmd_run, o as DEFAULT_OPTIONS, r as cmd_wrap, s as resolve_options, t as cmd_init } from "./commands-LpvDep8T.mjs";
1
+ import { a as resolve_session_dir, c as LogManager, i as parse_service_configs, l as SESSION_ENV_VAR, n as cmd_run, o as DEFAULT_OPTIONS, r as cmd_wrap, s as resolve_options, t as cmd_init, u as should_exclude } from "./commands-BGQ-_7t4.mjs";
2
2
 
3
3
  //#region src/formatter.ts
4
4
  function format_log_line(entry) {
@@ -121,4 +121,4 @@ function generate_client_script(options) {
121
121
  }
122
122
 
123
123
  //#endregion
124
- export { DEFAULT_OPTIONS, LogManager, cmd_init, cmd_run, cmd_wrap, format_log_line, generate_client_script, parse_service_configs, resolve_options, resolve_session_dir, should_exclude };
124
+ export { DEFAULT_OPTIONS, LogManager, SESSION_ENV_VAR, cmd_init, cmd_run, cmd_wrap, format_log_line, generate_client_script, parse_service_configs, resolve_options, resolve_session_dir, should_exclude };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-tail-core",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "description": "Core utilities for agent-tail log capture plugins.",
6
6
  "license": "MIT",
7
7
  "repository": {