intention-coding 0.5.1 → 0.5.3
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.cjs +301 -17
- package/dist/services/export-excel/index.d.ts.map +1 -1
- package/dist/services/image-analysis/analyzer.d.ts +4 -0
- package/dist/services/image-analysis/analyzer.d.ts.map +1 -1
- package/dist/services/image-analysis/index.d.ts.map +1 -1
- package/dist/services/image-converter/index.d.ts +2 -2
- package/dist/services/read-excel/index.d.ts.map +1 -1
- package/dist/utils/common.d.ts +8 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/dify.d.ts +24 -2
- package/dist/utils/dify.d.ts.map +1 -1
- package/dist/utils/path-utils.d.ts +72 -0
- package/dist/utils/path-utils.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -318,18 +318,39 @@ var __webpack_exports__ = {};
|
|
|
318
318
|
var external_html_to_md_default = /*#__PURE__*/ __webpack_require__.n(external_html_to_md_namespaceObject);
|
|
319
319
|
const external_os_namespaceObject = require("os");
|
|
320
320
|
const sanitizeFileName = (input)=>input.replace(/[\\/:*?"<>|\n\r#%&]/g, '').trim().replace(/\s+/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
|
|
321
|
-
|
|
322
|
-
if ('
|
|
321
|
+
function normalizePath(filePath) {
|
|
322
|
+
if (!filePath || 'string' != typeof filePath) throw new Error("\u6587\u4EF6\u8DEF\u5F84\u4E0D\u80FD\u4E3A\u7A7A");
|
|
323
|
+
filePath = filePath.trim().replace(/^["']|["']$/g, '');
|
|
324
|
+
if ('win32' === process.platform) {
|
|
325
|
+
if (filePath.startsWith('\\\\')) return '\\\\?\\UNC\\' + filePath.substring(2);
|
|
326
|
+
if (filePath.match(/^[a-zA-Z]:/)) filePath = filePath.replace(/\\/g, '/');
|
|
327
|
+
}
|
|
323
328
|
const normalized = external_path_default().normalize(filePath);
|
|
324
329
|
const resolved = external_path_default().resolve(normalized);
|
|
330
|
+
return resolved;
|
|
331
|
+
}
|
|
332
|
+
async function validateAndResolvePath(filePath) {
|
|
333
|
+
if (!filePath) throw new Error("\u6587\u4EF6\u8DEF\u5F84\u53C2\u6570\u7F3A\u5931\uFF0C\u8BF7\u63D0\u4F9B filePath \u53C2\u6570");
|
|
334
|
+
const resolved = normalizePath(filePath);
|
|
325
335
|
try {
|
|
326
336
|
await external_fs_namespaceObject.promises.access(resolved, external_fs_namespaceObject.constants.R_OK);
|
|
327
337
|
} catch (error) {
|
|
328
|
-
|
|
329
|
-
|
|
338
|
+
const osInfo = `[${process.platform}]`;
|
|
339
|
+
logger.warn(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB} ${osInfo}: ${resolved}`, error);
|
|
340
|
+
throw new Error(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB} ${osInfo}: ${resolved}`);
|
|
330
341
|
}
|
|
331
342
|
return resolved;
|
|
332
343
|
}
|
|
344
|
+
function isValidExcelPath(filePath) {
|
|
345
|
+
if (!filePath) return false;
|
|
346
|
+
const normalized = normalizePath(filePath);
|
|
347
|
+
const ext = external_path_default().extname(normalized).toLowerCase();
|
|
348
|
+
return [
|
|
349
|
+
'.xlsx',
|
|
350
|
+
'.xls',
|
|
351
|
+
'.xlsm'
|
|
352
|
+
].includes(ext);
|
|
353
|
+
}
|
|
333
354
|
var util_util;
|
|
334
355
|
(function(util) {
|
|
335
356
|
util.assertEqual = (_)=>{};
|
|
@@ -4663,6 +4684,202 @@ ${requirementSection}
|
|
|
4663
4684
|
}
|
|
4664
4685
|
}
|
|
4665
4686
|
const openAIService = new OpenAIService();
|
|
4687
|
+
async function invokeFlow(params, streamCb) {
|
|
4688
|
+
const { appid = 'app-ESTcrkOPOmkxdrO0120mE4s1', data, timeout = 1800000 } = params;
|
|
4689
|
+
const controller = new AbortController();
|
|
4690
|
+
const signal = controller.signal;
|
|
4691
|
+
if ('undefined' == typeof ReadableStream) throw new Error('ReadableStream is not supported in this environment');
|
|
4692
|
+
const fetchData = async (retryCount = 0)=>{
|
|
4693
|
+
try {
|
|
4694
|
+
const fetchOptions = {
|
|
4695
|
+
method: 'POST',
|
|
4696
|
+
headers: {
|
|
4697
|
+
Authorization: `Bearer ${appid}`,
|
|
4698
|
+
'Content-Type': 'application/json'
|
|
4699
|
+
},
|
|
4700
|
+
body: JSON.stringify({
|
|
4701
|
+
inputs: data,
|
|
4702
|
+
response_mode: 'streaming',
|
|
4703
|
+
user: "aico-mcp"
|
|
4704
|
+
}),
|
|
4705
|
+
signal
|
|
4706
|
+
};
|
|
4707
|
+
const res = await fetch('http://11.0.166.20:9199/v1/workflows/run', fetchOptions);
|
|
4708
|
+
if (!res.ok) {
|
|
4709
|
+
if (retryCount < 3) {
|
|
4710
|
+
await new Promise((resolve)=>setTimeout(resolve, 1000));
|
|
4711
|
+
return fetchData(retryCount + 1);
|
|
4712
|
+
}
|
|
4713
|
+
const errorResponse = await res.text();
|
|
4714
|
+
throw new Error(`\u{7F51}\u{7EDC}\u{54CD}\u{5E94}\u{5F02}\u{5E38}: ${res.status} ${res.statusText} - ${errorResponse}`);
|
|
4715
|
+
}
|
|
4716
|
+
if (res.ok) if (res.body) {
|
|
4717
|
+
const reader = res.body.getReader();
|
|
4718
|
+
const decoder = new TextDecoder('utf-8');
|
|
4719
|
+
if (streamCb) return void new ReadableStream({
|
|
4720
|
+
start (controller) {
|
|
4721
|
+
let buffer = '';
|
|
4722
|
+
function push() {
|
|
4723
|
+
reader.read().then(({ done, value })=>{
|
|
4724
|
+
if (done) {
|
|
4725
|
+
const lines = buffer.split('\n');
|
|
4726
|
+
for (const line of lines)handleLine(line, controller);
|
|
4727
|
+
if (streamCb) streamCb({
|
|
4728
|
+
isEnd: true
|
|
4729
|
+
});
|
|
4730
|
+
controller.close();
|
|
4731
|
+
return;
|
|
4732
|
+
}
|
|
4733
|
+
const chunkText = decoder.decode(value, {
|
|
4734
|
+
stream: true
|
|
4735
|
+
});
|
|
4736
|
+
buffer += chunkText;
|
|
4737
|
+
const lines = buffer.split('\n');
|
|
4738
|
+
for(let i = 0; i < lines.length - 1; i++)handleLine(lines[i], controller);
|
|
4739
|
+
buffer = lines[lines.length - 1];
|
|
4740
|
+
push();
|
|
4741
|
+
});
|
|
4742
|
+
}
|
|
4743
|
+
function handleLine(line, controller) {
|
|
4744
|
+
line = line.trim();
|
|
4745
|
+
if (line.startsWith('data:')) {
|
|
4746
|
+
const dataStr = line.slice(5).trim();
|
|
4747
|
+
if ('' === dataStr) return;
|
|
4748
|
+
try {
|
|
4749
|
+
const jsonData = JSON.parse(dataStr);
|
|
4750
|
+
if (jsonData.data?.text) {
|
|
4751
|
+
const wrappedData = {
|
|
4752
|
+
content: jsonData.data.text.toString(),
|
|
4753
|
+
controller
|
|
4754
|
+
};
|
|
4755
|
+
if (streamCb) streamCb(wrappedData);
|
|
4756
|
+
}
|
|
4757
|
+
} catch (e) {
|
|
4758
|
+
console.error("\u89E3\u6790JSON\u5931\u8D25:", e);
|
|
4759
|
+
}
|
|
4760
|
+
}
|
|
4761
|
+
}
|
|
4762
|
+
push();
|
|
4763
|
+
}
|
|
4764
|
+
});
|
|
4765
|
+
{
|
|
4766
|
+
let buffer = '';
|
|
4767
|
+
let accumulatedText = '';
|
|
4768
|
+
let isResponseEnded = false;
|
|
4769
|
+
const readAll = async ()=>{
|
|
4770
|
+
const { done, value } = await reader.read();
|
|
4771
|
+
if (done) {
|
|
4772
|
+
if (!isResponseEnded) throw new Error("\u54CD\u5E94\u63D0\u524D\u7ED3\u675F");
|
|
4773
|
+
return accumulatedText;
|
|
4774
|
+
}
|
|
4775
|
+
const chunkText = decoder.decode(value, {
|
|
4776
|
+
stream: true
|
|
4777
|
+
});
|
|
4778
|
+
buffer += chunkText;
|
|
4779
|
+
const lines = buffer.split('\n');
|
|
4780
|
+
for(let i = 0; i < lines.length - 1; i++){
|
|
4781
|
+
const line = lines[i].trim();
|
|
4782
|
+
if (!line.startsWith('data:')) continue;
|
|
4783
|
+
const dataStr = line.slice(5).trim();
|
|
4784
|
+
if ('' !== dataStr) try {
|
|
4785
|
+
const jsonData = JSON.parse(dataStr);
|
|
4786
|
+
switch(jsonData.event){
|
|
4787
|
+
case 'message':
|
|
4788
|
+
case 'agent_message':
|
|
4789
|
+
case 'text_chunk':
|
|
4790
|
+
{
|
|
4791
|
+
const content = 'text_chunk' === jsonData.event ? jsonData.data.text : jsonData.answer;
|
|
4792
|
+
accumulatedText += content;
|
|
4793
|
+
break;
|
|
4794
|
+
}
|
|
4795
|
+
case 'workflow_finished':
|
|
4796
|
+
accumulatedText = jsonData.data;
|
|
4797
|
+
isResponseEnded = true;
|
|
4798
|
+
break;
|
|
4799
|
+
case 'message_end':
|
|
4800
|
+
isResponseEnded = true;
|
|
4801
|
+
break;
|
|
4802
|
+
case 'error':
|
|
4803
|
+
throw new Error(`\u{670D}\u{52A1}\u{5668}\u{9519}\u{8BEF}: ${jsonData.code}, ${jsonData.message}`);
|
|
4804
|
+
default:
|
|
4805
|
+
break;
|
|
4806
|
+
}
|
|
4807
|
+
} catch (e) {
|
|
4808
|
+
throw new Error("\u89E3\u6790JSON\u5931\u8D25: " + e.message);
|
|
4809
|
+
}
|
|
4810
|
+
}
|
|
4811
|
+
buffer = lines[lines.length - 1];
|
|
4812
|
+
return readAll();
|
|
4813
|
+
};
|
|
4814
|
+
return readAll();
|
|
4815
|
+
}
|
|
4816
|
+
} else throw new Error("\u54CD\u5E94\u4F53\u4E3A\u7A7A");
|
|
4817
|
+
{
|
|
4818
|
+
const errorResponse = await res.text();
|
|
4819
|
+
throw new Error(`\u{7F51}\u{7EDC}\u{54CD}\u{5E94}\u{5F02}\u{5E38}: ${res.status} ${res.statusText} - ${errorResponse}`);
|
|
4820
|
+
}
|
|
4821
|
+
} catch (error) {
|
|
4822
|
+
if ('AbortError' === error.name) throw new Error("\u8BF7\u6C42\u5DF2\u88AB\u4E2D\u6B62\uFF0C\u8D85\u65F6");
|
|
4823
|
+
throw error;
|
|
4824
|
+
}
|
|
4825
|
+
};
|
|
4826
|
+
try {
|
|
4827
|
+
const result = await Promise.race([
|
|
4828
|
+
fetchData(),
|
|
4829
|
+
new Promise((_, reject)=>{
|
|
4830
|
+
setTimeout(()=>{
|
|
4831
|
+
controller.abort();
|
|
4832
|
+
reject(new Error("\u8BF7\u6C42\u8D85\u65F6"));
|
|
4833
|
+
}, timeout);
|
|
4834
|
+
})
|
|
4835
|
+
]);
|
|
4836
|
+
if (streamCb) return;
|
|
4837
|
+
return result;
|
|
4838
|
+
} catch (error) {
|
|
4839
|
+
controller.abort();
|
|
4840
|
+
throw error;
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4843
|
+
async function uploadFile(params) {
|
|
4844
|
+
const { appid, filePath, user = 'aico-mcp' } = params;
|
|
4845
|
+
try {
|
|
4846
|
+
const fileBuffer = await external_fs_default().promises.readFile(filePath);
|
|
4847
|
+
const fileName = external_path_default().basename(filePath);
|
|
4848
|
+
const fileExtension = external_path_default().extname(filePath).toLowerCase().slice(1);
|
|
4849
|
+
const mimeTypes = {
|
|
4850
|
+
png: 'image/png',
|
|
4851
|
+
jpeg: 'image/jpeg',
|
|
4852
|
+
jpg: 'image/jpeg',
|
|
4853
|
+
webp: 'image/webp',
|
|
4854
|
+
gif: 'image/gif'
|
|
4855
|
+
};
|
|
4856
|
+
const mimeType = mimeTypes[fileExtension] || 'application/octet-stream';
|
|
4857
|
+
const formData = new FormData();
|
|
4858
|
+
formData.append('file', new Blob([
|
|
4859
|
+
fileBuffer.buffer
|
|
4860
|
+
], {
|
|
4861
|
+
type: mimeType
|
|
4862
|
+
}), fileName);
|
|
4863
|
+
formData.append('user', user);
|
|
4864
|
+
const response = await fetch('http://11.0.166.20:9199/v1/files/upload', {
|
|
4865
|
+
method: 'POST',
|
|
4866
|
+
headers: {
|
|
4867
|
+
Authorization: `Bearer ${appid}`
|
|
4868
|
+
},
|
|
4869
|
+
body: formData
|
|
4870
|
+
});
|
|
4871
|
+
if (!response.ok) {
|
|
4872
|
+
const errorText = await response.text();
|
|
4873
|
+
throw new Error(`\u{6587}\u{4EF6}\u{4E0A}\u{4F20}\u{5931}\u{8D25}: ${response.status} ${response.statusText} - ${errorText}`);
|
|
4874
|
+
}
|
|
4875
|
+
const result = await response.json();
|
|
4876
|
+
if (!result.id || !result.name) throw new Error("\u65E0\u6548\u7684\u6587\u4EF6\u4E0A\u4F20\u54CD\u5E94\u683C\u5F0F");
|
|
4877
|
+
return result;
|
|
4878
|
+
} catch (error) {
|
|
4879
|
+
if (error instanceof Error) throw new Error(`\u{6587}\u{4EF6}\u{4E0A}\u{4F20}\u{5931}\u{8D25}: ${error.message}`);
|
|
4880
|
+
throw new Error("\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25: \u672A\u77E5\u9519\u8BEF");
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4666
4883
|
var types_AnalysisType = /*#__PURE__*/ function(AnalysisType) {
|
|
4667
4884
|
AnalysisType["GENERAL"] = "general";
|
|
4668
4885
|
AnalysisType["OBJECTS"] = "objects";
|
|
@@ -4761,15 +4978,13 @@ ${requirementSection}
|
|
|
4761
4978
|
const analysisContent = this.parseAIResponse(aiResponse);
|
|
4762
4979
|
return analysisContent;
|
|
4763
4980
|
} catch (error) {
|
|
4764
|
-
logger.
|
|
4981
|
+
logger.warn("\u4E3BAI\u5206\u6790\u5931\u8D25\uFF0C\u5C1D\u8BD5Dify\u515C\u5E95\u5206\u6790", {
|
|
4765
4982
|
error,
|
|
4766
4983
|
params: {
|
|
4767
4984
|
image_path: imagePath
|
|
4768
4985
|
}
|
|
4769
4986
|
});
|
|
4770
|
-
|
|
4771
|
-
originalError: error
|
|
4772
|
-
});
|
|
4987
|
+
return await this.fallbackToDifyAnalysis(imagePath, context);
|
|
4773
4988
|
}
|
|
4774
4989
|
}
|
|
4775
4990
|
buildAnalysisPrompt(imagePath, basicInfo, context) {
|
|
@@ -5034,6 +5249,59 @@ ${context}
|
|
|
5034
5249
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
5035
5250
|
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
5036
5251
|
}
|
|
5252
|
+
async fallbackToDifyAnalysis(imagePath, context) {
|
|
5253
|
+
logger.info("\u5F00\u59CBDify\u515C\u5E95\u56FE\u7247\u5206\u6790", {
|
|
5254
|
+
imagePath: imagePath,
|
|
5255
|
+
context: context
|
|
5256
|
+
});
|
|
5257
|
+
try {
|
|
5258
|
+
const uploadResult = await uploadFile({
|
|
5259
|
+
appid: 'app-AvlLh0nfN4l9oz1MSW4sEAQ6',
|
|
5260
|
+
filePath: imagePath,
|
|
5261
|
+
user: 'aico-mcp'
|
|
5262
|
+
});
|
|
5263
|
+
logger.info("\u6587\u4EF6\u4E0A\u4F20\u6210\u529F\uFF0C\u6587\u4EF6ID:", uploadResult.id);
|
|
5264
|
+
const workflowData = {
|
|
5265
|
+
imagePath: {
|
|
5266
|
+
type: 'image',
|
|
5267
|
+
transfer_method: 'local_file',
|
|
5268
|
+
upload_file_id: uploadResult.id
|
|
5269
|
+
},
|
|
5270
|
+
context: context || "\u8BF7\u5206\u6790\u8FD9\u5F20\u56FE\u7247\u7684\u5185\u5BB9"
|
|
5271
|
+
};
|
|
5272
|
+
const workflowResponse = await invokeFlow({
|
|
5273
|
+
appid: 'app-AvlLh0nfN4l9oz1MSW4sEAQ6',
|
|
5274
|
+
data: workflowData
|
|
5275
|
+
});
|
|
5276
|
+
logger.info("Dify\u5DE5\u4F5C\u6D41\u8C03\u7528\u6210\u529F", {
|
|
5277
|
+
response: workflowResponse
|
|
5278
|
+
});
|
|
5279
|
+
if (workflowResponse?.status === 'failed') throw new Error(`Dify\u{5DE5}\u{4F5C}\u{6D41}\u{6267}\u{884C}\u{5931}\u{8D25}: ${workflowResponse.error || "\u672A\u77E5\u9519\u8BEF"}`);
|
|
5280
|
+
if (workflowResponse?.status !== 'succeeded') throw new Error(`Dify\u{5DE5}\u{4F5C}\u{6D41}\u{72B6}\u{6001}\u{5F02}\u{5E38}: ${workflowResponse?.status}`);
|
|
5281
|
+
let summary = "\u5206\u6790\u5B8C\u6210";
|
|
5282
|
+
if ('string' == typeof workflowResponse) summary = workflowResponse;
|
|
5283
|
+
else if (workflowResponse?.data?.text) summary = workflowResponse.data.text;
|
|
5284
|
+
else if (workflowResponse?.answer) summary = workflowResponse.answer;
|
|
5285
|
+
else if (workflowResponse?.outputs?.text) summary = workflowResponse.outputs.text;
|
|
5286
|
+
return {
|
|
5287
|
+
summary: summary,
|
|
5288
|
+
details: {
|
|
5289
|
+
dify_response: workflowResponse,
|
|
5290
|
+
fallback_used: true
|
|
5291
|
+
},
|
|
5292
|
+
tags: [
|
|
5293
|
+
'dify-fallback'
|
|
5294
|
+
]
|
|
5295
|
+
};
|
|
5296
|
+
} catch (error) {
|
|
5297
|
+
logger.error("Dify\u670D\u52A1\u8C03\u7528\u5931\u8D25", {
|
|
5298
|
+
error: error instanceof Error ? error.message : String(error),
|
|
5299
|
+
imagePath: imagePath,
|
|
5300
|
+
context: context
|
|
5301
|
+
});
|
|
5302
|
+
throw new ImageAnalysisError(`\u{56FE}\u{7247}\u{5206}\u{6790}\u{670D}\u{52A1}\u{8C03}\u{7528}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`, types_AnalysisErrorCodes.AI_SERVICE_ERROR);
|
|
5303
|
+
}
|
|
5304
|
+
}
|
|
5037
5305
|
}
|
|
5038
5306
|
const ImageAnalysisParamsSchema = objectType({
|
|
5039
5307
|
image_path: stringType().min(1).describe("\u56FE\u7247\u6587\u4EF6\u8DEF\u5F84"),
|
|
@@ -6660,12 +6928,15 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
6660
6928
|
const { filePath, options = {} } = args;
|
|
6661
6929
|
if (!filePath) throw new Error("\u6587\u4EF6\u8DEF\u5F84\u53C2\u6570\u7F3A\u5931\uFF0C\u8BF7\u63D0\u4F9B filePath \u53C2\u6570");
|
|
6662
6930
|
try {
|
|
6931
|
+
if (!isValidExcelPath(filePath)) throw new Error(`\u{6587}\u{4EF6}\u{683C}\u{5F0F}\u{4E0D}\u{652F}\u{6301}\u{FF0C}\u{8BF7}\u{63D0}\u{4F9B}\u{6709}\u{6548}\u{7684}Excel\u{6587}\u{4EF6}\u{8DEF}\u{5F84}(.xlsx, .xls, .xlsm): ${filePath}`);
|
|
6663
6932
|
const resolvedPath = await validateAndResolvePath(filePath);
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6933
|
+
logger.info("\u5F00\u59CB\u8BFB\u53D6Excel\u6587\u4EF6", {
|
|
6934
|
+
tool: 'read_excel',
|
|
6935
|
+
originalPath: filePath,
|
|
6936
|
+
resolvedPath: resolvedPath,
|
|
6937
|
+
platform: process.platform,
|
|
6938
|
+
options: options
|
|
6939
|
+
});
|
|
6669
6940
|
const buffer = await promises_namespaceObject.readFile(resolvedPath);
|
|
6670
6941
|
const workbook = external_xlsx_namespaceObject.read(buffer, {
|
|
6671
6942
|
type: 'buffer',
|
|
@@ -6737,20 +7008,29 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
6737
7008
|
};
|
|
6738
7009
|
} catch (error) {
|
|
6739
7010
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
6740
|
-
|
|
7011
|
+
const osInfo = `[${process.platform}]`;
|
|
7012
|
+
logger.error(`Excel\u{8BFB}\u{53D6}\u{5931}\u{8D25} ${osInfo}: ${errorMsg}`, {
|
|
6741
7013
|
tool: "read_excel",
|
|
6742
7014
|
filePath,
|
|
7015
|
+
resolvedPath: error.resolvedPath || filePath,
|
|
7016
|
+
platform: process.platform,
|
|
6743
7017
|
options
|
|
6744
7018
|
});
|
|
7019
|
+
let userFriendlyMessage = `Excel\u{8BFB}\u{53D6}\u{5931}\u{8D25}: ${errorMsg}`;
|
|
7020
|
+
if (errorMsg.includes("\u6587\u4EF6\u4E0D\u5B58\u5728")) userFriendlyMessage += "\n\uD83D\uDCA1 \u89E3\u51B3\u65B9\u6848\uFF1A\u8BF7\u68C0\u67E5\u6587\u4EF6\u8DEF\u5F84\u662F\u5426\u6B63\u786E\uFF0C\u786E\u4FDD\u6587\u4EF6\u5B58\u5728\u4E14\u53EF\u8BFB";
|
|
7021
|
+
else if (errorMsg.includes("\u6587\u4EF6\u683C\u5F0F\u4E0D\u652F\u6301")) userFriendlyMessage += "\n\uD83D\uDCA1 \u89E3\u51B3\u65B9\u6848\uFF1A\u8BF7\u786E\u4FDD\u6587\u4EF6\u662F\u6709\u6548\u7684Excel\u683C\u5F0F(.xlsx, .xls, .xlsm)";
|
|
7022
|
+
else if (errorMsg.includes("\u8DEF\u5F84\u53C2\u6570\u7F3A\u5931")) userFriendlyMessage += "\n\uD83D\uDCA1 \u89E3\u51B3\u65B9\u6848\uFF1A\u8BF7\u63D0\u4F9B\u5B8C\u6574\u7684\u6587\u4EF6\u8DEF\u5F84\u53C2\u6570";
|
|
6745
7023
|
return {
|
|
6746
7024
|
content: [
|
|
6747
7025
|
{
|
|
6748
7026
|
type: "text",
|
|
6749
7027
|
text: JSON.stringify({
|
|
6750
7028
|
success: false,
|
|
6751
|
-
message:
|
|
7029
|
+
message: userFriendlyMessage,
|
|
7030
|
+
platform: process.platform,
|
|
7031
|
+
originalPath: filePath,
|
|
6752
7032
|
data: null
|
|
6753
|
-
})
|
|
7033
|
+
}, null, 2)
|
|
6754
7034
|
}
|
|
6755
7035
|
],
|
|
6756
7036
|
isError: true
|
|
@@ -6857,7 +7137,7 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
6857
7137
|
};
|
|
6858
7138
|
external_xlsx_namespaceObject.utils.book_append_sheet(workbook, worksheet, options.sheetName || 'Sheet1');
|
|
6859
7139
|
let finalOutputPath;
|
|
6860
|
-
if (outputPath) finalOutputPath =
|
|
7140
|
+
if (outputPath) finalOutputPath = normalizePath(outputPath);
|
|
6861
7141
|
else {
|
|
6862
7142
|
const excelDir = external_path_default().join(getStorageDir(), 'excel');
|
|
6863
7143
|
await promises_namespaceObject.mkdir(excelDir, {
|
|
@@ -6866,6 +7146,10 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
6866
7146
|
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
6867
7147
|
finalOutputPath = external_path_default().join(excelDir, `export_${timestamp}.${options.format || 'xlsx'}`);
|
|
6868
7148
|
}
|
|
7149
|
+
const outputDir = external_path_default().dirname(finalOutputPath);
|
|
7150
|
+
await promises_namespaceObject.mkdir(outputDir, {
|
|
7151
|
+
recursive: true
|
|
7152
|
+
});
|
|
6869
7153
|
const buffer = external_xlsx_namespaceObject.write(workbook, {
|
|
6870
7154
|
type: 'buffer',
|
|
6871
7155
|
bookType: options.format || 'xlsx'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/export-excel/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBlC,CAAC;AAEH,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;QAChC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE;YACJ,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAClC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SACnC,CAAC;KACL,CAAC;CACL;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAIF,GAAG;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/export-excel/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBlC,CAAC;AAEH,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;QAChC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE;YACJ,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAClC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SACnC,CAAC;KACL,CAAC;CACL;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAIF,GAAG;;;;;;;;;;;;;CA+K5B,CAAC"}
|
|
@@ -51,5 +51,9 @@ export declare class ImageAnalyzer {
|
|
|
51
51
|
private extractNonFunctionalRequirements;
|
|
52
52
|
private extractUserStories;
|
|
53
53
|
private formatFileSize;
|
|
54
|
+
/**
|
|
55
|
+
* Dify兜底分析 - 当所有现有分析方法失败时调用
|
|
56
|
+
*/
|
|
57
|
+
private fallbackToDifyAnalysis;
|
|
54
58
|
}
|
|
55
59
|
//# sourceMappingURL=analyzer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/services/image-analysis/analyzer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/services/image-analysis/analyzer.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,cAAc,EAQf,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACG,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAmDhF;;OAEG;YACW,iBAAiB;IAgC/B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAwB3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAgCvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;OAEG;YACW,iBAAiB;IAyB/B;;OAEG;YACW,aAAa;IAsC3B;;OAEG;YACW,cAAc;IA0B5B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAahC,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,mBAAmB;IA2B3B,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,6BAA6B;IA2BrC,OAAO,CAAC,gCAAgC;IAqBxC,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,cAAc;IAUtB;;OAEG;YACW,sBAAsB;CAiFrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/image-analysis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/image-analysis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,QAAA,MAAM,yBAAyB;;;;;;;;;EAI3B,CAAC;AAEL,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEhF;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;oBASH;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;CAqD/D,CAAC;AAGF,eAAO,MAAM,iBAAiB;;;;;;;oBAxDN;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;CAwDjB,CAAC;AA4GhD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EACV,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
|
@@ -9,7 +9,7 @@ declare const ImageConversionParamsSchema: z.ZodObject<{
|
|
|
9
9
|
output_directory: z.ZodOptional<z.ZodString>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
11
|
input_paths: string | string[];
|
|
12
|
-
output_format: "
|
|
12
|
+
output_format: "png" | "jpeg" | "jpg" | "webp" | "gif" | "bmp" | "tiff" | "ico";
|
|
13
13
|
maintain_aspect_ratio: boolean;
|
|
14
14
|
width?: number | undefined;
|
|
15
15
|
height?: number | undefined;
|
|
@@ -17,7 +17,7 @@ declare const ImageConversionParamsSchema: z.ZodObject<{
|
|
|
17
17
|
output_directory?: string | undefined;
|
|
18
18
|
}, {
|
|
19
19
|
input_paths: string | string[];
|
|
20
|
-
output_format: "
|
|
20
|
+
output_format: "png" | "jpeg" | "jpg" | "webp" | "gif" | "bmp" | "tiff" | "ico";
|
|
21
21
|
width?: number | undefined;
|
|
22
22
|
height?: number | undefined;
|
|
23
23
|
quality?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/read-excel/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUhC,CAAC;AAEH,MAAM,WAAW,eAAe;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC;CACL;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAIA,GAAG;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/read-excel/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUhC,CAAC;AAEH,MAAM,WAAW,eAAe;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC;CACL;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAIA,GAAG;;;;;;;;;;;;;CA+J5B,CAAC"}
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -10,8 +10,16 @@ export declare const sanitizeFileName: (input: string) => string;
|
|
|
10
10
|
* @returns 不含图片的纯文本Markdown
|
|
11
11
|
*/
|
|
12
12
|
export declare function removeImagesFromMarkdown(content: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* 跨平台路径标准化处理
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizePath(filePath: string): string;
|
|
13
17
|
/**
|
|
14
18
|
* 安全验证并标准化路径
|
|
15
19
|
*/
|
|
16
20
|
export declare function validateAndResolvePath(filePath: string): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* 检查路径是否为有效的Excel文件
|
|
23
|
+
*/
|
|
24
|
+
export declare function isValidExcelPath(filePath: string): boolean;
|
|
17
25
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CActC;AAED,iBAAiB;AACjB,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,MAWhD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAiBhE;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkB9E"}
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CActC;AAED,iBAAiB;AACjB,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,MAWhD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAiBhE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA8BtD;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkB9E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAO1D"}
|
package/dist/utils/dify.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ReadableStreamController } from "stream/web";
|
|
2
1
|
interface Params {
|
|
3
2
|
appid?: string;
|
|
4
3
|
data: any;
|
|
@@ -6,9 +5,18 @@ interface Params {
|
|
|
6
5
|
}
|
|
7
6
|
type StreamCallback = (data: {
|
|
8
7
|
content?: string;
|
|
9
|
-
controller?:
|
|
8
|
+
controller?: any;
|
|
10
9
|
isEnd?: boolean;
|
|
11
10
|
}) => void;
|
|
11
|
+
interface DifyFileUploadResponse {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
size: number;
|
|
15
|
+
extension: string;
|
|
16
|
+
mime_type: string;
|
|
17
|
+
created_by: number;
|
|
18
|
+
created_at: number;
|
|
19
|
+
}
|
|
12
20
|
/**
|
|
13
21
|
* 调用工作流
|
|
14
22
|
*
|
|
@@ -27,5 +35,19 @@ export declare function invokeFlow(params: Params, streamCb?: StreamCallback): P
|
|
|
27
35
|
* @returns 移除代码块后的内容
|
|
28
36
|
*/
|
|
29
37
|
export declare function removeCodeBlock(content: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* 上传文件到Dify API
|
|
40
|
+
*
|
|
41
|
+
* @param params 上传参数
|
|
42
|
+
* @param params.appid 应用ID
|
|
43
|
+
* @param params.filePath 本地文件路径
|
|
44
|
+
* @param params.user 用户标识
|
|
45
|
+
* @returns Promise<DifyFileUploadResponse> 文件上传响应
|
|
46
|
+
*/
|
|
47
|
+
export declare function uploadFile(params: {
|
|
48
|
+
appid?: string;
|
|
49
|
+
filePath: string;
|
|
50
|
+
user?: string;
|
|
51
|
+
}): Promise<DifyFileUploadResponse>;
|
|
30
52
|
export {};
|
|
31
53
|
//# sourceMappingURL=dify.d.ts.map
|
package/dist/utils/dify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dify.d.ts","sourceRoot":"","sources":["../../src/utils/dify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dify.d.ts","sourceRoot":"","sources":["../../src/utils/dify.ts"],"names":[],"mappings":"AAGA,UAAU,MAAM;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,cAAc,GAAG,CAAC,IAAI,EAAE;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,KAAK,IAAI,CAAC;AAGX,UAAU,sBAAsB;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,CAwNxF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,UAY9C;AAGD;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAyDlC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 跨平台路径工具集
|
|
3
|
+
* 提供Windows、Linux、macOS三平台的路径兼容性处理
|
|
4
|
+
*/
|
|
5
|
+
export interface PathInfo {
|
|
6
|
+
original: string;
|
|
7
|
+
normalized: string;
|
|
8
|
+
absolute: string;
|
|
9
|
+
exists: boolean;
|
|
10
|
+
isFile: boolean;
|
|
11
|
+
isDirectory: boolean;
|
|
12
|
+
size?: number;
|
|
13
|
+
platform: string;
|
|
14
|
+
isValid: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 检测操作系统类型
|
|
18
|
+
*/
|
|
19
|
+
export declare function getPlatformInfo(): {
|
|
20
|
+
platform: NodeJS.Platform;
|
|
21
|
+
arch: NodeJS.Architecture;
|
|
22
|
+
version: string;
|
|
23
|
+
cwd: string;
|
|
24
|
+
homedir: string;
|
|
25
|
+
tmpdir: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 检查路径是否为Windows路径
|
|
29
|
+
*/
|
|
30
|
+
export declare function isWindowsPath(filePath: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 检查路径是否为Linux/macOS路径
|
|
33
|
+
*/
|
|
34
|
+
export declare function isUnixPath(filePath: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* 将Windows路径转换为Unix风格路径
|
|
37
|
+
*/
|
|
38
|
+
export declare function windowsToUnixPath(filePath: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* 将Unix路径转换为Windows路径
|
|
41
|
+
*/
|
|
42
|
+
export declare function unixToWindowsPath(filePath: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* 跨平台路径标准化
|
|
45
|
+
*/
|
|
46
|
+
export declare function normalizeCrossPlatformPath(filePath: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* 获取路径详细信息
|
|
49
|
+
*/
|
|
50
|
+
export declare function getPathInfo(filePath: string): Promise<PathInfo>;
|
|
51
|
+
/**
|
|
52
|
+
* 验证路径是否可读
|
|
53
|
+
*/
|
|
54
|
+
export declare function validatePathAccess(filePath: string): Promise<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* 检查是否为Excel文件路径
|
|
57
|
+
*/
|
|
58
|
+
export declare function isExcelFilePath(filePath: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* 安全地解析和验证文件路径
|
|
61
|
+
*/
|
|
62
|
+
export declare function safeResolvePath(filePath: string): Promise<{
|
|
63
|
+
success: boolean;
|
|
64
|
+
resolvedPath?: string;
|
|
65
|
+
error?: string;
|
|
66
|
+
info?: PathInfo;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* 获取跨平台路径兼容性建议
|
|
70
|
+
*/
|
|
71
|
+
export declare function getPathCompatibilityAdvice(filePath: string): string[];
|
|
72
|
+
//# sourceMappingURL=path-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../src/utils/path-utils.ts"],"names":[],"mappings":"AAMA;;;GAGG;AAEH,MAAM,WAAW,QAAQ;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,eAAe;;;;;;;EAS9B;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY1D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAsB1D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAqCnE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CA8BrE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQ3E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOzD;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;CACnB,CAAC,CAsCD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CA0BrE"}
|