/******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 556: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const { execSync } = __nccwpck_require__(317); const fs = __nccwpck_require__(896); const core = __nccwpck_require__(894); const github = __nccwpck_require__(994); function listMarkdownFiles(executor = execSync) { const output = executor("git ls-files '*.md'", { encoding: "utf8", }).trim(); return output ? output.split("\n").filter(Boolean) : []; } function getConfig({ coreModule = core, githubModule = github, env = process.env, } = {}) { const apiUrl = coreModule.getInput("api_url") || "http://agent-api.k8s.private"; const apiToken = coreModule.getInput("api_token"); const route = coreModule.getInput("route") || "agent-lake"; const method = coreModule.getInput("method") || "embeddings_insert"; const debug = (coreModule.getInput("debug") || "false").toLowerCase() === "true"; const repoFull = env.GITHUB_REPOSITORY || ""; const [owner = "", repo = ""] = repoFull.split("/"); const segmentId = "docs.code"; const serverUrl = ( env.GITHUB_SERVER_URL || githubModule.context.serverUrl || "https://git.yusufali.ca" ).replace(/\/$/, ""); const headers = { "Content-Type": "application/json", }; if (apiToken) { headers.Apitoken = apiToken; } return { apiUrl, apiToken, route, method, debug, owner, repo, segmentId, serverUrl, headers, }; } function sanitizeDocumentId(value) { return value.replace(/[^A-Za-z0-9.]/g, ""); } function buildStoreText({ owner, repo, file, content }) { return [ `repo_name: ${repo}`, `repo_owner: ${owner}`, `path: ${file}`, "", content, ].join("\n"); } function buildRequestPayload({ route, method, segmentId, owner, repo, file, content, }) { return { type: "input", route, argumentId: "plain", force: true, instanceId: null, inputs: { method, inputs: { segment_id: segmentId, document_id: sanitizeDocumentId([owner, repo, file].join(".")), embed_text: "", store_text: buildStoreText({ owner, repo, file, content }), }, }, }; } async function post( { apiUrl, headers, requestPayload, coreModule, fetchFn, waitFn }, retries = 0, ) { try { const response = await fetchFn(apiUrl, { method: "POST", headers, body: JSON.stringify(requestPayload), }); const responseText = await response.text(); if (!response.ok) { coreModule.setFailed( `Agent API request failed (${response.status}): ${responseText}`, ); } else { coreModule.info(`Agent response: ${responseText}`); } } catch (error) { if (retries < 5) { const delayMs = 1000 * (retries + 1); await waitFn(delayMs); return post( { apiUrl, headers, requestPayload, coreModule, fetchFn, waitFn }, retries + 1, ); } coreModule.setFailed(`Error sending task to agent: ${error}`); } } async function main({ coreModule = core, githubModule = github, env = process.env, executor = execSync, fsModule = fs, fetchFn = fetch, waitFn = (delayMs) => new Promise((resolve) => setTimeout(resolve, delayMs)), } = {}) { const config = getConfig({ coreModule, githubModule, env }); const markdownFiles = listMarkdownFiles(executor); for (const file of markdownFiles) { const content = fsModule.readFileSync(file, "utf8"); const requestPayload = buildRequestPayload({ route: config.route, method: config.method, segmentId: config.segmentId, owner: config.owner, repo: config.repo, file, content, }); if (config.debug) { coreModule.info(`API URL: ${config.apiUrl}`); coreModule.info(`Route: ${config.route}`); coreModule.info(`Server URL: ${config.serverUrl}`); coreModule.info(`Using auth: ${Boolean(config.apiToken)}`); coreModule.info(`Request payload: ${JSON.stringify(requestPayload)}`); } await post({ apiUrl: config.apiUrl, headers: config.headers, requestPayload, coreModule, fetchFn, waitFn, }); } } module.exports = { buildRequestPayload, buildStoreText, getConfig, listMarkdownFiles, main, post, sanitizeDocumentId, }; if (require.main === require.cache[eval('__filename')]) { main(); } /***/ }), /***/ 894: /***/ ((module) => { module.exports = eval("require")("@actions/core"); /***/ }), /***/ 994: /***/ ((module) => { module.exports = eval("require")("@actions/github"); /***/ }), /***/ 317: /***/ ((module) => { "use strict"; module.exports = require("child_process"); /***/ }), /***/ 896: /***/ ((module) => { "use strict"; module.exports = require("fs"); /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __nccwpck_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ // no module.id needed /******/ // no module.loaded needed /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ var threw = true; /******/ try { /******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__); /******/ threw = false; /******/ } finally { /******/ if(threw) delete __webpack_module_cache__[moduleId]; /******/ } /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/compat */ /******/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; /******/ /************************************************************************/ /******/ /******/ // startup /******/ // Load entry module and return exports /******/ // This entry module is referenced by other modules so it can't be inlined /******/ var __webpack_exports__ = __nccwpck_require__(556); /******/ module.exports = __webpack_exports__; /******/ /******/ })() ;