agent-office-sdk
v0.0.6
Published
TypeScript SDK for Agent Office API - AI-powered document editing
Maintainers
Readme
Agent Office SDK
TypeScript SDK for the Agent Office API - AI-powered document editing for agentic workflows.
Installation
npm install agent-office-sdk
# or
bun add agent-office-sdkQuick Start
import { AgentOffice } from "agent-office-sdk";
import fs from "fs";
// Initialize the client
const client = new AgentOffice({
apiKey: "sk_ao_your_api_key", // Get your key from https://agentoffice.dev
});
// Upload a document
const fileBuffer = fs.readFileSync("./document.docx");
const file = new File([fileBuffer], "document.docx");
const { docId, markdown } = await client.documents.create({
file: file,
returnMarkdown: true,
});
// Edit the document
await client.edit({
docId: docId,
editUid: crypto.randomUUID(),
editInstructions: "Change the title to 'My New Title'",
trackedChanges: false,
});
// Download the edited document
const result = await client.documents.download({ docId: docId });
const fileResponse = await fetch(result.downloadUrl);
// Save or process the file...Features
- 📝 Upload and convert documents (DOCX, PDF, etc.)
- ✏️ AI-powered document editing
- 📖 Read document content as Markdown
- 💾 Download edited documents
- 🔄 Track changes support
API Reference
Client Initialization
const client = new AgentOffice({
apiKey: string, // Required: Your API key
baseUrl: string, // Optional: Default is https://api.agentoffice.dev
});Documents
Create Document
await client.documents.create({
file: File, // The document file
returnMarkdown: boolean, // Return markdown content
ttlSeconds: number, // Time to live in seconds
});Download Document
await client.documents.download({
docId: string,
expiresIn: number, // Presigned URL expiration in seconds
});List Documents
await client.documents.list();Edit Document
await client.edit({
docId: string,
editUid: string, // Unique identifier for the edit
editInstructions: string, // Natural language edit instructions
lookupText: string, // Text to locate the edit position
trackedChanges: boolean, // Enable track changes
useLargeModel: boolean, // Use larger AI model
});Read Document
await client.read({
docId: string,
readUid: string, // Unique identifier for the read
});License
MIT
Support
- Website: https://agentoffice.dev
- Documentation: https://docs.agentoffice.dev
