@agentproto/corpus-cli 0.5.0 → 0.7.0

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.
@@ -1,5 +1,5 @@
1
1
  export { N as NodeFsAdapter, a as NodeFsAdapterOptions, O as OsIdentityAdapter, b as OsIdentityAdapterOptions } from '../os-identity.adapter-CLBmnRoD.js';
2
- import { FetcherPort, FetchedSource, DistillPort, DistillInput, DistilledItem, SinkPort, SinkItem, SinkPushResult } from '@agentproto/corpus';
2
+ import { FetcherPort, FetchedSource, PrSourcePort, PrQuery, PrDoc, DistillPort, DistillInput, DistilledItem, SinkPort, SinkItem, SinkPushResult } from '@agentproto/corpus';
3
3
  export { buildDistillPrompt, parseItems } from '@agentproto/corpus';
4
4
  import { z } from 'zod';
5
5
 
@@ -357,6 +357,119 @@ declare class HttpReadabilityFetcher implements FetcherPort {
357
357
  fetch(url: string): Promise<FetchedSource | null>;
358
358
  }
359
359
 
360
+ /**
361
+ * PdfFetcher — a browser-free FetcherPort for PDF documents. Downloads
362
+ * the file with plain `fetch` (no headless browser needed) and extracts
363
+ * text with `unpdf` — a pure-JS wrapper around a serverless build of
364
+ * Mozilla's pdf.js, no native binary (no poppler/pdftotext install
365
+ * required). Mirrors {@link HttpReadabilityFetcher}'s shape: same
366
+ * fetch-then-sniff routing, same "return null when it's not mine, throw
367
+ * on a hard failure" contract.
368
+ *
369
+ * Routing (first-non-null-wins CompositeFetcher, see composite-fetcher.ts):
370
+ * claims a URL when EITHER the path ends in `.pdf` (query string
371
+ * ignored) OR the response's `content-type` is `application/pdf` — the
372
+ * second case matters most in practice: court registries and
373
+ * jurisprudence portals routinely serve PDFs from extension-less URLs
374
+ * (`/decisions/12345`, not `/decisions/12345.pdf`). Anything else
375
+ * returns `null` so a downstream fetcher (readability, browser) takes it.
376
+ *
377
+ * A legal/regulatory PDF is cited BY PAGE, so page boundaries are
378
+ * preserved in the extracted text as explicit `--- page N of M ---`
379
+ * markers rather than being merged into one undifferentiated blob.
380
+ *
381
+ * Fails LOUDLY — never returns an empty/partial source in silence — on:
382
+ * - a URL that matched by extension/content-type but isn't really a
383
+ * PDF (magic-bytes check: must start with `%PDF-`)
384
+ * - a password-protected / encrypted PDF (pdf.js throws
385
+ * `PasswordException` before any page can be read)
386
+ * - a scanned PDF with no text layer (0 characters extracted across
387
+ * every page) — this is the case that must NOT look like "checked,
388
+ * nothing there": it means "this needs OCR", a different problem.
389
+ *
390
+ * Provenance survives into the corpus frontmatter via
391
+ * `FetchedSource.metadata`, which `WebImporter` merges verbatim into
392
+ * `corpusMetadata` (→ `metadata.corpus.*` in the archived source's
393
+ * frontmatter): page count, the PDF file's own sha256 (what makes the
394
+ * source independently verifiable), and the document-info title/author/
395
+ * producer/creation/modification dates when the PDF carries them.
396
+ *
397
+ * The actual PDF decoding (bytes → per-page text + doc info) is injected
398
+ * as `extract` — same pattern as {@link YtDlpWhisperFetcher}'s
399
+ * `download`/`stt` seams — so this adapter is unit-testable with a fake
400
+ * extractor and no real PDF parsing, while the default wires the real
401
+ * `unpdf` engine.
402
+ */
403
+
404
+ /** Per-page text + the PDF's own Info dictionary, decoded from raw bytes. */
405
+ interface PdfExtraction {
406
+ readonly totalPages: number;
407
+ readonly pageTexts: readonly string[];
408
+ /** The PDF Info dictionary as pdf.js reports it (Title/Author/Producer/CreationDate/ModDate/…). */
409
+ readonly info: Readonly<Record<string, unknown>>;
410
+ }
411
+ /**
412
+ * Decode PDF bytes into per-page text + document info. Rejects with a
413
+ * pdf.js `PasswordException` (`.name === "PasswordException"`) for an
414
+ * encrypted/password-protected document — the fetcher classifies that
415
+ * itself; this function does not swallow it. Real implementation uses
416
+ * `unpdf`; inject a fake for tests.
417
+ */
418
+ type PdfExtractor = (bytes: Uint8Array) => Promise<PdfExtraction>;
419
+ interface PdfFetcherOptions {
420
+ readonly userAgent?: string;
421
+ /** Abort the download after this many ms. Default 60_000. */
422
+ readonly timeoutMs?: number;
423
+ /** Defaults to a real `unpdf`-backed extractor. Inject a fake for tests. */
424
+ readonly extract?: PdfExtractor;
425
+ }
426
+ declare class PdfFetcher implements FetcherPort {
427
+ private readonly ua;
428
+ private readonly timeoutMs;
429
+ private readonly extract;
430
+ constructor(opts?: PdfFetcherOptions);
431
+ fetch(url: string): Promise<FetchedSource | null>;
432
+ }
433
+
434
+ /**
435
+ * GhPrSourceAdapter — a PrSourcePort backed by the GitHub CLI (`gh`). This is
436
+ * how the local `corpus` runtime resolves a repo query to its pull requests:
437
+ * the SAME `gh` binary the rest of the repo already talks to GitHub through
438
+ * (see the daemon's `gh pr create` lane), reusing the user's existing `gh`
439
+ * auth — no new HTTP client, no token plumbing in the corpus layer.
440
+ *
441
+ * query → gh pr list --repo <repo> --json number … (enumerate)
442
+ * → gh pr view <n> --repo <repo> --json … (per-PR detail)
443
+ *
444
+ * Per-PR resilience lives HERE, not in the pure importer: a single PR that
445
+ * `gh pr view` cannot fetch (deleted, permission) is skipped with a stderr
446
+ * notice and simply not yielded, so one bad PR never aborts the batch. A
447
+ * failure to even *list* PRs (bad repo, `gh` unauthenticated) throws — that is
448
+ * a hard batch abort the importer surfaces.
449
+ *
450
+ * The `gh` invocation is injected as `run` so the adapter is unit-testable with
451
+ * a fake runner — no binary, no network. All `gh` JSON is parsed through zod;
452
+ * no `any` crosses the boundary.
453
+ */
454
+
455
+ /** Run a `gh` subcommand and resolve its stdout. Injectable for tests. */
456
+ type GhRunner = (args: readonly string[]) => Promise<string>;
457
+ interface GhPrSourceAdapterOptions {
458
+ /** Defaults to a `gh` subprocess runner. */
459
+ readonly run?: GhRunner;
460
+ /** Path to the `gh` binary (default: "gh" on PATH). */
461
+ readonly ghBin?: string;
462
+ }
463
+ declare class GhPrSourceAdapter implements PrSourcePort {
464
+ private readonly run;
465
+ constructor(opts?: GhPrSourceAdapterOptions);
466
+ listPullRequests(query: PrQuery): AsyncIterable<PrDoc>;
467
+ /** Resolve the query to a concrete, capped list of PR numbers. */
468
+ private resolveNumbers;
469
+ /** Fetch one PR's detail and shape it into a PrDoc, or null if empty. */
470
+ private viewPr;
471
+ }
472
+
360
473
  /**
361
474
  * Usage telemetry for the metered distill path — cost visibility + optional
362
475
  * Langfuse export. SDK-free (raw fetch to Langfuse's ingestion API), mirroring
@@ -570,4 +683,4 @@ declare class McpSink implements SinkPort {
570
683
  push(item: SinkItem): Promise<SinkPushResult>;
571
684
  }
572
685
 
573
- export { AnthropicDistiller, type AnthropicDistillerOptions, AssemblyAiStt, type AssemblyAiSttOptions, type AudioDownload, type AudioDownloader, type AudioSplitter, BrowserMcpFetcher, type BrowserMcpFetcherOptions, type BrowserMcpLike, CLI_ENGINES, ChunkedStt, type ChunkedSttOptions, CliAgentDistiller, type CliAgentDistillerOptions, type CliEngine, CompositeFetcher, type ConnectMcpHttpOptions, HttpReadabilityFetcher, type HttpReadabilityFetcherOptions, type McpClientLike, McpSink, type McpSinkConfig, OpenAiWhisperStt, type OpenAiWhisperSttOptions, ScrapeMcpFetcher, type ScrapeMcpFetcherOptions, type SttPort, ThrottleFetcher, type ThrottleFetcherOptions, type Transcript, YtDlpWhisperFetcher, type YtDlpWhisperFetcherOptions, connectMcpHttp };
686
+ export { AnthropicDistiller, type AnthropicDistillerOptions, AssemblyAiStt, type AssemblyAiSttOptions, type AudioDownload, type AudioDownloader, type AudioSplitter, BrowserMcpFetcher, type BrowserMcpFetcherOptions, type BrowserMcpLike, CLI_ENGINES, ChunkedStt, type ChunkedSttOptions, CliAgentDistiller, type CliAgentDistillerOptions, type CliEngine, CompositeFetcher, type ConnectMcpHttpOptions, GhPrSourceAdapter, type GhPrSourceAdapterOptions, type GhRunner, HttpReadabilityFetcher, type HttpReadabilityFetcherOptions, type McpClientLike, McpSink, type McpSinkConfig, OpenAiWhisperStt, type OpenAiWhisperSttOptions, type PdfExtraction, type PdfExtractor, PdfFetcher, type PdfFetcherOptions, ScrapeMcpFetcher, type ScrapeMcpFetcherOptions, type SttPort, ThrottleFetcher, type ThrottleFetcherOptions, type Transcript, YtDlpWhisperFetcher, type YtDlpWhisperFetcherOptions, connectMcpHttp };
@@ -1,4 +1,4 @@
1
- import { randomBytes } from 'crypto';
1
+ import { randomBytes, createHash } from 'crypto';
2
2
  import { stat, readFile, mkdir, writeFile, rename, appendFile, readdir, rm, mkdtemp } from 'fs/promises';
3
3
  import path, { join, basename, extname } from 'path';
4
4
  import { existsSync } from 'fs';
@@ -8,6 +8,7 @@ import { execFile } from 'child_process';
8
8
  import { promisify } from 'util';
9
9
  import { normalizeLanguageTag, buildDistillPrompt, parseItems } from '@agentproto/corpus';
10
10
  export { buildDistillPrompt, parseItems } from '@agentproto/corpus';
11
+ import { getDocumentProxy, extractText as extractText$1, getMeta } from 'unpdf';
11
12
  import { parseClaudeJsonOutput, spawnWithStdin } from '@agentproto/cli-exec';
12
13
 
13
14
  /**
@@ -761,6 +762,306 @@ function extractReadable(html) {
761
762
  function decodeEntities(s) {
762
763
  return s.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&nbsp;/g, " ").replace(/&#(\d+);/g, (_, n) => String.fromCharCode(Number(n)));
763
764
  }
765
+ var PDF_MAGIC = "%PDF-";
766
+ var DEFAULT_UA2 = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0 Safari/537.36";
767
+ async function defaultPdfExtractor(bytes) {
768
+ const pdf = await getDocumentProxy(bytes);
769
+ const [extracted, meta] = await Promise.all([
770
+ extractText$1(pdf, { mergePages: false }),
771
+ getMeta(pdf, { parseDates: true })
772
+ ]);
773
+ return { totalPages: extracted.totalPages, pageTexts: extracted.text, info: meta.info };
774
+ }
775
+ var PdfFetcher = class {
776
+ ua;
777
+ timeoutMs;
778
+ extract;
779
+ constructor(opts = {}) {
780
+ this.ua = opts.userAgent ?? DEFAULT_UA2;
781
+ this.timeoutMs = opts.timeoutMs ?? 6e4;
782
+ this.extract = opts.extract ?? defaultPdfExtractor;
783
+ }
784
+ async fetch(url) {
785
+ let res;
786
+ try {
787
+ res = await fetch(url, {
788
+ headers: { "user-agent": this.ua },
789
+ redirect: "follow",
790
+ signal: AbortSignal.timeout(this.timeoutMs)
791
+ });
792
+ } catch {
793
+ return null;
794
+ }
795
+ if (!res.ok) return null;
796
+ const contentType = res.headers.get("content-type") ?? "";
797
+ const byExtension = isPdfExtension(url);
798
+ const byContentType = contentType.toLowerCase().includes("application/pdf");
799
+ if (!byExtension && !byContentType) return null;
800
+ const buffer = await res.arrayBuffer();
801
+ const bytes = new Uint8Array(buffer);
802
+ const magic = decodeAscii(bytes.slice(0, 5));
803
+ if (magic !== PDF_MAGIC) {
804
+ throw new Error(
805
+ `not a PDF: ${url} (magic bytes: ${JSON.stringify(magic)}, content-type: ${contentType || "none"})`
806
+ );
807
+ }
808
+ const sha256 = "sha256:" + createHash("sha256").update(bytes).digest("hex");
809
+ let extraction;
810
+ try {
811
+ extraction = await this.extract(bytes);
812
+ } catch (e) {
813
+ if (isPasswordProtected(e)) {
814
+ throw new Error(`PDF is password-protected/encrypted: ${url}`);
815
+ }
816
+ throw new Error(`failed to open PDF: ${url} (${msg2(e)})`);
817
+ }
818
+ const { totalPages, pageTexts, info } = extraction;
819
+ const hasText = pageTexts.some((t) => t.trim().length > 0);
820
+ if (!hasText) {
821
+ throw new Error(
822
+ `PDF has no extractable text layer (scanned document, not OCR'd): ${url} \u2014 ${totalPages} page(s), 0 characters extracted`
823
+ );
824
+ }
825
+ const text = pageTexts.map((t, i) => `--- page ${i + 1} of ${totalPages} ---
826
+
827
+ ${t.trim()}`).join("\n\n");
828
+ const pdfTitle = stringField(info, "Title");
829
+ const pdfAuthor = stringField(info, "Author");
830
+ const pdfProducer = stringField(info, "Producer");
831
+ const pdfCreatedAt = dateField(info, "CreationDate");
832
+ const pdfModifiedAt = dateField(info, "ModDate");
833
+ return {
834
+ title: pdfTitle || titleFromUrl(url),
835
+ text,
836
+ kind: "pdf",
837
+ via: "extraction",
838
+ metadata: {
839
+ pdfPageCount: totalPages,
840
+ pdfSha256: sha256,
841
+ ...pdfTitle ? { pdfTitle } : {},
842
+ ...pdfAuthor ? { pdfAuthor } : {},
843
+ ...pdfProducer ? { pdfProducer } : {},
844
+ ...pdfCreatedAt ? { pdfCreatedAt } : {},
845
+ ...pdfModifiedAt ? { pdfModifiedAt } : {}
846
+ }
847
+ };
848
+ }
849
+ };
850
+ function isPdfExtension(url) {
851
+ try {
852
+ return /\.pdf$/i.test(new URL(url).pathname);
853
+ } catch {
854
+ return false;
855
+ }
856
+ }
857
+ function decodeAscii(bytes) {
858
+ let out = "";
859
+ for (const b of bytes) out += String.fromCharCode(b);
860
+ return out;
861
+ }
862
+ function isPasswordProtected(e) {
863
+ if (!(e instanceof Error)) return false;
864
+ return e.name === "PasswordException" || /password/i.test(e.message);
865
+ }
866
+ function stringField(info, key) {
867
+ const v = info[key];
868
+ return typeof v === "string" && v.trim() ? v.trim() : void 0;
869
+ }
870
+ function dateField(info, key) {
871
+ const v = info[key];
872
+ return v instanceof Date && !Number.isNaN(v.getTime()) ? v.toISOString() : void 0;
873
+ }
874
+ function titleFromUrl(url) {
875
+ try {
876
+ const last = new URL(url).pathname.split("/").filter(Boolean).pop();
877
+ return last ? decodeURIComponent(last) : url;
878
+ } catch {
879
+ return url;
880
+ }
881
+ }
882
+ function msg2(e) {
883
+ return e instanceof Error ? e.message : String(e);
884
+ }
885
+ var execFileAsync3 = promisify(execFile);
886
+ var GH_ACTOR = z.object({ login: z.string().optional(), name: z.string().optional() }).loose();
887
+ var GH_PR_LIST_ITEM = z.object({ number: z.number() }).loose();
888
+ var GH_PR_LIST = z.array(GH_PR_LIST_ITEM);
889
+ var GH_COMMENT = z.object({
890
+ author: GH_ACTOR.nullish(),
891
+ body: z.string().optional(),
892
+ path: z.string().optional(),
893
+ createdAt: z.string().optional(),
894
+ submittedAt: z.string().optional()
895
+ }).loose();
896
+ var GH_FILE = z.object({
897
+ path: z.string(),
898
+ additions: z.number().optional(),
899
+ deletions: z.number().optional()
900
+ }).loose();
901
+ var GH_PR_VIEW = z.object({
902
+ number: z.number(),
903
+ title: z.string().optional(),
904
+ body: z.string().optional(),
905
+ author: GH_ACTOR.nullish(),
906
+ url: z.string().optional(),
907
+ state: z.string().optional(),
908
+ mergedAt: z.string().nullish(),
909
+ reviews: z.array(GH_COMMENT).optional(),
910
+ comments: z.array(GH_COMMENT).optional(),
911
+ reviewRequests: z.array(GH_ACTOR).optional(),
912
+ additions: z.number().optional(),
913
+ deletions: z.number().optional(),
914
+ changedFiles: z.number().optional(),
915
+ files: z.array(GH_FILE).optional()
916
+ }).loose();
917
+ var VIEW_FIELDS = [
918
+ "number",
919
+ "title",
920
+ "body",
921
+ "author",
922
+ "url",
923
+ "state",
924
+ "mergedAt",
925
+ "reviews",
926
+ "comments",
927
+ "reviewRequests",
928
+ "additions",
929
+ "deletions",
930
+ "changedFiles",
931
+ "files"
932
+ ].join(",");
933
+ var GhPrSourceAdapter = class {
934
+ run;
935
+ constructor(opts = {}) {
936
+ this.run = opts.run ?? defaultGhRunner(opts.ghBin ?? "gh");
937
+ }
938
+ async *listPullRequests(query) {
939
+ const numbers = await this.resolveNumbers(query);
940
+ for (const n of numbers) {
941
+ let pr;
942
+ try {
943
+ pr = await this.viewPr(query, n);
944
+ } catch (e) {
945
+ process.stderr.write(
946
+ `corpus: skipping ${query.repo}#${n} \u2014 ${msg3(e)}
947
+ `
948
+ );
949
+ continue;
950
+ }
951
+ if (pr) yield pr;
952
+ }
953
+ }
954
+ /** Resolve the query to a concrete, capped list of PR numbers. */
955
+ async resolveNumbers(query) {
956
+ const cap = query.maxPRs ?? 1e3;
957
+ if (query.prNumbers && query.prNumbers.length > 0) {
958
+ return query.prNumbers.slice(0, cap);
959
+ }
960
+ const args = [
961
+ "pr",
962
+ "list",
963
+ "--repo",
964
+ query.repo,
965
+ "--state",
966
+ "all",
967
+ "--limit",
968
+ String(cap),
969
+ "--json",
970
+ "number"
971
+ ];
972
+ if (query.since) args.push("--search", `updated:>=${query.since}`);
973
+ const out = await this.run(args);
974
+ return GH_PR_LIST.parse(parseJson(out)).map((item) => item.number).sort((a, b) => a - b);
975
+ }
976
+ /** Fetch one PR's detail and shape it into a PrDoc, or null if empty. */
977
+ async viewPr(query, number) {
978
+ const out = await this.run([
979
+ "pr",
980
+ "view",
981
+ String(number),
982
+ "--repo",
983
+ query.repo,
984
+ "--json",
985
+ VIEW_FIELDS
986
+ ]);
987
+ const v = GH_PR_VIEW.parse(parseJson(out));
988
+ const reviewComments = toReviewComments([
989
+ ...v.reviews ?? [],
990
+ ...v.comments ?? []
991
+ ]);
992
+ const reviewers = uniqueLogins([
993
+ ...(v.reviews ?? []).map((r) => r.author),
994
+ ...v.reviewRequests ?? []
995
+ ]);
996
+ const doc = {
997
+ number: v.number,
998
+ title: v.title ?? "",
999
+ body: v.body ?? "",
1000
+ ...actorLabel(v.author) ? { author: actorLabel(v.author) } : {},
1001
+ ...v.url ? { url: v.url } : {},
1002
+ ...v.state ? { state: v.state.toLowerCase() } : {},
1003
+ ...v.mergedAt ? { mergedAt: v.mergedAt } : {},
1004
+ ...reviewers.length > 0 ? { reviewers } : {},
1005
+ ...reviewComments.length > 0 ? { reviewComments } : {},
1006
+ ...query.includeDiffSummary ? { diffSummary: buildDiffSummary(v) } : {}
1007
+ };
1008
+ return doc;
1009
+ }
1010
+ };
1011
+ function actorLabel(actor) {
1012
+ const label = actor?.login ?? actor?.name;
1013
+ return label && label.length > 0 ? label : void 0;
1014
+ }
1015
+ function toReviewComments(raw) {
1016
+ const out = [];
1017
+ for (const c of raw) {
1018
+ const body = (c.body ?? "").trim();
1019
+ if (!body) continue;
1020
+ const author = actorLabel(c.author);
1021
+ const at = c.submittedAt ?? c.createdAt;
1022
+ out.push({
1023
+ body,
1024
+ ...author ? { author } : {},
1025
+ ...c.path ? { path: c.path } : {},
1026
+ ...at ? { at } : {}
1027
+ });
1028
+ }
1029
+ return out;
1030
+ }
1031
+ function uniqueLogins(actors) {
1032
+ const seen = /* @__PURE__ */ new Set();
1033
+ for (const a of actors) {
1034
+ const label = actorLabel(a);
1035
+ if (label) seen.add(label);
1036
+ }
1037
+ return [...seen];
1038
+ }
1039
+ function buildDiffSummary(v) {
1040
+ const lines = [];
1041
+ for (const f of v.files ?? []) {
1042
+ const add = f.additions ?? 0;
1043
+ const del = f.deletions ?? 0;
1044
+ lines.push(`${f.path} | +${add} -${del}`);
1045
+ }
1046
+ const totals = v.changedFiles !== void 0 ? `${v.changedFiles} files changed, +${v.additions ?? 0} -${v.deletions ?? 0}` : void 0;
1047
+ return [...totals ? [totals] : [], ...lines].join("\n");
1048
+ }
1049
+ function parseJson(out) {
1050
+ const trimmed = out.trim();
1051
+ if (!trimmed) return [];
1052
+ return JSON.parse(trimmed);
1053
+ }
1054
+ function msg3(e) {
1055
+ return e instanceof Error ? e.message : String(e);
1056
+ }
1057
+ function defaultGhRunner(bin) {
1058
+ return async (args) => {
1059
+ const { stdout } = await execFileAsync3(bin, [...args], {
1060
+ maxBuffer: 32 * 1024 * 1024
1061
+ });
1062
+ return stdout;
1063
+ };
1064
+ }
764
1065
 
