@sourcegraph/amp 0.0.1748937736-gb61f9e → 0.0.1748952139-g3a80f1
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/amp.js +3 -3
- package/dist/client-eeeVpbOj.js +55 -0
- package/dist/client-eeeVpbOj.js.map +1 -0
- package/dist/{console-Dok1Wcwn.js → console-CN5EK-5f.js} +667 -662
- package/dist/console-CN5EK-5f.js.map +1 -0
- package/dist/{create_file.node-C-YeOXhP.js → create_file.node-BPbwLrpo.js} +2 -2
- package/dist/{create_file.node-C-YeOXhP.js.map → create_file.node-BPbwLrpo.js.map} +1 -1
- package/dist/{edit_file.node-Cvsfx7pt.js → edit_file.node-CoKkV9T6.js} +3 -3
- package/dist/{edit_file.node-Cvsfx7pt.js.map → edit_file.node-CoKkV9T6.js.map} +1 -1
- package/dist/{executable-DmtB95BF.js → executable-Dbw4UQsn.js} +2 -2
- package/dist/{executable-DmtB95BF.js.map → executable-Dbw4UQsn.js.map} +1 -1
- package/dist/{files-4uCbUmV7.js → files-vC7gbodq.js} +2 -2
- package/dist/{files-4uCbUmV7.js.map → files-vC7gbodq.js.map} +1 -1
- package/dist/{glob.node-RP059oWX.js → glob.node-Br1inBMB.js} +4 -4
- package/dist/{glob.node-RP059oWX.js.map → glob.node-Br1inBMB.js.map} +1 -1
- package/dist/{index-CPC32RPi.js → index-Dgb2bOc6.js} +2 -2
- package/dist/{index-CPC32RPi.js.map → index-Dgb2bOc6.js.map} +1 -1
- package/dist/{list_directory.node-JfCvF09W.js → list_directory.node-DGkXRIzx.js} +2 -2
- package/dist/{list_directory.node-JfCvF09W.js.map → list_directory.node-DGkXRIzx.js.map} +1 -1
- package/dist/{load-profile-CLxEjyWl.js → load-profile-DvvdVESK.js} +2 -2
- package/dist/{load-profile-CLxEjyWl.js.map → load-profile-DvvdVESK.js.map} +1 -1
- package/dist/{main-DpQQJHE4.js → main-CcCjhyno.js} +1229 -1248
- package/dist/main-CcCjhyno.js.map +1 -0
- package/dist/{node-Bjgpi_MV.js → node-BWA8OH3Y.js} +3 -3
- package/dist/{node-Bjgpi_MV.js.map → node-BWA8OH3Y.js.map} +1 -1
- package/dist/{node-CHXrHmHR.js → node-BlIuu9mO.js} +2 -2
- package/dist/{node-CHXrHmHR.js.map → node-BlIuu9mO.js.map} +1 -1
- package/dist/node-CFZqx9i7.js +43 -0
- package/dist/node-CFZqx9i7.js.map +1 -0
- package/dist/{node-3gS1o4eu.js → node-DrR1mumq.js} +4 -4
- package/dist/{node-3gS1o4eu.js.map → node-DrR1mumq.js.map} +1 -1
- package/dist/{node-D2BIeojc.js → node-bCOCJc2z.js} +2 -2
- package/dist/{node-D2BIeojc.js.map → node-bCOCJc2z.js.map} +1 -1
- package/dist/{node-CdCbaOgJ.js → node-uQP2zFCU.js} +3 -3
- package/dist/{node-CdCbaOgJ.js.map → node-uQP2zFCU.js.map} +1 -1
- package/dist/{read_file.node-BEjFBYF8.js → read_file.node-B_mwwcms.js} +2 -2
- package/dist/{read_file.node-BEjFBYF8.js.map → read_file.node-B_mwwcms.js.map} +1 -1
- package/dist/{stdio-h4IgaI9t.js → stdio-CbcJDG9x.js} +3 -3
- package/dist/{stdio-h4IgaI9t.js.map → stdio-CbcJDG9x.js.map} +1 -1
- package/dist/storybook.js +1 -1
- package/dist/{undo_edit.node-DnT_lcaR.js → undo_edit.node-CymsB0Md.js} +2 -2
- package/dist/{undo_edit.node-DnT_lcaR.js.map → undo_edit.node-CymsB0Md.js.map} +1 -1
- package/package.json +1 -1
- package/dist/client-TG0TgWWB.js +0 -35
- package/dist/client-TG0TgWWB.js.map +0 -1
- package/dist/console-Dok1Wcwn.js.map +0 -1
- package/dist/main-DpQQJHE4.js.map +0 -1
- package/dist/node-B0o5uOa2.js +0 -26
- package/dist/node-B0o5uOa2.js.map +0 -1
@@ -4,7 +4,7 @@ import * as i from "node:fs";
|
|
4
4
|
import * as o from "node:path";
|
5
5
|
import { join as f } from "node:path";
|
6
6
|
import { promisify as p } from "node:util";
|
7
|
-
import { C as l, aI as n } from "./console-
|
7
|
+
import { C as l, aI as n } from "./console-CN5EK-5f.js";
|
8
8
|
import { homedir as w } from "node:os";
|
9
9
|
const d = f(w(), ".amp", "file-changes"), u = p(m);
|
10
10
|
function b(a) {
|
@@ -110,4 +110,4 @@ export {
|
|
110
110
|
y as listFilesGit,
|
111
111
|
b as nodeFileSystem
|
112
112
|
};
|
113
|
-
//# sourceMappingURL=node-
|
113
|
+
//# sourceMappingURL=node-BlIuu9mO.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"node-
|
1
|
+
{"version":3,"file":"node-BlIuu9mO.js","sources":["../../core/src/platform/fs/backups.node.ts","../../core/src/platform/fs/node.ts"],"sourcesContent":["import { homedir } from 'node:os'\nimport { join } from 'node:path'\n\nexport const BACKUP_DIR_NODE = join(homedir(), '.amp', 'file-changes')\n","import { execFile } from 'node:child_process'\nimport * as fs from 'node:fs'\nimport * as path from 'node:path'\nimport { promisify } from 'node:util'\nimport logger from '../../common/logger'\nimport { type FileChangeRecord } from '../../threads/file-tracking/common'\nimport type { ThreadID } from '../../threads/thread'\nimport { BACKUP_DIR_NODE } from './backups.node'\nimport { FileNotExistError, type FileSystem } from './fs'\n\nconst execFileAsync = promisify(execFile)\n\nexport function nodeFileSystem(threadID: ThreadID): FileSystem {\n\tconst backupDir = path.join(BACKUP_DIR_NODE, threadID)\n\treturn {\n\t\trelativePath: (a: string, b: string) => path.relative(a, b),\n\t\tjoinPath: (...paths: string[]) => path.join(...paths),\n\n\t\treadFile: async (path: string, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\treturn await fs.promises.readFile(path, { encoding: 'utf8', signal })\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\treadBinaryFile: async (path: string, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\t// Read as Buffer without encoding\n\t\t\t\treturn await fs.promises.readFile(path, { signal })\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\tgetMtime: async (path: string, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\t// Node.js stat doesn't support AbortSignal directly\n\t\t\t\tconst stats = await fs.promises.stat(path)\n\t\t\t\treturn stats.mtimeMs\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\tstat: async (path: string) => {\n\t\t\ttry {\n\t\t\t\tconst stats = await fs.promises.stat(path)\n\t\t\t\treturn {\n\t\t\t\t\tsize: stats.size,\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\twriteFile: async (path, content, signal) => {\n\t\t\tawait fs.promises.writeFile(path, content, { encoding: 'utf-8', signal })\n\t\t},\n\t\tdeleteFile: async (path, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\tawait fs.promises.unlink(path)\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\tmkdirp: async (path) => {\n\t\t\tawait fs.promises.mkdir(path, { recursive: true })\n\t\t},\n\t\tstoreFileChange: async (backupFileName: string, fileChange: FileChangeRecord) => {\n\t\t\tconst backupPath = path.join(backupDir, backupFileName)\n\t\t\tawait fs.promises.writeFile(backupPath, JSON.stringify(fileChange, null, 2), 'utf8')\n\t\t},\n\t\tlistBackupFiles: async () => {\n\t\t\ttry {\n\t\t\t\t// Ensure backup directory exists\n\t\t\t\tif (\n\t\t\t\t\t!(await fs.promises\n\t\t\t\t\t\t.stat(backupDir)\n\t\t\t\t\t\t.then((s) => s.isDirectory())\n\t\t\t\t\t\t.catch(() => false))\n\t\t\t\t) {\n\t\t\t\t\tawait fs.promises.mkdir(backupDir, { recursive: true })\n\t\t\t\t\treturn []\n\t\t\t\t}\n\t\t\t\treturn await fs.promises.readdir(backupDir)\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error('Error listing backup files:', error)\n\t\t\t\treturn []\n\t\t\t}\n\t\t},\n\t\tloadFileChange: async (backupFileName: string) => {\n\t\t\ttry {\n\t\t\t\tconst backupPath = path.join(backupDir, backupFileName)\n\t\t\t\tconst content = await fs.promises.readFile(backupPath, 'utf8')\n\t\t\t\treturn JSON.parse(content) as FileChangeRecord\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(`Error loading backup file ${backupFileName}:`, error)\n\t\t\t\treturn null\n\t\t\t}\n\t\t},\n\t\tcleanupBackupFiles: async () => {\n\t\t\ttry {\n\t\t\t\tif (\n\t\t\t\t\tawait fs.promises\n\t\t\t\t\t\t.stat(backupDir)\n\t\t\t\t\t\t.then((s) => s.isDirectory())\n\t\t\t\t\t\t.catch(() => false)\n\t\t\t\t) {\n\t\t\t\t\tawait fs.promises.rm(backupDir, { recursive: true, force: true })\n\t\t\t\t\tlogger.debug(`Cleaned up backup directory: ${backupDir}`)\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(`Error cleaning up backup files in ${backupDir}:`, error)\n\t\t\t}\n\t\t},\n\t\tlistFiles: async (dir: string) => listFilesGit(dir),\n\t\texclusiveWriter: false,\n\t}\n}\n\nfunction isNodeFSNotExistError(error: unknown): boolean {\n\treturn (\n\t\terror !== null &&\n\t\ttypeof error === 'object' &&\n\t\t'code' in error &&\n\t\t(error as { code: string }).code === 'ENOENT'\n\t)\n}\n\n/**\n * Lists files in a directory using git ls-files.\n * Exported for reuse by other filesystem implementations.\n */\nexport async function listFilesGit(dir: string): Promise<string[]> {\n\ttry {\n\t\tconst { stdout: trackedFiles } = await execFileAsync('git', ['ls-files'], {\n\t\t\tcwd: dir,\n\t\t})\n\n\t\tconst { stdout: untrackedFiles } = await execFileAsync(\n\t\t\t'git',\n\t\t\t['ls-files', '--others', '--exclude-standard'],\n\t\t\t{\n\t\t\t\tcwd: dir,\n\t\t\t},\n\t\t)\n\n\t\treturn [...trackedFiles.split('\\n'), ...untrackedFiles.split('\\n')].filter(Boolean)\n\t} catch {\n\t\treturn []\n\t}\n}\n"],"names":["BACKUP_DIR_NODE","join","homedir","execFileAsync","promisify","execFile","nodeFileSystem","threadID","backupDir","path","a","b","paths","signal","fs","error","isNodeFSNotExistError","FileNotExistError","content","backupFileName","fileChange","backupPath","s","logger","dir","listFilesGit","trackedFiles","untrackedFiles"],"mappings":";;;;;;;;AAGO,MAAMA,IAAkBC,EAAKC,KAAW,QAAQ,cAAc,GCO/DC,IAAgBC,EAAUC,CAAQ;AAEjC,SAASC,EAAeC,GAAgC;AAC9D,QAAMC,IAAYC,EAAK,KAAKT,GAAiBO,CAAQ;AAC9C,SAAA;AAAA,IACN,cAAc,CAACG,GAAWC,MAAcF,EAAK,SAASC,GAAGC,CAAC;AAAA,IAC1D,UAAU,IAAIC,MAAoBH,EAAK,KAAK,GAAGG,CAAK;AAAA,IAEpD,UAAU,OAAOH,GAAcI,MAAyB;AACnD,UAAA;AACI,eAAA,MAAMC,EAAG,SAAS,SAASL,GAAM,EAAE,UAAU,QAAQ,QAAAI,GAAQ;AAAA,eAC5DE,GAAO;AACX,cAAAC,EAAsBD,CAAK,IACxB,IAAIE,EAAkBR,CAAI,IAE3BM;AAAA,MAAA;AAAA,IAER;AAAA,IACA,gBAAgB,OAAON,GAAcI,MAAyB;AACzD,UAAA;AAEH,eAAO,MAAMC,EAAG,SAAS,SAASL,GAAM,EAAE,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zE,KAAKqB;AAAA,IAAA,CACL,GAEK,EAAE,QAAQG,EAAe,IAAI,MAAMxB;AAAA,MACxC;AAAA,MACA,CAAC,YAAY,YAAY,oBAAoB;AAAA,MAC7C;AAAA,QACC,KAAKqB;AAAA,MAAA;AAAA,IAEP;AAEA,WAAO,CAAC,GAAGE,EAAa,MAAM;AAAA,CAAI,GAAG,GAAGC,EAAe,MAAM;AAAA,CAAI,CAAC,EAAE,OAAO,OAAO;AAAA,EAAA,QAC3E;AACP,WAAO,CAAC;AAAA,EAAA;AAEV;"}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
import { i as a, F as c, f as i } from "./client-eeeVpbOj.js";
|
3
|
+
import { p as m, aQ as l } from "./console-CN5EK-5f.js";
|
4
|
+
const h = ({ args: e }, { threadID: o }) => m(async (s) => {
|
5
|
+
try {
|
6
|
+
const r = await a.webSearch(
|
7
|
+
{
|
8
|
+
query: e.query,
|
9
|
+
numResults: e.num_results || 5,
|
10
|
+
thread: o
|
11
|
+
},
|
12
|
+
{ signal: s }
|
13
|
+
);
|
14
|
+
if (!r.ok)
|
15
|
+
throw new Error(
|
16
|
+
`Failed to perform web search: ${r.error.message || "Unknown error"}`
|
17
|
+
);
|
18
|
+
return {
|
19
|
+
status: "done",
|
20
|
+
result: r.result
|
21
|
+
};
|
22
|
+
} catch {
|
23
|
+
if (c) {
|
24
|
+
const n = `/api/web-search?query=${encodeURIComponent(e.query)}&numResults=${e.num_results || 5}`, t = await i(n, {
|
25
|
+
method: "GET",
|
26
|
+
signal: s,
|
27
|
+
headers: o ? { [l]: o } : void 0
|
28
|
+
});
|
29
|
+
if (!t.ok) {
|
30
|
+
const u = await t.text();
|
31
|
+
throw new Error(`Server returned ${t.status}: ${u}`);
|
32
|
+
}
|
33
|
+
return {
|
34
|
+
status: "done",
|
35
|
+
result: await t.json()
|
36
|
+
};
|
37
|
+
}
|
38
|
+
}
|
39
|
+
});
|
40
|
+
export {
|
41
|
+
h as nodeWebSearchTool
|
42
|
+
};
|
43
|
+
//# sourceMappingURL=node-CFZqx9i7.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"node-CFZqx9i7.js","sources":["../../core/src/tools/builtin/web_search/node.ts"],"sourcesContent":["import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport { fetchFromAmpServer } from '../../../server-api/client'\nimport { HEADER_KEY_THREAD_ID } from '../../../server-api/headers'\nimport {\n\tFALLBACK_TO_OLD_INTERNAL_API,\n\tinternalAPIClient,\n} from '../../../server-api/internal-api-client'\nimport type { webSearchToolReg } from './common'\n\nexport const nodeWebSearchTool: NonNullable<(typeof webSearchToolReg)['fn']> = (\n\t{ args },\n\t{ threadID },\n) => {\n\treturn promiseFactoryToObservable(async (signal) => {\n\t\ttry {\n\t\t\tconst resp = await internalAPIClient.webSearch(\n\t\t\t\t{\n\t\t\t\t\tquery: args.query,\n\t\t\t\t\tnumResults: args.num_results || 5,\n\t\t\t\t\tthread: threadID,\n\t\t\t\t},\n\t\t\t\t{ signal },\n\t\t\t)\n\t\t\tif (!resp.ok) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to perform web search: ${resp.error.message || 'Unknown error'}`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tstatus: 'done' as const,\n\t\t\t\tresult: resp.result,\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (FALLBACK_TO_OLD_INTERNAL_API) {\n\t\t\t\t// Fallback to old API\n\t\t\t\tconst url = `/api/web-search?query=${encodeURIComponent(args.query)}&numResults=${args.num_results || 5}`\n\t\t\t\tconst response = await fetchFromAmpServer(url, {\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\tsignal,\n\t\t\t\t\theaders: threadID ? { [HEADER_KEY_THREAD_ID]: threadID } : undefined,\n\t\t\t\t})\n\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tconst errorText = await response.text()\n\t\t\t\t\tthrow new Error(`Server returned ${response.status}: ${errorText}`)\n\t\t\t\t}\n\n\t\t\t\tconst results = await response.json()\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'done' as const,\n\t\t\t\t\tresult: results,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t}\n\t})\n}\n"],"names":["nodeWebSearchTool","args","threadID","promiseFactoryToObservable","signal","resp","internalAPIClient","FALLBACK_TO_OLD_INTERNAL_API","url","response","fetchFromAmpServer","HEADER_KEY_THREAD_ID","errorText"],"mappings":";;;AASO,MAAMA,IAAkE,CAC9E,EAAE,MAAAC,KACF,EAAE,UAAAC,QAEKC,EAA2B,OAAOC,MAAW;AAC/C,MAAA;AACG,UAAAC,IAAO,MAAMC,EAAkB;AAAA,MACpC;AAAA,QACC,OAAOL,EAAK;AAAA,QACZ,YAAYA,EAAK,eAAe;AAAA,QAChC,QAAQC;AAAA,MACT;AAAA,MACA,EAAE,QAAAE,EAAO;AAAA,IACV;AACI,QAAA,CAACC,EAAK;AACT,YAAM,IAAI;AAAA,QACT,iCAAiCA,EAAK,MAAM,WAAW,eAAe;AAAA,MACvE;AAGM,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,QAAQA,EAAK;AAAA,IACd;AAAA,UACe;AACf,QAAIE,GAA8B;AAE3B,YAAAC,IAAM,yBAAyB,mBAAmBP,EAAK,KAAK,CAAC,eAAeA,EAAK,eAAe,CAAC,IACjGQ,IAAW,MAAMC,EAAmBF,GAAK;AAAA,QAC9C,QAAQ;AAAA,QACR,QAAAJ;AAAA,QACA,SAASF,IAAW,EAAE,CAACS,CAAoB,GAAGT,EAAa,IAAA;AAAA,MAAA,CAC3D;AAEG,UAAA,CAACO,EAAS,IAAI;AACX,cAAAG,IAAY,MAAMH,EAAS,KAAK;AACtC,cAAM,IAAI,MAAM,mBAAmBA,EAAS,MAAM,KAAKG,CAAS,EAAE;AAAA,MAAA;AAI5D,aAAA;AAAA,QACN,QAAQ;AAAA,QACR,QAHe,MAAMH,EAAS,KAAK;AAAA,MAIpC;AAAA,IAAA;AAAA,EAGD;AACD,CACA;"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import { p as f } from "./index-
|
3
|
-
import { aB as m, g, m as c, aM as h, aN as d, aO as b, aP as E, c as S, O as _ } from "./console-
|
4
|
-
import { r as v } from "./executable-
|
2
|
+
import { p as f } from "./index-Dgb2bOc6.js";
|
3
|
+
import { aB as m, g, m as c, aM as h, aN as d, aO as b, aP as E, c as S, O as _ } from "./console-CN5EK-5f.js";
|
4
|
+
import { r as v } from "./executable-Dbw4UQsn.js";
|
5
5
|
const O = ({ args: a }, { dirs: s }) => {
|
6
6
|
for (const e of s)
|
7
7
|
m(e);
|
@@ -82,4 +82,4 @@ export {
|
|
82
82
|
O as nodeGrepTool,
|
83
83
|
P as ripgrepFiles
|
84
84
|
};
|
85
|
-
//# sourceMappingURL=node-
|
85
|
+
//# sourceMappingURL=node-DrR1mumq.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"node-
|
1
|
+
{"version":3,"file":"node-DrR1mumq.js","sources":["../../core/src/tools/builtin/grep/node.ts"],"sourcesContent":["import { catchError, combineLatest, map, Observable } from '@sourcegraph/observable'\nimport pm from 'picomatch'\nimport type { ToolRun } from '../../tool-service'\nimport { checkArgSafety, checkDirURIIsFile, spawnAndObserveChildProcess } from '../node-helpers'\nimport type { GrepToolArgs } from './common'\nimport {\n\tGREP_MAX_COLUMN_LENGTH,\n\tGREP_MAX_RESULTS_PER_FILE,\n\ttype GrepToolDef,\n\ttype grepToolReg,\n} from './common'\nimport { ripgrepExecutable } from './executable'\n\nexport const nodeGrepTool: NonNullable<(typeof grepToolReg)['fn']> = ({ args }, { dirs }) => {\n\tfor (const dir of dirs) {\n\t\tcheckDirURIIsFile(dir)\n\t}\n\treturn combineLatest(...dirs.map((dir) => ripgrepFiles(dir.fsPath, args))).pipe(\n\t\tmap<ToolRun<GrepToolDef>[], ToolRun<GrepToolDef>>((results) => {\n\t\t\tconst progress: string[] = []\n\t\t\tfor (const result of results) {\n\t\t\t\tif (result.status === 'in-progress') {\n\t\t\t\t\tprogress.push(...(result?.progress ?? []))\n\t\t\t\t} else if (result.status === 'done') {\n\t\t\t\t\tprogress.push(...result.result)\n\t\t\t\t} else if (result.status === 'cancelled') {\n\t\t\t\t\tprogress.push(...(result.progress ?? []))\n\t\t\t\t} else if (result.status === 'error') {\n\t\t\t\t\tprogress.push(...(result.progress ?? []))\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst errors = results.filter((result) => result.status === 'error')\n\t\t\tif (errors.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tprogress,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tmessage: errors\n\t\t\t\t\t\t\t.map<string>((error) => error?.error?.message ?? '')\n\t\t\t\t\t\t\t.join('\\n'),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst status = results.every((result) => result.status === 'done')\n\t\t\t\t? 'done'\n\t\t\t\t: results.some((result) => result.status === 'cancelled')\n\t\t\t\t\t? 'cancelled'\n\t\t\t\t\t: 'in-progress'\n\t\t\treturn {\n\t\t\t\tstatus,\n\t\t\t\tprogress,\n\t\t\t\tresult: progress,\n\t\t\t}\n\t\t}),\n\t)\n}\n\nexport function ripgrepFiles(dir: string, args: GrepToolArgs): Observable<ToolRun<GrepToolDef>> {\n\tconst ripgrepArgs: string[] = [\n\t\t'--with-filename',\n\t\t'--line-number',\n\t\t'--no-heading',\n\t\t'--no-require-git',\n\t\t'--max-columns',\n\t\tGREP_MAX_COLUMN_LENGTH.toString(),\n\t\t'--trim',\n\t\t'--max-count',\n\t\tGREP_MAX_RESULTS_PER_FILE.toString(),\n\t]\n\tif (!args.caseSensitive) {\n\t\tripgrepArgs.push('-i')\n\t}\n\tripgrepArgs.push('--regexp', args.pattern)\n\tif (args.path) {\n\t\tcheckArgSafety(args.path)\n\t\tripgrepArgs.push(args.path)\n\t}\n\n\t// Interpret the `glob` property in TypeScript instead of using the ripgrep\n\t// option `--glob` because using `--glob` disables the built-in gitignore\n\t// feature. We do the same thing in the Glob tool.\n\tconst matchesGlobPattern = args?.glob\n\t\t? pm(args.glob, { nocase: !args.caseSensitive, dot: true })\n\t\t: undefined\n\n\treturn spawnAndObserveChildProcess(ripgrepExecutable(), ripgrepArgs, {\n\t\tcwd: dir,\n\t\tstdio: ['ignore', 'pipe', 'pipe'],\n\t}).pipe(\n\t\tmap(({ stdout, stderr: _stderr, exitCode, exited }): ToolRun<GrepToolDef> => {\n\t\t\tconst matches = stdout\n\t\t\t\t.trim()\n\t\t\t\t.split('\\n')\n\t\t\t\t.filter((line) => {\n\t\t\t\t\tif (line.length === 0) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t\tif (matchesGlobPattern) {\n\t\t\t\t\t\tconst [filename] = line.split(':', 1)\n\t\t\t\t\t\tif (filename && !matchesGlobPattern(filename)) {\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn true\n\t\t\t\t})\n\n\t\t\tif (!exited) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'in-progress',\n\t\t\t\t\tprogress: matches,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ripgrep exit code 1 means \"no matches found\"\n\t\t\tif (exited && exitCode && exitCode >= 2) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tprogress: matches,\n\t\t\t\t\terror: { message: `ripgrep exited with code ${exitCode}` },\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tstatus: 'done',\n\t\t\t\tprogress: matches,\n\t\t\t\tresult: matches,\n\t\t\t}\n\t\t}),\n\t\tcatchError((error) =>\n\t\t\tObservable.of({\n\t\t\t\tstatus: 'error',\n\t\t\t\tprogress: [],\n\t\t\t\terror: { message: String(error) },\n\t\t\t}),\n\t\t),\n\t)\n}\n"],"names":["nodeGrepTool","args","dirs","dir","checkDirURIIsFile","combineLatest","ripgrepFiles","map","results","progress","result","errors","error","ripgrepArgs","GREP_MAX_COLUMN_LENGTH","GREP_MAX_RESULTS_PER_FILE","checkArgSafety","matchesGlobPattern","pm","spawnAndObserveChildProcess","ripgrepExecutable","stdout","_stderr","exitCode","exited","matches","line","filename","catchError","Observable"],"mappings":";;;;AAaO,MAAMA,IAAwD,CAAC,EAAE,MAAAC,KAAQ,EAAE,MAAAC,QAAW;AAC5F,aAAWC,KAAOD;AACjB,IAAAE,EAAkBD,CAAG;AAEtB,SAAOE,EAAc,GAAGH,EAAK,IAAI,CAACC,MAAQG,EAAaH,EAAI,QAAQF,CAAI,CAAC,CAAC,EAAE;AAAA,IAC1EM,EAAkD,CAACC,MAAY;AAC9D,YAAMC,IAAqB,CAAC;AAC5B,iBAAWC,KAAUF;AAChB,QAAAE,EAAO,WAAW,gBACrBD,EAAS,KAAK,GAAIC,GAAQ,YAAY,CAAA,CAAG,IAC/BA,EAAO,WAAW,SACnBD,EAAA,KAAK,GAAGC,EAAO,MAAM,IACpBA,EAAO,WAAW,cAC5BD,EAAS,KAAK,GAAIC,EAAO,YAAY,CAAA,CAAG,IAC9BA,EAAO,WAAW,WAC5BD,EAAS,KAAK,GAAIC,EAAO,YAAY,CAAA,CAAG;AAG1C,YAAMC,IAASH,EAAQ,OAAO,CAACE,MAAWA,EAAO,WAAW,OAAO;AAC/D,aAAAC,EAAO,SAAS,IACZ;AAAA,QACN,QAAQ;AAAA,QACR,UAAAF;AAAA,QACA,OAAO;AAAA,UACN,SAASE,EACP,IAAY,CAACC,MAAUA,GAAO,OAAO,WAAW,EAAE,EAClD,KAAK;AAAA,CAAI;AAAA,QAAA;AAAA,MAEb,IAOM;AAAA,QACN,QANcJ,EAAQ,MAAM,CAACE,MAAWA,EAAO,WAAW,MAAM,IAC9D,SACAF,EAAQ,KAAK,CAACE,MAAWA,EAAO,WAAW,WAAW,IACrD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,QACR,UAAUE;AAAA,QACV,QAAQA;AAAA,MACT,IAnBQ;AAAA,QACN,QAAQ;AAAA,QACR,UAAUA;AAAA,MACX;AAAA,IAgBD,CACA;AAAA,IACDG;AAAA,MAAW,CAAChB,MACXiB,EAAW,GAAG;AAAA,QACb,QAAQ;AAAA,QACR,UAAU,CAAC;AAAA,QACX,OAAO,EAAE,SAAS,OAAOjB,CAAK,EAAE;AAAA,MAChC,CAAA;AAAA,IAAA;AAAA,EAEH;AACD;"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import { aa as Pe, a9 as st, p as lt } from "./console-
|
2
|
+
import { aa as Pe, a9 as st, p as lt } from "./console-CN5EK-5f.js";
|
3
3
|
var pe = {}, Pu = {}, be = {}, Me;
|
4
4
|
function ne() {
|
5
5
|
return Me || (Me = 1, function(u) {
|
@@ -4850,4 +4850,4 @@ ${a}`
|
|
4850
4850
|
export {
|
4851
4851
|
ea as nodeReadWebPageTool
|
4852
4852
|
};
|
4853
|
-
//# sourceMappingURL=node-
|
4853
|
+
//# sourceMappingURL=node-bCOCJc2z.js.map
|