@unityclaw/skills 1.0.0

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.
@@ -0,0 +1,375 @@
1
+ ---
2
+ name: unityclaw-document-convert
3
+ description: Convert documents between formats (PDF, Word, PPT, Excel, Image)
4
+ version: 1.0.0
5
+ metadata:
6
+ openclaw:
7
+ requires:
8
+ env:
9
+ - UNITYCLAW_API_KEY
10
+ bins:
11
+ - node
12
+ - npm
13
+ primaryEnv: UNITYCLAW_API_KEY
14
+ emoji: "📄"
15
+ homepage: https://unityclaw.com
16
+ install:
17
+ - kind: node
18
+ package: "@unityclaw/sdk"
19
+ bins: []
20
+ ---
21
+
22
+ # UnityClaw Document Convert
23
+
24
+ Convert documents between various formats including PDF, Word, PowerPoint, Excel, and images.
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ npm install @unityclaw/sdk
30
+ ```
31
+
32
+ ## Configuration
33
+
34
+ Set your API key as environment variable:
35
+
36
+ ```bash
37
+ export UNITYCLAW_API_KEY=your-api-key
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ```typescript
43
+ import { UnityClawClient } from '@unityclaw/sdk';
44
+
45
+ const client = new UnityClawClient();
46
+
47
+ // Convert PDF to Word
48
+ const result = await client.document.pdf2Word({
49
+ attachment: [
50
+ { tmp_url: 'https://example.com/document.pdf', name: 'document.pdf' }
51
+ ]
52
+ });
53
+
54
+ if (result.code === 0) {
55
+ console.log('Converted document:', result.data);
56
+ }
57
+ ```
58
+
59
+ ## Available APIs
60
+
61
+ ### Image Conversions
62
+
63
+ | Method | Description |
64
+ |--------|-------------|
65
+ | `image2Word()` | Convert image to Word document |
66
+ | `image2Ppt()` | Convert image to PowerPoint |
67
+ | `image2Excel()` | Convert image to Excel |
68
+ | `image2Pdf()` | Convert image to PDF |
69
+
70
+ ### PDF Conversions
71
+
72
+ | Method | Description |
73
+ |--------|-------------|
74
+ | `pdf2Word()` | Convert PDF to Word document |
75
+ | `pdf2Ppt()` | Convert PDF to PowerPoint |
76
+ | `pdf2Excel()` | Convert PDF to Excel |
77
+ | `pdf2Image()` | Convert PDF to images |
78
+
79
+ ### Generic Conversion
80
+
81
+ | Method | Description |
82
+ |--------|-------------|
83
+ | `convert()` | Generic conversion with format specification |
84
+
85
+ ## API Reference
86
+
87
+ ### Image to Word
88
+
89
+ ```typescript
90
+ await client.document.image2Word({
91
+ attachment: AttachmentFieldItem[]
92
+ }): Promise<APIResponse<AttachmentResult[]>>
93
+ ```
94
+
95
+ ### Image to PowerPoint
96
+
97
+ ```typescript
98
+ await client.document.image2Ppt({
99
+ attachment: AttachmentFieldItem[]
100
+ }): Promise<APIResponse<AttachmentResult[]>>
101
+ ```
102
+
103
+ ### Image to Excel
104
+
105
+ ```typescript
106
+ await client.document.image2Excel({
107
+ attachment: AttachmentFieldItem[]
108
+ }): Promise<APIResponse<AttachmentResult[]>>
109
+ ```
110
+
111
+ ### Image to PDF
112
+
113
+ ```typescript
114
+ await client.document.image2Pdf({
115
+ attachment: AttachmentFieldItem[]
116
+ }): Promise<APIResponse<AttachmentResult[]>>
117
+ ```
118
+
119
+ ### PDF to Word
120
+
121
+ ```typescript
122
+ await client.document.pdf2Word({
123
+ attachment: AttachmentFieldItem[]
124
+ }): Promise<APIResponse<AttachmentResult[]>>
125
+ ```
126
+
127
+ ### PDF to PowerPoint
128
+
129
+ ```typescript
130
+ await client.document.pdf2Ppt({
131
+ attachment: AttachmentFieldItem[]
132
+ }): Promise<APIResponse<AttachmentResult[]>>
133
+ ```
134
+
135
+ ### PDF to Excel
136
+
137
+ ```typescript
138
+ await client.document.pdf2Excel({
139
+ attachment: AttachmentFieldItem[]
140
+ }): Promise<APIResponse<AttachmentResult[]>>
141
+ ```
142
+
143
+ ### PDF to Image
144
+
145
+ ```typescript
146
+ await client.document.pdf2Image({
147
+ attachment: AttachmentFieldItem[]
148
+ }): Promise<APIResponse<AttachmentResult[]>>
149
+ ```
150
+
151
+ ### Generic Convert
152
+
153
+ ```typescript
154
+ await client.document.convert({
155
+ attachment: AttachmentFieldItem[];
156
+ input_format?: string;
157
+ output_format: string;
158
+ }): Promise<APIResponse<AttachmentResult[]>>
159
+ ```
160
+
161
+ ## Examples
162
+
163
+ ### PDF to Word
164
+
165
+ ```typescript
166
+ const client = new UnityClawClient();
167
+
168
+ const result = await client.document.pdf2Word({
169
+ attachment: [
170
+ { tmp_url: 'https://example.com/report.pdf', name: 'report.pdf' }
171
+ ]
172
+ });
173
+
174
+ if (result.code === 0 && result.data) {
175
+ console.log('Word document:', result.data[0].content);
176
+ }
177
+ ```
178
+
179
+ ### PDF to PowerPoint
180
+
181
+ ```typescript
182
+ const result = await client.document.pdf2Ppt({
183
+ attachment: [
184
+ { tmp_url: 'https://example.com/slides.pdf', name: 'slides.pdf' }
185
+ ]
186
+ });
187
+ ```
188
+
189
+ ### PDF to Excel
190
+
191
+ ```typescript
192
+ const result = await client.document.pdf2Excel({
193
+ attachment: [
194
+ { tmp_url: 'https://example.com/data.pdf', name: 'data.pdf' }
195
+ ]
196
+ });
197
+ ```
198
+
199
+ ### PDF to Image
200
+
201
+ ```typescript
202
+ const result = await client.document.pdf2Image({
203
+ attachment: [
204
+ { tmp_url: 'https://example.com/document.pdf', name: 'document.pdf' }
205
+ ]
206
+ });
207
+
208
+ // Returns array of images (one per page)
209
+ if (result.code === 0 && result.data) {
210
+ result.data.forEach((img, i) => {
211
+ console.log(`Page ${i + 1}: ${img.content}`);
212
+ });
213
+ }
214
+ ```
215
+
216
+ ### Image to Word (OCR)
217
+
218
+ ```typescript
219
+ const result = await client.document.image2Word({
220
+ attachment: [
221
+ { tmp_url: 'https://example.com/scanned-doc.jpg', name: 'scanned.jpg' }
222
+ ]
223
+ });
224
+ ```
225
+
226
+ ### Image to PowerPoint
227
+
228
+ ```typescript
229
+ const result = await client.document.image2Ppt({
230
+ attachment: [
231
+ { tmp_url: 'https://example.com/diagram.png', name: 'diagram.png' }
232
+ ]
233
+ });
234
+ ```
235
+
236
+ ### Image to Excel
237
+
238
+ ```typescript
239
+ const result = await client.document.image2Excel({
240
+ attachment: [
241
+ { tmp_url: 'https://example.com/spreadsheet.png', name: 'spreadsheet.png' }
242
+ ]
243
+ });
244
+ ```
245
+
246
+ ### Image to PDF
247
+
248
+ ```typescript
249
+ const result = await client.document.image2Pdf({
250
+ attachment: [
251
+ { tmp_url: 'https://example.com/page1.jpg', name: 'page1.jpg' },
252
+ { tmp_url: 'https://example.com/page2.jpg', name: 'page2.jpg' }
253
+ ]
254
+ });
255
+ ```
256
+
257
+ ### Generic Convert
258
+
259
+ ```typescript
260
+ // Image to PDF
261
+ const result = await client.document.convert({
262
+ attachment: [{ tmp_url: 'https://...', name: 'image.jpg' }],
263
+ input_format: 'image',
264
+ output_format: 'pdf'
265
+ });
266
+
267
+ // PDF to Word
268
+ const result = await client.document.convert({
269
+ attachment: [{ tmp_url: 'https://...', name: 'doc.pdf' }],
270
+ input_format: 'pdf',
271
+ output_format: 'word'
272
+ });
273
+ ```
274
+
275
+ ### Batch Conversion
276
+
277
+ ```typescript
278
+ const pdfFiles = [
279
+ { tmp_url: 'https://example.com/doc1.pdf', name: 'doc1.pdf' },
280
+ { tmp_url: 'https://example.com/doc2.pdf', name: 'doc2.pdf' },
281
+ { tmp_url: 'https://example.com/doc3.pdf', name: 'doc3.pdf' }
282
+ ];
283
+
284
+ const results = await Promise.all(
285
+ pdfFiles.map(file => client.document.pdf2Word({ attachment: [file] }))
286
+ );
287
+
288
+ results.forEach((result, i) => {
289
+ if (result.code === 0) {
290
+ console.log(`File ${i + 1} converted: ${result.data?.[0]?.content}`);
291
+ }
292
+ });
293
+ ```
294
+
295
+ ### Convert Then Translate
296
+
297
+ ```typescript
298
+ // Convert image to Word, then translate
299
+ const converted = await client.document.image2Word({
300
+ attachment: [{ tmp_url: 'https://...', name: 'image.jpg' }]
301
+ });
302
+
303
+ if (converted.code === 0 && converted.data) {
304
+ const translated = await client.document.translate({
305
+ attachment: converted.data,
306
+ source_language: 'en',
307
+ target_language: 'zh'
308
+ });
309
+
310
+ console.log('Translated document:', translated.data);
311
+ }
312
+ ```
313
+
314
+ ## Response Format
315
+
316
+ ```typescript
317
+ interface AttachmentResult {
318
+ name: string;
319
+ contentType: 'attachment/url';
320
+ content: string; // URL to converted document
321
+ }
322
+ ```
323
+
324
+ ## Error Handling
325
+
326
+ ```typescript
327
+ const result = await client.document.pdf2Word({
328
+ attachment: [{ tmp_url: 'https://...', name: 'doc.pdf' }]
329
+ });
330
+
331
+ if (result.code !== 0) {
332
+ console.error('Conversion failed:', result.msg);
333
+ } else {
334
+ console.log('Success:', result.data);
335
+ }
336
+ ```
337
+
338
+ ## Task Folders
339
+
340
+ Each execution creates a task folder:
341
+
342
+ ```typescript
343
+ const result = await client.document.pdf2Word({
344
+ attachment: [{ tmp_url: 'https://...', name: 'doc.pdf' }]
345
+ });
346
+
347
+ console.log('Task ID:', result.taskId);
348
+ console.log('Task Folder:', result.taskFolder);
349
+ console.log('Downloaded Files:', result.attachments);
350
+ ```
351
+
352
+ ## Conversion Matrix
353
+
354
+ | From | To | Method |
355
+ |------|-----|--------|
356
+ | PDF | Word | `pdf2Word()` |
357
+ | PDF | PowerPoint | `pdf2Ppt()` |
358
+ | PDF | Excel | `pdf2Excel()` |
359
+ | PDF | Image | `pdf2Image()` |
360
+ | Image | Word | `image2Word()` |
361
+ | Image | PowerPoint | `image2Ppt()` |
362
+ | Image | Excel | `image2Excel()` |
363
+ | Image | PDF | `image2Pdf()` |
364
+
365
+ ## Best Practices
366
+
367
+ 1. **File Size**: Large files may take longer to process
368
+ 2. **Format Fidelity**: Complex formatting may have minor differences
369
+ 3. **Batch Processing**: Use Promise.all for multiple files
370
+ 4. **Error Recovery**: Always check result.code before proceeding
371
+
372
+ ## Related Skills
373
+
374
+ - [unityclaw-document-translation](../unityclaw-document-translation/SKILL.md) - Translate documents
375
+ - [unityclaw-image-compress](../unityclaw-image-compress/SKILL.md) - Compress images before conversion
@@ -0,0 +1,273 @@
1
+ ---
2
+ name: unityclaw-document-translation
3
+ description: Translate documents between multiple languages while preserving formatting
4
+ version: 1.0.0
5
+ metadata:
6
+ openclaw:
7
+ requires:
8
+ env:
9
+ - UNITYCLAW_API_KEY
10
+ bins:
11
+ - node
12
+ - npm
13
+ primaryEnv: UNITYCLAW_API_KEY
14
+ emoji: "🌐"
15
+ homepage: https://unityclaw.com
16
+ install:
17
+ - kind: node
18
+ package: "@unityclaw/sdk"
19
+ bins: []
20
+ ---
21
+
22
+ # UnityClaw Document Translation
23
+
24
+ Translate documents between multiple languages while preserving original formatting and structure.
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ npm install @unityclaw/sdk
30
+ ```
31
+
32
+ ## Configuration
33
+
34
+ Set your API key as environment variable:
35
+
36
+ ```bash
37
+ export UNITYCLAW_API_KEY=your-api-key
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ```typescript
43
+ import { UnityClawClient } from '@unityclaw/sdk';
44
+
45
+ const client = new UnityClawClient();
46
+
47
+ const result = await client.document.translate({
48
+ attachment: [
49
+ { tmp_url: 'https://example.com/document.pdf', name: 'document.pdf' }
50
+ ],
51
+ source_language: { value: 'en', label: 'English' },
52
+ target_language: { value: 'zh', label: 'Chinese' }
53
+ });
54
+
55
+ if (result.code === 0) {
56
+ console.log('Translated document:', result.data);
57
+ }
58
+ ```
59
+
60
+ ## API Reference
61
+
62
+ ### translate()
63
+
64
+ Translate a document from one language to another.
65
+
66
+ ```typescript
67
+ await client.document.translate({
68
+ attachment: AttachmentFieldItem[];
69
+ source_language: LabelFieldItem | string;
70
+ target_language: LabelFieldItem | string;
71
+ }): Promise<APIResponse<AttachmentResult[]>>
72
+ ```
73
+
74
+ ## Parameters
75
+
76
+ | Parameter | Type | Required | Description |
77
+ |-----------|------|----------|-------------|
78
+ | `attachment` | `AttachmentFieldItem[]` | Yes | Document(s) to translate |
79
+ | `source_language` | `LabelFieldItem \| string` | Yes | Source language code |
80
+ | `target_language` | `LabelFieldItem \| string` | Yes | Target language code |
81
+
82
+ ## Supported Languages
83
+
84
+ | Code | Language |
85
+ |------|----------|
86
+ | `en` | English |
87
+ | `zh` | Chinese (Simplified) |
88
+ | `zh-TW` | Chinese (Traditional) |
89
+ | `ja` | Japanese |
90
+ | `ko` | Korean |
91
+ | `es` | Spanish |
92
+ | `fr` | French |
93
+ | `de` | German |
94
+ | `pt` | Portuguese |
95
+ | `ru` | Russian |
96
+ | `ar` | Arabic |
97
+ | `it` | Italian |
98
+ | `nl` | Dutch |
99
+ | `pl` | Polish |
100
+ | `tr` | Turkish |
101
+ | `vi` | Vietnamese |
102
+ | `th` | Thai |
103
+ | `id` | Indonesian |
104
+
105
+ ## Supported Document Formats
106
+
107
+ - PDF (.pdf)
108
+ - Word (.doc, .docx)
109
+ - PowerPoint (.ppt, .pptx)
110
+ - Excel (.xls, .xlsx)
111
+ - Text (.txt)
112
+ - RTF (.rtf)
113
+
114
+ ## Examples
115
+
116
+ ### PDF Translation
117
+
118
+ ```typescript
119
+ const client = new UnityClawClient();
120
+
121
+ const result = await client.document.translate({
122
+ attachment: [
123
+ { tmp_url: 'https://example.com/report.pdf', name: 'report.pdf' }
124
+ ],
125
+ source_language: { value: 'en', label: 'English' },
126
+ target_language: { value: 'zh', label: 'Chinese' }
127
+ });
128
+
129
+ if (result.code === 0 && result.data) {
130
+ console.log('Translated PDF:', result.data[0].content);
131
+ }
132
+ ```
133
+
134
+ ### Word Document Translation
135
+
136
+ ```typescript
137
+ const result = await client.document.translate({
138
+ attachment: [
139
+ { tmp_url: 'https://example.com/contract.docx', name: 'contract.docx' }
140
+ ],
141
+ source_language: 'en',
142
+ target_language: 'ja'
143
+ });
144
+ ```
145
+
146
+ ### Simple String Parameters
147
+
148
+ ```typescript
149
+ // Use simple strings for language codes
150
+ const result = await client.document.translate({
151
+ attachment: [
152
+ { tmp_url: 'https://example.com/doc.pdf', name: 'doc.pdf' }
153
+ ],
154
+ source_language: 'en',
155
+ target_language: 'zh'
156
+ });
157
+ ```
158
+
159
+ ### Batch Translation
160
+
161
+ ```typescript
162
+ const documents = [
163
+ { tmp_url: 'https://example.com/doc1.pdf', name: 'doc1.pdf' },
164
+ { tmp_url: 'https://example.com/doc2.pdf', name: 'doc2.pdf' },
165
+ { tmp_url: 'https://example.com/doc3.pdf', name: 'doc3.pdf' }
166
+ ];
167
+
168
+ const result = await client.document.translate({
169
+ attachment: documents,
170
+ source_language: { value: 'en', label: 'English' },
171
+ target_language: { value: 'zh', label: 'Chinese' }
172
+ });
173
+
174
+ if (result.code === 0 && result.data) {
175
+ result.data.forEach((doc, i) => {
176
+ console.log(`Document ${i + 1}: ${doc.content}`);
177
+ });
178
+ }
179
+ ```
180
+
181
+ ### Multi-Language Translation
182
+
183
+ ```typescript
184
+ const translateTo = async (
185
+ documentUrl: string,
186
+ targetLanguages: string[]
187
+ ) => {
188
+ const client = new UnityClawClient();
189
+ const results = await Promise.all(
190
+ targetLanguages.map(lang =>
191
+ client.document.translate({
192
+ attachment: [{ tmp_url: documentUrl, name: 'document.pdf' }],
193
+ source_language: 'en',
194
+ target_language: lang
195
+ })
196
+ )
197
+ );
198
+
199
+ return results;
200
+ };
201
+
202
+ // Translate English document to multiple languages
203
+ const translations = await translateTo(
204
+ 'https://example.com/english-doc.pdf',
205
+ ['zh', 'ja', 'ko', 'es', 'fr']
206
+ );
207
+ ```
208
+
209
+ ### Chinese to English
210
+
211
+ ```typescript
212
+ const result = await client.document.translate({
213
+ attachment: [
214
+ { tmp_url: 'https://example.com/chinese-doc.pdf', name: 'chinese.pdf' }
215
+ ],
216
+ source_language: { value: 'zh', label: 'Chinese' },
217
+ target_language: { value: 'en', label: 'English' }
218
+ });
219
+ ```
220
+
221
+ ## Response Format
222
+
223
+ ```typescript
224
+ interface AttachmentResult {
225
+ name: string;
226
+ contentType: 'attachment/url';
227
+ content: string; // URL to translated document
228
+ }
229
+ ```
230
+
231
+ ## Error Handling
232
+
233
+ ```typescript
234
+ const result = await client.document.translate({
235
+ attachment: [{ tmp_url: 'https://...', name: 'doc.pdf' }],
236
+ source_language: 'en',
237
+ target_language: 'zh'
238
+ });
239
+
240
+ if (result.code !== 0) {
241
+ console.error('Translation failed:', result.msg);
242
+ } else {
243
+ console.log('Success:', result.data);
244
+ }
245
+ ```
246
+
247
+ ## Task Folders
248
+
249
+ Each execution creates a task folder:
250
+
251
+ ```typescript
252
+ const result = await client.document.translate({
253
+ attachment: [{ tmp_url: 'https://...', name: 'doc.pdf' }],
254
+ source_language: 'en',
255
+ target_language: 'zh'
256
+ });
257
+
258
+ console.log('Task ID:', result.taskId);
259
+ console.log('Task Folder:', result.taskFolder);
260
+ console.log('Downloaded Files:', result.attachments);
261
+ ```
262
+
263
+ ## Best Practices
264
+
265
+ 1. **Format Preservation**: Original formatting is maintained
266
+ 2. **Large Documents**: May take longer for extensive documents
267
+ 3. **Language Detection**: Specify source language for accuracy
268
+ 4. **Quality Review**: Review translations for context-specific terms
269
+
270
+ ## Related Skills
271
+
272
+ - [unityclaw-document-convert](../unityclaw-document-convert/SKILL.md) - Convert document formats
273
+ - [unityclaw-media-analysis](../unityclaw-media-analysis/SKILL.md) - Analyze video/audio content