File Transfer

👤 ghostwritten 📦 v0.2.0 ⭐ 4.1 ⬇️ 1K 下載
🤖 AI-Agent 免費

📖 技能介紹

File Transfer Skill

Overview

Context-aware file transfer skill for OpenClaw ecosystem. Intelligently transfers files based on conversation context with progress tracking.

Features

  • Context-Aware: Automatically detects group/private chat and infers transfer intent
  • File Validation: MIME type checking, size limits, chunked reading
  • Telegram Support: Full adapter with progress tracking (simulated)
  • Extensible: Adapter pattern for adding new channels

Installation

npm install file-transfer

Usage

Basic File Transfer

import { FileTransferSkill } from 'file-transfer';

const skill = new FileTransferSkill({
  channels: { telegram: { enabled: true } }
});

const result = await skill.sendFileWithContext({
  file: '/path/to/document.pdf',
  caption: 'Team weekly report',
  context: { chatId: '-1003655501651' }
});

Direct Adapter Usage

import { TelegramAdapter } from 'file-transfer/src/adapters/telegram-adapter.js';

const adapter = new TelegramAdapter();
const result = await adapter.sendFile({
  filePath: '/path/to/file.pdf',
  chatId: '-1003655501651',
  caption: 'Document sharing'
});

Tool Definitions

7w4.net小蔥技能站收錄全網優質技能,值得收藏。

sendFileWithContext

Transfers a file with intelligent context detection.

Parameters: - file (string, required): Path to the file - caption (string, optional): File description - context (object, optional): Conversation context with chatId

Returns: - success (boolean): Transfer success status - messageId (string): Message ID - context (object): Context analysis result (scenario, urgency, confidence) - stats (object): Transfer statistics (size, duration, channel)

getTransferHistory

Retrieves file transfer history.

Parameters: - options (object, optional): Query options

Returns: - history (array): Transfer history records - stats (object): Transfer statistics

Configuration

const skill = new FileTransferSkill({
  contextEngine: {
    enableAI: false,
    maxHistoryLength: 10
  },
  file: {
    maxFileSize: 100 * 1024 * 1024,  // 100MB
    allowedMimeTypes: ['application/pdf', 'image/jpeg', ...]
  },
  channels: {
    telegram: {
      enabled: true,
      maxFileSize: 50 * 1024 * 1024  // 50MB
    }
  }
});

Context Analysis

The ContextEngine analyzes file transfers and returns:

Field Values Description
scenario share, backup, collaborate, archive Transfer intent
urgency low, medium, high, critical Priority level
confidence 0.0 - 1.0 Analysis confidence
fileCategory document, image, video, archive, code File classification

Current Limitations

  • Telegram adapter uses simulated transfer (no real API integration yet)
  • WhatsApp and Discord adapters are planned but not implemented
  • Transfer history is not persisted

Testing

npm test                  # All tests
npm run test:unit         # Unit tests
npm run test:integration  # Integration tests

License

MIT License - see LICENSE for details.

🤖 AI 評測

這個檔案傳輸工具整體質量良好,介面友好,適合需要傳輸檔案的使用者。優點是操作簡單、文件詳細、支援多種檔案型別。不足之處在於目前僅支援 Telegram 平臺(且為模擬傳輸),不支援 WhatsApp 等其他常用聊天軟體,且傳輸記錄不會儲存。如果需要真實可用的檔案傳輸功能,建議等待後續版本更新真實 API 支援後再使用。

📊 多維度評分

適應性4.2
規範性4.1
有效性4.1
可靠性4.1
可信度4.4

📁 包含檔案 (19 個)

📄 README.md 3.8 KB
📄 SKILL.md 3.1 KB
📄 _meta.json 132 B
📄 docs/API.md 5.9 KB
📄 docs/CONTRIBUTING.md 7.8 KB
📄 docs/DEVELOPMENT.md 4.2 KB
📄 examples/telegram-example.js 5.7 KB
📄 jest.config.js 732 B
📄 lint-staged.config.js 199 B
📄 package.json 2 KB
📄 src/adapters/telegram-adapter.js 6.9 KB
📄 src/core/context-engine.js 9.1 KB
📄 src/core/file-manager.js 6.2 KB
📄 src/index.js 4.3 KB
📄 src/utils/format.js 519 B
📄 tests/integration/telegram-adapter.test.js 5.3 KB
📄 tests/setup.js 739 B
📄 tests/unit/context-engine.test.js 10.3 KB
📄 tests/unit/file-manager.test.js 6.6 KB