paperclip-plugin-telegram 0.2.1 → 0.2.3

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.
Files changed (62) hide show
  1. package/README.md +28 -3
  2. package/dist/acp-bridge.d.ts +34 -0
  3. package/dist/acp-bridge.js +805 -0
  4. package/dist/acp-bridge.js.map +1 -0
  5. package/dist/adapter.d.ts +35 -0
  6. package/dist/adapter.js +75 -0
  7. package/dist/adapter.js.map +1 -0
  8. package/dist/command-registry.d.ts +3 -0
  9. package/dist/command-registry.js +273 -0
  10. package/dist/command-registry.js.map +1 -0
  11. package/dist/commands.d.ts +10 -0
  12. package/dist/commands.js +213 -0
  13. package/dist/commands.js.map +1 -0
  14. package/dist/constants.d.ts +44 -0
  15. package/dist/constants.js +48 -0
  16. package/dist/constants.js.map +1 -0
  17. package/dist/escalation.d.ts +41 -0
  18. package/dist/escalation.js +254 -0
  19. package/dist/escalation.js.map +1 -0
  20. package/dist/formatters.d.ts +13 -0
  21. package/dist/formatters.js +130 -0
  22. package/dist/formatters.js.map +1 -0
  23. package/dist/index.js +4 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/manifest.d.ts +3 -0
  26. package/dist/manifest.js +232 -0
  27. package/dist/manifest.js.map +1 -0
  28. package/dist/media-pipeline.d.ts +46 -0
  29. package/dist/media-pipeline.js +161 -0
  30. package/dist/media-pipeline.js.map +1 -0
  31. package/dist/telegram-api.d.ts +28 -0
  32. package/dist/telegram-api.js +147 -0
  33. package/dist/telegram-api.js.map +1 -0
  34. package/dist/watch-registry.d.ts +9 -0
  35. package/dist/watch-registry.js +272 -0
  36. package/dist/watch-registry.js.map +1 -0
  37. package/dist/worker.d.ts +1 -0
  38. package/dist/worker.js +548 -0
  39. package/dist/worker.js.map +1 -0
  40. package/package.json +9 -5
  41. package/src/acp-bridge.ts +0 -1273
  42. package/src/adapter.ts +0 -129
  43. package/src/command-registry.ts +0 -482
  44. package/src/commands.ts +0 -346
  45. package/src/constants.ts +0 -51
  46. package/src/escalation.ts +0 -421
  47. package/src/formatters.ts +0 -148
  48. package/src/manifest.ts +0 -246
  49. package/src/media-pipeline.ts +0 -234
  50. package/src/telegram-api.ts +0 -202
  51. package/src/watch-registry.ts +0 -369
  52. package/src/worker.ts +0 -783
  53. package/tests/acp-bridge.test.ts +0 -314
  54. package/tests/command-registry.test.ts +0 -283
  55. package/tests/commands.test.ts +0 -213
  56. package/tests/escalation.test.ts +0 -550
  57. package/tests/formatters.test.ts +0 -185
  58. package/tests/media-pipeline.test.ts +0 -324
  59. package/tests/telegram-api.test.ts +0 -108
  60. package/tests/watch-registry.test.ts +0 -404
  61. package/tsconfig.json +0 -16
  62. /package/{src/index.ts → dist/index.d.ts} +0 -0
package/README.md CHANGED
@@ -104,13 +104,24 @@ curl -X POST http://127.0.0.1:3100/api/plugins/install \
104
104
  -d '{"packageName":"paperclip-plugin-telegram"}'
