@framers/agentos-ext-send-file-to-channel 0.1.0 → 0.1.1

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.
package/manifest.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "$schema": "https://agentos.sh/schemas/extension-manifest-v1.json",
3
3
  "id": "com.framers.tools.send-file-to-channel",
4
4
  "name": "Send File to Channel",
5
- "version": "0.1.0",
5
+ "version": "0.1.1",
6
6
  "description": "Send a local file to the user via the current chat channel with platform-aware size limit enforcement.",
7
- "author": { "name": "Manic Agency LLC", "url": "https://manic.agency" },
7
+ "author": { "name": "Frame", "url": "https://frame.dev" },
8
8
  "license": "MIT",
9
9
  "keywords": ["file", "send", "channel", "telegram", "whatsapp", "discord"],
10
10
  "agentosVersion": "^2.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@framers/agentos-ext-send-file-to-channel",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Send a local file to the user via the current chat channel (Telegram, WhatsApp, etc)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -14,7 +14,7 @@
14
14
  "./package.json": "./package.json"
15
15
  },
16
16
  "peerDependencies": {
17
- "@framers/agentos": "^0.5.2"
17
+ "@framers/agentos": ">=0.10.40"
18
18
  },
19
19
  "keywords": [
20
20
  "agentos",
@@ -32,17 +32,29 @@
32
32
  },
33
33
  "repository": {
34
34
  "type": "git",
35
- "url": "git+https://github.com/framersai/agentos-extensions.git",
35
+ "url": "git+https://github.com/framerslab/agentos-extensions.git",
36
36
  "directory": "registry/curated/tools/send-file-to-channel"
37
37
  },
38
- "homepage": "https://github.com/framersai/agentos-extensions/tree/master/registry/curated/tools/send-file-to-channel#readme",
38
+ "homepage": "https://github.com/framerslab/agentos-extensions/tree/master/registry/curated/tools/send-file-to-channel#readme",
39
39
  "bugs": {
40
- "url": "https://github.com/framersai/agentos-extensions/issues"
40
+ "url": "https://github.com/framerslab/agentos-extensions/issues"
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "manifest.json",
45
+ "README.md"
46
+ ],
47
+ "devDependencies": {
48
+ "@framers/agentos": "^0.10.40",
49
+ "@types/node": "^20.12.12",
50
+ "rimraf": "^5.0.7",
51
+ "typescript": "^5.4.5",
52
+ "vitest": "^3.2.7"
41
53
  },
42
54
  "scripts": {
43
55
  "build": "tsc",
44
56
  "dev": "tsc --watch",
45
- "test": "vitest run",
57
+ "test": "vitest run --passWithNoTests",
46
58
  "clean": "rimraf dist"
47
59
  }
48
60
  }
