@exellix/graph-engine 7.2.13 → 7.2.14

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.2.14
4
+
5
+ ### Fixed
6
+
7
+ - **`test:live` / Node ESM:** Load `@x12i/logxer` via dynamic import in `graphEngineLogxer` (avoids CJS `trails` → `require('nanoid')` `ERR_REQUIRE_ESM` on Node 22). Inline run-log diagnostic normalization in `buildRunLog` (no static logxer import).
8
+ - **Live script:** Remove redundant direct `@x12i/logxer` import; use `GRAPH_ENGINE_LOGS_LEVEL` / `LOGXER_PACKAGE_LEVELS` env instead.
9
+
3
10
  ## 7.2.13
4
11
 
5
12
  ### Added
@@ -1,4 +1,3 @@
1
- import { normalizeLogRecord } from '@x12i/logxer';
2
1
  import { AI_TASKS_LOGXER_RUN_ID_METADATA_KEY, AI_TASKS_RUN_LOG_METADATA_KEY, DEFAULT_MAX_RUN_LOG_DATA_JSON_CHARS, DEFAULT_MAX_RUN_LOG_ENTRIES, } from '../types/runLog.js';
3
2
  function safeJsonLen(value) {
4
3
  try {
@@ -38,6 +37,22 @@ function isRunLogScope(x) {
38
37
  x === 'logxer' ||
39
38
  x === 'pipeline');
40
39
  }
40
+ /** Read promoted diagnostic fields without importing @x12i/logxer at module load. */
41
+ function normalizeRunLogDiagnostics(row) {
42
+ const data = row.data != null && typeof row.data === 'object' && !Array.isArray(row.data)
43
+ ? row.data
44
+ : undefined;
45
+ const codeRaw = row.code ?? data?.code;
46
+ const code = typeof codeRaw === 'string' && codeRaw.length > 0 ? codeRaw : undefined;
47
+ const diagRaw = row.diagnostics ?? data?.diagnostics;
48
+ const diagnostics = diagRaw != null && typeof diagRaw === 'object' && !Array.isArray(diagRaw)
49
+ ? diagRaw
50
+ : undefined;
51
+ return {
52
+ ...(code ? { code } : {}),
53
+ ...(diagnostics ? { diagnostics } : {}),
54
+ };
55
+ }
41
56
  /** Normalize @exellix/ai-tasks epoch-ms or ISO `ts` to epoch ms for exellix-graph `RunLogEntry`. */
42
57
  export function parseRunLogEntryTs(v) {
43
58
  if (typeof v === 'number' && Number.isFinite(v))
@@ -69,9 +84,7 @@ export function normalizeExternalRunLogEntries(raw) {
69
84
  ? r.correlationIds
70
85
  : undefined;
71
86
  const data = 'data' in r ? r.data : undefined;
72
- const normalized = normalizeLogRecord(r);
73
- const code = typeof normalized.code === 'string' && normalized.code.length > 0 ? normalized.code : undefined;
74
- const diagnostics = normalized.diagnostics;
87
+ const { code, diagnostics } = normalizeRunLogDiagnostics(r);
75
88
  const debugKind = typeof r.debugKind === 'string' && r.debugKind.length > 0
76
89
  ? r.debugKind
77
90
  : undefined;
@@ -1,35 +1,24 @@
1
1
  /**
2
2
  * Graph-engine Logxer integration (@x12i/logxer 4.5.x).
3
- * Structured runtime logs, correlation context, stack log-level pass-through, and queryable in-process logs.
3
+ * Dynamic import avoids Node ESM loading CJS logxer trails nanoid@5 ERR_REQUIRE_ESM on some runtimes.
4
4
  */
5
- import { DebugLogAbstract, exceptionEvidence, fieldEvidence, runWithLogContext, patchLogContext } from '@x12i/logxer';
6
5
  import type { GetJobLogsInput, GetJobLogsResult, Logxer, LogRuntimeContext, StackLoggingOptions } from '@x12i/logxer';
7
6
  import type { LogxerQueryableClient, RuntimeObjects } from './runtimeObjects.js';
8
7
  /** Env prefix for package-level log level: `GRAPH_ENGINE_LOGS_LEVEL` (canonical). */
9
8
  export declare const GRAPH_ENGINE_LOGXER_ENV_PREFIX: "GRAPH_ENGINE";
10
- /**
11
- * Factory for a graph-engine Logxer instance.
12
- * Pass `logging` from host {@link StackLoggingOptions} (logxer 4.5+ stack pass-through).
13
- */
9
+ /** Factory for a graph-engine Logxer instance (logxer 4.5+ stack pass-through). */
14
10
  export declare function createGraphEngineLogxer(options?: {
15
11
  logging?: StackLoggingOptions;
16
12
  }): Logxer;
17
13
  /** Default process logger (env / host registry). Lazily created without stack overrides. */
18
14
  export declare function getGraphEngineLogxer(): Logxer;
19
- /** Bind the logger used for the current graph run (cleared in {@link clearGraphEngineRunLogxer}). */
20
- export declare function bindGraphEngineRunLogxer(logxer: Logxer): void;
15
+ export declare function bindGraphEngineRunLogxer(instance: Logxer): void;
21
16
  export declare function clearGraphEngineRunLogxer(): void;
22
- /** Queryable client surface for {@link RuntimeObjects.logxerClient}. */
23
- export declare function createGraphEngineLogxerClient(logxer?: Logxer): LogxerQueryableClient;
24
- /** Attach graph-level Logxer query client when hosts omit one on runtimeObjects. */
25
- export declare function ensureGraphEngineLogxerOnRuntimeObjects(runtimeObjects: RuntimeObjects | undefined, logxer?: Logxer): void;
26
- /** Run graph work with Logxer correlation ids (jobId, taskId, graphId, runId). */
17
+ export declare function createGraphEngineLogxerClient(instance?: Logxer): LogxerQueryableClient;
18
+ export declare function ensureGraphEngineLogxerOnRuntimeObjects(runtimeObjects: RuntimeObjects | undefined, instance?: Logxer): void;
27
19
  export declare function runGraphWithLogContext<T>(ctx: LogRuntimeContext, fn: () => T | Promise<T>): Promise<T>;
28
- /** Narrow node-scoped correlation inside an active graph run context. */
29
20
  export declare function patchGraphNodeLogContext(nodeId: string): void;
30
- /** Gated verbose/state traces (replaces DEBUG_EXECUTION_MEMORY / DEBUG_OUTPUT_MAPPING console.log). */
31
21
  export declare function traceExecutionMemory(scope: 'executeNode' | 'executeGraph', message: string, data?: Record<string, unknown>): void;
32
- /** Emit a catalog-backed graph error log when a node/graph failure occurs. */
33
22
  export declare function logGraphEngineErrorCode(code: string, _message: string, ctx: {
34
23
  graphId?: string;
35
24
  nodeId?: string;
@@ -38,5 +27,15 @@ export declare function logGraphEngineErrorCode(code: string, _message: string,
38
27
  error?: unknown;
39
28
  evidence?: Record<string, unknown>;
40
29
  }): void;
41
- export { DebugLogAbstract, fieldEvidence, exceptionEvidence, runWithLogContext, patchLogContext };
30
+ export declare const DebugLogAbstract: {
31
+ readonly STATE: "STATE";
32
+ readonly INTENT: "INTENT";
33
+ readonly EVENT: "EVENT";
34
+ readonly TRACE: "TRACE";
35
+ readonly ANOMALY: "ANOMALY";
36
+ };
37
+ export declare const fieldEvidence: typeof import("@x12i/logxer").fieldEvidence;
38
+ export declare const exceptionEvidence: typeof import("@x12i/logxer").exceptionEvidence;
39
+ export declare const runWithLogContext: typeof import("@x12i/logxer").runWithLogContext;
40
+ export declare const patchLogContext: typeof import("@x12i/logxer").patchLogContext;
42
41
  export type { GetJobLogsInput, GetJobLogsResult, LogRuntimeContext, StackLoggingOptions };
@@ -1,8 +1,4 @@
1
- /**
2
- * Graph-engine Logxer integration (@x12i/logxer 4.5.x).
3
- * Structured runtime logs, correlation context, stack log-level pass-through, and queryable in-process logs.
4
- */
5
- import { createLogxer, DebugLogAbstract, exceptionEvidence, fieldEvidence, runWithLogContext, patchLogContext, } from '@x12i/logxer';
1
+ const logxer = await import('@x12i/logxer');
6
2
  import { ExellixGraphErrorCode } from '../errors/exellixGraphErrorCodes.js';
7
3
  import { EXELLIX_GRAPH_RUNTIME_PACKAGE_NAME } from './runtimeObjects.js';
8
4
  /** Env prefix for package-level log level: `GRAPH_ENGINE_LOGS_LEVEL` (canonical). */
@@ -86,12 +82,9 @@ function buildGraphEngineLogxerConfig(logging) {
86
82
  ...(logging ? { stack: logging } : {}),
87
83
  };
88
84
  }
89
- /**
90
- * Factory for a graph-engine Logxer instance.
91
- * Pass `logging` from host {@link StackLoggingOptions} (logxer 4.5+ stack pass-through).
92
- */
85
+ /** Factory for a graph-engine Logxer instance (logxer 4.5+ stack pass-through). */
93
86
  export function createGraphEngineLogxer(options) {
94
- return createLogxer({
87
+ return logxer.createLogxer({
95
88
  packageName: EXELLIX_GRAPH_RUNTIME_PACKAGE_NAME,
96
89
  envPrefix: GRAPH_ENGINE_LOGXER_ENV_PREFIX,
97
90
  debugNamespace: 'graph-engine',
@@ -104,37 +97,31 @@ export function getGraphEngineLogxer() {
104
97
  }
105
98
  return activeRunLogxer ?? defaultLogxer;
106
99
  }
107
- /** Bind the logger used for the current graph run (cleared in {@link clearGraphEngineRunLogxer}). */
108
- export function bindGraphEngineRunLogxer(logxer) {
109
- activeRunLogxer = logxer;
100
+ export function bindGraphEngineRunLogxer(instance) {
101
+ activeRunLogxer = instance;
110
102
  }
111
103
  export function clearGraphEngineRunLogxer() {
112
104
  activeRunLogxer = undefined;
113
105
  }
114
- /** Queryable client surface for {@link RuntimeObjects.logxerClient}. */
115
- export function createGraphEngineLogxerClient(logxer) {
116
- const target = logxer ?? getGraphEngineLogxer();
106
+ export function createGraphEngineLogxerClient(instance) {
107
+ const target = instance ?? getGraphEngineLogxer();
117
108
  return {
118
109
  getJobLogs(input) {
119
110
  return target.getJobLogs(input);
120
111
  },
121
112
  };
122
113
  }
123
- /** Attach graph-level Logxer query client when hosts omit one on runtimeObjects. */
124
- export function ensureGraphEngineLogxerOnRuntimeObjects(runtimeObjects, logxer) {
114
+ export function ensureGraphEngineLogxerOnRuntimeObjects(runtimeObjects, instance) {
125
115
  if (!runtimeObjects || runtimeObjects.logxerClient != null)
126
116
  return;
127
- runtimeObjects.logxerClient = createGraphEngineLogxerClient(logxer);
117
+ runtimeObjects.logxerClient = createGraphEngineLogxerClient(instance);
128
118
  }
129
- /** Run graph work with Logxer correlation ids (jobId, taskId, graphId, runId). */
130
119
  export function runGraphWithLogContext(ctx, fn) {
131
- return runWithLogContext(ctx, fn);
120
+ return logxer.runWithLogContext(ctx, fn);
132
121
  }
133
- /** Narrow node-scoped correlation inside an active graph run context. */
134
122
  export function patchGraphNodeLogContext(nodeId) {
135
- patchLogContext({ nodeId });
123
+ logxer.patchLogContext({ nodeId });
136
124
  }
137
- /** Gated verbose/state traces (replaces DEBUG_EXECUTION_MEMORY / DEBUG_OUTPUT_MAPPING console.log). */
138
125
  export function traceExecutionMemory(scope, message, data) {
139
126
  if (process.env.DEBUG_EXECUTION_MEMORY !== 'true' &&
140
127
  process.env.DEBUG_OUTPUT_MAPPING !== 'true') {
@@ -143,23 +130,26 @@ export function traceExecutionMemory(scope, message, data) {
143
130
  getGraphEngineLogxer().verbose(message, {
144
131
  scope,
145
132
  ...data,
146
- debugKind: DebugLogAbstract.STATE,
133
+ debugKind: logxer.DebugLogAbstract.STATE,
147
134
  });
148
135
  }
149
- /** Emit a catalog-backed graph error log when a node/graph failure occurs. */
150
136
  export function logGraphEngineErrorCode(code, _message, ctx) {
151
- const logxer = getGraphEngineLogxer();
137
+ const instance = getGraphEngineLogxer();
152
138
  const evidence = [
153
- ...(ctx.error != null ? [exceptionEvidence(ctx.error)] : []),
154
- ...Object.entries(ctx.evidence ?? {}).map(([path, value]) => fieldEvidence(path, value)),
139
+ ...(ctx.error != null ? [logxer.exceptionEvidence(ctx.error)] : []),
140
+ ...Object.entries(ctx.evidence ?? {}).map(([path, value]) => logxer.fieldEvidence(path, value)),
155
141
  ];
156
- logxer.errorCode(code, {
142
+ instance.errorCode(code, {
157
143
  graphId: ctx.graphId,
158
144
  nodeId: ctx.nodeId,
159
145
  jobId: ctx.jobId,
160
146
  taskId: ctx.taskId,
161
- debugKind: DebugLogAbstract.ANOMALY,
147
+ debugKind: logxer.DebugLogAbstract.ANOMALY,
162
148
  ...(evidence.length ? { evidence } : {}),
163
149
  });
164
150
  }
165
- export { DebugLogAbstract, fieldEvidence, exceptionEvidence, runWithLogContext, patchLogContext };
151
+ export const DebugLogAbstract = logxer.DebugLogAbstract;
152
+ export const fieldEvidence = logxer.fieldEvidence;
153
+ export const exceptionEvidence = logxer.exceptionEvidence;
154
+ export const runWithLogContext = logxer.runWithLogContext;
155
+ export const patchLogContext = logxer.patchLogContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exellix/graph-engine",
3
- "version": "7.2.13",
3
+ "version": "7.2.14",
4
4
  "type": "module",
5
5
  "description": "Graph executor SDK",
6
6
  "main": "dist/src/index.js",