"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/domain/delegates/memoryRecall/search.ts
var search_exports = {};
__export(search_exports, {
  searchMemoryRecall: () => searchMemoryRecall
});
module.exports = __toCommonJS(search_exports);
async function searchMemoryRecall(input, kValue, client) {
  console.log(`searchMemoryRecall input search query: ${input}}`);
  const token = await client.auth.signIn();
  const apiKey = token.access_token;
  const headers = {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json"
  };
  const url = `${client.url}/api/v2/ontologies/${client.ontologyRid}/queries/memoryRecalVectorSearch/execute`;
  const body = JSON.stringify({
    parameters: {
      input,
      kValue
    }
  });
  const apiResult = await fetch(url, {
    method: "POST",
    headers,
    body
  });
  const apiResponse = await apiResult.json();
  if (apiResponse.errorCode) {
    console.log(`errorInstanceId: ${apiResponse.errorCode} errorName: ${apiResponse.errorName} errorCode: ${apiResponse.errorCode}`);
    throw new Error(`An error occurred while calling memory recall search errorInstanceId: ${apiResponse.errorInstanceId} errorCode: ${apiResponse.errorCode}`);
  }
  console.log(`the threads ontology returned: ${JSON.stringify(apiResponse)}`);
  return apiResponse.value;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  searchMemoryRecall
});
