@absolutejs/absolute 0.19.0-beta.637 → 0.19.0-beta.639

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ai/index.js CHANGED
@@ -749,7 +749,7 @@ var formatLeadMediaCueSummary = (input) => {
749
749
  return parts.length > 0 ? parts.join(" \xB7 ") : "none";
750
750
  };
751
751
  var formatRAGTraceMetadataRow = (key, value) => ({
752
- label: key === "sqliteQueryMode" ? "SQLite query mode" : key === "postgresQueryMode" ? "Postgres query mode" : key === "sqliteQueryPushdownMode" ? "SQLite pushdown mode" : key === "postgresQueryPushdownMode" ? "Postgres pushdown mode" : key === "sqliteQueryPushdownApplied" ? "SQLite pushdown applied" : key === "postgresQueryPushdownApplied" ? "Postgres pushdown applied" : key === "sqliteQueryPushdownClauseCount" ? "SQLite pushdown clauses" : key === "postgresQueryPushdownClauseCount" ? "Postgres pushdown clauses" : key === "sqliteQueryPushdownCoverageRatio" ? "SQLite pushdown coverage" : key === "postgresQueryPushdownCoverageRatio" ? "Postgres pushdown coverage" : key === "sqliteQueryTotalFilterClauseCount" ? "SQLite total filter clauses" : key === "postgresQueryTotalFilterClauseCount" ? "Postgres total filter clauses" : key === "sqliteQueryJsRemainderClauseCount" ? "SQLite JS remainder clauses" : key === "sqliteQueryMultiplierUsed" ? "SQLite query multiplier" : key === "sqliteQueryCandidateLimitUsed" ? "SQLite candidate limit" : key === "sqliteQueryMaxBackfillsUsed" ? "SQLite max backfills" : key === "sqliteQueryMinResultsUsed" ? "SQLite min results" : key === "sqliteQueryFillPolicyUsed" ? "SQLite fill policy" : key === "postgresQueryJsRemainderClauseCount" ? "Postgres JS remainder clauses" : key === "postgresQueryMultiplierUsed" ? "Postgres query multiplier" : key === "postgresQueryCandidateLimitUsed" ? "Postgres candidate limit" : key === "postgresQueryMaxBackfillsUsed" ? "Postgres max backfills" : key === "postgresQueryMinResultsUsed" ? "Postgres min results" : key === "postgresQueryFillPolicyUsed" ? "Postgres fill policy" : key === "sqliteQueryJsRemainderRatio" ? "SQLite JS remainder share" : key === "postgresQueryJsRemainderRatio" ? "Postgres JS remainder share" : key === "sqliteQueryFilteredCandidates" ? "SQLite filtered candidates" : key === "postgresQueryFilteredCandidates" ? "Postgres filtered candidates" : key === "sqliteQueryInitialSearchK" ? "SQLite initial searchK" : key === "postgresQueryInitialSearchK" ? "Postgres initial searchK" : key === "sqliteQueryFinalSearchK" ? "SQLite final searchK" : key === "postgresQueryFinalSearchK" ? "Postgres final searchK" : key === "sqliteQuerySearchExpansionRatio" ? "SQLite search expansion" : key === "postgresQuerySearchExpansionRatio" ? "Postgres search expansion" : key === "sqliteQueryBackfillCount" ? "SQLite backfill count" : key === "sqliteQueryBackfillLimitReached" ? "SQLite backfill limit reached" : key === "sqliteQueryMinResultsSatisfied" ? "SQLite min results satisfied" : key === "postgresQueryBackfillCount" ? "Postgres backfill count" : key === "postgresQueryBackfillLimitReached" ? "Postgres backfill limit reached" : key === "postgresQueryMinResultsSatisfied" ? "Postgres min results satisfied" : key === "sqliteQueryReturnedCount" ? "SQLite returned hits" : key === "postgresQueryReturnedCount" ? "Postgres returned hits" : key === "sqliteQueryCandidateYieldRatio" ? "SQLite candidate yield" : key === "postgresQueryCandidateYieldRatio" ? "Postgres candidate yield" : key === "sqliteQueryTopKFillRatio" ? "SQLite topK fill rate" : key === "postgresQueryTopKFillRatio" ? "Postgres topK fill rate" : key === "sqliteQueryUnderfilledTopK" ? "SQLite underfilled topK" : key === "postgresQueryUnderfilledTopK" ? "Postgres underfilled topK" : key === "sqliteQueryCandidateBudgetExhausted" ? "SQLite candidate budget exhausted" : key === "postgresQueryCandidateBudgetExhausted" ? "Postgres candidate budget exhausted" : key === "sqliteQueryCandidateCoverage" ? "SQLite candidate coverage" : key === "postgresQueryCandidateCoverage" ? "Postgres candidate coverage" : key === "leadSpeakerCue" ? "Lead speaker cue" : key === "leadSpeakerAttributionCue" ? "Lead speaker attribution" : key === "leadChannelAttributionCue" ? "Lead channel attribution" : key === "leadChannelCue" ? "Lead channel cue" : key === "leadContinuityCue" ? "Lead continuity cue" : key,
752
+ label: key === "sqliteQueryMode" ? "SQLite query mode" : key === "postgresQueryMode" ? "Postgres query mode" : key === "sqliteQueryPushdownMode" ? "SQLite pushdown mode" : key === "postgresQueryPushdownMode" ? "Postgres pushdown mode" : key === "sqliteQueryPushdownApplied" ? "SQLite pushdown applied" : key === "postgresQueryPushdownApplied" ? "Postgres pushdown applied" : key === "sqliteQueryPushdownClauseCount" ? "SQLite pushdown clauses" : key === "postgresQueryPushdownClauseCount" ? "Postgres pushdown clauses" : key === "sqliteQueryPushdownCoverageRatio" ? "SQLite pushdown coverage" : key === "postgresQueryPushdownCoverageRatio" ? "Postgres pushdown coverage" : key === "sqliteQueryTotalFilterClauseCount" ? "SQLite total filter clauses" : key === "postgresQueryTotalFilterClauseCount" ? "Postgres total filter clauses" : key === "sqliteQueryJsRemainderClauseCount" ? "SQLite JS remainder clauses" : key === "sqliteQueryMultiplierUsed" ? "SQLite query multiplier" : key === "sqliteQueryPlannerProfileUsed" ? "SQLite query profile" : key === "sqliteQueryCandidateLimitUsed" ? "SQLite candidate limit" : key === "sqliteQueryMaxBackfillsUsed" ? "SQLite max backfills" : key === "sqliteQueryMinResultsUsed" ? "SQLite min results" : key === "sqliteQueryFillPolicyUsed" ? "SQLite fill policy" : key === "postgresQueryJsRemainderClauseCount" ? "Postgres JS remainder clauses" : key === "postgresQueryMultiplierUsed" ? "Postgres query multiplier" : key === "postgresQueryPlannerProfileUsed" ? "Postgres query profile" : key === "postgresQueryCandidateLimitUsed" ? "Postgres candidate limit" : key === "postgresQueryMaxBackfillsUsed" ? "Postgres max backfills" : key === "postgresQueryMinResultsUsed" ? "Postgres min results" : key === "postgresQueryFillPolicyUsed" ? "Postgres fill policy" : key === "sqliteQueryJsRemainderRatio" ? "SQLite JS remainder share" : key === "postgresQueryJsRemainderRatio" ? "Postgres JS remainder share" : key === "sqliteQueryFilteredCandidates" ? "SQLite filtered candidates" : key === "postgresQueryFilteredCandidates" ? "Postgres filtered candidates" : key === "sqliteQueryInitialSearchK" ? "SQLite initial searchK" : key === "postgresQueryInitialSearchK" ? "Postgres initial searchK" : key === "sqliteQueryFinalSearchK" ? "SQLite final searchK" : key === "postgresQueryFinalSearchK" ? "Postgres final searchK" : key === "sqliteQuerySearchExpansionRatio" ? "SQLite search expansion" : key === "postgresQuerySearchExpansionRatio" ? "Postgres search expansion" : key === "sqliteQueryBackfillCount" ? "SQLite backfill count" : key === "sqliteQueryBackfillLimitReached" ? "SQLite backfill limit reached" : key === "sqliteQueryMinResultsSatisfied" ? "SQLite min results satisfied" : key === "postgresQueryBackfillCount" ? "Postgres backfill count" : key === "postgresQueryBackfillLimitReached" ? "Postgres backfill limit reached" : key === "postgresQueryMinResultsSatisfied" ? "Postgres min results satisfied" : key === "sqliteQueryReturnedCount" ? "SQLite returned hits" : key === "postgresQueryReturnedCount" ? "Postgres returned hits" : key === "sqliteQueryCandidateYieldRatio" ? "SQLite candidate yield" : key === "postgresQueryCandidateYieldRatio" ? "Postgres candidate yield" : key === "sqliteQueryTopKFillRatio" ? "SQLite topK fill rate" : key === "postgresQueryTopKFillRatio" ? "Postgres topK fill rate" : key === "sqliteQueryUnderfilledTopK" ? "SQLite underfilled topK" : key === "postgresQueryUnderfilledTopK" ? "Postgres underfilled topK" : key === "sqliteQueryCandidateBudgetExhausted" ? "SQLite candidate budget exhausted" : key === "postgresQueryCandidateBudgetExhausted" ? "Postgres candidate budget exhausted" : key === "sqliteQueryCandidateCoverage" ? "SQLite candidate coverage" : key === "postgresQueryCandidateCoverage" ? "Postgres candidate coverage" : key === "leadSpeakerCue" ? "Lead speaker cue" : key === "leadSpeakerAttributionCue" ? "Lead speaker attribution" : key === "leadChannelAttributionCue" ? "Lead channel attribution" : key === "leadChannelCue" ? "Lead channel cue" : key === "leadContinuityCue" ? "Lead continuity cue" : key,
753
753
  value: key === "sourceAwareChunkReason" ? formatSourceAwareChunkReason(value) ?? formatRAGTraceValue(value) : key === "leadSpeakerAttributionCue" ? formatLeadSpeakerAttributionCue(value) ?? formatRAGTraceValue(value) : key === "leadChannelAttributionCue" ? formatLeadChannelAttributionCue(value) ?? formatRAGTraceValue(value) : key === "leadContinuityCue" ? formatLeadContinuityCue(value) ?? formatRAGTraceValue(value) : formatRAGTraceValue(value)
754
754
  });
