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

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

7w4.net提供免费和付费技能下载。

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