packfs-core
Version:
Semantic filesystem operations for LLM agent frameworks with natural language understanding. See LLM_AGENT_GUIDE.md for copy-paste examples.
61 lines • 1.98 kB
JavaScript
/**
* LangChain tool implementation for PackFS
*/
export class PackFSLangChainTool {
constructor(config = {}) {
this.config = {
toolName: 'packfs_filesystem',
description: 'Secure filesystem operations for LLM agents',
...config
};
}
/**
* Get tool definition for LangChain
*/
getToolDefinition() {
return {
name: this.config.toolName,
description: this.config.description,
parameters: {
type: 'object',
properties: {
operation: {
type: 'string',
enum: ['read', 'write', 'list', 'exists', 'stat'],
description: 'The filesystem operation to perform'
},
path: {
type: 'string',
description: 'The file or directory path'
},
content: {
type: 'string',
description: 'Content to write (for write operations)'
}
},
required: ['operation', 'path']
}
};
}
/**
* Execute filesystem operation
*/
async execute(operation, path, _content) {
// Stub implementation - will be expanded with actual filesystem operations
switch (operation) {
case 'read':
return `Reading file: ${path}`;
case 'write':
return `Writing to file: ${path}`;
case 'list':
return `Listing directory: ${path}`;
case 'exists':
return `Checking existence: ${path}`;
case 'stat':
return `Getting stats: ${path}`;
default:
throw new Error(`Unknown operation: ${operation}`);
}
}
}
//# sourceMappingURL=tool.js.map