@ugm/desiagent 0.1.21
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/README.md +251 -0
- package/dist/__tests__/test-utils.d.ts +24 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -0
- package/dist/__tests__/test-utils.js +32 -0
- package/dist/__tests__/test-utils.js.map +1 -0
- package/dist/core/execution/agents.d.ts +60 -0
- package/dist/core/execution/agents.d.ts.map +1 -0
- package/dist/core/execution/agents.js +249 -0
- package/dist/core/execution/agents.js.map +1 -0
- package/dist/core/execution/artifacts.d.ts +27 -0
- package/dist/core/execution/artifacts.d.ts.map +1 -0
- package/dist/core/execution/artifacts.js +93 -0
- package/dist/core/execution/artifacts.js.map +1 -0
- package/dist/core/execution/costs.d.ts +160 -0
- package/dist/core/execution/costs.d.ts.map +1 -0
- package/dist/core/execution/costs.js +196 -0
- package/dist/core/execution/costs.js.map +1 -0
- package/dist/core/execution/dagExecutor.d.ts +112 -0
- package/dist/core/execution/dagExecutor.d.ts.map +1 -0
- package/dist/core/execution/dagExecutor.js +647 -0
- package/dist/core/execution/dagExecutor.js.map +1 -0
- package/dist/core/execution/dags.d.ts +167 -0
- package/dist/core/execution/dags.d.ts.map +1 -0
- package/dist/core/execution/dags.js +713 -0
- package/dist/core/execution/dags.js.map +1 -0
- package/dist/core/execution/executions.d.ts +158 -0
- package/dist/core/execution/executions.d.ts.map +1 -0
- package/dist/core/execution/executions.js +258 -0
- package/dist/core/execution/executions.js.map +1 -0
- package/dist/core/execution/goals.d.ts +62 -0
- package/dist/core/execution/goals.d.ts.map +1 -0
- package/dist/core/execution/goals.js +245 -0
- package/dist/core/execution/goals.js.map +1 -0
- package/dist/core/execution/runs.d.ts +65 -0
- package/dist/core/execution/runs.d.ts.map +1 -0
- package/dist/core/execution/runs.js +219 -0
- package/dist/core/execution/runs.js.map +1 -0
- package/dist/core/execution/tools.d.ts +24 -0
- package/dist/core/execution/tools.d.ts.map +1 -0
- package/dist/core/execution/tools.js +33 -0
- package/dist/core/execution/tools.js.map +1 -0
- package/dist/core/orchestration/index.d.ts +7 -0
- package/dist/core/orchestration/index.d.ts.map +1 -0
- package/dist/core/orchestration/index.js +7 -0
- package/dist/core/orchestration/index.js.map +1 -0
- package/dist/core/orchestration/orchestrator.d.ts +39 -0
- package/dist/core/orchestration/orchestrator.d.ts.map +1 -0
- package/dist/core/orchestration/orchestrator.js +141 -0
- package/dist/core/orchestration/orchestrator.js.map +1 -0
- package/dist/core/orchestration/planner.d.ts +63 -0
- package/dist/core/orchestration/planner.d.ts.map +1 -0
- package/dist/core/orchestration/planner.js +99 -0
- package/dist/core/orchestration/planner.js.map +1 -0
- package/dist/core/providers/factory.d.ts +25 -0
- package/dist/core/providers/factory.d.ts.map +1 -0
- package/dist/core/providers/factory.js +86 -0
- package/dist/core/providers/factory.js.map +1 -0
- package/dist/core/providers/index.d.ts +11 -0
- package/dist/core/providers/index.d.ts.map +1 -0
- package/dist/core/providers/index.js +10 -0
- package/dist/core/providers/index.js.map +1 -0
- package/dist/core/providers/ollama.d.ts +36 -0
- package/dist/core/providers/ollama.d.ts.map +1 -0
- package/dist/core/providers/ollama.js +123 -0
- package/dist/core/providers/ollama.js.map +1 -0
- package/dist/core/providers/openai.d.ts +33 -0
- package/dist/core/providers/openai.d.ts.map +1 -0
- package/dist/core/providers/openai.js +114 -0
- package/dist/core/providers/openai.js.map +1 -0
- package/dist/core/providers/openrouter.d.ts +38 -0
- package/dist/core/providers/openrouter.d.ts.map +1 -0
- package/dist/core/providers/openrouter.js +269 -0
- package/dist/core/providers/openrouter.js.map +1 -0
- package/dist/core/providers/types.d.ts +101 -0
- package/dist/core/providers/types.d.ts.map +1 -0
- package/dist/core/providers/types.js +7 -0
- package/dist/core/providers/types.js.map +1 -0
- package/dist/core/tools/base.d.ts +56 -0
- package/dist/core/tools/base.d.ts.map +1 -0
- package/dist/core/tools/base.js +60 -0
- package/dist/core/tools/base.js.map +1 -0
- package/dist/core/tools/bash.d.ts +50 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +179 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit.d.ts +39 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +67 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/executor.d.ts +33 -0
- package/dist/core/tools/executor.d.ts.map +1 -0
- package/dist/core/tools/executor.js +105 -0
- package/dist/core/tools/executor.js.map +1 -0
- package/dist/core/tools/fetchPage.d.ts +46 -0
- package/dist/core/tools/fetchPage.d.ts.map +1 -0
- package/dist/core/tools/fetchPage.js +87 -0
- package/dist/core/tools/fetchPage.js.map +1 -0
- package/dist/core/tools/fetchURLs.d.ts +39 -0
- package/dist/core/tools/fetchURLs.d.ts.map +1 -0
- package/dist/core/tools/fetchURLs.js +67 -0
- package/dist/core/tools/fetchURLs.js.map +1 -0
- package/dist/core/tools/glob.d.ts +36 -0
- package/dist/core/tools/glob.d.ts.map +1 -0
- package/dist/core/tools/glob.js +78 -0
- package/dist/core/tools/glob.js.map +1 -0
- package/dist/core/tools/grep.d.ts +51 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +152 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +22 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +22 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/llmExecute.d.ts +153 -0
- package/dist/core/tools/llmExecute.d.ts.map +1 -0
- package/dist/core/tools/llmExecute.js +105 -0
- package/dist/core/tools/llmExecute.js.map +1 -0
- package/dist/core/tools/readEmail.d.ts +68 -0
- package/dist/core/tools/readEmail.d.ts.map +1 -0
- package/dist/core/tools/readEmail.js +182 -0
- package/dist/core/tools/readEmail.js.map +1 -0
- package/dist/core/tools/readFile.d.ts +42 -0
- package/dist/core/tools/readFile.d.ts.map +1 -0
- package/dist/core/tools/readFile.js +79 -0
- package/dist/core/tools/readFile.js.map +1 -0
- package/dist/core/tools/registry.d.ts +53 -0
- package/dist/core/tools/registry.d.ts.map +1 -0
- package/dist/core/tools/registry.js +112 -0
- package/dist/core/tools/registry.js.map +1 -0
- package/dist/core/tools/sendEmail.d.ts +83 -0
- package/dist/core/tools/sendEmail.d.ts.map +1 -0
- package/dist/core/tools/sendEmail.js +132 -0
- package/dist/core/tools/sendEmail.js.map +1 -0
- package/dist/core/tools/sendWebhook.d.ts +48 -0
- package/dist/core/tools/sendWebhook.d.ts.map +1 -0
- package/dist/core/tools/sendWebhook.js +61 -0
- package/dist/core/tools/sendWebhook.js.map +1 -0
- package/dist/core/tools/webSearch.d.ts +34 -0
- package/dist/core/tools/webSearch.d.ts.map +1 -0
- package/dist/core/tools/webSearch.js +104 -0
- package/dist/core/tools/webSearch.js.map +1 -0
- package/dist/core/tools/writeFile.d.ts +49 -0
- package/dist/core/tools/writeFile.d.ts.map +1 -0
- package/dist/core/tools/writeFile.js +120 -0
- package/dist/core/tools/writeFile.js.map +1 -0
- package/dist/db/client.d.ts +22 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +178 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/schema.d.ts +1846 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +175 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/errors/index.d.ts +80 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +135 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +172 -0
- package/dist/index.js.map +1 -0
- package/dist/services/initDB.d.ts +17 -0
- package/dist/services/initDB.d.ts.map +1 -0
- package/dist/services/initDB.js +212 -0
- package/dist/services/initDB.js.map +1 -0
- package/dist/types/agent.d.ts +354 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +63 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/client.d.ts +309 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +2 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/config.d.ts +96 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +33 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/dag.d.ts +253 -0
- package/dist/types/dag.d.ts.map +1 -0
- package/dist/types/dag.js +46 -0
- package/dist/types/dag.js.map +1 -0
- package/dist/types/execution.d.ts +171 -0
- package/dist/types/execution.d.ts.map +1 -0
- package/dist/types/execution.js +41 -0
- package/dist/types/execution.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/util/cron-validator.d.ts +16 -0
- package/dist/util/cron-validator.d.ts.map +1 -0
- package/dist/util/cron-validator.js +31 -0
- package/dist/util/cron-validator.js.map +1 -0
- package/dist/util/dag-utils.d.ts +54 -0
- package/dist/util/dag-utils.d.ts.map +1 -0
- package/dist/util/dag-utils.js +167 -0
- package/dist/util/dag-utils.js.map +1 -0
- package/dist/util/logger.d.ts +21 -0
- package/dist/util/logger.d.ts.map +1 -0
- package/dist/util/logger.js +87 -0
- package/dist/util/logger.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grep Tool
|
|
3
|
+
*
|
|
4
|
+
* Search file contents with regex patterns using Bun APIs
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { join, resolve } from 'path';
|
|
8
|
+
import { BaseTool } from './base.js';
|
|
9
|
+
const grepInputSchema = z.object({
|
|
10
|
+
pattern: z.string().describe('Regex pattern to search for'),
|
|
11
|
+
path: z
|
|
12
|
+
.string()
|
|
13
|
+
.default('.')
|
|
14
|
+
.describe('Directory or file path to search in (relative to artifacts, defaults to ".")'),
|
|
15
|
+
glob: z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('File glob pattern to filter files (e.g., "**/*.ts")'),
|
|
19
|
+
caseSensitive: z.boolean().default(true).describe('Whether search is case sensitive'),
|
|
20
|
+
maxResults: z.number().int().min(1).max(1000).default(50).describe('Maximum number of matches to return'),
|
|
21
|
+
});
|
|
22
|
+
export class GrepTool extends BaseTool {
|
|
23
|
+
name = 'grep';
|
|
24
|
+
description = 'Search file contents with regex patterns in the artifacts directory. Returns matching lines with file paths and line numbers.';
|
|
25
|
+
inputSchema = grepInputSchema;
|
|
26
|
+
getArtifactsDir(ctx) {
|
|
27
|
+
return resolve(ctx.artifactsDir || process.env.ARTIFACTS_DIR || './artifacts');
|
|
28
|
+
}
|
|
29
|
+
isBinaryFile(buffer) {
|
|
30
|
+
const sampleSize = Math.min(buffer.length, 8000);
|
|
31
|
+
for (let i = 0; i < sampleSize; i++) {
|
|
32
|
+
if (buffer[i] === 0) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
sanitizePath(inputPath) {
|
|
39
|
+
return inputPath.replace(/\.\./g, '');
|
|
40
|
+
}
|
|
41
|
+
async execute(input, ctx) {
|
|
42
|
+
const ARTIFACTS_DIR = this.getArtifactsDir(ctx);
|
|
43
|
+
const safePath = this.sanitizePath(input.path);
|
|
44
|
+
const fullPath = join(ARTIFACTS_DIR, safePath);
|
|
45
|
+
if (!fullPath.startsWith(ARTIFACTS_DIR)) {
|
|
46
|
+
throw new Error('Invalid path: must be within artifacts directory');
|
|
47
|
+
}
|
|
48
|
+
ctx.logger.info(`Grep search: pattern="${input.pattern}" path="${safePath}"`);
|
|
49
|
+
ctx.emitEvent?.started?.(`🔍 Searching for "${input.pattern}" in ${safePath}`);
|
|
50
|
+
const flags = input.caseSensitive ? 'g' : 'gi';
|
|
51
|
+
let regex;
|
|
52
|
+
try {
|
|
53
|
+
regex = new RegExp(input.pattern, flags);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new Error(`Invalid regex pattern: ${input.pattern}`);
|
|
57
|
+
}
|
|
58
|
+
const matches = [];
|
|
59
|
+
let totalMatches = 0;
|
|
60
|
+
let filesSearched = 0;
|
|
61
|
+
let truncated = false;
|
|
62
|
+
const filesToSearch = [];
|
|
63
|
+
try {
|
|
64
|
+
const file = Bun.file(fullPath);
|
|
65
|
+
const exists = await file.exists();
|
|
66
|
+
if (exists) {
|
|
67
|
+
const stat = await file.stat();
|
|
68
|
+
if (stat && !stat.isDirectory()) {
|
|
69
|
+
filesToSearch.push(fullPath);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// It's a directory, use glob
|
|
73
|
+
const globPattern = input.glob || '**/*';
|
|
74
|
+
const glob = new Bun.Glob(globPattern);
|
|
75
|
+
for await (const match of glob.scan({
|
|
76
|
+
cwd: fullPath,
|
|
77
|
+
onlyFiles: true,
|
|
78
|
+
})) {
|
|
79
|
+
filesToSearch.push(join(fullPath, match));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw new Error(`Path not found: ${safePath}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error.message.includes('Path not found')) {
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
// Try as directory
|
|
92
|
+
const globPattern = input.glob || '**/*';
|
|
93
|
+
const glob = new Bun.Glob(globPattern);
|
|
94
|
+
for await (const match of glob.scan({
|
|
95
|
+
cwd: fullPath,
|
|
96
|
+
onlyFiles: true,
|
|
97
|
+
})) {
|
|
98
|
+
filesToSearch.push(join(fullPath, match));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (const filePath of filesToSearch) {
|
|
102
|
+
if (truncated)
|
|
103
|
+
break;
|
|
104
|
+
try {
|
|
105
|
+
const file = Bun.file(filePath);
|
|
106
|
+
const buffer = Buffer.from(await file.arrayBuffer());
|
|
107
|
+
if (this.isBinaryFile(buffer)) {
|
|
108
|
+
ctx.logger.debug(`Skipping binary file: ${filePath}`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
filesSearched++;
|
|
112
|
+
const content = buffer.toString('utf-8');
|
|
113
|
+
const lines = content.split('\n');
|
|
114
|
+
for (let i = 0; i < lines.length; i++) {
|
|
115
|
+
const line = lines[i];
|
|
116
|
+
regex.lastIndex = 0;
|
|
117
|
+
const matchResult = regex.exec(line);
|
|
118
|
+
if (matchResult) {
|
|
119
|
+
totalMatches++;
|
|
120
|
+
if (matches.length < input.maxResults) {
|
|
121
|
+
const relativePath = filePath.startsWith(ARTIFACTS_DIR)
|
|
122
|
+
? filePath.slice(ARTIFACTS_DIR.length + 1)
|
|
123
|
+
: filePath;
|
|
124
|
+
matches.push({
|
|
125
|
+
file: relativePath,
|
|
126
|
+
line: i + 1,
|
|
127
|
+
content: line.slice(0, 200),
|
|
128
|
+
match: matchResult[0],
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
truncated = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
ctx.logger.debug(`Could not read file: ${filePath}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
ctx.logger.info(`Grep complete: ${totalMatches} matches in ${filesSearched} files${truncated ? ' (truncated)' : ''}`);
|
|
142
|
+
ctx.emitEvent?.completed?.(`🔍 Found ${totalMatches} matches in ${filesSearched} files${truncated ? ' (results truncated)' : ''}`);
|
|
143
|
+
return {
|
|
144
|
+
pattern: input.pattern,
|
|
145
|
+
matches,
|
|
146
|
+
totalMatches,
|
|
147
|
+
filesSearched,
|
|
148
|
+
truncated,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=grep.js.map
|
|
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;YACZ,aAAa;YACb,SAAS;SACV,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools Module
|
|
3
|
+
*
|
|
4
|
+
* Tool implementations and registry for desiAgent.
|
|
5
|
+
*/
|
|
6
|
+
export { BaseTool, type ToolContext } from './base.js';
|
|
7
|
+
export { BashTool } from './bash.js';
|
|
8
|
+
export { ReadFileTool } from './readFile.js';
|
|
9
|
+
export { WriteFileTool } from './writeFile.js';
|
|
10
|
+
export { FetchPageTool } from './fetchPage.js';
|
|
11
|
+
export { WebSearchTool } from './webSearch.js';
|
|
12
|
+
export { FetchURLsTool } from './fetchURLs.js';
|
|
13
|
+
export { GlobTool } from './glob.js';
|
|
14
|
+
export { GrepTool } from './grep.js';
|
|
15
|
+
export { EditTool } from './edit.js';
|
|
16
|
+
export { SendEmailTool } from './sendEmail.js';
|
|
17
|
+
export { ReadEmailTool } from './readEmail.js';
|
|
18
|
+
export { SendWebhookTool } from './sendWebhook.js';
|
|
19
|
+
export { LlmExecuteTool } from './llmExecute.js';
|
|
20
|
+
export { ToolRegistry, createToolRegistry } from './registry.js';
|
|
21
|
+
export { ToolExecutor } from './executor.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools Module
|
|
3
|
+
*
|
|
4
|
+
* Tool implementations and registry for desiAgent.
|
|
5
|
+
*/
|
|
6
|
+
export { BaseTool } from './base.js';
|
|
7
|
+
export { BashTool } from './bash.js';
|
|
8
|
+
export { ReadFileTool } from './readFile.js';
|
|
9
|
+
export { WriteFileTool } from './writeFile.js';
|
|
10
|
+
export { FetchPageTool } from './fetchPage.js';
|
|
11
|
+
export { WebSearchTool } from './webSearch.js';
|
|
12
|
+
export { FetchURLsTool } from './fetchURLs.js';
|
|
13
|
+
export { GlobTool } from './glob.js';
|
|
14
|
+
export { GrepTool } from './grep.js';
|
|
15
|
+
export { EditTool } from './edit.js';
|
|
16
|
+
export { SendEmailTool } from './sendEmail.js';
|
|
17
|
+
export { ReadEmailTool } from './readEmail.js';
|
|
18
|
+
export { SendWebhookTool } from './sendWebhook.js';
|
|
19
|
+
export { LlmExecuteTool } from './llmExecute.js';
|
|
20
|
+
export { ToolRegistry, createToolRegistry } from './registry.js';
|
|
21
|
+
export { ToolExecutor } from './executor.js';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAoB,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Execute Tool
|
|
3
|
+
*
|
|
4
|
+
* Execute a prompt using a specified LLM provider and model.
|
|
5
|
+
* This tool is NOT registered in the default registry - it's used internally by DAGExecutor.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { BaseTool, type ToolContext } from './base.js';
|
|
9
|
+
declare const llmExecuteInputSchema: z.ZodObject<{
|
|
10
|
+
provider: z.ZodEnum<["openai", "openrouter", "ollama"]>;
|
|
11
|
+
model: z.ZodString;
|
|
12
|
+
task: z.ZodString;
|
|
13
|
+
prompt: z.ZodString;
|
|
14
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
15
|
+
filename: z.ZodString;
|
|
16
|
+
content: z.ZodString;
|
|
17
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
content: string;
|
|
20
|
+
filename: string;
|
|
21
|
+
mimeType?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
content: string;
|
|
24
|
+
filename: string;
|
|
25
|
+
mimeType?: string | undefined;
|
|
26
|
+
}>, "many">>;
|
|
27
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
29
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
reasoning_effort?: "low" | "medium" | "high" | undefined;
|
|
33
|
+
max_tokens?: number | undefined;
|
|
34
|
+
temperature?: number | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
reasoning_effort?: "low" | "medium" | "high" | undefined;
|
|
37
|
+
max_tokens?: number | undefined;
|
|
38
|
+
temperature?: number | undefined;
|
|
39
|
+
}>>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
model: string;
|
|
42
|
+
provider: "openai" | "openrouter" | "ollama";
|
|
43
|
+
task: string;
|
|
44
|
+
prompt: string;
|
|
45
|
+
params?: {
|
|
46
|
+
reasoning_effort?: "low" | "medium" | "high" | undefined;
|
|
47
|
+
max_tokens?: number | undefined;
|
|
48
|
+
temperature?: number | undefined;
|
|
49
|
+
} | undefined;
|
|
50
|
+
attachments?: {
|
|
51
|
+
content: string;
|
|
52
|
+
filename: string;
|
|
53
|
+
mimeType?: string | undefined;
|
|
54
|
+
}[] | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
model: string;
|
|
57
|
+
provider: "openai" | "openrouter" | "ollama";
|
|
58
|
+
task: string;
|
|
59
|
+
prompt: string;
|
|
60
|
+
params?: {
|
|
61
|
+
reasoning_effort?: "low" | "medium" | "high" | undefined;
|
|
62
|
+
max_tokens?: number | undefined;
|
|
63
|
+
temperature?: number | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
attachments?: {
|
|
66
|
+
content: string;
|
|
67
|
+
filename: string;
|
|
68
|
+
mimeType?: string | undefined;
|
|
69
|
+
}[] | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
type LlmExecuteInput = z.infer<typeof llmExecuteInputSchema>;
|
|
72
|
+
interface LlmExecuteOutput {
|
|
73
|
+
content: string;
|
|
74
|
+
usage?: {
|
|
75
|
+
promptTokens?: number;
|
|
76
|
+
completionTokens?: number;
|
|
77
|
+
totalTokens?: number;
|
|
78
|
+
};
|
|
79
|
+
costUsd?: number;
|
|
80
|
+
generationStats?: Record<string, any>;
|
|
81
|
+
finishReason?: string;
|
|
82
|
+
reasoning?: string;
|
|
83
|
+
}
|
|
84
|
+
export declare class LlmExecuteTool extends BaseTool<LlmExecuteInput, LlmExecuteOutput> {
|
|
85
|
+
name: string;
|
|
86
|
+
description: string;
|
|
87
|
+
inputSchema: z.ZodObject<{
|
|
88
|
+
provider: z.ZodEnum<["openai", "openrouter", "ollama"]>;
|
|
89
|
+
model: z.ZodString;
|
|
90
|
+
task: z.ZodString;
|
|
91
|
+
prompt: z.ZodString;
|
|
92
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
93
|
+
filename: z.ZodString;
|
|
94
|
+
content: z.ZodString;
|
|
95
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
content: string;
|
|
98
|
+
filename: string;
|
|
99
|
+
mimeType?: string | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
content: string;
|
|
102
|
+
filename: string;
|
|
103
|
+
mimeType?: string | undefined;
|
|
104
|
+
}>, "many">>;
|
|
105
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
106
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
107
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
108
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
reasoning_effort?: "low" | "medium" | "high" | undefined;
|
|
111
|
+
max_tokens?: number | undefined;
|
|
112
|
+
temperature?: number | undefined;
|
|
113
|
+
}, {
|
|
114
|
+
reasoning_effort?: "low" | "medium" | "high" | undefined;
|
|
115
|
+
max_tokens?: number | undefined;
|
|
116
|
+
temperature?: number | undefined;
|
|
117
|
+
}>>;
|
|
118
|
+
}, "strip", z.ZodTypeAny, {
|
|
119
|
+
model: string;
|
|
120
|
+
provider: "openai" | "openrouter" | "ollama";
|
|
121
|
+
task: string;
|
|
122
|
+
prompt: string;
|
|
123
|
+
params?: {
|
|
124
|
+
reasoning_effort?: "low" | "medium" | "high" | undefined;
|
|
125
|
+
max_tokens?: number | undefined;
|
|
126
|
+
temperature?: number | undefined;
|
|
127
|
+
} | undefined;
|
|
128
|
+
attachments?: {
|
|
129
|
+
content: string;
|
|
130
|
+
filename: string;
|
|
131
|
+
mimeType?: string | undefined;
|
|
132
|
+
}[] | undefined;
|
|
133
|
+
}, {
|
|
134
|
+
model: string;
|
|
135
|
+
provider: "openai" | "openrouter" | "ollama";
|
|
136
|
+
task: string;
|
|
137
|
+
prompt: string;
|
|
138
|
+
params?: {
|
|
139
|
+
reasoning_effort?: "low" | "medium" | "high" | undefined;
|
|
140
|
+
max_tokens?: number | undefined;
|
|
141
|
+
temperature?: number | undefined;
|
|
142
|
+
} | undefined;
|
|
143
|
+
attachments?: {
|
|
144
|
+
content: string;
|
|
145
|
+
filename: string;
|
|
146
|
+
mimeType?: string | undefined;
|
|
147
|
+
}[] | undefined;
|
|
148
|
+
}>;
|
|
149
|
+
private isImageFile;
|
|
150
|
+
execute(input: LlmExecuteInput, ctx: ToolContext): Promise<LlmExecuteOutput>;
|
|
151
|
+
}
|
|
152
|
+
export {};
|
|
153
|
+
//# sourceMappingURL=llmExecute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmExecute.d.ts","sourceRoot":"","sources":["../../../src/core/tools/llmExecute.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAgBvD,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOzB,CAAC;AAEH,KAAK,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE7D,UAAU,gBAAgB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,cAAe,SAAQ,QAAQ,CAAC,eAAe,EAAE,gBAAgB,CAAC;IAC7E,IAAI,SAAgB;IACpB,WAAW,SAA2G;IACtH,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAyB;IAEpC,OAAO,CAAC,WAAW;IAeb,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAwEnF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Execute Tool
|
|
3
|
+
*
|
|
4
|
+
* Execute a prompt using a specified LLM provider and model.
|
|
5
|
+
* This tool is NOT registered in the default registry - it's used internally by DAGExecutor.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { BaseTool } from './base.js';
|
|
9
|
+
import { createLLMProvider } from '../providers/factory.js';
|
|
10
|
+
const attachmentSchema = z.object({
|
|
11
|
+
filename: z.string().describe('Name of the file'),
|
|
12
|
+
content: z.string().describe('Content of the file'),
|
|
13
|
+
mimeType: z.string().optional().describe('MIME type of the file'),
|
|
14
|
+
});
|
|
15
|
+
const paramsSchema = z.object({
|
|
16
|
+
reasoning_effort: z.enum(['low', 'medium', 'high']).optional().describe('Reasoning effort level'),
|
|
17
|
+
max_tokens: z.number().int().positive().optional().describe('Maximum tokens in response'),
|
|
18
|
+
temperature: z.number().min(0).max(2).optional().describe('Temperature for response randomness'),
|
|
19
|
+
}).optional();
|
|
20
|
+
const llmExecuteInputSchema = z.object({
|
|
21
|
+
provider: z.enum(['openai', 'openrouter', 'ollama']).describe('LLM provider name'),
|
|
22
|
+
model: z.string().describe('Model name to use'),
|
|
23
|
+
task: z.string().describe('Task name or identifier'),
|
|
24
|
+
prompt: z.string().describe('Prompt to send to the LLM'),
|
|
25
|
+
attachments: z.array(attachmentSchema).optional().describe('Optional array of file attachments'),
|
|
26
|
+
params: paramsSchema.describe('Optional parameters for LLM call'),
|
|
27
|
+
});
|
|
28
|
+
export class LlmExecuteTool extends BaseTool {
|
|
29
|
+
name = 'llmExecute';
|
|
30
|
+
description = 'cd Execute a prompt using a specified LLM provider and model with optional attachments and parameters';
|
|
31
|
+
inputSchema = llmExecuteInputSchema;
|
|
32
|
+
isImageFile(mimeType, filename) {
|
|
33
|
+
const imageMimeTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/webp', 'image/gif'];
|
|
34
|
+
if (mimeType && imageMimeTypes.includes(mimeType.toLowerCase())) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (filename) {
|
|
38
|
+
const ext = filename.toLowerCase().split('.').pop();
|
|
39
|
+
return ['png', 'jpg', 'jpeg', 'webp', 'gif'].includes(ext || '');
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
async execute(input, ctx) {
|
|
44
|
+
ctx.logger.debug({
|
|
45
|
+
provider: input.provider,
|
|
46
|
+
model: input.model,
|
|
47
|
+
hasAttachments: !!input.attachments?.length,
|
|
48
|
+
}, '╰─Executing LLM call');
|
|
49
|
+
try {
|
|
50
|
+
const provider = createLLMProvider({
|
|
51
|
+
provider: input.provider,
|
|
52
|
+
model: input.model,
|
|
53
|
+
});
|
|
54
|
+
const validation = await provider.validateToolCallSupport(input.model);
|
|
55
|
+
if (!validation.supported) {
|
|
56
|
+
ctx.logger.warn(`╰─Model ${input.model} not supported: ${validation.message}`);
|
|
57
|
+
}
|
|
58
|
+
let userContent = input.prompt;
|
|
59
|
+
if (input.attachments && input.attachments.length > 0) {
|
|
60
|
+
const textFiles = input.attachments.filter(att => !this.isImageFile(att.mimeType, att.filename));
|
|
61
|
+
if (textFiles.length > 0) {
|
|
62
|
+
const attachmentText = textFiles
|
|
63
|
+
.map(att => `\n\n--- File: ${att.filename} ---\n${att.content}`)
|
|
64
|
+
.join('');
|
|
65
|
+
userContent = `${input.prompt}${attachmentText}`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const messages = [
|
|
69
|
+
{
|
|
70
|
+
role: 'system',
|
|
71
|
+
content: `Task: ${input.task}`,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
role: 'user',
|
|
75
|
+
content: userContent,
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
const temperature = input.params?.temperature ?? 0.7;
|
|
79
|
+
const maxTokens = input.params?.max_tokens;
|
|
80
|
+
const response = await provider.chat({
|
|
81
|
+
messages,
|
|
82
|
+
temperature,
|
|
83
|
+
maxTokens,
|
|
84
|
+
});
|
|
85
|
+
ctx.logger.debug('LLM execution completed');
|
|
86
|
+
ctx.emitEvent?.completed?.(`✨ completed`);
|
|
87
|
+
return {
|
|
88
|
+
content: response.content,
|
|
89
|
+
usage: response.usage,
|
|
90
|
+
costUsd: response.costUsd,
|
|
91
|
+
generationStats: response.generationStats,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
ctx.logger.error({
|
|
96
|
+
err: error,
|
|
97
|
+
provider: input.provider,
|
|
98
|
+
model: input.model,
|
|
99
|
+
task: input.task,
|
|
100
|
+
}, 'LLM execution failed');
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=llmExecute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmExecute.js","sourceRoot":"","sources":["../../../src/core/tools/llmExecute.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAoB,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IACjD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACnD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ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GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,aAAa,CAAC,CAAC;YAE1C,OAAO;gBACL,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,OAAO,EAAG,QAAgB,CAAC,OAAO;gBAClC,eAAe,EAAG,QAAgB,CAAC,eAAe;aACnD,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;gBACf,GAAG,EAAE,KAAK;gBACV,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,IAAI,EAAE,KAAK,CAAC,IAAI;aACjB,EAAE,sBAAsB,CAAC,CAAC;YAC3B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read Email Tool
|
|
3
|
+
*
|
|
4
|
+
* Read emails from Gmail via IMAP with filtering capabilities.
|
|
5
|
+
* Uses the same credentials as sendEmail (app password).
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { BaseTool, type ToolContext } from './base.js';
|
|
9
|
+
declare const readEmailInputSchema: z.ZodObject<{
|
|
10
|
+
maxResults: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
unreadOnly: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
sender: z.ZodOptional<z.ZodString>;
|
|
13
|
+
search: z.ZodOptional<z.ZodString>;
|
|
14
|
+
mailbox: z.ZodDefault<z.ZodString>;
|
|
15
|
+
markAsRead: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
snippets: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
remove_urls: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
maxResults: number;
|
|
20
|
+
unreadOnly: boolean;
|
|
21
|
+
mailbox: string;
|
|
22
|
+
markAsRead: boolean;
|
|
23
|
+
snippets: boolean;
|
|
24
|
+
remove_urls: boolean;
|
|
25
|
+
sender?: string | undefined;
|
|
26
|
+
search?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
maxResults?: number | undefined;
|
|
29
|
+
unreadOnly?: boolean | undefined;
|
|
30
|
+
sender?: string | undefined;
|
|
31
|
+
search?: string | undefined;
|
|
32
|
+
mailbox?: string | undefined;
|
|
33
|
+
markAsRead?: boolean | undefined;
|
|
34
|
+
snippets?: boolean | undefined;
|
|
35
|
+
remove_urls?: boolean | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
type ReadEmailInput = z.infer<typeof readEmailInputSchema>;
|
|
38
|
+
interface EmailMessage {
|
|
39
|
+
uid: number;
|
|
40
|
+
messageId?: string;
|
|
41
|
+
from?: string;
|
|
42
|
+
to?: string;
|
|
43
|
+
subject?: string;
|
|
44
|
+
date?: string;
|
|
45
|
+
snippet?: string;
|
|
46
|
+
body?: string;
|
|
47
|
+
isRead: boolean;
|
|
48
|
+
hasAttachments: boolean;
|
|
49
|
+
}
|
|
50
|
+
interface ReadEmailOutput {
|
|
51
|
+
success: boolean;
|
|
52
|
+
emails: EmailMessage[];
|
|
53
|
+
count: number;
|
|
54
|
+
mailbox: string;
|
|
55
|
+
error?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare class ReadEmailTool extends BaseTool<any, ReadEmailOutput> {
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
inputSchema: any;
|
|
61
|
+
private getImapConfig;
|
|
62
|
+
private buildSearchCriteria;
|
|
63
|
+
private truncateBody;
|
|
64
|
+
private stripUrls;
|
|
65
|
+
execute(rawInput: ReadEmailInput, ctx: ToolContext): Promise<ReadEmailOutput>;
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=readEmail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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