755
755
  var buildRAGRetrievalTracePresentation = (trace) => {
@@ -2521,6 +2521,7 @@ var formatSQLitePlannerCueSummary = (input) => {
2521
2521
  typeof input?.sqliteQueryPushdownClauseCount === "number" ? `clauses ${input.sqliteQueryPushdownClauseCount}` : undefined,
2522
2522
  typeof input?.sqliteQueryPushdownCoverageRatio === "number" ? `pushdown ${(input.sqliteQueryPushdownCoverageRatio * 100).toFixed(0)}%` : undefined,
2523
2523
  typeof input?.sqliteQueryJsRemainderClauseCount === "number" ? `js remainder ${input.sqliteQueryJsRemainderClauseCount}` : undefined,
2524
+ input?.sqliteQueryPlannerProfileUsed ? `profile ${input.sqliteQueryPlannerProfileUsed}` : undefined,
2524
2525
  typeof input?.sqliteQueryMultiplierUsed === "number" ? `x${input.sqliteQueryMultiplierUsed}` : undefined,
2525
2526
  typeof input?.sqliteQueryCandidateLimitUsed === "number" ? `cap ${input.sqliteQueryCandidateLimitUsed}` : undefined,
2526
2527
  typeof input?.sqliteQueryMaxBackfillsUsed === "number" ? `backfills ${input.sqliteQueryMaxBackfillsUsed}` : undefined,
@@ -2553,6 +2554,7 @@ var formatPostgresPlannerCueSummary = (input) => {
2553
2554
  typeof input?.postgresQueryPushdownClauseCount === "number" ? `clauses ${input.postgresQueryPushdownClauseCount}` : undefined,
2554
2555
  typeof input?.postgresQueryPushdownCoverageRatio === "number" ? `pushdown ${(input.postgresQueryPushdownCoverageRatio * 100).toFixed(0)}%` : undefined,
2555
2556
  typeof input?.postgresQueryJsRemainderClauseCount === "number" ? `js remainder ${input.postgresQueryJsRemainderClauseCount}` : undefined,
2557
+ input?.postgresQueryPlannerProfileUsed ? `profile ${input.postgresQueryPlannerProfileUsed}` : undefined,
2556
2558
  typeof input?.postgresQueryMultiplierUsed === "number" ? `x${input.postgresQueryMultiplierUsed}` : undefined,
2557
2559
  typeof input?.postgresQueryCandidateLimitUsed === "number" ? `cap ${input.postgresQueryCandidateLimitUsed}` : undefined,
2558
2560
  typeof input?.postgresQueryMaxBackfillsUsed === "number" ? `backfills ${input.postgresQueryMaxBackfillsUsed}` : undefined,
@@ -16662,6 +16664,37 @@ var prepareRAGDirectoryDocuments = async (input) => prepareRAGDocuments(await lo
16662
16664
 
16663
16665
  // src/ai/rag/collection.ts
16664
16666
  var DEFAULT_TOP_K2 = 6;
16667
+ var resolveNativeQueryProfile = (input) => {
16668
+ if (!input.profile) {
16669
+ return;
16670
+ }
16671
+ if (input.profile === "latency") {
16672
+ return {
16673
+ candidateLimit: Math.max(1, Math.min(input.candidateTopK, input.topK)),
16674
+ fillPolicy: "satisfy_min_results",
16675
+ maxBackfills: 0,
16676
+ minResults: 1,
16677
+ plannerProfile: input.profile,
16678
+ queryMultiplier: 1
16679
+ };
16680
+ }
16681
+ if (input.profile === "recall") {
16682
+ return {
16683
+ fillPolicy: "strict_topk",
16684
+ maxBackfills: 4,
16685
+ minResults: input.topK,
16686
+ plannerProfile: input.profile,
16687
+ queryMultiplier: 8
16688
+ };
16689
+ }
16690
+ return {
16691
+ fillPolicy: "satisfy_min_results",
16692
+ maxBackfills: 1,
16693
+ minResults: Math.max(1, Math.min(input.topK, Math.ceil(input.topK / 2))),
16694
+ plannerProfile: input.profile,
16695
+ queryMultiplier: 4
16696
+ };
16697
+ };
16665
16698
  var VARIANT_RESULT_WEIGHT = 0.92;
16666
16699
  var normalizeTraceCueText = (value) => value.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim().replace(/\s+/g, " ");
16667
16700
  var queryIncludesTraceCue = (query, value) => {
@@ -16991,6 +17024,7 @@ var buildStoreQueryPlanTraceMetadata = (store) => {
16991
17024
  sqliteQueryTotalFilterClauseCount: sqliteNativePlan.totalFilterClauseCount,
16992
17025
  sqliteQueryJsRemainderClauseCount: sqliteNativePlan.jsRemainderClauseCount,
16993
17026
  sqliteQueryMultiplierUsed: sqliteNativePlan.queryMultiplierUsed ?? null,
17027
+ sqliteQueryPlannerProfileUsed: sqliteNativePlan.plannerProfileUsed ?? null,
16994
17028
  sqliteQueryCandidateLimitUsed: sqliteNativePlan.candidateLimitUsed ?? null,
16995
17029
  sqliteQueryMaxBackfillsUsed: sqliteNativePlan.maxBackfillsUsed ?? null,
16996
17030
  sqliteQueryMinResultsUsed: sqliteNativePlan.minResultsUsed ?? null,
@@ -17024,6 +17058,7 @@ var buildStoreQueryPlanTraceMetadata = (store) => {
17024
17058
  postgresQueryTotalFilterClauseCount: postgresNativePlan.totalFilterClauseCount,
17025
17059
  postgresQueryJsRemainderClauseCount: postgresNativePlan.jsRemainderClauseCount,
17026
17060
  postgresQueryMultiplierUsed: postgresNativePlan.queryMultiplierUsed ?? null,
17061
+ postgresQueryPlannerProfileUsed: postgresNativePlan.plannerProfileUsed ?? null,
17027
17062
  postgresQueryCandidateLimitUsed: postgresNativePlan.candidateLimitUsed ?? null,
17028
17063
  postgresQueryMaxBackfillsUsed: postgresNativePlan.maxBackfillsUsed ?? null,
17029
17064
  postgresQueryMinResultsUsed: postgresNativePlan.minResultsUsed ?? null,
@@ -17154,6 +17189,11 @@ var createRAGCollection = (options) => {
17154
17189
  });
17155
17190
  }
17156
17191
  const resultGroups = await Promise.all(searchQueries.map(async (query, queryIndex) => {
17192
+ const nativeQueryProfile = resolveNativeQueryProfile({
17193
+ candidateTopK,
17194
+ profile: input.nativeQueryProfile,
17195
+ topK
17196
+ });
17157
17197
  const [vectorResults2, lexicalResults2] = await Promise.all([
17158
17198
  runVector ? embed({
17159
17199
  model,
@@ -17161,11 +17201,12 @@ var createRAGCollection = (options) => {
17161
17201
  text: query
17162
17202
  }, "query").then((nextQueryVector) => options.store.query({
17163
17203
  filter: input.filter,
17164
- candidateLimit: input.nativeCandidateLimit,
17165
- fillPolicy: input.nativeFillPolicy,
17166
- maxBackfills: input.nativeMaxBackfills,
17167
- minResults: input.nativeMinResults,
17168
- queryMultiplier: input.nativeQueryMultiplier,
17204
+ candidateLimit: input.nativeCandidateLimit ?? nativeQueryProfile?.candidateLimit,
17205
+ fillPolicy: input.nativeFillPolicy ?? nativeQueryProfile?.fillPolicy,
17206
+ maxBackfills: input.nativeMaxBackfills ?? nativeQueryProfile?.maxBackfills,
17207
+ minResults: input.nativeMinResults ?? nativeQueryProfile?.minResults,
17208
+ plannerProfile: nativeQueryProfile?.plannerProfile,
17209
+ queryMultiplier: input.nativeQueryMultiplier ?? nativeQueryProfile?.queryMultiplier,
17169
17210
  queryVector: nextQueryVector,
17170
17211
  topK: candidateTopK
17171
17212
  })) : Promise.resolve([]),
@@ -22155,6 +22196,7 @@ var ragChat = (config) => {
22155
22196
  }
22156
22197
  const input = {
22157
22198
  filter: getObjectProperty(body, "filter"),
22199
+ nativeQueryProfile: body.nativeQueryProfile === "latency" || body.nativeQueryProfile === "balanced" || body.nativeQueryProfile === "recall" ? body.nativeQueryProfile : undefined,
22158
22200
  nativeCandidateLimit: typeof body.nativeCandidateLimit === "number" ? body.nativeCandidateLimit : undefined,
22159
22201
  nativeMaxBackfills: typeof body.nativeMaxBackfills === "number" ? body.nativeMaxBackfills : undefined,
22160
22202
  nativeMinResults: typeof body.nativeMinResults === "number" ? body.nativeMinResults : undefined,
@@ -26388,6 +26430,8 @@ var DEFAULT_DIRECTORY_EXTENSIONS2 = [
26388
26430
  ".yml",
26389
26431
  ".pdf"
26390
26432
  ];
26433
+ var DEFAULT_GITHUB_EXTENSION_FILTER = DEFAULT_DIRECTORY_EXTENSIONS2;
26434
+ var DEFAULT_GITHUB_MAX_DEPTH = 12;
26391
26435
  var isSyncExtractionFailure = (message) => message.startsWith("No RAG file extractor matched") || message.includes("could not extract readable text from this PDF") || message.includes("detected malformed JSONL") || message.includes("detected malformed CSV") || message.includes("detected malformed TSV") || message.includes("detected malformed XML") || message.includes("detected malformed YAML") || message.startsWith("RAG extractor ") || message.includes("extract failed");
26392
26436
  var inferSyncExtractionRemediation = (message) => {
26393
26437
  if (message.includes("could not extract readable text from this PDF")) {
@@ -27629,6 +27673,248 @@ var loadDiscoveredURLDocuments = async (input) => {
27629
27673
  }
27630
27674
  };
27631
27675
  };
27676
+ var normalizeGitHubPath = (path) => path?.trim().replace(/^[\\/]+/g, "").replace(/[\\]+/g, "/").replace(/\/+/g, "/").replace(/\/$/, "");
27677
+ var normalizeGitHubPathFilter = (path) => normalizeGitHubPath(path)?.toLowerCase();
27678
+ var matchesPathFilter = (path, pattern) => {
27679
+ const normalizedPath = normalizeGitHubPath(path)?.toLowerCase();
27680
+ const normalizedPattern = normalizeGitHubPathFilter(pattern);
27681
+ if (!normalizedPath || !normalizedPattern) {
27682
+ return false;
27683
+ }
27684
+ const isDirectory = normalizedPattern.endsWith("/");
27685
+ const patternWithoutTrailingSlash = isDirectory ? normalizedPattern.replace(/\/$/, "") : normalizedPattern;
27686
+ if (normalizedPath === patternWithoutTrailingSlash) {
27687
+ return true;
27688
+ }
27689
+ if (isDirectory && normalizedPath.startsWith(`${patternWithoutTrailingSlash}/`)) {
27690
+ return true;
27691
+ }
27692
+ return normalizedPath.includes(normalizedPattern);
27693
+ };
27694
+ var shouldIncludeGitHubPath = (path, input) => {
27695
+ const normalizedPath = normalizeGitHubPath(path)?.toLowerCase();
27696
+ if (!normalizedPath) {
27697
+ return false;
27698
+ }
27699
+ const extension = normalizedPath.includes(".") ? normalizedPath.slice(normalizedPath.lastIndexOf(".")) : "";
27700
+ if (!input.includeExtensions.has(extension)) {
27701
+ return false;
27702
+ }
27703
+ if ((input.includePaths?.length ?? 0) > 0) {
27704
+ const matchedInclude = input.includePaths?.some((pattern) => matchesPathFilter(normalizedPath, pattern));
27705
+ if (!matchedInclude) {
27706
+ return false;
27707
+ }
27708
+ }
27709
+ if ((input.excludePaths?.length ?? 0) > 0) {
27710
+ if ((input.excludePaths ?? []).some((pattern) => matchesPathFilter(normalizedPath, pattern))) {
27711
+ return false;
27712
+ }
27713
+ }
27714
+ return true;
27715
+ };
27716
+ var buildGitHubHeaders = (token) => {
27717
+ if (!token) {
27718
+ return;
27719
+ }
27720
+ return {
27721
+ Authorization: `Bearer ${token}`,
27722
+ Accept: "application/vnd.github+json",
27723
+ "X-GitHub-Api-Version": "2022-11-28"
27724
+ };
27725
+ };
27726
+ var buildGitHubContentsURL = (input) => {
27727
+ const apiBase = input.apiBaseURL.replace(/\/$/, "");
27728
+ const normalizedPath = normalizeGitHubPath(input.path);
27729
+ const encodedPath = normalizedPath?.split("/").filter(Boolean).map((segment) => encodeURIComponent(segment)).join("/") ?? "";
27730
+ const endpoint = `/repos/${encodeURIComponent(input.repo.owner)}/${encodeURIComponent(input.repo.repo)}/contents`;
27731
+ const url = new URL(encodedPath ? `${endpoint}/${encodedPath}` : endpoint, `${apiBase}/`);
27732
+ if (input.branch) {
27733
+ url.searchParams.set("ref", input.branch);
27734
+ }
27735
+ url.searchParams.set("per_page", "100");
27736
+ return url.toString();
27737
+ };
27738
+ var parseGitHubContents = async (response, path) => {
27739
+ const body = await response.json();
27740
+ if (Array.isArray(body)) {
27741
+ return body;
27742
+ }
27743
+ if (body && typeof body === "object" && typeof body.type === "string") {
27744
+ return [body];
27745
+ }
27746
+ throw new Error(`Unexpected GitHub contents response at ${path}`);
27747
+ };
27748
+ var buildGitHubRawURL = (input) => {
27749
+ if (input.fallbackDownloadURL && typeof input.fallbackDownloadURL === "string") {
27750
+ return input.fallbackDownloadURL;
27751
+ }
27752
+ const branch = input.branch ?? "main";
27753
+ const encodedPath = normalizeGitHubPath(input.path)?.split("/").filter(Boolean).map((segment) => encodeURIComponent(segment)).join("/") ?? "";
27754
+ return `https://raw.githubusercontent.com/${encodeURIComponent(input.repo.owner)}/${encodeURIComponent(input.repo.repo)}/${encodeURIComponent(branch)}/${encodedPath}`;
27755
+ };
27756
+ var loadDiscoveredGitHubRepositoryFiles = async (input) => {
27757
+ const queue = [
27758
+ { depth: 0, path: normalizeGitHubPath(input.repo.pathPrefix) }
27759
+ ];
27760
+ const seen = new Set;
27761
+ const collected = [];
27762
+ while (queue.length > 0) {
27763
+ const current = queue.shift();
27764
+ if (!current) {
27765
+ continue;
27766
+ }
27767
+ const currentPath = normalizeGitHubPath(current.path) ?? "";
27768
+ if (seen.has(currentPath)) {
27769
+ continue;
27770
+ }
27771
+ seen.add(currentPath);
27772
+ const requestURL = buildGitHubContentsURL({
27773
+ apiBaseURL: input.apiBaseURL,
27774
+ branch: input.branch ?? input.repo.branch,
27775
+ path: currentPath,
27776
+ repo: input.repo
27777
+ });
27778
+ const response = await fetch(requestURL, {
27779
+ headers: input.requestHeaders
27780
+ });
27781
+ if (!response.ok) {
27782
+ throw new Error(`Failed to list GitHub repo contents at ${currentPath || `${input.repo.owner}/${input.repo.repo}`}: ${response.status} ${response.statusText}`);
27783
+ }
27784
+ const entries = await parseGitHubContents(response, requestURL);
27785
+ for (const entry of entries) {
27786
+ if (typeof entry.path !== "string" || typeof entry.type !== "string") {
27787
+ continue;
27788
+ }
27789
+ if (entry.type === "file") {
27790
+ if (!shouldIncludeGitHubPath(entry.path, {
27791
+ excludePaths: input.repo.excludePaths,
27792
+ includeExtensions: input.includeExtensions,
27793
+ includePaths: input.repo.includePaths
27794
+ })) {
27795
+ continue;
27796
+ }
27797
+ const repoBranch = input.repo.branch ?? input.branch;
27798
+ const fileURL = buildGitHubRawURL({
27799
+ repo: input.repo,
27800
+ branch: repoBranch,
27801
+ fallbackDownloadURL: entry.download_url,
27802
+ path: entry.path
27803
+ });
27804
+ const fileRepo = `${input.repo.owner}/${input.repo.repo}`;
27805
+ collected.push({
27806
+ repository: fileRepo,
27807
+ repoBranch,
27808
+ repoPath: currentPath,
27809
+ metadata: {
27810
+ ...input.defaults?.repoMetadata ?? {},
27811
+ repo: fileRepo,
27812
+ repoBranch,
27813
+ repoName: input.repo.repo,
27814
+ repoOwner: input.repo.owner,
27815
+ repoPath: entry.path,
27816
+ ...input.repo.metadata ?? {},
27817
+ source: input.source
27818
+ },
27819
+ source: input.source,
27820
+ path: entry.path,
27821
+ title: `${input.repo.owner}/${input.repo.repo}:${entry.path}`,
27822
+ url: fileURL
27823
+ });
27824
+ if (typeof input.maxFilesPerRepo === "number" && collected.length >= input.maxFilesPerRepo) {
27825
+ return collected;
27826
+ }
27827
+ continue;
27828
+ }
27829
+ if (entry.type === "dir" && current.depth < input.maxDepth) {
27830
+ queue.push({ depth: current.depth + 1, path: entry.path });
27831
+ }
27832
+ }
27833
+ }
27834
+ return collected;
27835
+ };
27836
+ var buildGitHubExtensionSet = (value) => {
27837
+ const extensionValues = value === undefined || value.length === 0 ? DEFAULT_GITHUB_EXTENSION_FILTER : value;
27838
+ const extensions = new Set;
27839
+ for (const raw of extensionValues) {
27840
+ const normalized = typeof raw === "string" && raw.trim().length > 0 ? raw.trim().startsWith(".") ? raw.trim().toLowerCase() : `.${raw.trim().toLowerCase()}` : undefined;
27841
+ if (normalized) {
27842
+ extensions.add(normalized);
27843
+ }
27844
+ }
27845
+ if (extensions.size === 0) {
27846
+ for (const extension of DEFAULT_GITHUB_EXTENSION_FILTER) {
27847
+ extensions.add(extension);
27848
+ }
27849
+ }
27850
+ return extensions;
27851
+ };
27852
+ var createRAGGitHubSyncSource = (options) => ({
27853
+ description: options.description,
27854
+ id: options.id,
27855
+ kind: "url",
27856
+ label: options.label,
27857
+ metadata: options.metadata,
27858
+ retryAttempts: options.retryAttempts,
27859
+ retryDelayMs: options.retryDelayMs,
27860
+ target: options.repos.length === 1 ? `${options.repos[0]?.owner ?? "unknown"}/${options.repos[0]?.repo ?? "repo"}` : `${options.repos.length} repos`,
27861
+ sync: async ({ collection, deleteDocument, listDocuments }) => {
27862
+ const requestHeaders = buildGitHubHeaders(options.token);
27863
+ const extensionFilter = buildGitHubExtensionSet(options.includeExtensions);
27864
+ const apiBaseURL = options.apiBaseUrl?.trim().replace(/\/$/, "") || "https://api.github.com";
27865
+ const maxDepth = Math.max(0, Math.min(options.maxDepth ?? DEFAULT_GITHUB_MAX_DEPTH, 64));
27866
+ const discoveredFiles = (await Promise.all(options.repos.map(async (repo) => {
27867
+ return loadDiscoveredGitHubRepositoryFiles({
27868
+ branch: repo.branch,
27869
+ apiBaseURL,
27870
+ includeExtensions: extensionFilter,
27871
+ maxDepth,
27872
+ maxFilesPerRepo: options.maxFilesPerRepo,
27873
+ repo,
27874
+ requestHeaders,
27875
+ source: options.label,
27876
+ defaults: {
27877
+ repoMetadata: {
27878
+ repoOwner: repo.owner,
27879
+ repoName: repo.repo,
27880
+ repoBranch: repo.branch,
27881
+ repoPrefix: repo.pathPrefix ?? ""
27882
+ }
27883
+ }
27884
+ });
27885
+ }))).flat();
27886
+ const result = await loadDiscoveredURLDocuments({
27887
+ baseMetadata: options.baseMetadata,
27888
+ chunkingRegistry: options.chunkingRegistry,
27889
+ collection,
27890
+ defaultChunking: options.defaultChunking,
27891
+ deleteDocument,
27892
+ extractorRegistry: options.extractorRegistry,
27893
+ extractors: options.extractors,
27894
+ listDocuments,
27895
+ sourceId: options.id,
27896
+ urlEntries: discoveredFiles.map((entry) => ({
27897
+ metadata: {
27898
+ ...entry.metadata,
27899
+ repoPath: entry.path,
27900
+ repoBranch: entry.repoBranch,
27901
+ repo: entry.repository,
27902
+ sourcePath: entry.path
27903
+ },
27904
+ title: entry.title,
27905
+ url: entry.url
27906
+ }))
27907
+ });
27908
+ return {
27909
+ ...result,
27910
+ metadata: {
27911
+ ...result.metadata ?? {},
27912
+ discoveredFileCount: discoveredFiles.length,
27913
+ repoCount: options.repos.length
27914
+ }
27915
+ };
27916
+ }
27917
+ });
27632
27918
  var createRAGFeedSyncSource = (options) => ({
27633
27919
  description: options.description,
27634
27920
  id: options.id,
@@ -29023,6 +29309,26 @@ var buildPostgresFilterPlan = (filter, startIndex = 0) => {
29023
29309
  const comparison = operator === "$gt" ? ">" : operator === "$gte" ? ">=" : operator === "$lt" ? "<" : "<=";
29024
29310
  return `((${actualSql}) ~ '^-?[0-9]+(\\.[0-9]+)?$' AND (${actualSql})::double precision ${comparison} ${bind(expected)})`;
29025
29311
  }
29312
+ case "$contains":
29313
+ if (isScalarField) {
29314
+ return null;
29315
+ }
29316
+ if (toPostgresFilterBinding(expected) === undefined) {
29317
+ return null;
29318
+ }
29319
+ return `(${metadataValueSql} IS NOT NULL AND ${metadataValueSql} ? ${bind(String(expected))})`;
29320
+ case "$containsAny":
29321
+ case "$containsAll": {
29322
+ if (isScalarField || !Array.isArray(expected)) {
29323
+ return null;
29324
+ }
29325
+ const values = expected.map((entry2) => toPostgresFilterBinding(entry2)).filter((entry2) => entry2 !== undefined);
29326
+ if (values.length === 0 || values.length !== expected.length) {
29327
+ return null;
29328
+ }
29329
+ const sqlArray = `ARRAY[${values.map((value2) => bind(String(value2))).join(", ")}]::text[]`;
29330
+ return `(${metadataValueSql} IS NOT NULL AND ${metadataValueSql} ${operator === "$containsAny" ? "?|" : "?&"} ${sqlArray})`;
29331
+ }
29026
29332
  default:
29027
29333
  return null;
29028
29334
  }
@@ -29063,7 +29369,7 @@ var buildPostgresPushdownFilter = (filter) => {
29063
29369
  }
29064
29370
  continue;
29065
29371
  }
29066
- if (Array.isArray(value) || isOperatorFilterRecord(value) && Object.keys(value).some((operator) => operator === "$contains" || operator === "$containsAny" || operator === "$containsAll")) {
29372
+ if (Array.isArray(value) || isOperatorFilterRecord(value) && Object.keys(value).some((operator) => !(operator === "$exists" || operator === "$in" || operator === "$contains" || operator === "$containsAny" || operator === "$containsAll" || operator === "$ne" || operator === "$gt" || operator === "$gte" || operator === "$lt" || operator === "$lte"))) {
29067
29373
  continue;
29068
29374
  }
29069
29375
  const isScalarColumnKey = ["chunkId", "source", "title"].includes(key);
@@ -29216,6 +29522,7 @@ var updatePostgresLastQueryPlan = (input) => {
29216
29522
  maxBackfillsUsed: input.maxBackfillsUsed,
29217
29523
  minResultsUsed: input.minResultsUsed,
29218
29524
  fillPolicyUsed: input.fillPolicyUsed,
29525
+ plannerProfileUsed: input.plannerProfileUsed,
29219
29526
  jsRemainderClauseCount: pushdown.jsRemainderClauseCount,
29220
29527
  queryMultiplierUsed: input.queryMultiplierUsed,
29221
29528
  jsRemainderRatio: pushdown.jsRemainderRatio,
@@ -29404,6 +29711,7 @@ var createPostgresRAGStore = (options = {}) => {
29404
29711
  maxBackfillsUsed: maxBackfills,
29405
29712
  minResultsUsed: minResults,
29406
29713
  fillPolicyUsed: fillTarget.fillPolicy,
29714
+ plannerProfileUsed: input.plannerProfile,
29407
29715
  filter: input.filter,
29408
29716
  pushdownFilter,
29409
29717
  queryMultiplierUsed: queryMultiplier2,
@@ -30225,6 +30533,7 @@ var updateSQLiteLastQueryPlan = (input) => {
30225
30533
  initialSearchK: input.initialSearchK,
30226
30534
  searchExpansionRatio: typeof input.initialSearchK === "number" && typeof input.finalSearchK === "number" && input.initialSearchK > 0 ? input.finalSearchK / input.initialSearchK : undefined,
30227
30535
  jsRemainderClauseCount: pushdown.jsRemainderClauseCount,
30536
+ plannerProfileUsed: input.plannerProfileUsed,
30228
30537
  candidateLimitUsed: input.candidateLimitUsed,
30229
30538
  maxBackfillsUsed: input.maxBackfillsUsed,
30230
30539
  minResultsUsed: input.minResultsUsed,
@@ -30376,6 +30685,7 @@ var createSQLiteRAGStore = (options = {}) => {
30376
30685
  initialSearchK: rawRows.length,
30377
30686
  nativeDiagnostics,
30378
30687
  pushdownFilter,
30688
+ plannerProfileUsed: input.plannerProfile,
30379
30689
  queryMultiplierUsed: input.queryMultiplier,
30380
30690
  queryMode: "json_fallback",
30381
30691
  returnedCount: limited.length,
@@ -30482,6 +30792,7 @@ var createSQLiteRAGStore = (options = {}) => {
30482
30792
  initialSearchK: searchK,
30483
30793
  nativeDiagnostics,
30484
30794
  pushdownFilter,
30795
+ plannerProfileUsed: input.plannerProfile,
30485
30796
  candidateLimitUsed: candidateLimit,
30486
30797
  maxBackfillsUsed: maxBackfills,
30487
30798
  minResultsUsed: minResults,
@@ -32572,6 +32883,7 @@ export {
32572
32883
  createRAGHTMXConfig,
32573
32884
  createRAGGraphEmailSyncClient,
32574
32885
  createRAGGmailEmailSyncClient,
32886
+ createRAGGitHubSyncSource,
32575
32887
  createRAGFileSyncStateStore,
32576
32888
  createRAGFileSearchTraceStore,
32577
32889
  createRAGFileSearchTracePruneHistoryStore,
@@ -32657,5 +32969,5 @@ export {
32657
32969
  addRAGEvaluationSuiteCase
32658
32970
  };
32659
32971
 
32660
- //# debugId=690A2FC8A2432BC964756E2164756E21
32972
+ //# debugId=7B7D71C6EA35C8D164756E2164756E21
32661
32973
  //# sourceMappingURL=index.js.map