{"path":"QUICKSTART.md","size":1891,"locked":false,"binary":false,"truncated":false,"content":"# QUICKSTART — AgentSafeWorkspace SDK\n\nIntegrate safe file operations and command policy validation into your AI agent tool handlers in 5 minutes.\n\n### 1. Basic Integration\n\n```javascript\nimport { createSafeWorkspace, SecurityViolationError } from './src/index.mjs';\n\nconst workspace = createSafeWorkspace({\n  rootPath: process.cwd(),\n  allowedCommands: ['npm test', 'git diff', 'node scripts/validate.js']\n});\n\n// Tool Handler: Read File\nexport async function handleAgentReadFile({ path }) {\n  try {\n    const file = workspace.readSafeFile(path);\n    return {\n      content: file.content.toString('utf8'),\n      sha256: file.sha256\n    };\n  } catch (err) {\n    if (err instanceof SecurityViolationError) {\n      return { error: `SECURITY_BLOCKED: ${err.message}` };\n    }\n    throw err;\n  }\n}\n\n// Tool Handler: Execute Shell Command\nexport async function handleAgentExecuteCommand({ command }) {\n  try {\n    const evaluation = workspace.validateCommand(command);\n    // Execute command safely\n    // const output = execSync(evaluation.commandLine);\n    return { status: 'SUCCESS', auditHash: evaluation.auditHash };\n  } catch (err) {\n    if (err instanceof SecurityViolationError) {\n      return { error: `COMMAND_BLOCKED: ${err.message}` };\n    }\n    throw err;\n  }\n}\n```\n\n### 2. LangChain / AutoGPT Tool Wrapping\n\n```javascript\nimport { DynamicStructuredTool } from \"@langchain/core/tools\";\nimport { z } from \"zod\";\n\nexport function createSafeReadTool(workspace) {\n  return new DynamicStructuredTool({\n    name: \"read_workspace_file\",\n    description: \"Read a file safely inside the project workspace\",\n    schema: z.object({ filePath: z.string() }),\n    func: async ({ filePath }) => {\n      try {\n        const res = workspace.readSafeFile(filePath);\n        return res.content.toString('utf8');\n      } catch (err) {\n        return `ERROR: ${err.message}`;\n      }\n    }\n  });\n}\n```\n"}