@lumifai/harness-tool-pack-file-processing 0.0.1

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 ADDED
@@ -0,0 +1,13 @@
1
+ # @lumifai/harness-tool-pack-file-processing
2
+
3
+ Extract text from workspace PDF files and write results under `/processed/`.
4
+
5
+ ```ts
6
+ import { createFileProcessingToolPack } from '@lumifai/harness-tool-pack-file-processing';
7
+
8
+ createFileProcessingToolPack();
9
+ ```
10
+
11
+ `process_pdf` reads a workspace PDF, runs OCR-aware extraction via LiteParse, and returns an `output_path` reference instead of inline content. Bundled agent skills ship in this package and are merged into `workspace.skills` when the pack is enabled.
12
+
13
+ Tool pack id: `file-processing`. Disabled by default (`enabledByDefault: false`). Default policy: `process_pdf` → `ask`.
@@ -0,0 +1,3 @@
1
+ import type { ToolsInput } from '@mastra/core/agent';
2
+ export declare function createFileProcessingTools(): ToolsInput;
3
+ export declare function createFileProcessingToolPack(): import("@lumifai/harness-tool-packs").ToolPack;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createFileProcessingTools = createFileProcessingTools;
37
+ exports.createFileProcessingToolPack = createFileProcessingToolPack;
38
+ const tools_1 = require("@mastra/core/tools");
39
+ const zod_1 = require("zod");
40
+ const harness_tool_packs_1 = require("@lumifai/harness-tool-packs");
41
+ const utils_1 = require("./utils");
42
+ const workspaceFilePathSchema = zod_1.z
43
+ .string()
44
+ .min(1)
45
+ .describe('Absolute workspace path to a file, e.g. /documents/report.pdf');
46
+ function createFileProcessingTools() {
47
+ const processPdf = (0, tools_1.createTool)({
48
+ id: 'process_pdf',
49
+ description: 'Extract text content from a PDF file and write it to /processed/ as plain text. Returns a reference path, not the content itself.',
50
+ inputSchema: zod_1.z.object({
51
+ path: workspaceFilePathSchema,
52
+ }),
53
+ execute: async (inputData, context) => {
54
+ const { LiteParse } = await Promise.resolve().then(() => __importStar(require('@llamaindex/liteparse')));
55
+ const { normalizedPath, buffer } = await (0, utils_1.readWorkspaceBinaryFile)(context, inputData.path);
56
+ const parser = new LiteParse({ ocrEnabled: true, quiet: true });
57
+ const result = await parser.parse(buffer);
58
+ const outputContent = result.pages
59
+ .map((page) => `--- Page ${page.pageNum} ---\n${page.text}`)
60
+ .join('\n\n');
61
+ const outputPath = (0, utils_1.deriveOutputPath)(normalizedPath, 'txt');
62
+ await (0, utils_1.writeProcessedText)(context, outputPath, outputContent);
63
+ return {
64
+ source_path: normalizedPath,
65
+ output_path: outputPath,
66
+ page_count: result.pages.length,
67
+ char_count: outputContent.length,
68
+ };
69
+ },
70
+ });
71
+ return {
72
+ processPdf,
73
+ };
74
+ }
75
+ function createFileProcessingToolPack() {
76
+ return (0, harness_tool_packs_1.defineToolPack)({
77
+ id: 'file-processing',
78
+ description: 'Extract text from PDF files.',
79
+ enabledByDefault: false,
80
+ tools: createFileProcessingTools(),
81
+ permissionPolicies: {
82
+ process_pdf: 'ask',
83
+ },
84
+ });
85
+ }
86
+ //# sourceMappingURL=file-processing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-processing.js","sourceRoot":"","sources":["../src/file-processing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,8DAkCC;AAED,oEAUC;AA1DD,8CAAgD;AAChD,6BAAwB;AAExB,oEAA6D;AAE7D,mCAAwF;AAExF,MAAM,uBAAuB,GAAG,OAAC;KAC9B,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,QAAQ,CAAC,+DAA+D,CAAC,CAAC;AAE7E,SAAgB,yBAAyB;IACvC,MAAM,UAAU,GAAG,IAAA,kBAAU,EAAC;QAC5B,EAAE,EAAE,aAAa;QACjB,WAAW,EACT,mIAAmI;QACrI,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,uBAAuB;SAC9B,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;YACpC,MAAM,EAAE,SAAS,EAAE,GAAG,wDAAa,uBAAuB,GAAC,CAAC;YAC5D,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,+BAAuB,EAAC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;YAE1F,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAChE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAE1C,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK;iBAC/B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,IAAI,CAAC,OAAO,SAAS,IAAI,CAAC,IAAI,EAAE,CAAC;iBAC3D,IAAI,CAAC,MAAM,CAAC,CAAC;YAEhB,MAAM,UAAU,GAAG,IAAA,wBAAgB,EAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,IAAA,0BAAkB,EAAC,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;YAE7D,OAAO;gBACL,WAAW,EAAE,cAAc;gBAC3B,WAAW,EAAE,UAAU;gBACvB,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;gBAC/B,UAAU,EAAE,aAAa,CAAC,MAAM;aACjC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,UAAU;KACX,CAAC;AACJ,CAAC;AAED,SAAgB,4BAA4B;IAC1C,OAAO,IAAA,mCAAc,EAAC;QACpB,EAAE,EAAE,iBAAiB;QACrB,WAAW,EAAE,8BAA8B;QAC3C,gBAAgB,EAAE,KAAK;QACvB,KAAK,EAAE,yBAAyB,EAAE;QAClC,kBAAkB,EAAE;YAClB,WAAW,EAAE,KAAK;SACnB;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1 @@
1
+ export { createFileProcessingTools, createFileProcessingToolPack } from './file-processing';
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFileProcessingToolPack = exports.createFileProcessingTools = void 0;
4
+ var file_processing_1 = require("./file-processing");
5
+ Object.defineProperty(exports, "createFileProcessingTools", { enumerable: true, get: function () { return file_processing_1.createFileProcessingTools; } });
6
+ Object.defineProperty(exports, "createFileProcessingToolPack", { enumerable: true, get: function () { return file_processing_1.createFileProcessingToolPack; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA4F;AAAnF,4HAAA,yBAAyB,OAAA;AAAE,+HAAA,4BAA4B,OAAA"}
@@ -0,0 +1,8 @@
1
+ import type { ToolExecutionContext } from '@mastra/core/tools';
2
+ export declare function normalizeWorkspaceFilePath(path: string): string;
3
+ export declare function readWorkspaceBinaryFile(context: ToolExecutionContext, path: string): Promise<{
4
+ normalizedPath: string;
5
+ buffer: Buffer;
6
+ }>;
7
+ export declare function writeProcessedText(context: ToolExecutionContext, outputPath: string, content: string): Promise<void>;
8
+ export declare function deriveOutputPath(sourcePath: string, suffix: string): string;
package/dist/utils.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeWorkspaceFilePath = normalizeWorkspaceFilePath;
4
+ exports.readWorkspaceBinaryFile = readWorkspaceBinaryFile;
5
+ exports.writeProcessedText = writeProcessedText;
6
+ exports.deriveOutputPath = deriveOutputPath;
7
+ function normalizeWorkspaceFilePath(path) {
8
+ const trimmed = path.trim();
9
+ if (!trimmed.startsWith('/')) {
10
+ throw new Error(`Path must be absolute within the workspace: ${path}`);
11
+ }
12
+ return trimmed;
13
+ }
14
+ async function readWorkspaceBinaryFile(context, path) {
15
+ const normalizedPath = normalizeWorkspaceFilePath(path);
16
+ const workspace = context.workspace;
17
+ if (!workspace?.filesystem?.readFile) {
18
+ throw new Error(`File processing tools require a workspace filesystem to read ${normalizedPath}`);
19
+ }
20
+ const fileContent = await workspace.filesystem.readFile(normalizedPath);
21
+ const buffer = Buffer.isBuffer(fileContent) ? fileContent : Buffer.from(fileContent);
22
+ return { normalizedPath, buffer };
23
+ }
24
+ async function writeProcessedText(context, outputPath, content) {
25
+ const workspace = context.workspace;
26
+ if (!workspace?.filesystem?.writeFile) {
27
+ throw new Error(`File processing tools require a workspace filesystem to write ${outputPath}`);
28
+ }
29
+ const dir = outputPath.substring(0, outputPath.lastIndexOf('/'));
30
+ if (dir && dir !== '/') {
31
+ await workspace.filesystem.mkdir(dir, { recursive: true });
32
+ }
33
+ await workspace.filesystem.writeFile(outputPath, content);
34
+ }
35
+ function deriveOutputPath(sourcePath, suffix) {
36
+ const parts = sourcePath.split('/');
37
+ const filename = parts[parts.length - 1] ?? sourcePath;
38
+ parts[parts.length - 1] = `${filename}.${suffix}`;
39
+ return parts.join('/');
40
+ }
41
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAEA,gEAMC;AAED,0DAeC;AAED,gDAgBC;AAED,4CAKC;AAhDD,SAAgB,0BAA0B,CAAC,IAAY;IACrD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,+CAA+C,IAAI,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAC3C,OAA6B,EAC7B,IAAY;IAEZ,MAAM,cAAc,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACpC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,gEAAgE,cAAc,EAAE,CACjF,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACxE,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrF,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;AACpC,CAAC;AAEM,KAAK,UAAU,kBAAkB,CACtC,OAA6B,EAC7B,UAAkB,EAClB,OAAe;IAEf,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACpC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,iEAAiE,UAAU,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,MAAM,GAAG,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IACjE,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,gBAAgB,CAAC,UAAkB,EAAE,MAAc;IACjE,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,UAAU,CAAC;IACvD,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,QAAQ,IAAI,MAAM,EAAE,CAAC;IAClD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@lumifai/harness-tool-pack-file-processing",
3
+ "version": "0.0.1",
4
+ "license": "UNLICENSED",
5
+ "engines": {
6
+ "node": ">=22.13.0"
7
+ },
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "main": "dist/index.js",
18
+ "types": "dist/index.d.ts",
19
+ "files": [
20
+ "dist",
21
+ "!dist/**/*.test.*",
22
+ "skills"
23
+ ],
24
+ "dependencies": {
25
+ "@llamaindex/liteparse": "^2.0.8",
26
+ "@mastra/core": "1.50.1",
27
+ "zod": "^4.4.3",
28
+ "@lumifai/harness-tool-packs": "0.0.1"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "registry": "https://registry.npmjs.org/"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.json"
36
+ }
37
+ }
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: file-processing
3
+ description: Extract text from PDF files for LLM consumption
4
+ version: 1.1.0
5
+ tags:
6
+ - file-processing
7
+ - pdf
8
+ ---
9
+
10
+ # File Processing Tools
11
+
12
+ Use the file-processing tool pack to extract text from PDF documents. Extracted content is written to the workspace filesystem as plain text files, keeping your context window clean.
13
+
14
+ ## Available Tools
15
+
16
+ | Tool | Format | Output |
17
+ | ------------- | ------ | ---------------------- |
18
+ | `process_pdf` | PDF | Text with page markers |
19
+
20
+ ## Workflow
21
+
22
+ 1. Call `process_pdf` with the absolute workspace path to the file.
23
+ 2. The tool writes extracted text to `/processed/<filename>.txt`.
24
+ 3. Use the returned `output_path` to reference the extracted content in subsequent operations.
25
+
26
+ ## Tips
27
+
28
+ - All tools return metadata only (paths, counts) — the extracted text stays in the filesystem.
29
+ - Processed files are written to `/processed/` to keep them organized and separate from source files.