@@ -1,85 +0,0 @@
1
- // @ts-nocheck
2
- /**
3
- * @fileoverview Send File to Channel — relay a local file to the user's chat.
4
- *
5
- * Checks file existence and size against platform-specific limits before sending.
6
- * Requires a ChannelContext to be injected by the ChatTaskResponder.
7
- *
8
- * @module agentos-ext-send-file-to-channel/SendFileToChannelTool
9
- */
10
-
11
- import { stat } from 'node:fs/promises';
12
- import { existsSync } from 'node:fs';
13
- import { basename } from 'node:path';
14
- import type { ChannelContext, SendFileInput, SendFileOutput } from './types.js';
15
- import { PLATFORM_FILE_LIMITS, DEFAULT_FILE_LIMIT } from './types.js';
16
-
17
- /** ITool implementation for sending files via chat channels. */
18
- export class SendFileToChannelTool {
19
- readonly id = 'send_file_to_channel';
20
- readonly name = 'send_file_to_channel';
21
- readonly displayName = 'Send File to Channel';
22
- readonly description = 'Send a file from the local filesystem to the user via the current chat channel (Telegram, WhatsApp, etc).';
23
- readonly parameters = {
24
- type: 'object' as const,
25
- properties: {
26
- filePath: { type: 'string', description: 'Absolute path to the file to send' },
27
- caption: { type: 'string', description: 'Optional message to accompany the file' },
28
- },
29
- required: ['filePath'],
30
- };
31
-
32
- private channelContext?: ChannelContext;
33
-
34
- /** Set the channel context for the current conversation. Called by ChatTaskResponder. */
35
- setChannelContext(ctx: ChannelContext): void {
36
- this.channelContext = ctx;
37
- }
38
-
39
- /** Execute the file send. */
40
- async execute(input: SendFileInput): Promise<SendFileOutput> {
41
- if (!this.channelContext) {
42
- return {
43
- sent: false,
44
- platform: 'unknown',
45
- fileName: '',
46
- size: 0,
47
- error: 'No active chat channel. This tool only works when invoked via a messaging channel.',
48
- };
49
- }
50
-
51
- if (!existsSync(input.filePath)) {
52
- return {
53
- sent: false,
54
- platform: this.channelContext.platform,
55
- fileName: basename(input.filePath),
56
- size: 0,
57
- error: `File not found: ${input.filePath}`,
58
- };
59
- }
60
-
61
- const fileStat = await stat(input.filePath);
62
- const limit = PLATFORM_FILE_LIMITS[this.channelContext.platform] ?? DEFAULT_FILE_LIMIT;
63
- const sizeMB = (fileStat.size / 1024 / 1024).toFixed(1);
64
- const limitMB = (limit / 1024 / 1024).toFixed(0);
65
-
66
- if (fileStat.size > limit) {
67
- return {
68
- sent: false,
69
- platform: this.channelContext.platform,
70
- fileName: basename(input.filePath),
71
- size: fileStat.size,
72
- error: `File is ${sizeMB}MB but ${this.channelContext.platform} limit is ${limitMB}MB. Would you like me to compress it first?`,
73
- };
74
- }
75
-
76
- await this.channelContext.sendFileFn(input.filePath, input.caption);
77
-
78
- return {
79
- sent: true,
80
- platform: this.channelContext.platform,
81
- fileName: basename(input.filePath),
82
- size: fileStat.size,
83
- };
84
- }
85
- }
package/src/index.ts DELETED
@@ -1,20 +0,0 @@
1
- // @ts-nocheck
2
- /**
3
- * @fileoverview Extension pack factory for the send-file-to-channel tool.
4
- * @module agentos-ext-send-file-to-channel
5
- */
6
-
7
- import { SendFileToChannelTool } from './SendFileToChannelTool.js';
8
-
9
- export { SendFileToChannelTool } from './SendFileToChannelTool.js';
10
- export type { ChannelContext, SendFileInput, SendFileOutput } from './types.js';
11
-
12
- /** Create the send-file-to-channel extension pack. */
13
- export function createExtensionPack() {
14
- const tool = new SendFileToChannelTool();
15
- return {
16
- name: '@framers/agentos-ext-send-file-to-channel',
17
- version: '0.1.0',
18
- descriptors: [{ id: 'send_file_to_channel', kind: 'tool' as const, priority: 50, payload: tool }],
19
- };
20
- }
package/src/types.ts DELETED
@@ -1,52 +0,0 @@
1
- // @ts-nocheck
2
- /**
3
- * @fileoverview Types for the send-file-to-channel extension tool.
4
- * @module agentos-ext-send-file-to-channel/types
5
- */
6
-
7
- /** Channel context injected by ChatTaskResponder at tool execution time. */
8
- export interface ChannelContext {
9
- /** Platform identifier (telegram, whatsapp, whatsapp_cloud, whatsapp_twilio, discord, slack). */
10
- platform: string;
11
- /** Chat/conversation ID on the platform. */
12
- chatId: string;
13
- /** Sender user ID on the platform. */
14
- userId: string;
15
- /** Function to send a file to the current chat. */
16
- sendFileFn: (filePath: string, caption?: string) => Promise<void>;
17
- }
18
-
19
- /** Input schema for the send_file_to_channel tool. */
20
- export interface SendFileInput {
21
- /** Absolute path to the file to send. */
22
- filePath: string;
23
- /** Optional caption to accompany the file. */
24
- caption?: string;
25
- }
26
-
27
- /** Output schema for the send_file_to_channel tool. */
28
- export interface SendFileOutput {
29
- /** Whether the file was sent successfully. */
30
- sent: boolean;
31
- /** Platform the file was sent to. */
32
- platform: string;
33
- /** Name of the file sent. */
34
- fileName: string;
35
- /** File size in bytes. */
36
- size: number;
37
- /** Error message if sending failed. */
38
- error?: string;
39
- }
40
-
41
- /** Per-platform file size limits in bytes. */
42
- export const PLATFORM_FILE_LIMITS: Record<string, number> = {
43
- telegram: 50 * 1024 * 1024,
44
- whatsapp_cloud: 100 * 1024 * 1024,
45
- whatsapp_twilio: 16 * 1024 * 1024,
46
- whatsapp: 100 * 1024 * 1024,
47
- discord: 25 * 1024 * 1024,
48
- slack: 1024 * 1024 * 1024,
49
- };
50
-
51
- /** Default limit for unknown platforms: 25MB. */
52
- export const DEFAULT_FILE_LIMIT = 25 * 1024 * 1024;
@@ -1,70 +0,0 @@
1
- // @ts-nocheck
2
- import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest';
3
- import { mkdirSync, writeFileSync, rmSync } from 'node:fs';
4
- import { join } from 'node:path';
5
- import { tmpdir } from 'node:os';
6
- import { SendFileToChannelTool } from '../src/SendFileToChannelTool.js';
7
- import type { ChannelContext } from '../src/types.js';
8
-
9
- const TEST_DIR = join(tmpdir(), 'send-file-test-' + Date.now());
10
-
11
- beforeAll(() => {
12
- mkdirSync(TEST_DIR, { recursive: true });
13
- writeFileSync(join(TEST_DIR, 'small.txt'), 'hello');
14
- writeFileSync(join(TEST_DIR, 'large.bin'), Buffer.alloc(60 * 1024 * 1024, 0xaa)); // 60MB
15
- });
16
-
17
- afterAll(() => {
18
- rmSync(TEST_DIR, { recursive: true, force: true });
19
- });
20
-
21
- function makeTool(platform: string = 'telegram'): SendFileToChannelTool {
22
- const tool = new SendFileToChannelTool();
23
- const sendFileFn = vi.fn().mockResolvedValue(undefined);
24
- tool.setChannelContext({
25
- platform,
26
- chatId: 'chat-1',
27
- userId: 'user-1',
28
- sendFileFn,
29
- });
30
- return tool;
31
- }
32
-
33
- describe('SendFileToChannelTool', () => {
34
- it('sends a file successfully', async () => {
35
- const tool = makeTool('telegram');
36
- const result = await tool.execute({ filePath: join(TEST_DIR, 'small.txt'), caption: 'Here you go' });
37
- expect(result.sent).toBe(true);
38
- expect(result.platform).toBe('telegram');
39
- expect(result.fileName).toBe('small.txt');
40
- expect(result.size).toBeGreaterThan(0);
41
- });
42
-
43
- it('returns error when file not found', async () => {
44
- const tool = makeTool();
45
- const result = await tool.execute({ filePath: '/nonexistent.txt' });
46
- expect(result.sent).toBe(false);
47
- expect(result.error).toContain('File not found');
48
- });
49
-
50
- it('returns error when no channel context', async () => {
51
- const tool = new SendFileToChannelTool(); // no context set
52
- const result = await tool.execute({ filePath: join(TEST_DIR, 'small.txt') });
53
- expect(result.sent).toBe(false);
54
- expect(result.error).toContain('No active chat channel');
55
- });
56
-
57
- it('returns error when file exceeds platform limit', async () => {
58
- const tool = makeTool('telegram'); // 50MB limit
59
- const result = await tool.execute({ filePath: join(TEST_DIR, 'large.bin') });
60
- expect(result.sent).toBe(false);
61
- expect(result.error).toContain('limit is 50MB');
62
- expect(result.error).toContain('compress');
63
- });
64
-
65
- it('allows large files on slack (1GB limit)', async () => {
66
- const tool = makeTool('slack');
67
- const result = await tool.execute({ filePath: join(TEST_DIR, 'large.bin') });
68
- expect(result.sent).toBe(true);
69
- });
70
- });
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "declaration": true,
7
- "declarationMap": true,
8
- "sourceMap": true,
9
- "outDir": "dist",
10
- "rootDir": "src",
11
- "strict": true,
12
- "esModuleInterop": true,
13
- "skipLibCheck": true
14
- },
15
- "include": ["src"],
16
- "exclude": ["dist", "test", "node_modules"]
17
- }