@sahu-01/openpaw 1.0.1 → 1.0.2
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/index.js +305 -76
- package/package.json +7 -5
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
9
9
|
var __esm = (fn, res) => function __init() {
|
|
10
10
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
11
|
};
|
|
12
|
-
var __commonJS = (cb, mod) => function
|
|
12
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
13
13
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
14
|
};
|
|
15
15
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -3234,7 +3234,7 @@ var require_typescript = __commonJS({
|
|
|
3234
3234
|
walkUpParenthesizedTypesAndGetParentAndChild: () => walkUpParenthesizedTypesAndGetParentAndChild,
|
|
3235
3235
|
whitespaceOrMapCommentRegExp: () => whitespaceOrMapCommentRegExp,
|
|
3236
3236
|
writeCommentRange: () => writeCommentRange,
|
|
3237
|
-
writeFile: () =>
|
|
3237
|
+
writeFile: () => writeFile4,
|
|
3238
3238
|
writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
|
|
3239
3239
|
zipWith: () => zipWith
|
|
3240
3240
|
});
|
|
@@ -9566,7 +9566,7 @@ ${lanes.join("\n")}
|
|
|
9566
9566
|
writeOutputIsTTY() {
|
|
9567
9567
|
return process.stdout.isTTY;
|
|
9568
9568
|
},
|
|
9569
|
-
readFile:
|
|
9569
|
+
readFile: readFile5,
|
|
9570
9570
|
writeFile: writeFile22,
|
|
9571
9571
|
watchFile: watchFile2,
|
|
9572
9572
|
watchDirectory,
|
|
@@ -9772,7 +9772,7 @@ ${lanes.join("\n")}
|
|
|
9772
9772
|
callback
|
|
9773
9773
|
);
|
|
9774
9774
|
}
|
|
9775
|
-
function
|
|
9775
|
+
function readFile5(fileName, _encoding) {
|
|
9776
9776
|
let buffer;
|
|
9777
9777
|
try {
|
|
9778
9778
|
buffer = _fs.readFileSync(fileName);
|
|
@@ -21877,7 +21877,7 @@ ${lanes.join("\n")}
|
|
|
21877
21877
|
sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
|
|
21878
21878
|
return combinePaths(newDirPath, sourceFilePath);
|
|
21879
21879
|
}
|
|
21880
|
-
function
|
|
21880
|
+
function writeFile4(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
|
|
21881
21881
|
host.writeFile(
|
|
21882
21882
|
fileName,
|
|
21883
21883
|
text,
|
|
@@ -46328,7 +46328,7 @@ ${lanes.join("\n")}
|
|
|
46328
46328
|
const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
|
|
46329
46329
|
return possibleOption ? createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
|
|
46330
46330
|
}
|
|
46331
|
-
function parseCommandLineWorker(diagnostics, commandLine,
|
|
46331
|
+
function parseCommandLineWorker(diagnostics, commandLine, readFile5) {
|
|
46332
46332
|
const options = {};
|
|
46333
46333
|
let watchOptions;
|
|
46334
46334
|
const fileNames = [];
|
|
@@ -46376,7 +46376,7 @@ ${lanes.join("\n")}
|
|
|
46376
46376
|
}
|
|
46377
46377
|
}
|
|
46378
46378
|
function parseResponseFile(fileName) {
|
|
46379
|
-
const text = tryReadFile(fileName,
|
|
46379
|
+
const text = tryReadFile(fileName, readFile5 || ((fileName2) => sys.readFile(fileName2)));
|
|
46380
46380
|
if (!isString(text)) {
|
|
46381
46381
|
errors.push(text);
|
|
46382
46382
|
return;
|
|
@@ -46479,8 +46479,8 @@ ${lanes.join("\n")}
|
|
|
46479
46479
|
unknownDidYouMeanDiagnostic: Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
|
|
46480
46480
|
optionTypeMismatchDiagnostic: Diagnostics.Compiler_option_0_expects_an_argument
|
|
46481
46481
|
};
|
|
46482
|
-
function parseCommandLine(commandLine,
|
|
46483
|
-
return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine,
|
|
46482
|
+
function parseCommandLine(commandLine, readFile5) {
|
|
46483
|
+
return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile5);
|
|
46484
46484
|
}
|
|
46485
46485
|
function getOptionFromName(optionName, allowShort) {
|
|
46486
46486
|
return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
|
|
@@ -46562,8 +46562,8 @@ ${lanes.join("\n")}
|
|
|
46562
46562
|
watchOptionsToExtend
|
|
46563
46563
|
);
|
|
46564
46564
|
}
|
|
46565
|
-
function readConfigFile(fileName,
|
|
46566
|
-
const textOrDiagnostic = tryReadFile(fileName,
|
|
46565
|
+
function readConfigFile(fileName, readFile5) {
|
|
46566
|
+
const textOrDiagnostic = tryReadFile(fileName, readFile5);
|
|
46567
46567
|
return isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
|
|
46568
46568
|
}
|
|
46569
46569
|
function parseConfigFileTextToJson(fileName, jsonText) {
|
|
@@ -46578,14 +46578,14 @@ ${lanes.join("\n")}
|
|
|
46578
46578
|
error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : void 0
|
|
46579
46579
|
};
|
|
46580
46580
|
}
|
|
46581
|
-
function readJsonConfigFile(fileName,
|
|
46582
|
-
const textOrDiagnostic = tryReadFile(fileName,
|
|
46581
|
+
function readJsonConfigFile(fileName, readFile5) {
|
|
46582
|
+
const textOrDiagnostic = tryReadFile(fileName, readFile5);
|
|
46583
46583
|
return isString(textOrDiagnostic) ? parseJsonText(fileName, textOrDiagnostic) : { fileName, parseDiagnostics: [textOrDiagnostic] };
|
|
46584
46584
|
}
|
|
46585
|
-
function tryReadFile(fileName,
|
|
46585
|
+
function tryReadFile(fileName, readFile5) {
|
|
46586
46586
|
let text;
|
|
46587
46587
|
try {
|
|
46588
|
-
text =
|
|
46588
|
+
text = readFile5(fileName);
|
|
46589
46589
|
} catch (e) {
|
|
46590
46590
|
return createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
|
|
46591
46591
|
}
|
|
@@ -130628,7 +130628,7 @@ ${lanes.join("\n")}
|
|
|
130628
130628
|
return;
|
|
130629
130629
|
}
|
|
130630
130630
|
const buildInfo = host.getBuildInfo() || { version };
|
|
130631
|
-
|
|
130631
|
+
writeFile4(
|
|
130632
130632
|
host,
|
|
130633
130633
|
emitterDiagnostics,
|
|
130634
130634
|
buildInfoPath,
|
|
@@ -130840,7 +130840,7 @@ ${lanes.join("\n")}
|
|
|
130840
130840
|
}
|
|
130841
130841
|
if (sourceMapFilePath) {
|
|
130842
130842
|
const sourceMap = sourceMapGenerator.toString();
|
|
130843
|
-
|
|
130843
|
+
writeFile4(
|
|
130844
130844
|
host,
|
|
130845
130845
|
emitterDiagnostics,
|
|
130846
130846
|
sourceMapFilePath,
|
|
@@ -130855,7 +130855,7 @@ ${lanes.join("\n")}
|
|
|
130855
130855
|
}
|
|
130856
130856
|
const text = writer.getText();
|
|
130857
130857
|
const data = { sourceMapUrlPos, diagnostics: transform2.diagnostics };
|
|
130858
|
-
|
|
130858
|
+
writeFile4(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, data);
|
|
130859
130859
|
writer.clear();
|
|
130860
130860
|
return !data.skippedDtsWrite;
|
|
130861
130861
|
}
|
|
@@ -136243,12 +136243,12 @@ ${lanes.join("\n")}
|
|
|
136243
136243
|
function createCompilerHost(options, setParentNodes) {
|
|
136244
136244
|
return createCompilerHostWorker(options, setParentNodes);
|
|
136245
136245
|
}
|
|
136246
|
-
function createGetSourceFile(
|
|
136246
|
+
function createGetSourceFile(readFile5, setParentNodes) {
|
|
136247
136247
|
return (fileName, languageVersionOrOptions, onError) => {
|
|
136248
136248
|
let text;
|
|
136249
136249
|
try {
|
|
136250
136250
|
mark("beforeIORead");
|
|
136251
|
-
text =
|
|
136251
|
+
text = readFile5(fileName);
|
|
136252
136252
|
mark("afterIORead");
|
|
136253
136253
|
measure("I/O Read", "beforeIORead", "afterIORead");
|
|
136254
136254
|
} catch (e) {
|
|
@@ -137152,7 +137152,7 @@ ${lanes.join("\n")}
|
|
|
137152
137152
|
getRedirectFromOutput,
|
|
137153
137153
|
forEachResolvedProjectReference: forEachResolvedProjectReference2
|
|
137154
137154
|
});
|
|
137155
|
-
const
|
|
137155
|
+
const readFile5 = host.readFile.bind(host);
|
|
137156
137156
|
(_e = tracing) == null ? void 0 : _e.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
|
|
137157
137157
|
const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
|
|
137158
137158
|
(_f = tracing) == null ? void 0 : _f.pop();
|
|
@@ -137378,7 +137378,7 @@ ${lanes.join("\n")}
|
|
|
137378
137378
|
shouldTransformImportCall,
|
|
137379
137379
|
emitBuildInfo,
|
|
137380
137380
|
fileExists: fileExists2,
|
|
137381
|
-
readFile:
|
|
137381
|
+
readFile: readFile5,
|
|
137382
137382
|
directoryExists,
|
|
137383
137383
|
getSymlinkCache,
|
|
137384
137384
|
realpath: (_o = host.realpath) == null ? void 0 : _o.bind(host),
|
|
@@ -198737,7 +198737,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
198737
198737
|
walkUpParenthesizedTypesAndGetParentAndChild: () => walkUpParenthesizedTypesAndGetParentAndChild,
|
|
198738
198738
|
whitespaceOrMapCommentRegExp: () => whitespaceOrMapCommentRegExp,
|
|
198739
198739
|
writeCommentRange: () => writeCommentRange,
|
|
198740
|
-
writeFile: () =>
|
|
198740
|
+
writeFile: () => writeFile4,
|
|
198741
198741
|
writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
|
|
198742
198742
|
zipWith: () => zipWith
|
|
198743
198743
|
});
|
|
@@ -212795,19 +212795,19 @@ var require_range = __commonJS({
|
|
|
212795
212795
|
var replaceCaret = (comp, options) => {
|
|
212796
212796
|
debug("caret", comp, options);
|
|
212797
212797
|
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
212798
|
-
const
|
|
212798
|
+
const z6 = options.includePrerelease ? "-0" : "";
|
|
212799
212799
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
212800
212800
|
debug("caret", comp, _, M, m, p, pr);
|
|
212801
212801
|
let ret;
|
|
212802
212802
|
if (isX(M)) {
|
|
212803
212803
|
ret = "";
|
|
212804
212804
|
} else if (isX(m)) {
|
|
212805
|
-
ret = `>=${M}.0.0${
|
|
212805
|
+
ret = `>=${M}.0.0${z6} <${+M + 1}.0.0-0`;
|
|
212806
212806
|
} else if (isX(p)) {
|
|
212807
212807
|
if (M === "0") {
|
|
212808
|
-
ret = `>=${M}.${m}.0${
|
|
212808
|
+
ret = `>=${M}.${m}.0${z6} <${M}.${+m + 1}.0-0`;
|
|
212809
212809
|
} else {
|
|
212810
|
-
ret = `>=${M}.${m}.0${
|
|
212810
|
+
ret = `>=${M}.${m}.0${z6} <${+M + 1}.0.0-0`;
|
|
212811
212811
|
}
|
|
212812
212812
|
} else if (pr) {
|
|
212813
212813
|
debug("replaceCaret pr", pr);
|
|
@@ -212824,9 +212824,9 @@ var require_range = __commonJS({
|
|
|
212824
212824
|
debug("no pr");
|
|
212825
212825
|
if (M === "0") {
|
|
212826
212826
|
if (m === "0") {
|
|
212827
|
-
ret = `>=${M}.${m}.${p}${
|
|
212827
|
+
ret = `>=${M}.${m}.${p}${z6} <${M}.${m}.${+p + 1}-0`;
|
|
212828
212828
|
} else {
|
|
212829
|
-
ret = `>=${M}.${m}.${p}${
|
|
212829
|
+
ret = `>=${M}.${m}.${p}${z6} <${M}.${+m + 1}.0-0`;
|
|
212830
212830
|
}
|
|
212831
212831
|
} else {
|
|
212832
212832
|
ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
@@ -225441,7 +225441,7 @@ var require_async2 = __commonJS({
|
|
|
225441
225441
|
readdirWithFileTypes(directory, settings, callback);
|
|
225442
225442
|
return;
|
|
225443
225443
|
}
|
|
225444
|
-
|
|
225444
|
+
readdir4(directory, settings, callback);
|
|
225445
225445
|
}
|
|
225446
225446
|
exports2.read = read;
|
|
225447
225447
|
function readdirWithFileTypes(directory, settings, callback) {
|
|
@@ -225490,7 +225490,7 @@ var require_async2 = __commonJS({
|
|
|
225490
225490
|
});
|
|
225491
225491
|
};
|
|
225492
225492
|
}
|
|
225493
|
-
function
|
|
225493
|
+
function readdir4(directory, settings, callback) {
|
|
225494
225494
|
settings.fs.readdir(directory, (readdirError, names) => {
|
|
225495
225495
|
if (readdirError !== null) {
|
|
225496
225496
|
callFailureCallback(callback, readdirError);
|
|
@@ -225525,7 +225525,7 @@ var require_async2 = __commonJS({
|
|
|
225525
225525
|
});
|
|
225526
225526
|
});
|
|
225527
225527
|
}
|
|
225528
|
-
exports2.readdir =
|
|
225528
|
+
exports2.readdir = readdir4;
|
|
225529
225529
|
function callFailureCallback(callback, error) {
|
|
225530
225530
|
callback(error);
|
|
225531
225531
|
}
|
|
@@ -225549,7 +225549,7 @@ var require_sync2 = __commonJS({
|
|
|
225549
225549
|
if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
|
|
225550
225550
|
return readdirWithFileTypes(directory, settings);
|
|
225551
225551
|
}
|
|
225552
|
-
return
|
|
225552
|
+
return readdir4(directory, settings);
|
|
225553
225553
|
}
|
|
225554
225554
|
exports2.read = read;
|
|
225555
225555
|
function readdirWithFileTypes(directory, settings) {
|
|
@@ -225574,7 +225574,7 @@ var require_sync2 = __commonJS({
|
|
|
225574
225574
|
});
|
|
225575
225575
|
}
|
|
225576
225576
|
exports2.readdirWithFileTypes = readdirWithFileTypes;
|
|
225577
|
-
function
|
|
225577
|
+
function readdir4(directory, settings) {
|
|
225578
225578
|
const names = settings.fs.readdirSync(directory);
|
|
225579
225579
|
return names.map((name) => {
|
|
225580
225580
|
const entryPath = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
|
|
@@ -225590,7 +225590,7 @@ var require_sync2 = __commonJS({
|
|
|
225590
225590
|
return entry;
|
|
225591
225591
|
});
|
|
225592
225592
|
}
|
|
225593
|
-
exports2.readdir =
|
|
225593
|
+
exports2.readdir = readdir4;
|
|
225594
225594
|
}
|
|
225595
225595
|
});
|
|
225596
225596
|
|
|
@@ -228553,11 +228553,11 @@ var require_brace_expansion = __commonJS({
|
|
|
228553
228553
|
if (pad) {
|
|
228554
228554
|
var need = width - c.length;
|
|
228555
228555
|
if (need > 0) {
|
|
228556
|
-
var
|
|
228556
|
+
var z6 = new Array(need + 1).join("0");
|
|
228557
228557
|
if (i < 0)
|
|
228558
|
-
c = "-" +
|
|
228558
|
+
c = "-" + z6 + c.slice(1);
|
|
228559
228559
|
else
|
|
228560
|
-
c =
|
|
228560
|
+
c = z6 + c;
|
|
228561
228561
|
}
|
|
228562
228562
|
}
|
|
228563
228563
|
}
|
|
@@ -230700,8 +230700,8 @@ function scanSource(source, fileName) {
|
|
|
230700
230700
|
return findings;
|
|
230701
230701
|
}
|
|
230702
230702
|
async function scanFile(filePath) {
|
|
230703
|
-
const { readFile:
|
|
230704
|
-
const source = await
|
|
230703
|
+
const { readFile: readFile5 } = await import("fs/promises");
|
|
230704
|
+
const source = await readFile5(filePath, "utf8");
|
|
230705
230705
|
return scanSource(source, filePath);
|
|
230706
230706
|
}
|
|
230707
230707
|
function scanCredentialsSource(source, fileName) {
|
|
@@ -230729,20 +230729,20 @@ function scanCredentialsSource(source, fileName) {
|
|
|
230729
230729
|
return findings;
|
|
230730
230730
|
}
|
|
230731
230731
|
async function scanCredentials(filePath) {
|
|
230732
|
-
const { readFile:
|
|
230733
|
-
const source = await
|
|
230732
|
+
const { readFile: readFile5 } = await import("fs/promises");
|
|
230733
|
+
const source = await readFile5(filePath, "utf8");
|
|
230734
230734
|
return scanCredentialsSource(source, filePath);
|
|
230735
230735
|
}
|
|
230736
230736
|
async function scanDirectory(dirPath) {
|
|
230737
|
-
const { readdir:
|
|
230738
|
-
const { join:
|
|
230737
|
+
const { readdir: readdir4, stat: stat3 } = await import("fs/promises");
|
|
230738
|
+
const { join: join5 } = await import("path");
|
|
230739
230739
|
const findings = [];
|
|
230740
230740
|
const credentialFindings = [];
|
|
230741
230741
|
let scannedFiles = 0;
|
|
230742
230742
|
async function scanRecursive(currentPath) {
|
|
230743
|
-
const entries = await
|
|
230743
|
+
const entries = await readdir4(currentPath);
|
|
230744
230744
|
for (const entry of entries) {
|
|
230745
|
-
const fullPath =
|
|
230745
|
+
const fullPath = join5(currentPath, entry);
|
|
230746
230746
|
const stats = await stat3(fullPath);
|
|
230747
230747
|
if (stats.isDirectory()) {
|
|
230748
230748
|
if (!["node_modules", "dist", "build", ".git", ".turbo"].includes(entry)) {
|
|
@@ -230786,22 +230786,22 @@ var OpenClawAuthProfilesSchema = import_zod4.z.object({
|
|
|
230786
230786
|
});
|
|
230787
230787
|
var WORKSPACE_FILES = ["AGENTS.md", "SOUL.md", ".cursorrules", "CLAUDE.md"];
|
|
230788
230788
|
async function copyWorkspaceFiles(sourceDir, destDir) {
|
|
230789
|
-
const { readdir:
|
|
230790
|
-
const { join:
|
|
230791
|
-
await
|
|
230792
|
-
const files = await
|
|
230789
|
+
const { readdir: readdir4, copyFile: copyFile2, mkdir: mkdir4 } = await import("fs/promises");
|
|
230790
|
+
const { join: join5 } = await import("path");
|
|
230791
|
+
await mkdir4(destDir, { recursive: true });
|
|
230792
|
+
const files = await readdir4(sourceDir);
|
|
230793
230793
|
const copied = [];
|
|
230794
230794
|
for (const file of files) {
|
|
230795
230795
|
if (WORKSPACE_FILES.includes(file)) {
|
|
230796
|
-
await
|
|
230796
|
+
await copyFile2(join5(sourceDir, file), join5(destDir, file));
|
|
230797
230797
|
copied.push(file);
|
|
230798
230798
|
}
|
|
230799
230799
|
}
|
|
230800
230800
|
return copied;
|
|
230801
230801
|
}
|
|
230802
230802
|
async function translateConfig(sourcePath, destPath, source) {
|
|
230803
|
-
const { readFile:
|
|
230804
|
-
const content = await
|
|
230803
|
+
const { readFile: readFile5, writeFile: writeFile4 } = await import("fs/promises");
|
|
230804
|
+
const content = await readFile5(sourcePath, "utf8");
|
|
230805
230805
|
const sourceConfig = JSON.parse(content);
|
|
230806
230806
|
const openpawConfig = {
|
|
230807
230807
|
version: "1.0.0",
|
|
@@ -230809,7 +230809,7 @@ async function translateConfig(sourcePath, destPath, source) {
|
|
|
230809
230809
|
migrated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
230810
230810
|
...sourceConfig
|
|
230811
230811
|
};
|
|
230812
|
-
await
|
|
230812
|
+
await writeFile4(destPath, JSON.stringify(openpawConfig, null, 2));
|
|
230813
230813
|
}
|
|
230814
230814
|
function mapProviderToCredentialType(type) {
|
|
230815
230815
|
if (type === "oauth" || type === "oauth_token") return "oauth_token";
|
|
@@ -230818,8 +230818,8 @@ function mapProviderToCredentialType(type) {
|
|
|
230818
230818
|
return "api_key";
|
|
230819
230819
|
}
|
|
230820
230820
|
async function migrateCredentials(openclawDir, vault) {
|
|
230821
|
-
const { readFile:
|
|
230822
|
-
const { join:
|
|
230821
|
+
const { readFile: readFile5, writeFile: writeFile4, copyFile: copyFile2, readdir: readdir4, stat: stat3 } = await import("fs/promises");
|
|
230822
|
+
const { join: join5 } = await import("path");
|
|
230823
230823
|
const result = {
|
|
230824
230824
|
profilesProcessed: 0,
|
|
230825
230825
|
credentialsImported: 0,
|
|
@@ -230827,10 +230827,10 @@ async function migrateCredentials(openclawDir, vault) {
|
|
|
230827
230827
|
credentialIds: [],
|
|
230828
230828
|
errors: []
|
|
230829
230829
|
};
|
|
230830
|
-
const agentsDir =
|
|
230830
|
+
const agentsDir = join5(openclawDir, "agents");
|
|
230831
230831
|
let agentDirs;
|
|
230832
230832
|
try {
|
|
230833
|
-
agentDirs = await
|
|
230833
|
+
agentDirs = await readdir4(agentsDir);
|
|
230834
230834
|
} catch (error) {
|
|
230835
230835
|
if (error.code === "ENOENT") {
|
|
230836
230836
|
return result;
|
|
@@ -230838,7 +230838,7 @@ async function migrateCredentials(openclawDir, vault) {
|
|
|
230838
230838
|
throw error;
|
|
230839
230839
|
}
|
|
230840
230840
|
for (const agentDir of agentDirs) {
|
|
230841
|
-
const authProfilesPath =
|
|
230841
|
+
const authProfilesPath = join5(agentsDir, agentDir, "agent", "auth-profiles.json");
|
|
230842
230842
|
try {
|
|
230843
230843
|
await stat3(authProfilesPath);
|
|
230844
230844
|
} catch (error) {
|
|
@@ -230848,11 +230848,11 @@ async function migrateCredentials(openclawDir, vault) {
|
|
|
230848
230848
|
throw error;
|
|
230849
230849
|
}
|
|
230850
230850
|
try {
|
|
230851
|
-
const content = await
|
|
230851
|
+
const content = await readFile5(authProfilesPath, "utf8");
|
|
230852
230852
|
const parsed = JSON.parse(content);
|
|
230853
230853
|
const authProfiles = OpenClawAuthProfilesSchema.parse(parsed);
|
|
230854
230854
|
const backupPath = `${authProfilesPath}.bak`;
|
|
230855
|
-
await
|
|
230855
|
+
await copyFile2(authProfilesPath, backupPath);
|
|
230856
230856
|
result.filesBackedUp.push(backupPath);
|
|
230857
230857
|
const updatedProfiles = {};
|
|
230858
230858
|
for (const [profileName, profile] of Object.entries(authProfiles.profiles)) {
|
|
@@ -230875,7 +230875,7 @@ async function migrateCredentials(openclawDir, vault) {
|
|
|
230875
230875
|
version: authProfiles.version,
|
|
230876
230876
|
profiles: updatedProfiles
|
|
230877
230877
|
};
|
|
230878
|
-
await
|
|
230878
|
+
await writeFile4(authProfilesPath, JSON.stringify(updatedAuthProfiles, null, 2));
|
|
230879
230879
|
} catch (error) {
|
|
230880
230880
|
result.errors.push(`Error processing ${authProfilesPath}: ${error.message}`);
|
|
230881
230881
|
}
|
|
@@ -230883,8 +230883,230 @@ async function migrateCredentials(openclawDir, vault) {
|
|
|
230883
230883
|
return result;
|
|
230884
230884
|
}
|
|
230885
230885
|
|
|
230886
|
-
//
|
|
230886
|
+
// ../gateway/dist/index.js
|
|
230887
|
+
var import_ws = require("ws");
|
|
230887
230888
|
var import_promises3 = require("fs/promises");
|
|
230889
|
+
var import_path3 = require("path");
|
|
230890
|
+
var import_os2 = require("os");
|
|
230891
|
+
var import_child_process = require("child_process");
|
|
230892
|
+
var import_fs = require("fs");
|
|
230893
|
+
var import_zod5 = require("zod");
|
|
230894
|
+
init_dist();
|
|
230895
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
230896
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
230897
|
+
}) : x)(function(x) {
|
|
230898
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
230899
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
230900
|
+
});
|
|
230901
|
+
var DEFAULT_PORT = 18789;
|
|
230902
|
+
var SessionSchema = import_zod5.z.object({
|
|
230903
|
+
id: import_zod5.z.string(),
|
|
230904
|
+
createdAt: import_zod5.z.string(),
|
|
230905
|
+
lastActivity: import_zod5.z.string(),
|
|
230906
|
+
metadata: import_zod5.z.record(import_zod5.z.unknown())
|
|
230907
|
+
});
|
|
230908
|
+
var MessageSchema = import_zod5.z.object({
|
|
230909
|
+
sessionId: import_zod5.z.string().optional(),
|
|
230910
|
+
channelId: import_zod5.z.string().optional(),
|
|
230911
|
+
userId: import_zod5.z.string().optional(),
|
|
230912
|
+
content: import_zod5.z.string(),
|
|
230913
|
+
metadata: import_zod5.z.record(import_zod5.z.unknown()).optional()
|
|
230914
|
+
});
|
|
230915
|
+
async function findOpenClawBinary(openclawDir) {
|
|
230916
|
+
const pathBinary = process.platform === "win32" ? "openclaw.cmd" : "openclaw";
|
|
230917
|
+
const pathDirs = (process.env["PATH"] ?? "").split(process.platform === "win32" ? ";" : ":");
|
|
230918
|
+
for (const dir of pathDirs) {
|
|
230919
|
+
const fullPath = (0, import_path3.join)(dir, pathBinary);
|
|
230920
|
+
if ((0, import_fs.existsSync)(fullPath)) {
|
|
230921
|
+
return fullPath;
|
|
230922
|
+
}
|
|
230923
|
+
}
|
|
230924
|
+
const localBinary = (0, import_path3.join)(openclawDir, "node_modules", ".bin", "openclaw");
|
|
230925
|
+
if ((0, import_fs.existsSync)(localBinary)) {
|
|
230926
|
+
return localBinary;
|
|
230927
|
+
}
|
|
230928
|
+
return null;
|
|
230929
|
+
}
|
|
230930
|
+
async function findAuthProfileFiles(openclawDir) {
|
|
230931
|
+
const agentsDir = (0, import_path3.join)(openclawDir, "agents");
|
|
230932
|
+
const profileFiles = [];
|
|
230933
|
+
try {
|
|
230934
|
+
const agents = await (0, import_promises3.readdir)(agentsDir);
|
|
230935
|
+
for (const agent of agents) {
|
|
230936
|
+
const agentDir = (0, import_path3.join)(agentsDir, agent, "agent");
|
|
230937
|
+
const profilePath = (0, import_path3.join)(agentDir, "auth-profiles.json");
|
|
230938
|
+
if ((0, import_fs.existsSync)(profilePath)) {
|
|
230939
|
+
profileFiles.push(profilePath);
|
|
230940
|
+
}
|
|
230941
|
+
}
|
|
230942
|
+
} catch {
|
|
230943
|
+
}
|
|
230944
|
+
return profileFiles;
|
|
230945
|
+
}
|
|
230946
|
+
async function processAuthProfiles(profilePath, vault, backupSuffix) {
|
|
230947
|
+
const content = await (0, import_promises3.readFile)(profilePath, "utf8");
|
|
230948
|
+
const data = JSON.parse(content);
|
|
230949
|
+
let modified = false;
|
|
230950
|
+
if (data.profiles) {
|
|
230951
|
+
for (const profileName of Object.keys(data.profiles)) {
|
|
230952
|
+
const profile = data.profiles[profileName];
|
|
230953
|
+
if (profile && typeof profile.key === "string" && profile.key.startsWith("openpaw:vault:")) {
|
|
230954
|
+
const credId = profile.key.replace("openpaw:vault:", "");
|
|
230955
|
+
const result = vault.get(credId);
|
|
230956
|
+
if (result) {
|
|
230957
|
+
profile.key = result.value;
|
|
230958
|
+
modified = true;
|
|
230959
|
+
}
|
|
230960
|
+
}
|
|
230961
|
+
}
|
|
230962
|
+
}
|
|
230963
|
+
if (modified) {
|
|
230964
|
+
await (0, import_promises3.copyFile)(profilePath, `${profilePath}${backupSuffix}`);
|
|
230965
|
+
await (0, import_promises3.writeFile)(profilePath, JSON.stringify(data, null, 2), { mode: 384 });
|
|
230966
|
+
}
|
|
230967
|
+
return { original: content, processed: modified };
|
|
230968
|
+
}
|
|
230969
|
+
async function restoreAuthProfiles(profilePath, backupSuffix) {
|
|
230970
|
+
const backupPath = `${profilePath}${backupSuffix}`;
|
|
230971
|
+
if ((0, import_fs.existsSync)(backupPath)) {
|
|
230972
|
+
await (0, import_promises3.copyFile)(backupPath, profilePath);
|
|
230973
|
+
await (0, import_promises3.unlink)(backupPath);
|
|
230974
|
+
}
|
|
230975
|
+
}
|
|
230976
|
+
async function startGateway(config = {}) {
|
|
230977
|
+
const openpawDir = config.openpawDir ?? (0, import_path3.join)((0, import_os2.homedir)(), ".openpaw");
|
|
230978
|
+
const openclawDir = config.openclawDir ?? (0, import_path3.join)((0, import_os2.homedir)(), ".openclaw");
|
|
230979
|
+
const keyFile = (0, import_path3.join)(openpawDir, "master.key");
|
|
230980
|
+
const vaultFile = (0, import_path3.join)(openpawDir, "vault.json");
|
|
230981
|
+
let port = config.port ?? DEFAULT_PORT;
|
|
230982
|
+
try {
|
|
230983
|
+
const openclawConfig = JSON.parse(await (0, import_promises3.readFile)((0, import_path3.join)(openclawDir, "openclaw.json"), "utf8"));
|
|
230984
|
+
if (openclawConfig.port) {
|
|
230985
|
+
port = openclawConfig.port;
|
|
230986
|
+
}
|
|
230987
|
+
} catch {
|
|
230988
|
+
}
|
|
230989
|
+
let vault;
|
|
230990
|
+
try {
|
|
230991
|
+
const keyData = await (0, import_promises3.readFile)(keyFile);
|
|
230992
|
+
vault = await createVault(keyData, vaultFile);
|
|
230993
|
+
} catch (error) {
|
|
230994
|
+
if (error.code === "ENOENT") {
|
|
230995
|
+
throw new Error('Vault not initialized. Run "openpaw vault import" first to set up credentials.');
|
|
230996
|
+
}
|
|
230997
|
+
throw error;
|
|
230998
|
+
}
|
|
230999
|
+
const profileFiles = await findAuthProfileFiles(openclawDir);
|
|
231000
|
+
const backupSuffix = ".openpaw-backup";
|
|
231001
|
+
const processedFiles = [];
|
|
231002
|
+
for (const profilePath of profileFiles) {
|
|
231003
|
+
const result = await processAuthProfiles(profilePath, vault, backupSuffix);
|
|
231004
|
+
if (result.processed) {
|
|
231005
|
+
processedFiles.push(profilePath);
|
|
231006
|
+
}
|
|
231007
|
+
}
|
|
231008
|
+
let cleanedUp = false;
|
|
231009
|
+
let openclawProcess = null;
|
|
231010
|
+
const cleanup = async () => {
|
|
231011
|
+
if (cleanedUp) return;
|
|
231012
|
+
cleanedUp = true;
|
|
231013
|
+
console.log("\nRe-encrypting credentials...");
|
|
231014
|
+
for (const profilePath of processedFiles) {
|
|
231015
|
+
try {
|
|
231016
|
+
await restoreAuthProfiles(profilePath, backupSuffix);
|
|
231017
|
+
console.log(` Restored: ${profilePath}`);
|
|
231018
|
+
} catch (err) {
|
|
231019
|
+
console.error(` Failed to restore ${profilePath}: ${err.message}`);
|
|
231020
|
+
}
|
|
231021
|
+
}
|
|
231022
|
+
if (openclawProcess && !openclawProcess.killed) {
|
|
231023
|
+
openclawProcess.kill("SIGTERM");
|
|
231024
|
+
}
|
|
231025
|
+
console.log("Credentials secured.");
|
|
231026
|
+
};
|
|
231027
|
+
const cleanupSync = () => {
|
|
231028
|
+
if (cleanedUp) return;
|
|
231029
|
+
cleanedUp = true;
|
|
231030
|
+
const fs = __require("fs");
|
|
231031
|
+
for (const profilePath of processedFiles) {
|
|
231032
|
+
try {
|
|
231033
|
+
const backupPath = `${profilePath}${backupSuffix}`;
|
|
231034
|
+
if (fs.existsSync(backupPath)) {
|
|
231035
|
+
fs.copyFileSync(backupPath, profilePath);
|
|
231036
|
+
fs.unlinkSync(backupPath);
|
|
231037
|
+
}
|
|
231038
|
+
} catch {
|
|
231039
|
+
}
|
|
231040
|
+
}
|
|
231041
|
+
if (openclawProcess && !openclawProcess.killed) {
|
|
231042
|
+
openclawProcess.kill("SIGTERM");
|
|
231043
|
+
}
|
|
231044
|
+
};
|
|
231045
|
+
process.on("exit", cleanupSync);
|
|
231046
|
+
process.on("SIGINT", async () => {
|
|
231047
|
+
await cleanup();
|
|
231048
|
+
process.exit(0);
|
|
231049
|
+
});
|
|
231050
|
+
process.on("SIGTERM", async () => {
|
|
231051
|
+
await cleanup();
|
|
231052
|
+
process.exit(0);
|
|
231053
|
+
});
|
|
231054
|
+
process.on("uncaughtException", async (err) => {
|
|
231055
|
+
console.error("Uncaught exception:", err);
|
|
231056
|
+
await cleanup();
|
|
231057
|
+
process.exit(1);
|
|
231058
|
+
});
|
|
231059
|
+
process.on("unhandledRejection", async (reason) => {
|
|
231060
|
+
console.error("Unhandled rejection:", reason);
|
|
231061
|
+
await cleanup();
|
|
231062
|
+
process.exit(1);
|
|
231063
|
+
});
|
|
231064
|
+
const openclawBinary = await findOpenClawBinary(openclawDir);
|
|
231065
|
+
console.log(`Gateway running on port ${port}. Credentials decrypted in memory. Press Ctrl+C to stop and re-encrypt.`);
|
|
231066
|
+
if (processedFiles.length > 0) {
|
|
231067
|
+
console.log(`Decrypted ${processedFiles.length} auth-profiles.json file(s)`);
|
|
231068
|
+
}
|
|
231069
|
+
if (openclawBinary) {
|
|
231070
|
+
console.log(`Starting OpenClaw: ${openclawBinary}`);
|
|
231071
|
+
openclawProcess = (0, import_child_process.spawn)(openclawBinary, [], {
|
|
231072
|
+
stdio: "inherit",
|
|
231073
|
+
env: { ...process.env }
|
|
231074
|
+
});
|
|
231075
|
+
openclawProcess.on("exit", async (code) => {
|
|
231076
|
+
console.log(`OpenClaw exited with code ${code}`);
|
|
231077
|
+
await cleanup();
|
|
231078
|
+
process.exit(code ?? 0);
|
|
231079
|
+
});
|
|
231080
|
+
openclawProcess.on("error", async (err) => {
|
|
231081
|
+
console.error(`Failed to start OpenClaw: ${err.message}`);
|
|
231082
|
+
await cleanup();
|
|
231083
|
+
});
|
|
231084
|
+
} else {
|
|
231085
|
+
console.log("Starting OpenClaw via npx...");
|
|
231086
|
+
openclawProcess = (0, import_child_process.spawn)("npx", ["openclaw"], {
|
|
231087
|
+
stdio: "inherit",
|
|
231088
|
+
env: { ...process.env },
|
|
231089
|
+
shell: true
|
|
231090
|
+
});
|
|
231091
|
+
openclawProcess.on("exit", async (code) => {
|
|
231092
|
+
console.log(`OpenClaw exited with code ${code}`);
|
|
231093
|
+
await cleanup();
|
|
231094
|
+
process.exit(code ?? 0);
|
|
231095
|
+
});
|
|
231096
|
+
openclawProcess.on("error", async (err) => {
|
|
231097
|
+
console.error(`Failed to start OpenClaw: ${err.message}`);
|
|
231098
|
+
console.log("OpenClaw not found. Gateway running in standalone mode.");
|
|
231099
|
+
});
|
|
231100
|
+
}
|
|
231101
|
+
return {
|
|
231102
|
+
port,
|
|
231103
|
+
openclawProcess,
|
|
231104
|
+
cleanup
|
|
231105
|
+
};
|
|
231106
|
+
}
|
|
231107
|
+
|
|
231108
|
+
// src/index.ts
|
|
231109
|
+
var import_promises4 = require("fs/promises");
|
|
230888
231110
|
var import_node_path = require("path");
|
|
230889
231111
|
var import_node_os = require("os");
|
|
230890
231112
|
var import_node_readline = require("readline");
|
|
@@ -230906,13 +231128,13 @@ async function readLine(prompt) {
|
|
|
230906
231128
|
}
|
|
230907
231129
|
async function getMasterKey() {
|
|
230908
231130
|
try {
|
|
230909
|
-
const keyData = await (0,
|
|
231131
|
+
const keyData = await (0, import_promises4.readFile)(KEY_FILE);
|
|
230910
231132
|
return keyData;
|
|
230911
231133
|
} catch (error) {
|
|
230912
231134
|
if (error.code === "ENOENT") {
|
|
230913
231135
|
const key = generateMasterKey();
|
|
230914
|
-
await (0,
|
|
230915
|
-
await (0,
|
|
231136
|
+
await (0, import_promises4.mkdir)(CONFIG_DIR, { recursive: true });
|
|
231137
|
+
await (0, import_promises4.writeFile)(KEY_FILE, key, { mode: 384 });
|
|
230916
231138
|
console.log(`Created new master key at ${KEY_FILE}`);
|
|
230917
231139
|
return key;
|
|
230918
231140
|
}
|
|
@@ -231117,15 +231339,15 @@ program.command("migrate").description("Migrate from another agent framework").r
|
|
|
231117
231339
|
const key = await getMasterKey();
|
|
231118
231340
|
const sessionDir = (0, import_node_path.join)(options.source, "sessions");
|
|
231119
231341
|
try {
|
|
231120
|
-
const sessionFiles = await (0,
|
|
231342
|
+
const sessionFiles = await (0, import_promises4.readdir)(sessionDir);
|
|
231121
231343
|
const jsonlFiles = sessionFiles.filter((f) => f.endsWith(".jsonl"));
|
|
231122
231344
|
for (const file of jsonlFiles) {
|
|
231123
231345
|
const sourcePath = (0, import_node_path.join)(sessionDir, file);
|
|
231124
231346
|
const destPath = (0, import_node_path.join)(options.dest, "sessions", `${file}.enc`);
|
|
231125
|
-
await (0,
|
|
231126
|
-
const content = await (0,
|
|
231347
|
+
await (0, import_promises4.mkdir)((0, import_node_path.join)(options.dest, "sessions"), { recursive: true });
|
|
231348
|
+
const content = await (0, import_promises4.readFile)(sourcePath, "utf8");
|
|
231127
231349
|
const encrypted = encrypt(content, key);
|
|
231128
|
-
await (0,
|
|
231350
|
+
await (0, import_promises4.writeFile)(destPath, encrypted);
|
|
231129
231351
|
console.log(` Encrypted: ${file}`);
|
|
231130
231352
|
}
|
|
231131
231353
|
} catch (error) {
|
|
@@ -231185,9 +231407,16 @@ program.command("migrate").description("Migrate from another agent framework").r
|
|
|
231185
231407
|
process.exit(1);
|
|
231186
231408
|
}
|
|
231187
231409
|
});
|
|
231188
|
-
program.command("start").description("Start OpenPaw services").action(async () => {
|
|
231189
|
-
|
|
231190
|
-
|
|
231410
|
+
program.command("start").description("Start OpenPaw services").option("--port <port>", "Gateway port", "18789").option("--openclaw-dir <path>", "OpenClaw config directory", (0, import_node_path.join)((0, import_node_os.homedir)(), ".openclaw")).action(async (options) => {
|
|
231411
|
+
try {
|
|
231412
|
+
await startGateway({
|
|
231413
|
+
port: parseInt(options.port, 10),
|
|
231414
|
+
openclawDir: options.openclawDir
|
|
231415
|
+
});
|
|
231416
|
+
} catch (error) {
|
|
231417
|
+
console.error(`Error: ${error.message}`);
|
|
231418
|
+
process.exit(1);
|
|
231419
|
+
}
|
|
231191
231420
|
});
|
|
231192
231421
|
program.command("stop").description("Stop OpenPaw services").action(async () => {
|
|
231193
231422
|
console.log("Stopping OpenPaw services...");
|
|
@@ -231235,13 +231464,13 @@ program.command("doctor").description("Check dependencies and configuration").op
|
|
|
231235
231464
|
checks.push({ name: "Node.js", status: "FAIL", message: `${nodeVersion} (>= 18 required)` });
|
|
231236
231465
|
}
|
|
231237
231466
|
try {
|
|
231238
|
-
await (0,
|
|
231467
|
+
await (0, import_promises4.mkdir)(CONFIG_DIR, { recursive: true });
|
|
231239
231468
|
checks.push({ name: "Config directory", status: "PASS", message: CONFIG_DIR });
|
|
231240
231469
|
} catch (error) {
|
|
231241
231470
|
checks.push({ name: "Config directory", status: "FAIL", message: error.message });
|
|
231242
231471
|
}
|
|
231243
231472
|
try {
|
|
231244
|
-
const keyStats = await (0,
|
|
231473
|
+
const keyStats = await (0, import_promises4.readFile)(KEY_FILE);
|
|
231245
231474
|
if (keyStats.length === 32) {
|
|
231246
231475
|
checks.push({ name: "Master key", status: "PASS", message: "Valid 256-bit key" });
|
|
231247
231476
|
} else {
|
|
@@ -231255,7 +231484,7 @@ program.command("doctor").description("Check dependencies and configuration").op
|
|
|
231255
231484
|
}
|
|
231256
231485
|
}
|
|
231257
231486
|
try {
|
|
231258
|
-
await (0,
|
|
231487
|
+
await (0, import_promises4.readFile)(VAULT_FILE);
|
|
231259
231488
|
checks.push({ name: "Vault file", status: "PASS", message: VAULT_FILE });
|
|
231260
231489
|
} catch (error) {
|
|
231261
231490
|
if (error.code === "ENOENT") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sahu-01/openpaw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "OpenPaw CLI - Security-first wrapper for AI agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,13 +22,15 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"commander": "^12.0.0",
|
|
25
|
+
"ws": "^8.16.0",
|
|
25
26
|
"zod": "^3.22.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
29
|
+
"@zkagi/openpaw-detect": "workspace:*",
|
|
30
|
+
"@zkagi/openpaw-vault": "workspace:*",
|
|
31
|
+
"@zkagi/openpaw-scanner": "workspace:*",
|
|
32
|
+
"@zkagi/openpaw-migrate": "workspace:*",
|
|
33
|
+
"@zkagi/openpaw-gateway": "workspace:*",
|
|
32
34
|
"tsup": "^8.0.0",
|
|
33
35
|
"tsx": "^4.7.0",
|
|
34
36
|
"typescript": "^5.4.0",
|