2026-01-18 02:14:07 +00:00
|
|
|
import { createRequire } from "node:module";
|
|
|
|
|
import { resolveStateDir } from "../../config/paths.js";
|
2026-02-20 21:52:08 -06:00
|
|
|
import { transcribeAudioFile } from "../../media-understanding/transcribe-audio.js";
|
2026-02-01 10:03:47 +09:00
|
|
|
import { textToSpeechTelephony } from "../../tts/tts.js";
|
2026-03-03 02:06:50 +00:00
|
|
|
import { createRuntimeChannel } from "./runtime-channel.js";
|
|
|
|
|
import { createRuntimeConfig } from "./runtime-config.js";
|
|
|
|
|
import { createRuntimeEvents } from "./runtime-events.js";
|
|
|
|
|
import { createRuntimeLogging } from "./runtime-logging.js";
|
|
|
|
|
import { createRuntimeMedia } from "./runtime-media.js";
|
|
|
|
|
import { createRuntimeSystem } from "./runtime-system.js";
|
|
|
|
|
import { createRuntimeTools } from "./runtime-tools.js";
|
2026-02-19 15:11:21 +00:00
|
|
|
import type { PluginRuntime } from "./types.js";
|
2026-01-18 02:14:07 +00:00
|
|
|
|
|
|
|
|
let cachedVersion: string | null = null;
|
|
|
|
|
|
|
|
|
|
function resolveVersion(): string {
|
2026-01-31 16:19:20 +09:00
|
|
|
if (cachedVersion) {
|
|
|
|
|
return cachedVersion;
|
|
|
|
|
}
|
2026-01-18 02:14:07 +00:00
|
|
|
try {
|
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
|
const pkg = require("../../../package.json") as { version?: string };
|
|
|
|
|
cachedVersion = pkg.version ?? "unknown";
|
|
|
|
|
return cachedVersion;
|
|
|
|
|
} catch {
|
|
|
|
|
cachedVersion = "unknown";
|
|
|
|
|
return cachedVersion;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function createPluginRuntime(): PluginRuntime {
|
2026-03-03 02:06:50 +00:00
|
|
|
const runtime = {
|
2026-01-18 02:14:07 +00:00
|
|
|
version: resolveVersion(),
|
2026-02-19 16:09:50 +01:00
|
|
|
config: createRuntimeConfig(),
|
|
|
|
|
system: createRuntimeSystem(),
|
|
|
|
|
media: createRuntimeMedia(),
|
|
|
|
|
tts: { textToSpeechTelephony },
|
2026-02-20 21:52:08 -06:00
|
|
|
stt: { transcribeAudioFile },
|
2026-02-19 16:09:50 +01:00
|
|
|
tools: createRuntimeTools(),
|
|
|
|
|
channel: createRuntimeChannel(),
|
2026-03-03 02:06:50 +00:00
|
|
|
events: createRuntimeEvents(),
|
2026-02-19 16:09:50 +01:00
|
|
|
logging: createRuntimeLogging(),
|
|
|
|
|
state: { resolveStateDir },
|
2026-03-03 02:06:50 +00:00
|
|
|
} satisfies PluginRuntime;
|
2026-02-19 16:09:50 +01:00
|
|
|
|
2026-03-03 02:06:50 +00:00
|
|
|
return runtime;
|
2026-01-18 02:14:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type { PluginRuntime } from "./types.js";
|