import {
  readEnvVar
} from "./chunk-MARWOCVP.js";
import "./chunk-PZ5AY32C.js";

// src/sdk-compat.ts
function detectSdkCapabilities(api) {
  const hasRegisterMemoryPromptSection = typeof api.registerMemoryPromptSection === "function";
  const hasRegisterMemoryCapability = typeof api.registerMemoryCapability === "function";
  const hasRuntimeNamespace = typeof api.runtime === "object" && api.runtime !== null;
  const hasRegistrationMode = typeof api.registrationMode === "string";
  const runtimeVersion = hasRuntimeNamespace && typeof api.runtime?.version === "string" ? api.runtime.version : null;
  const isNewSdk = hasRegisterMemoryPromptSection || hasRegisterMemoryCapability || hasRuntimeNamespace || hasRegistrationMode;
  const sdkVersion = runtimeVersion ?? (isNewSdk ? readEnvVar("OPENCLAW_SERVICE_VERSION") : null) ?? "legacy";
  const hasNewHookSystem = hasRegisterMemoryPromptSection || hasRegisterMemoryCapability || hasRegistrationMode;
  return {
    hasBeforePromptBuild: hasNewHookSystem,
    hasRegisterMemoryPromptSection,
    hasRegisterMemoryCapability,
    hasDefinePluginEntry: isNewSdk,
    // entry point is less risky, keep broad detection
    hasRuntimeNamespace,
    hasRegistrationMode,
    hasTypedHooks: hasNewHookSystem,
    sdkVersion,
    registrationMode: hasRegistrationMode ? api.registrationMode : void 0
  };
}
export {
  detectSdkCapabilities
};
//# sourceMappingURL=sdk-compat.js.map