@framers/agentos-ext-cli-executor 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +96 -21
- package/README.md +130 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/services/shellService.d.ts +10 -0
- package/dist/services/shellService.d.ts.map +1 -1
- package/dist/services/shellService.js +33 -0
- package/dist/services/shellService.js.map +1 -1
- package/dist/tools/{createPdf.d.ts → createDocument.d.ts} +13 -10
- package/dist/tools/createDocument.d.ts.map +1 -0
- package/dist/tools/createDocument.js +201 -0
- package/dist/tools/createDocument.js.map +1 -0
- package/dist/tools/createSpreadsheet.d.ts +35 -0
- package/dist/tools/createSpreadsheet.d.ts.map +1 -0
- package/dist/tools/createSpreadsheet.js +185 -0
- package/dist/tools/createSpreadsheet.js.map +1 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/execute.js +1 -0
- package/dist/tools/execute.js.map +1 -1
- package/dist/tools/fileRead.d.ts.map +1 -1
- package/dist/tools/fileRead.js +1 -0
- package/dist/tools/fileRead.js.map +1 -1
- package/dist/tools/fileWrite.d.ts.map +1 -1
- package/dist/tools/fileWrite.js +14 -1
- package/dist/tools/fileWrite.js.map +1 -1
- package/dist/tools/listDir.d.ts.map +1 -1
- package/dist/tools/listDir.js +1 -0
- package/dist/tools/listDir.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/manifest.json +17 -3
- package/package.json +14 -8
- package/dist/tools/createPdf.d.ts.map +0 -1
- package/dist/tools/createPdf.js +0 -215
- package/dist/tools/createPdf.js.map +0 -1
- package/dist/tools/readDocument.d.ts +0 -41
- package/dist/tools/readDocument.d.ts.map +0 -1
- package/dist/tools/readDocument.js +0 -252
- package/dist/tools/readDocument.js.map +0 -1
package/manifest.json
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"$schema": "https://agentos.sh/schemas/extension-manifest-v1.json",
|
|
3
3
|
"id": "com.framers.system.cli-executor",
|
|
4
4
|
"name": "CLI Executor Extension",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.3.0",
|
|
6
6
|
"description": "Execute shell commands and manage files for AgentOS agents",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Frame.dev",
|
|
9
9
|
"email": "support@frame.dev",
|
|
10
|
-
"url": "https://github.com/
|
|
10
|
+
"url": "https://github.com/framerslab"
|
|
11
11
|
},
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"keywords": ["cli", "shell", "command", "execute", "terminal", "bash", "powershell", "script"],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"categories": ["system", "automation", "development"],
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/
|
|
18
|
+
"url": "https://github.com/framerslab/agentos-extensions"
|
|
19
19
|
},
|
|
20
20
|
"extensions": [
|
|
21
21
|
{
|
|
@@ -53,6 +53,20 @@
|
|
|
53
53
|
"description": "Create a real PDF document from text content",
|
|
54
54
|
"entry": "./dist/tools/createPdf.js"
|
|
55
55
|
},
|
|
56
|
+
{
|
|
57
|
+
"kind": "tool",
|
|
58
|
+
"id": "create_spreadsheet",
|
|
59
|
+
"displayName": "Create Spreadsheet",
|
|
60
|
+
"description": "Create an Excel (.xlsx) or CSV file from structured data",
|
|
61
|
+
"entry": "./dist/tools/createSpreadsheet.js"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"kind": "tool",
|
|
65
|
+
"id": "create_document",
|
|
66
|
+
"displayName": "Create Document",
|
|
67
|
+
"description": "Create a Word document (.docx) from text or markdown",
|
|
68
|
+
"entry": "./dist/tools/createDocument.js"
|
|
69
|
+
},
|
|
56
70
|
{
|
|
57
71
|
"kind": "tool",
|
|
58
72
|
"id": "read_document",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@framers/agentos-ext-cli-executor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "CLI executor extension for AgentOS - execute shell commands and manage files",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,26 +39,32 @@
|
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
42
|
-
"url": "https://github.com/
|
|
42
|
+
"url": "git+https://github.com/framerslab/agentos-extensions.git",
|
|
43
43
|
"directory": "registry/curated/system/cli-executor"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"
|
|
46
|
+
"docx": "^9.0.2",
|
|
47
47
|
"mammoth": "^1.8.0",
|
|
48
|
-
"pdf-parse": "^1.1.1"
|
|
48
|
+
"pdf-parse": "^1.1.1",
|
|
49
|
+
"xlsx": "^0.18.5"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
|
-
"@framers/agentos": "
|
|
52
|
+
"@framers/agentos": ">=0.10.40"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@types/node": "^20.0.0",
|
|
56
|
+
"jszip": "^3.10.1",
|
|
55
57
|
"typescript": "^5.4.0",
|
|
56
|
-
"vitest": "^
|
|
57
|
-
"@framers/agentos": "0.
|
|
58
|
+
"vitest": "^3.2.7",
|
|
59
|
+
"@framers/agentos": "^0.10.40"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/framerslab/agentos-extensions/tree/master/registry/curated/system/cli-executor#readme",
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/framerslab/agentos-extensions/issues"
|
|
58
64
|
},
|
|
59
65
|
"scripts": {
|
|
60
66
|
"build": "tsc",
|
|
61
|
-
"test": "vitest run",
|
|
67
|
+
"test": "vitest run --passWithNoTests",
|
|
62
68
|
"test:watch": "vitest",
|
|
63
69
|
"clean": "rm -rf dist"
|
|
64
70
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createPdf.d.ts","sourceRoot":"","sources":["../../src/tools/createPdf.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AA8K3G,qBAAa,aAAc,YAAW,KAAK;IACzC,SAAgB,EAAE,uBAAuB;IACzC,SAAgB,IAAI,gBAAgB;IACpC,SAAgB,WAAW,gBAAgB;IAC3C,SAAgB,WAAW,qHACyF;IACpH,SAAgB,QAAQ,YAAY;IACpC,SAAgB,cAAc,QAAQ;IAEtC,SAAgB,WAAW,EAAE,gBAAgB,CA0B3C;IAEI,OAAO,CACX,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,EACD,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IA4B/E,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE;CAM/E"}
|
package/dist/tools/createPdf.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create PDF Tool
|
|
3
|
-
* Generate real PDF files from text content.
|
|
4
|
-
*
|
|
5
|
-
* @module @framers/agentos-ext-cli-executor
|
|
6
|
-
*/
|
|
7
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
|
8
|
-
import { dirname, resolve } from 'node:path';
|
|
9
|
-
/**
|
|
10
|
-
* Generate a valid PDF 1.4 binary buffer from plain text content.
|
|
11
|
-
*
|
|
12
|
-
* Supports:
|
|
13
|
-
* - Multi-page text layout with automatic pagination
|
|
14
|
-
* - UTF-8 → WinAnsiEncoding (Latin-1 subset)
|
|
15
|
-
* - Configurable margins, font size, page dimensions
|
|
16
|
-
* - Document metadata (Title, Author, CreationDate)
|
|
17
|
-
*/
|
|
18
|
-
function generatePdf(text, opts = {}) {
|
|
19
|
-
const fontSize = opts.fontSize ?? 12;
|
|
20
|
-
const margin = opts.margin ?? 72; // 1 inch
|
|
21
|
-
const pageW = opts.pageWidth ?? 612; // US Letter
|
|
22
|
-
const pageH = opts.pageHeight ?? 792;
|
|
23
|
-
const lineHeight = fontSize * 1.4;
|
|
24
|
-
const usableW = pageW - margin * 2;
|
|
25
|
-
const usableH = pageH - margin * 2;
|
|
26
|
-
const linesPerPage = Math.floor(usableH / lineHeight);
|
|
27
|
-
// Approximate characters per line (Helvetica average ~0.5 * fontSize)
|
|
28
|
-
const avgCharWidth = fontSize * 0.5;
|
|
29
|
-
const charsPerLine = Math.floor(usableW / avgCharWidth);
|
|
30
|
-
// Word-wrap text into lines
|
|
31
|
-
const rawLines = text.split('\n');
|
|
32
|
-
const wrapped = [];
|
|
33
|
-
for (const raw of rawLines) {
|
|
34
|
-
if (raw.length === 0) {
|
|
35
|
-
wrapped.push('');
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
let remaining = raw;
|
|
39
|
-
while (remaining.length > 0) {
|
|
40
|
-
if (remaining.length <= charsPerLine) {
|
|
41
|
-
wrapped.push(remaining);
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
// Find last space within charsPerLine
|
|
45
|
-
let breakAt = remaining.lastIndexOf(' ', charsPerLine);
|
|
46
|
-
if (breakAt <= 0)
|
|
47
|
-
breakAt = charsPerLine;
|
|
48
|
-
wrapped.push(remaining.slice(0, breakAt));
|
|
49
|
-
remaining = remaining.slice(breakAt).trimStart();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Paginate
|
|
53
|
-
const pages = [];
|
|
54
|
-
for (let i = 0; i < wrapped.length; i += linesPerPage) {
|
|
55
|
-
pages.push(wrapped.slice(i, i + linesPerPage));
|
|
56
|
-
}
|
|
57
|
-
if (pages.length === 0)
|
|
58
|
-
pages.push(['']);
|
|
59
|
-
// ── Build PDF objects ──────────────────────────────────────────────────
|
|
60
|
-
const objects = [];
|
|
61
|
-
const offsets = [];
|
|
62
|
-
let nextObj = 1;
|
|
63
|
-
const addObj = (content) => {
|
|
64
|
-
const id = nextObj++;
|
|
65
|
-
objects.push(`${id} 0 obj\n${content}\nendobj\n`);
|
|
66
|
-
return id;
|
|
67
|
-
};
|
|
68
|
-
// Escape PDF string: backslash, parens, non-ASCII → octal
|
|
69
|
-
const pdfStr = (s) => {
|
|
70
|
-
let out = '';
|
|
71
|
-
for (let i = 0; i < s.length; i++) {
|
|
72
|
-
const code = s.charCodeAt(i);
|
|
73
|
-
const ch = s[i];
|
|
74
|
-
if (ch === '\\' || ch === '(' || ch === ')') {
|
|
75
|
-
out += '\\' + ch;
|
|
76
|
-
}
|
|
77
|
-
else if (code < 32 || code > 126) {
|
|
78
|
-
// Replace non-printable / non-ASCII with '?'
|
|
79
|
-
out += '?';
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
out += ch;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return out;
|
|
86
|
-
};
|
|
87
|
-
// 1: Catalog
|
|
88
|
-
const catalogId = addObj(`<< /Type /Catalog /Pages 2 0 R >>`);
|
|
89
|
-
// 2: Pages (placeholder — will be rewritten)
|
|
90
|
-
const pagesIdx = objects.length;
|
|
91
|
-
addObj('PLACEHOLDER');
|
|
92
|
-
// 3: Font
|
|
93
|
-
const fontId = addObj(`<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>`);
|
|
94
|
-
// Create page objects + content streams
|
|
95
|
-
const pageObjIds = [];
|
|
96
|
-
for (const pageLines of pages) {
|
|
97
|
-
// Build content stream
|
|
98
|
-
const streamLines = [];
|
|
99
|
-
streamLines.push('BT');
|
|
100
|
-
streamLines.push(`/F1 ${fontSize} Tf`);
|
|
101
|
-
// Start at top-left with margin
|
|
102
|
-
let y = pageH - margin - fontSize;
|
|
103
|
-
streamLines.push(`${margin} ${y.toFixed(1)} Td`);
|
|
104
|
-
for (let i = 0; i < pageLines.length; i++) {
|
|
105
|
-
if (i > 0) {
|
|
106
|
-
streamLines.push(`0 ${(-lineHeight).toFixed(1)} Td`);
|
|
107
|
-
}
|
|
108
|
-
streamLines.push(`(${pdfStr(pageLines[i])}) Tj`);
|
|
109
|
-
}
|
|
110
|
-
streamLines.push('ET');
|
|
111
|
-
const stream = streamLines.join('\n');
|
|
112
|
-
const streamId = addObj(`<< /Length ${Buffer.byteLength(stream, 'latin1')} >>\nstream\n${stream}\nendstream`);
|
|
113
|
-
const pageId = addObj(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${pageW} ${pageH}] ` +
|
|
114
|
-
`/Contents ${streamId} 0 R /Resources << /Font << /F1 ${fontId} 0 R >> >> >>`);
|
|
115
|
-
pageObjIds.push(pageId);
|
|
116
|
-
}
|
|
117
|
-
// Rewrite Pages object with correct Kids
|
|
118
|
-
const kidsStr = pageObjIds.map((id) => `${id} 0 R`).join(' ');
|
|
119
|
-
objects[pagesIdx] = `2 0 obj\n<< /Type /Pages /Kids [${kidsStr}] /Count ${pageObjIds.length} >> \nendobj\n`;
|
|
120
|
-
// Info dictionary
|
|
121
|
-
const now = new Date();
|
|
122
|
-
const dateStr = `D:${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}`;
|
|
123
|
-
const infoParts = [`/CreationDate (${dateStr})`];
|
|
124
|
-
if (opts.title)
|
|
125
|
-
infoParts.push(`/Title (${pdfStr(opts.title)})`);
|
|
126
|
-
if (opts.author)
|
|
127
|
-
infoParts.push(`/Author (${pdfStr(opts.author)})`);
|
|
128
|
-
infoParts.push(`/Producer (Wunderland AgentOS)`);
|
|
129
|
-
const infoId = addObj(`<< ${infoParts.join(' ')} >>`);
|
|
130
|
-
// ── Serialize ──────────────────────────────────────────────────────────
|
|
131
|
-
let pdf = '%PDF-1.4\n%\xE2\xE3\xCF\xD3\n';
|
|
132
|
-
for (let i = 0; i < objects.length; i++) {
|
|
133
|
-
offsets[i] = Buffer.byteLength(pdf, 'latin1');
|
|
134
|
-
pdf += objects[i] + '\n';
|
|
135
|
-
}
|
|
136
|
-
const xrefOffset = Buffer.byteLength(pdf, 'latin1');
|
|
137
|
-
pdf += `xref\n0 ${nextObj}\n`;
|
|
138
|
-
pdf += '0000000000 65535 f \n';
|
|
139
|
-
for (let i = 0; i < objects.length; i++) {
|
|
140
|
-
pdf += `${String(offsets[i]).padStart(10, '0')} 00000 n \n`;
|
|
141
|
-
}
|
|
142
|
-
pdf += `trailer\n<< /Size ${nextObj} /Root ${catalogId} 0 R /Info ${infoId} 0 R >>\n`;
|
|
143
|
-
pdf += `startxref\n${xrefOffset}\n%%EOF\n`;
|
|
144
|
-
return Buffer.from(pdf, 'latin1');
|
|
145
|
-
}
|
|
146
|
-
// ── Tool ─────────────────────────────────────────────────────────────────────
|
|
147
|
-
export class CreatePdfTool {
|
|
148
|
-
id = 'cli-create-pdf-v1';
|
|
149
|
-
name = 'create_pdf';
|
|
150
|
-
displayName = 'Create PDF';
|
|
151
|
-
description = 'Create a real PDF document from text content. Use this instead of file_write when the user asks for a PDF file.';
|
|
152
|
-
category = 'system';
|
|
153
|
-
hasSideEffects = true;
|
|
154
|
-
inputSchema = {
|
|
155
|
-
type: 'object',
|
|
156
|
-
required: ['path', 'content'],
|
|
157
|
-
properties: {
|
|
158
|
-
path: {
|
|
159
|
-
type: 'string',
|
|
160
|
-
description: 'Output file path (should end in .pdf)',
|
|
161
|
-
},
|
|
162
|
-
content: {
|
|
163
|
-
type: 'string',
|
|
164
|
-
description: 'Text content to include in the PDF',
|
|
165
|
-
},
|
|
166
|
-
title: {
|
|
167
|
-
type: 'string',
|
|
168
|
-
description: 'PDF document title (metadata)',
|
|
169
|
-
},
|
|
170
|
-
author: {
|
|
171
|
-
type: 'string',
|
|
172
|
-
description: 'PDF document author (metadata)',
|
|
173
|
-
},
|
|
174
|
-
fontSize: {
|
|
175
|
-
type: 'number',
|
|
176
|
-
description: 'Font size in points (default: 12)',
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
additionalProperties: false,
|
|
180
|
-
};
|
|
181
|
-
async execute(input, _context) {
|
|
182
|
-
try {
|
|
183
|
-
const outPath = resolve(input.path);
|
|
184
|
-
const pdfBuffer = generatePdf(input.content, {
|
|
185
|
-
title: input.title,
|
|
186
|
-
author: input.author,
|
|
187
|
-
fontSize: input.fontSize,
|
|
188
|
-
});
|
|
189
|
-
await mkdir(dirname(outPath), { recursive: true });
|
|
190
|
-
await writeFile(outPath, pdfBuffer);
|
|
191
|
-
// Count pages from the generated content
|
|
192
|
-
const pageCount = (pdfBuffer.toString('latin1').match(/\/Type \/Page\b/g) || []).length;
|
|
193
|
-
return {
|
|
194
|
-
success: true,
|
|
195
|
-
output: {
|
|
196
|
-
path: outPath,
|
|
197
|
-
pages: pageCount,
|
|
198
|
-
bytes: pdfBuffer.length,
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
catch (error) {
|
|
203
|
-
return { success: false, error: error.message };
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
validateArgs(input) {
|
|
207
|
-
const errors = [];
|
|
208
|
-
if (!input.path || typeof input.path !== 'string')
|
|
209
|
-
errors.push('path is required (string)');
|
|
210
|
-
if (input.content === undefined || input.content === null)
|
|
211
|
-
errors.push('content is required');
|
|
212
|
-
return errors.length === 0 ? { isValid: true } : { isValid: false, errors };
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
//# sourceMappingURL=createPdf.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createPdf.js","sourceRoot":"","sources":["../../src/tools/createPdf.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAc7C;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,IAAY,EAAE,OAAmB,EAAE;IACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,SAAS;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,YAAY;IACjD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC;IACrC,MAAM,UAAU,GAAG,QAAQ,GAAG,GAAG,CAAC;IAClC,MAAM,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;IACnC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC,CAAC;IAEtD,sEAAsE;IACtE,MAAM,YAAY,GAAG,QAAQ,GAAG,GAAG,CAAC;IACpC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC;IAExD,4BAA4B;IAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;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,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI;YAAE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC9F,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read Document Tool
|
|
3
|
-
* Extract text content from binary document formats (xlsx, csv, docx, pdf).
|
|
4
|
-
*
|
|
5
|
-
* @module @framers/agentos-ext-cli-executor
|
|
6
|
-
*/
|
|
7
|
-
import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
8
|
-
import type { ShellService } from '../services/shellService.js';
|
|
9
|
-
import type { DocumentReadResult } from '../types.js';
|
|
10
|
-
/**
|
|
11
|
-
* Tool for reading binary document formats
|
|
12
|
-
*/
|
|
13
|
-
export declare class ReadDocumentTool implements ITool {
|
|
14
|
-
private shellService;
|
|
15
|
-
readonly id = "cli-read-document-v1";
|
|
16
|
-
/** Tool call name used by the LLM / ToolExecutor. */
|
|
17
|
-
readonly name = "read_document";
|
|
18
|
-
readonly displayName = "Read Document";
|
|
19
|
-
readonly description: string;
|
|
20
|
-
readonly category = "system";
|
|
21
|
-
readonly hasSideEffects = false;
|
|
22
|
-
readonly inputSchema: JSONSchemaObject;
|
|
23
|
-
constructor(shellService: ShellService);
|
|
24
|
-
/**
|
|
25
|
-
* Read and parse a document
|
|
26
|
-
*/
|
|
27
|
-
execute(input: {
|
|
28
|
-
path: string;
|
|
29
|
-
format?: string;
|
|
30
|
-
sheet?: string;
|
|
31
|
-
maxRows?: number;
|
|
32
|
-
}, _context: ToolExecutionContext): Promise<ToolExecutionResult<DocumentReadResult>>;
|
|
33
|
-
/**
|
|
34
|
-
* Validate input
|
|
35
|
-
*/
|
|
36
|
-
validateArgs(input: Record<string, any>): {
|
|
37
|
-
isValid: boolean;
|
|
38
|
-
errors?: any[];
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=readDocument.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readDocument.d.ts","sourceRoot":"","sources":["../../src/tools/readDocument.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA4JtD;;GAEG;AACH,qBAAa,gBAAiB,YAAW,KAAK;IAwChC,OAAO,CAAC,YAAY;IAvChC,SAAgB,EAAE,0BAA0B;IAC5C,qDAAqD;IACrD,SAAgB,IAAI,mBAAmB;IACvC,SAAgB,WAAW,mBAAmB;IAC9C,SAAgB,WAAW,SAK+C;IAC1E,SAAgB,QAAQ,YAAY;IACpC,SAAgB,cAAc,SAAS;IAEvC,SAAgB,WAAW,EAAE,gBAAgB,CAwB3C;gBAEkB,YAAY,EAAE,YAAY;IAE9C;;OAEG;IACG,OAAO,CACX,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,EACD,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;IAgEnD;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE;CAe/E"}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read Document Tool
|
|
3
|
-
* Extract text content from binary document formats (xlsx, csv, docx, pdf).
|
|
4
|
-
*
|
|
5
|
-
* @module @framers/agentos-ext-cli-executor
|
|
6
|
-
*/
|
|
7
|
-
import { extname } from 'node:path';
|
|
8
|
-
const EXTENSION_FORMAT_MAP = {
|
|
9
|
-
'.xlsx': 'xlsx',
|
|
10
|
-
'.xls': 'xlsx',
|
|
11
|
-
'.csv': 'csv',
|
|
12
|
-
'.tsv': 'csv',
|
|
13
|
-
'.docx': 'docx',
|
|
14
|
-
'.pdf': 'pdf',
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Escape pipe characters for markdown table cells.
|
|
18
|
-
*/
|
|
19
|
-
function escapeCell(value) {
|
|
20
|
-
if (value === null || value === undefined)
|
|
21
|
-
return '';
|
|
22
|
-
return String(value).replace(/\|/g, '\\|').replace(/\n/g, ' ');
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Convert sheet rows to a markdown table string.
|
|
26
|
-
*/
|
|
27
|
-
function toMarkdownTable(headers, rows, sheetName, totalRows, maxRows) {
|
|
28
|
-
const truncated = totalRows > maxRows;
|
|
29
|
-
const countLabel = truncated
|
|
30
|
-
? `(showing ${maxRows} of ${totalRows} rows)`
|
|
31
|
-
: `(${totalRows} rows)`;
|
|
32
|
-
const lines = [];
|
|
33
|
-
lines.push(`## Sheet: ${sheetName} ${countLabel}`);
|
|
34
|
-
lines.push(`| ${headers.map(escapeCell).join(' | ')} |`);
|
|
35
|
-
lines.push(`| ${headers.map(() => '---').join(' | ')} |`);
|
|
36
|
-
for (const row of rows) {
|
|
37
|
-
lines.push(`| ${row.map(escapeCell).join(' | ')} |`);
|
|
38
|
-
}
|
|
39
|
-
return lines.join('\n');
|
|
40
|
-
}
|
|
41
|
-
// ── Format-specific parsers ─────────────────────────────────────────────────
|
|
42
|
-
async function parseXlsx(buffer, opts) {
|
|
43
|
-
const XLSX = await import('xlsx');
|
|
44
|
-
const workbook = XLSX.read(buffer, { type: 'buffer' });
|
|
45
|
-
const sheetNames = opts.sheet
|
|
46
|
-
? workbook.SheetNames.filter((n) => n === opts.sheet)
|
|
47
|
-
: workbook.SheetNames;
|
|
48
|
-
if (opts.sheet && sheetNames.length === 0) {
|
|
49
|
-
throw new Error(`Sheet "${opts.sheet}" not found. Available sheets: ${workbook.SheetNames.join(', ')}`);
|
|
50
|
-
}
|
|
51
|
-
const contentParts = [];
|
|
52
|
-
const structuredSheets = [];
|
|
53
|
-
for (const name of sheetNames) {
|
|
54
|
-
const ws = workbook.Sheets[name];
|
|
55
|
-
const jsonRows = XLSX.utils.sheet_to_json(ws, { header: 1 });
|
|
56
|
-
if (jsonRows.length === 0)
|
|
57
|
-
continue;
|
|
58
|
-
const headers = (jsonRows[0] || []).map(String);
|
|
59
|
-
const dataRows = jsonRows.slice(1);
|
|
60
|
-
const totalRows = dataRows.length;
|
|
61
|
-
const truncated = totalRows > opts.maxRows;
|
|
62
|
-
const displayRows = dataRows.slice(0, opts.maxRows);
|
|
63
|
-
contentParts.push(toMarkdownTable(headers, displayRows, name, totalRows, opts.maxRows));
|
|
64
|
-
structuredSheets.push({
|
|
65
|
-
name,
|
|
66
|
-
headers,
|
|
67
|
-
rows: displayRows,
|
|
68
|
-
rowCount: totalRows,
|
|
69
|
-
truncated,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
content: contentParts.join('\n\n'),
|
|
74
|
-
structured: { sheets: structuredSheets },
|
|
75
|
-
metadata: { sheetNames: workbook.SheetNames },
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
async function parseCsv(buffer, opts) {
|
|
79
|
-
// Use xlsx to parse CSV for consistent handling of quoted fields, delimiters, etc.
|
|
80
|
-
const XLSX = await import('xlsx');
|
|
81
|
-
const workbook = XLSX.read(buffer, { type: 'buffer' });
|
|
82
|
-
const sheetName = workbook.SheetNames[0] || 'Sheet1';
|
|
83
|
-
const ws = workbook.Sheets[sheetName];
|
|
84
|
-
const jsonRows = XLSX.utils.sheet_to_json(ws, { header: 1 });
|
|
85
|
-
if (jsonRows.length === 0) {
|
|
86
|
-
return { content: '(empty CSV file)', structured: { sheets: [] } };
|
|
87
|
-
}
|
|
88
|
-
const headers = (jsonRows[0] || []).map(String);
|
|
89
|
-
const dataRows = jsonRows.slice(1);
|
|
90
|
-
const totalRows = dataRows.length;
|
|
91
|
-
const truncated = totalRows > opts.maxRows;
|
|
92
|
-
const displayRows = dataRows.slice(0, opts.maxRows);
|
|
93
|
-
return {
|
|
94
|
-
content: toMarkdownTable(headers, displayRows, 'CSV', totalRows, opts.maxRows),
|
|
95
|
-
structured: {
|
|
96
|
-
sheets: [{
|
|
97
|
-
name: 'CSV',
|
|
98
|
-
headers,
|
|
99
|
-
rows: displayRows,
|
|
100
|
-
rowCount: totalRows,
|
|
101
|
-
truncated,
|
|
102
|
-
}],
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
async function parseDocx(buffer) {
|
|
107
|
-
const mammoth = await import('mammoth');
|
|
108
|
-
const result = await mammoth.extractRawText({ buffer });
|
|
109
|
-
return {
|
|
110
|
-
content: result.value,
|
|
111
|
-
metadata: result.messages.length > 0
|
|
112
|
-
? { warnings: result.messages.map((m) => m.message) }
|
|
113
|
-
: undefined,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
async function parsePdf(buffer) {
|
|
117
|
-
// pdf-parse has no types — import default export
|
|
118
|
-
const pdfParse = (await import('pdf-parse')).default;
|
|
119
|
-
const result = await pdfParse(buffer);
|
|
120
|
-
return {
|
|
121
|
-
content: result.text,
|
|
122
|
-
metadata: {
|
|
123
|
-
pages: result.numpages,
|
|
124
|
-
info: result.info,
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
// ── Tool ─────────────────────────────────────────────────────────────────────
|
|
129
|
-
/**
|
|
130
|
-
* Tool for reading binary document formats
|
|
131
|
-
*/
|
|
132
|
-
export class ReadDocumentTool {
|
|
133
|
-
shellService;
|
|
134
|
-
id = 'cli-read-document-v1';
|
|
135
|
-
/** Tool call name used by the LLM / ToolExecutor. */
|
|
136
|
-
name = 'read_document';
|
|
137
|
-
displayName = 'Read Document';
|
|
138
|
-
description = 'Read and extract text content from binary document formats: ' +
|
|
139
|
-
'.xlsx/.xls (spreadsheets), .csv/.tsv (comma/tab-separated), ' +
|
|
140
|
-
'.docx (Word documents), .pdf (PDFs). ' +
|
|
141
|
-
'Returns structured text that can be analyzed. ' +
|
|
142
|
-
'For plain text files (.txt, .md, .json, etc.), use file_read instead.';
|
|
143
|
-
category = 'system';
|
|
144
|
-
hasSideEffects = false;
|
|
145
|
-
inputSchema = {
|
|
146
|
-
type: 'object',
|
|
147
|
-
required: ['path'],
|
|
148
|
-
properties: {
|
|
149
|
-
path: {
|
|
150
|
-
type: 'string',
|
|
151
|
-
description: 'File path to the document',
|
|
152
|
-
},
|
|
153
|
-
format: {
|
|
154
|
-
type: 'string',
|
|
155
|
-
enum: ['xlsx', 'csv', 'docx', 'pdf', 'auto'],
|
|
156
|
-
default: 'auto',
|
|
157
|
-
description: 'Document format. Auto-detected from extension if not specified.',
|
|
158
|
-
},
|
|
159
|
-
sheet: {
|
|
160
|
-
type: 'string',
|
|
161
|
-
description: 'For xlsx: specific sheet name to read. Reads all sheets if omitted.',
|
|
162
|
-
},
|
|
163
|
-
maxRows: {
|
|
164
|
-
type: 'number',
|
|
165
|
-
description: 'For xlsx/csv: maximum data rows to return per sheet (default: 500)',
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
additionalProperties: false,
|
|
169
|
-
};
|
|
170
|
-
constructor(shellService) {
|
|
171
|
-
this.shellService = shellService;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Read and parse a document
|
|
175
|
-
*/
|
|
176
|
-
async execute(input, _context) {
|
|
177
|
-
try {
|
|
178
|
-
// Detect format
|
|
179
|
-
const ext = extname(input.path).toLowerCase();
|
|
180
|
-
let format;
|
|
181
|
-
if (input.format && input.format !== 'auto') {
|
|
182
|
-
format = input.format;
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
const detected = EXTENSION_FORMAT_MAP[ext];
|
|
186
|
-
if (!detected) {
|
|
187
|
-
const supported = Object.keys(EXTENSION_FORMAT_MAP).join(', ');
|
|
188
|
-
return {
|
|
189
|
-
success: false,
|
|
190
|
-
error: `Unsupported document format "${ext}". Supported: ${supported}. ` +
|
|
191
|
-
(ext === '.doc'
|
|
192
|
-
? 'Legacy .doc format is not supported. Please convert to .docx first.'
|
|
193
|
-
: 'For plain text files, use file_read instead.'),
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
format = detected;
|
|
197
|
-
}
|
|
198
|
-
// Read file as buffer (enforces filesystem security)
|
|
199
|
-
const { buffer, path: absolutePath, size } = await this.shellService.readFileBuffer(input.path);
|
|
200
|
-
const maxRows = input.maxRows ?? 500;
|
|
201
|
-
// Parse by format
|
|
202
|
-
let parsed;
|
|
203
|
-
switch (format) {
|
|
204
|
-
case 'xlsx':
|
|
205
|
-
parsed = await parseXlsx(buffer, { sheet: input.sheet, maxRows });
|
|
206
|
-
break;
|
|
207
|
-
case 'csv':
|
|
208
|
-
parsed = await parseCsv(buffer, { maxRows });
|
|
209
|
-
break;
|
|
210
|
-
case 'docx':
|
|
211
|
-
parsed = await parseDocx(buffer);
|
|
212
|
-
break;
|
|
213
|
-
case 'pdf':
|
|
214
|
-
parsed = await parsePdf(buffer);
|
|
215
|
-
break;
|
|
216
|
-
default:
|
|
217
|
-
return { success: false, error: `Unknown format: ${format}` };
|
|
218
|
-
}
|
|
219
|
-
return {
|
|
220
|
-
success: true,
|
|
221
|
-
output: {
|
|
222
|
-
path: absolutePath,
|
|
223
|
-
format,
|
|
224
|
-
size,
|
|
225
|
-
content: parsed.content,
|
|
226
|
-
structured: parsed.structured,
|
|
227
|
-
metadata: parsed.metadata,
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
catch (error) {
|
|
232
|
-
return { success: false, error: error.message };
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Validate input
|
|
237
|
-
*/
|
|
238
|
-
validateArgs(input) {
|
|
239
|
-
const errors = [];
|
|
240
|
-
if (!input.path) {
|
|
241
|
-
errors.push('Path is required');
|
|
242
|
-
}
|
|
243
|
-
else if (typeof input.path !== 'string') {
|
|
244
|
-
errors.push('Path must be a string');
|
|
245
|
-
}
|
|
246
|
-
if (input.format && !['xlsx', 'csv', 'docx', 'pdf', 'auto'].includes(input.format)) {
|
|
247
|
-
errors.push(`Invalid format "${input.format}". Must be one of: xlsx, csv, docx, pdf, auto`);
|
|
248
|
-
}
|
|
249
|
-
return errors.length === 0 ? { isValid: true } : { isValid: false, errors };
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
//# sourceMappingURL=readDocument.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readDocument.js","sourceRoot":"","sources":["../../src/tools/readDocument.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,MAAM,oBAAoB,GAAmC;IAC3D,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,KAAK;CACd,CAAC;AAEF;;GAEG;AACH,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACrD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CA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