765
1066
  // src/ports/anthropic-distiller.ts
766
1067
  var ANTHROPIC_RESPONSE = z.object({
@@ -1084,10 +1385,10 @@ var SseMcpClient = class {
1084
1385
  try {
1085
1386
  const parsed = RPC_MESSAGE.safeParse(JSON.parse(payload));
1086
1387
  if (!parsed.success) return;
1087
- const msg3 = parsed.data;
1088
- if (typeof msg3.id === "number" && this.pending.has(msg3.id)) {
1089
- this.pending.get(msg3.id)(msg3);
1090
- this.pending.delete(msg3.id);
1388
+ const msg5 = parsed.data;
1389
+ if (typeof msg5.id === "number" && this.pending.has(msg5.id)) {
1390
+ this.pending.get(msg5.id)(msg5);
1391
+ this.pending.delete(msg5.id);
1091
1392
  }
1092
1393
  } catch {
1093
1394
  }
@@ -1154,7 +1455,7 @@ var McpSink = class {
1154
1455
  try {
1155
1456
  client = await this.ensure();
1156
1457
  } catch (e) {
1157
- return { uri: item.uri, ok: false, error: `connect: ${msg2(e)}` };
1458
+ return { uri: item.uri, ok: false, error: `connect: ${msg4(e)}` };
1158
1459
  }
1159
1460
  const args = template(this.config.args, item);
1160
1461
  const call = this.config.importedAlias ? { name: "mcp_imported_call", args: { alias: this.config.importedAlias, toolName: this.config.tool, args } } : { name: this.config.tool, args };
@@ -1163,7 +1464,7 @@ var McpSink = class {
1163
1464
  if (res.isError) return { uri: item.uri, ok: false, error: "tool returned isError" };
1164
1465
  return { uri: item.uri, ok: true };
1165
1466
  } catch (e) {
1166
- return { uri: item.uri, ok: false, error: msg2(e) };
1467
+ return { uri: item.uri, ok: false, error: msg4(e) };
1167
1468
  }
1168
1469
  }
1169
1470
  };
@@ -1207,10 +1508,10 @@ function stringify(v) {
1207
1508
  if (Array.isArray(v)) return v.join(", ");
1208
1509
  return v == null ? "" : String(v);
1209
1510
  }
1210
- function msg2(e) {
1511
+ function msg4(e) {
1211
1512
  return e instanceof Error ? e.message : String(e);
1212
1513
  }
1213
1514
 
1214
- export { AnthropicDistiller, AssemblyAiStt, BrowserMcpFetcher, CLI_ENGINES, ChunkedStt, CliAgentDistiller, CompositeFetcher, HttpReadabilityFetcher, McpSink, NodeFsAdapter, OpenAiWhisperStt, OsIdentityAdapter, ScrapeMcpFetcher, ThrottleFetcher, YtDlpWhisperFetcher, connectMcpHttp };
1515
+ export { AnthropicDistiller, AssemblyAiStt, BrowserMcpFetcher, CLI_ENGINES, ChunkedStt, CliAgentDistiller, CompositeFetcher, GhPrSourceAdapter, HttpReadabilityFetcher, McpSink, NodeFsAdapter, OpenAiWhisperStt, OsIdentityAdapter, PdfFetcher, ScrapeMcpFetcher, ThrottleFetcher, YtDlpWhisperFetcher, connectMcpHttp };
1215
1516
  //# sourceMappingURL=index.mjs.map
1216
1517
  //# sourceMappingURL=index.mjs.map