Files
Elydora-Node-SDK/src/plugins/grok-command.ts
T
雷电芽衣 3b5cbd6e17 chore(node-sdk): audit providers kimi grok qwen letta
Command files use shell-command and managedScriptReference; runtime checks use managed-runtime-status; jsonc-edit.ts and parseCommentedJsonObject replace copied JSONC helpers.

Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
2026-09-02 22:07:30 -04:00

31 lines
1.1 KiB
TypeScript

import path from 'node:path';
import { managedScriptReference, type ManagedScriptReference } from './common.js';
import {
encodedWindowsCommand,
isNodeExecutable,
parseEncodedWindowsCommand,
parseLegacyWindowsCommand,
parsePosixCommand,
posixSource,
} from './shell-command.js';
export type GrokRuntimeReference = ManagedScriptReference;
export function buildGrokCommand(scriptPath: string): string {
if (!path.isAbsolute(process.execPath) || !path.isAbsolute(scriptPath)) {
throw new Error('Grok hook commands require absolute executable and script paths');
}
return process.platform === 'win32' ? encodedWindowsCommand(scriptPath) : posixSource(scriptPath);
}
export function grokRuntimeReference(
command: string,
scriptName: string,
): GrokRuntimeReference | undefined {
const parsed = parsePosixCommand(command)
?? parseEncodedWindowsCommand(command)
?? parseLegacyWindowsCommand(command);
if (!parsed || !path.isAbsolute(parsed[0]) || !isNodeExecutable(parsed[0])) return undefined;
return managedScriptReference(parsed[1], scriptName);
}