@mandujs/core 0.41.1 → 0.42.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mandujs/core",
3
- "version": "0.41.1",
3
+ "version": "0.42.0",
4
4
  "description": "Mandu Framework Core - Spec, Generator, Guard, Runtime",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/index.ts CHANGED
@@ -1,3 +1,26 @@
1
+ /**
2
+ * Version marker — consumers (notably `@mandujs/mcp`) use this to detect
3
+ * that a stale nested copy of `@mandujs/core` was resolved and produce
4
+ * a helpful error instead of a cryptic "X is not a function". See #236.
5
+ *
6
+ * Read directly from the package's own `package.json` at module load
7
+ * time so the value can NEVER drift from the real published version.
8
+ * Best-effort — falls back to "unknown" if the file cannot be read
9
+ * (e.g. when the bundler strips `package.json` from the tree; we never
10
+ * strip it but keep this defensive).
11
+ */
12
+ export const __MANDU_CORE_VERSION__: string = (() => {
13
+ try {
14
+ // `import.meta.dir` → `<install>/src`; package.json is one level up.
15
+ const pkgPath = `${import.meta.dir}/../package.json`;
16
+ const raw = require("node:fs").readFileSync(pkgPath, "utf-8") as string;
17
+ const parsed = JSON.parse(raw) as { version?: string };
18
+ return typeof parsed.version === "string" ? parsed.version : "unknown";
19
+ } catch {
20
+ return "unknown";
21
+ }
22
+ })();
23
+
1
24
  export * from "./spec";
2
25
  export * from "./runtime";
3
26
  export * from "./generator";
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { newId } from "../id";
4
4
 
5
- export type EventType = "http" | "mcp" | "guard" | "build" | "error" | "cache" | "ws";
5
+ export type EventType = "http" | "mcp" | "guard" | "build" | "error" | "cache" | "ws" | "ate";
6
6
  export type ObservabilitySeverity = "info" | "warn" | "error";
7
7
 
8
8
  export interface ObservabilityEvent {
@@ -60,7 +60,7 @@ class ManduEventBus {
60
60
 
61
61
  getStats(windowMs?: number): Record<EventType, { count: number; errors: number; avgDuration: number }> {
62
62
  const cutoff = windowMs ? Date.now() - windowMs : 0;
63
- const ALL: EventType[] = ["http", "mcp", "guard", "build", "error", "cache", "ws"];
63
+ const ALL: EventType[] = ["http", "mcp", "guard", "build", "error", "cache", "ws", "ate"];
64
64
  const stats = {} as Record<EventType, { count: number; errors: number; avgDuration: number }>;
65
65
  const dur = {} as Record<EventType, number[]>;
66
66
  for (const t of ALL) { stats[t] = { count: 0, errors: 0, avgDuration: 0 }; dur[t] = []; }