105
105
  ```
106
106
 
107
- ### 4. Configure
107
+ ### 4. Store your bot token as a Paperclip secret
108
+
109
+ The bot token field requires a Paperclip secret reference (a UUID), not the raw token.
110
+
111
+ 1. In Paperclip, go to **Settings → Secrets → Create new secret**
112
+ 2. Paste your Telegram bot token as the secret value and save
113
+ 3. Copy the UUID of the created secret
114
+ 4. Use that UUID in the `telegramBotTokenRef` field below
115
+
116
+ Do the same for `transcriptionApiKeyRef` if you want Whisper transcription.
117
+
118
+ ### 5. Configure
108
119
 
109
120
  In your Paperclip instance settings, configure:
110
121
 
111
122
  | Setting | Required | Description |
112
123
  |---------|----------|-------------|
113
- | `telegramBotTokenRef` | Yes | Secret reference to your bot token |
124
+ | `telegramBotTokenRef` | Yes | Secret UUID for your bot token (see step 4) |
114
125
  | `defaultChatId` | Yes | Chat ID for notifications |
115
126
  | `approvalsChatId` | No | Separate chat for approvals |
116
127
  | `errorsChatId` | No | Separate chat for errors |
@@ -128,7 +139,7 @@ In your Paperclip instance settings, configure:
128
139
  | `maxSuggestionsPerHourPerCompany` | No | Rate limit for proactive suggestions (default: 10) |
129
140
  | `watchDeduplicationWindowMs` | No | Window before same watch+entity can re-fire (default: 86400000 / 24h) |
130
141
 
131
- ### 5. Add bot to group (optional)
142
+ ### 6. Add bot to group (optional)
132
143
 
133
144
  If using a group chat:
134
145
  1. Add the bot to your Telegram group
@@ -175,6 +186,20 @@ When a user replies to a bot notification, the plugin looks up which Paperclip e
175
186
  | Proactive suggestions | No | Watch conditions with built-in sales templates |
176
187
  | Architecture | Monorepo example | Standalone npm package |
177
188
 
189
+ ## Migration
190
+
191
+ ### v0.2.1
192
+
193
+ The `telegramBotTokenRef` and `transcriptionApiKeyRef` fields now require a Paperclip secret reference (a UUID), not the raw token value. If you previously entered your raw bot token in the field, follow these steps to migrate:
194
+
195
+ 1. Go to **Settings → Secrets → Create new secret**
196
+ 2. Paste your Telegram bot token as the secret value and save
197
+ 3. Copy the resulting UUID
198
+ 4. Open **Plugin Settings for Telegram Bot** and paste the UUID into "Telegram Bot Token"
199
+ 5. Save and restart the plugin
200
+
201
+ The plugin will fail to activate if a raw token (non-UUID) is entered in the field.
202
+
178
203
  ## Development
179
204
 
180
205
  ```bash
@@ -0,0 +1,34 @@
1
+ import type { PluginContext } from "@paperclipai/plugin-sdk";
2
+ export type ChatSession = {
3
+ sessionId: string;
4
+ agentId: string;
5
+ agentName: string;
6
+ agentDisplayName: string;
7
+ transport: "native" | "acp";
8
+ spawnedAt: string;
9
+ status: "active" | "closed";
10
+ lastActivityAt: string;
11
+ };
12
+ type AcpOutputEvent = {
13
+ sessionId: string;
14
+ chatId: string;
15
+ threadId: number;
16
+ text: string;
17
+ done?: boolean;
18
+ };
19
+ export declare function setupAcpOutputListener(ctx: PluginContext, token: string): void;
20
+ export declare function handleAcpCommand(ctx: PluginContext, token: string, chatId: string, args: string, messageThreadId?: number, companyId?: string): Promise<void>;
21
+ export declare function routeMessageToAgent(ctx: PluginContext, token: string, chatId: string, threadId: number, text: string, replyToMessageId?: number, companyId?: string): Promise<boolean>;
22
+ export declare function handleAcpOutput(ctx: PluginContext, token: string, event: AcpOutputEvent): Promise<void>;
23
+ export declare function handleHandoffToolCall(ctx: PluginContext, token: string, params: Record<string, unknown>, companyId: string, sourceAgentId: string): Promise<{
24
+ content?: string;
25
+ error?: string;
26
+ }>;
27
+ export declare function handleHandoffApproval(ctx: PluginContext, token: string, handoffId: string, actor: string, callbackQueryId: string, chatId: string | null, messageId: number | undefined): Promise<void>;
28
+ export declare function handleHandoffRejection(ctx: PluginContext, token: string, handoffId: string, actor: string, callbackQueryId: string, chatId: string | null, messageId: number | undefined): Promise<void>;
29
+ export declare function handleDiscussToolCall(ctx: PluginContext, token: string, params: Record<string, unknown>, companyId: string, sourceAgentId: string): Promise<{
30
+ content?: string;
31
+ error?: string;
32
+ }>;
33
+ export declare function getSessions(ctx: PluginContext, chatId: string, threadId: number): Promise<ChatSession[]>;
34
+ export {};