{"_id":"@agentxin-ai/plugin-unstructured","_rev":"2-c9a005a8dda4f9939dcf357280cf2b16","name":"@agentxin-ai/plugin-unstructured","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.3":{"name":"@agentxin-ai/plugin-unstructured","version":"0.0.3","_id":"@agentxin-ai/plugin-unstructured@0.0.3","maintainers":[{"name":"agentxin-ai","email":"1304040880@qq.com"}],"homepage":"https://github.com/agentxin-ai/agentxin-plugins#readme","bugs":{"url":"https://github.com/agentxin-ai/agentxin-plugins/issues"},"dist":{"shasum":"586e8772e9722a3a76984bec9ac4d0b5c46f031f","tarball":"https://registry.npmjs.org/@agentxin-ai/plugin-unstructured/-/plugin-unstructured-0.0.3.tgz","fileCount":2,"integrity":"sha512-5RgAFmbGDZUzga+P4b58uAS0Ley9FbbD6yUUdcpYmun6oX/EZldlo5HmYCPwC2tyB884UgM5JorF3LT6MKOtsA==","signatures":[{"sig":"MEUCIDXHxi4ontem4JmktUFhwiIv9GuYaUahOKYQpyH8PrIKAiEA61iseq+UkMofZVApYRbPxTuLZdNAGC9FEx7TLf8svhU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6890},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","@agentxin-plugins-starter/source":"./src/index.ts"},"./package.json":"./package.json"},"_npmUser":{"name":"agentxin-ai","email":"1304040880@qq.com"},"repository":{"url":"git+https://github.com/agentxin-ai/agentxin-plugins.git","type":"git"},"_npmVersion":"10.9.4","description":"`@agentxin-ai/plugin-unstructured` brings the [Unstructured](https://www.unstructured.io/) document partitioning API into the [AgentXin AI](https://github.com/agentxin-ai/agentxin) platform. It lets ingestion workflows call Unstructured’s `/general/v0/gen","directories":{},"_nodeVersion":"22.22.0","dependencies":{"tslib":"^2.3.0","unstructured-client":"^0.28.0"},"_hasShrinkwrap":false,"peerDependencies":{"zod":"^3.25.67","chalk":"^4.1.2","lodash-es":"^4.17.21","@nestjs/common":"^11.1.6","@nestjs/config":"^4.0.2","@langchain/core":"^0.3.72","@metad/contracts":"^3.6.0","@agentxin-ai/plugin-sdk":"^3.6.0"},"_npmOperationalInternal":{"tmp":"tmp/plugin-unstructured_0.0.3_1773917258223_0.372976421012327","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@agentxin-ai/plugin-unstructured","version":"0.0.4","repository":{"type":"git","url":"git+https://github.com/agentxin-ai/agentxin-plugins.git"},"bugs":{"url":"https://github.com/agentxin-ai/agentxin-plugins/issues"},"type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{"./package.json":"./package.json",".":{"@agentxin-plugins-starter/source":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"dependencies":{"tslib":"^2.3.0","unstructured-client":"^0.28.0"},"peerDependencies":{"@langchain/core":"^0.3.72","@metad/contracts":"^3.6.0","@nestjs/config":"^4.0.2","@nestjs/common":"^11.1.6","@agentxin-ai/plugin-sdk":"^3.6.0","chalk":"^4.1.2","lodash-es":"^4.17.21","zod":"^3.25.67"},"_id":"@agentxin-ai/plugin-unstructured@0.0.4","description":"`@agentxin-ai/plugin-unstructured` brings the [Unstructured](https://www.unstructured.io/) document partitioning API into the [AgentXin AI](https://github.com/agentxin-ai/agentxin) platform. It lets ingestion workflows call Unstructured’s `/general/v0/gen","homepage":"https://github.com/agentxin-ai/agentxin-plugins#readme","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-hG6ZoldnGrP9ZXigXqdu10pFpDjetZK1BrPKcZHNTJ0kXnlWyhpXvVq57/kD3F4eyPHpZQL6QZVux9zVLxM7Tg==","shasum":"b90221732b5788982f86476289cf293a7b5ab95e","tarball":"https://registry.npmjs.org/@agentxin-ai/plugin-unstructured/-/plugin-unstructured-0.0.4.tgz","fileCount":23,"unpackedSize":49876,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIB+KPjQTEZyb14QR5k0m5SQOPe9dJt8fCcWZ7ZUfGYriAiEAwRey2ZCe+0XhtEnT0OP//m/FKDA/l+KT5KXs91pxs8M="}]},"_npmUser":{"name":"agentxin-ai","email":"1304040880@qq.com"},"directories":{},"maintainers":[{"name":"agentxin-ai","email":"1304040880@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-unstructured_0.0.4_1775181985524_0.33705058966881163"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-19T10:47:38.088Z","modified":"2026-04-03T02:06:25.808Z","0.0.3":"2026-03-19T10:47:38.363Z","0.0.4":"2026-04-03T02:06:25.668Z"},"bugs":{"url":"https://github.com/agentxin-ai/agentxin-plugins/issues"},"homepage":"https://github.com/agentxin-ai/agentxin-plugins#readme","repository":{"type":"git","url":"git+https://github.com/agentxin-ai/agentxin-plugins.git"},"description":"`@agentxin-ai/plugin-unstructured` brings the [Unstructured](https://www.unstructured.io/) document partitioning API into the [AgentXin AI](https://github.com/agentxin-ai/agentxin) platform. It lets ingestion workflows call Unstructured’s `/general/v0/gen","maintainers":[{"name":"agentxin-ai","email":"1304040880@qq.com"}],"readme":"# AgentXin Plugin: Unstructured\n\n`@agentxin-ai/plugin-unstructured` brings the [Unstructured](https://www.unstructured.io/) document partitioning API into the [AgentXin AI](https://github.com/agentxin-ai/agentxin) platform. It lets ingestion workflows call Unstructured’s `/general/v0/general` endpoint, convert PDFs and mixed-format documents into markdown chunks, persist image/table assets to the AgentXin file system, and return `Document<ChunkMetadata>` objects that are ready for downstream RAG pipelines.\n\n## Installation\n\n```bash\npnpm add @agentxin-ai/plugin-unstructured\n# or\nnpm install @agentxin-ai/plugin-unstructured\n```\n\n> **Peer dependencies:** `@agentxin-ai/plugin-sdk`, `@nestjs/common@^11`, `@nestjs/config@^4`, `@metad/contracts`, `@langchain/core@^0.3.72`, `chalk@4`, `lodash-es`, and `zod`. Install them in the host service if they are not already available.\n\n## Quick Start\n\n1. **Collect Unstructured credentials**  \n   - Create an API key from the Unstructured dashboard.  \n   - Default base URL: `https://api.unstructuredapp.io`.\n\n2. **Configure the integration**  \n   - **Via AgentXin AI System:** Add an integration of type `unstructured` and fill in the fields below.  \n   - **Via environment variables (fallback when no integration is stored):**\n\n     ```sh\n     export UNSTRUCTURED_API_BASE_URL=https://api.unstructuredapp.io\n     export UNSTRUCTURED_API_TOKEN=your-unstructured-api-key\n     ```\n\n     Example integration JSON:\n\n     ```json\n     {\n       \"provider\": \"unstructured\",\n       \"options\": {\n         \"apiUrl\": \"https://api.unstructuredapp.io\",\n         \"apiKey\": \"your-unstructured-api-key\"\n       }\n     }\n     ```\n\n3. **Register the plugin with the AgentXin runtime**\n\n   ```sh .env\n   PLUGINS=@agentxin-ai/plugin-unstructured\n   ```\n\n   `register()` wires up the `UnstructuredPlugin` NestJS module globally and logs lifecycle events during `onStart`/`onStop`.\n\n4. **Trigger a document transformation**  \n   - When a knowledge ingestion job selects the “Unstructured” transformer, the plugin reads the source file via `XpFileSystem`, sends it to Unstructured, converts the response to markdown chunks, and writes referenced images/tables under the same folder.  \n   - To smoke-test credentials you can call the built-in controller:\n\n     ```bash\n     curl -X POST http://localhost:3000/unstructured/test \\\n       -H 'Content-Type: application/json' \\\n       -d '{\"options\":{\"apiUrl\":\"https://api.unstructuredapp.io\",\"apiKey\":\"YOUR_KEY\"}}'\n     ```\n\n     A `401` indicates malformed credentials (returned as `BadRequestException`), while `200` confirms partition access.\n\n## Integration Options\n\n| Field  | Type   | Description                              | Required | Default                         |\n| ------ | ------ | ---------------------------------------- | -------- | ------------------------------- |\n| `apiUrl` | string | Base URL of your Unstructured deployment | No       | `https://api.unstructuredapp.io` |\n| `apiKey` | string | API key used for `apiKeyAuth` headers     | Yes      | —                               |\n\n> Environment variables `UNSTRUCTURED_API_BASE_URL` and `UNSTRUCTURED_API_TOKEN` are used when no integration config is injected; explicit integration values take precedence.\n\n## Transformer Parameters\n\n`UnstructuredTransformerStrategy` forwards the following options to `partitionParameters`:\n\n| Option                     | Type                | Default          | Notes |\n| -------------------------- | ------------------- | ---------------- | ----- |\n| `chunkingStrategy`         | `'basic' \\| 'by_title' \\| 'by_page' \\| 'by_similarity'` | `undefined` | Matches Unstructured chunking presets. |\n| `maxCharacters`            | number              | `1000`           | Hard cap per chunk when chunking is enabled. |\n| `overlap`                  | number              | `0`              | Character tail appended to the next chunk for continuity. |\n| `strategy`                 | `'auto' \\| 'fast' \\| 'hi_res' \\| 'ocr_only' \\| 'vlm'` | `'auto'` | Parsing pipeline selection. |\n| `languages`                | string[]            | `['chi_sim','eng']` | Accepts any Tesseract language code (see Unstructured docs). |\n| `splitPdfPage`             | boolean             | `false`          | Client-side page splitting hint; ignored by backend. |\n| `splitPdfConcurrencyLevel` | number              | `2`              | Max concurrent requests when `splitPdfPage` is enabled. |\n\nEvery request automatically sets `extractImageBlockTypes` to `['Image','Table']` so that generated figures/tables can be written back as assets.\n\n## Permissions\n\n- **Integration:** Requires `integration:unstructured` permission to read API credentials during ingestion.\n- **File System:** Needs `read/write/list` on `XpFileSystem` to fetch source binaries and persist derived image/table resources.\n\nEnsure your policy grants both permissions to avoid runtime failures.\n\n## Output Content\n\n- **Markdown chunks:** Each Unstructured element is converted into markdown (headings, paragraphs, bullet lists), then merged into a `Document` instance.  \n- **Asset manifest:** When `Image` or `Table` elements include `image_base64`, the plugin stores the decoded PNG under `<source-folder>/images/<element-id>.png`, returns the public URL, and exposes it as `metadata.assets`.  \n- **Metadata:** Every chunk contains `{ parser: 'unstructured', source: <filePath> }`, enabling traceability and downstream splitting if desired.\n\n## Development & Debugging\n\n```bash\nnpm install\nnpx nx build @agentxin-ai/plugin-unstructured\nnpx nx test @agentxin-ai/plugin-unstructured\n```\n\nBuild artifacts land in `packages/unstructured/dist`. Ensure the published package includes `package.json`, compiled JS, and type declarations.\n\n## License\n\nThis plugin follows the repository’s [AGPL-3.0 License](../../../LICENSE).\n","readmeFilename":"README.md"}