bingocode 1.0.40 → 1.1.42

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 (63) hide show
  1. package/bin/bingo-win.cjs +2 -1
  2. package/bin/bingocode-win.cjs +2 -1
  3. package/bin/claude-win.cjs +2 -1
  4. package/bun.lock +1716 -0
  5. package/package.json +14 -2
  6. package/src/server/config/providers.yaml +1 -1
  7. package/src/server/proxy/transform/anthropicToOpenaiChat.ts +23 -9
  8. package/adapters/README.md +0 -87
  9. package/adapters/common/__tests__/chat-queue.test.ts +0 -61
  10. package/adapters/common/__tests__/format.test.ts +0 -148
  11. package/adapters/common/__tests__/http-client.test.ts +0 -105
  12. package/adapters/common/__tests__/message-buffer.test.ts +0 -84
  13. package/adapters/common/__tests__/message-dedup.test.ts +0 -57
  14. package/adapters/common/__tests__/session-store.test.ts +0 -62
  15. package/adapters/common/__tests__/ws-bridge.test.ts +0 -177
  16. package/adapters/common/attachment/__tests__/attachment-limits.test.ts +0 -52
  17. package/adapters/common/attachment/__tests__/attachment-store.test.ts +0 -108
  18. package/adapters/common/attachment/__tests__/image-block-watcher.test.ts +0 -115
  19. package/adapters/common/attachment/attachment-limits.ts +0 -58
  20. package/adapters/common/attachment/attachment-store.ts +0 -121
  21. package/adapters/common/attachment/attachment-types.ts +0 -29
  22. package/adapters/common/attachment/image-block-watcher.ts +0 -94
  23. package/adapters/common/chat-queue.ts +0 -24
  24. package/adapters/common/config.ts +0 -96
  25. package/adapters/common/format.ts +0 -229
  26. package/adapters/common/http-client.ts +0 -107
  27. package/adapters/common/message-buffer.ts +0 -91
  28. package/adapters/common/message-dedup.ts +0 -57
  29. package/adapters/common/pairing.ts +0 -149
  30. package/adapters/common/session-store.ts +0 -60
  31. package/adapters/common/ws-bridge.ts +0 -282
  32. package/adapters/feishu/__tests__/card-errors.test.ts +0 -194
  33. package/adapters/feishu/__tests__/cardkit.test.ts +0 -295
  34. package/adapters/feishu/__tests__/extract-payload.test.ts +0 -77
  35. package/adapters/feishu/__tests__/feishu.test.ts +0 -907
  36. package/adapters/feishu/__tests__/flush-controller.test.ts +0 -290
  37. package/adapters/feishu/__tests__/markdown-style.test.ts +0 -353
  38. package/adapters/feishu/__tests__/media.test.ts +0 -120
  39. package/adapters/feishu/__tests__/streaming-card.test.ts +0 -914
  40. package/adapters/feishu/card-errors.ts +0 -151
  41. package/adapters/feishu/cardkit.ts +0 -294
  42. package/adapters/feishu/extract-payload.ts +0 -95
  43. package/adapters/feishu/flush-controller.ts +0 -149
  44. package/adapters/feishu/index.ts +0 -1275
  45. package/adapters/feishu/markdown-style.ts +0 -212
  46. package/adapters/feishu/media.ts +0 -176
  47. package/adapters/feishu/streaming-card.ts +0 -612
  48. package/adapters/package.json +0 -23
  49. package/adapters/telegram/__tests__/media.test.ts +0 -86
  50. package/adapters/telegram/__tests__/telegram.test.ts +0 -115
  51. package/adapters/telegram/index.ts +0 -754
  52. package/adapters/telegram/media.ts +0 -89
  53. package/adapters/tsconfig.json +0 -18
  54. package/runtime/mac_helper.py +0 -775
  55. package/runtime/requirements-win.txt +0 -7
  56. package/runtime/requirements.txt +0 -6
  57. package/runtime/test_helpers.py +0 -322
  58. package/runtime/win_helper.py +0 -723
  59. package/scripts/count-app-loc.ts +0 -256
  60. package/scripts/release.ts +0 -130
  61. package/start-cli.bat +0 -7
  62. package/stubs/ant-claude-for-chrome-mcp.ts +0 -24
  63. package/stubs/color-diff-napi.ts +0 -45
@@ -1,86 +0,0 @@
1
- import { describe, it, expect, beforeEach, afterEach, mock } from 'bun:test'
2
- import * as fs from 'node:fs/promises'
3
- import * as path from 'node:path'
4
- import * as os from 'node:os'
5
- import { TelegramMediaService } from '../media.js'
6
- import { AttachmentStore } from '../../common/attachment/attachment-store.js'
7
-
8
- let tmpRoot: string
9
- let originalFetch: typeof fetch
10
-
11
- function makeMockBot() {
12
- const fetchMock = mock(async (url: string | URL) => {
13
- const u = typeof url === 'string' ? url : url.toString()
14
- expect(u).toContain('/file/botFAKE_TOKEN/photos/abc.jpg')
15
- return new Response(Buffer.from('PHOTODATA'), {
16
- status: 200,
17
- headers: { 'content-type': 'image/jpeg' },
18
- })
19
- })
20
- ;(globalThis as any).fetch = fetchMock
21
- return {
22
- token: 'FAKE_TOKEN',
23
- api: {
24
- getFile: mock(async (fileId: string) => ({
25
- file_id: fileId,
26
- file_unique_id: 'unique',
27
- file_path: 'photos/abc.jpg',
28
- })),
29
- sendPhoto: mock(async () => ({ message_id: 1 })),
30
- sendDocument: mock(async () => ({ message_id: 2 })),
31
- },
32
- fetchMock,
33
- }
34
- }
35
-
36
- beforeEach(async () => {
37
- originalFetch = globalThis.fetch
38
- tmpRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'tg-media-test-'))
39
- })
40
-
41
- afterEach(async () => {
42
- globalThis.fetch = originalFetch
43
- await fs.rm(tmpRoot, { recursive: true, force: true })
44
- })
45
-
46
- describe('TelegramMediaService', () => {
47
- it('downloadFile fetches the real URL and stores a LocalAttachment', async () => {
48
- const bot = makeMockBot()
49
- const store = new AttachmentStore({ root: tmpRoot, retentionMs: 60_000 })
50
- const svc = new TelegramMediaService(bot as any, store)
51
- const local = await svc.downloadFile('fid_123', 'sess-1', {
52
- fileName: 'abc.jpg',
53
- mimeType: 'image/jpeg',
54
- })
55
- expect(local.kind).toBe('image')
56
- expect(local.name).toBe('abc.jpg')
57
- expect(local.size).toBe('PHOTODATA'.length)
58
- expect(local.buffer.toString()).toBe('PHOTODATA')
59
- const onDisk = await fs.readFile(local.path)
60
- expect(onDisk.toString()).toBe('PHOTODATA')
61
- })
62
-
63
- it('sendPhoto calls bot.api.sendPhoto with InputFile-like payload', async () => {
64
- const bot = makeMockBot()
65
- const store = new AttachmentStore({ root: tmpRoot, retentionMs: 60_000 })
66
- const svc = new TelegramMediaService(bot as any, store)
67
- await svc.sendPhoto(42, Buffer.from('IMG'), 'caption text')
68
- expect(bot.api.sendPhoto).toHaveBeenCalledTimes(1)
69
- const args = (bot.api.sendPhoto as any).mock.calls[0]
70
- expect(args[0]).toBe(42)
71
- // grammY InputFile wraps the buffer; just verify it's an object.
72
- expect(args[1]).toBeDefined()
73
- expect(args[2]?.caption).toBe('caption text')
74
- })
75
-
76
- it('sendDocument calls bot.api.sendDocument', async () => {
77
- const bot = makeMockBot()
78
- const store = new AttachmentStore({ root: tmpRoot, retentionMs: 60_000 })
79
- const svc = new TelegramMediaService(bot as any, store)
80
- await svc.sendDocument(42, Buffer.from('DOC'), 'spec.pdf')
81
- expect(bot.api.sendDocument).toHaveBeenCalledTimes(1)
82
- const args = (bot.api.sendDocument as any).mock.calls[0]
83
- expect(args[0]).toBe(42)
84
- expect(args[1]).toBeDefined()
85
- })
86
- })
@@ -1,115 +0,0 @@
1
- import { describe, it, expect } from 'bun:test'
2
- import { splitMessage, formatPermissionRequest, truncateInput, escapeMarkdownV2 } from '../../common/format.js'
3
-
4
- /**
5
- * Telegram Adapter 翻译逻辑测试
6
- *
7
- * 由于 grammy Bot 需要实际 Token 才能初始化,
8
- * 这里测试的是不依赖 Bot 实例的核心翻译逻辑。
9
- */
10
-
11
- describe('Telegram message formatting', () => {
12
- describe('long message splitting', () => {
13
- it('splits messages at Telegram 4096 char limit', () => {
14
- const longText = 'a'.repeat(8000)
15
- const chunks = splitMessage(longText, 4000)
16
- expect(chunks.length).toBe(2)
17
- expect(chunks[0]!.length).toBeLessThanOrEqual(4000)
18
- expect(chunks[1]!.length).toBeLessThanOrEqual(4000)
19
- })
20
-
21
- it('keeps short messages as single chunk', () => {
22
- const chunks = splitMessage('Hello World', 4000)
23
- expect(chunks).toEqual(['Hello World'])
24
- })
25
-
26
- it('splits at paragraph boundary when possible', () => {
27
- const text = 'A'.repeat(2000) + '\n\n' + 'B'.repeat(2000)
28
- const chunks = splitMessage(text, 3000)
29
- expect(chunks.length).toBe(2)
30
- })
31
- })
32
-
33
- describe('permission request formatting', () => {
34
- it('formats Bash command request', () => {
35
- const result = formatPermissionRequest('Bash', { command: 'npm test' }, 'abcde')
36
- expect(result).toContain('🔐')
37
- expect(result).toContain('Bash')
38
- expect(result).toContain('npm test')
39
- expect(result).toContain('abcde')
40
- })
41
-
42
- it('formats Write file request', () => {
43
- const result = formatPermissionRequest(
44
- 'Write',
45
- { file_path: '/src/index.ts', content: 'console.log("hello")' },
46
- 'fghij',
47
- )
48
- expect(result).toContain('Write')
49
- expect(result).toContain('index.ts')
50
- expect(result).toContain('fghij')
51
- })
52
-
53
- it('truncates long input in permission request', () => {
54
- const longInput = { command: 'x'.repeat(500) }
55
- const result = formatPermissionRequest('Bash', longInput, 'xxxxx')
56
- expect(result.length).toBeLessThan(600)
57
- })
58
- })
59
-
60
- describe('callback_data parsing', () => {
61
- it('parses permit:requestId:yes format', () => {
62
- const data = 'permit:abcde:yes'
63
- const parts = data.split(':')
64
- expect(parts[0]).toBe('permit')
65
- expect(parts[1]).toBe('abcde')
66
- expect(parts[2]).toBe('yes')
67
- })
68
-
69
- it('parses permit:requestId:no format', () => {
70
- const data = 'permit:abcde:no'
71
- const parts = data.split(':')
72
- expect(parts[2]).toBe('no')
73
- })
74
-
75
- it('ignores non-permit callbacks', () => {
76
- const data = 'other:action'
77
- expect(data.startsWith('permit:')).toBe(false)
78
- })
79
- })
80
-
81
- describe('MarkdownV2 escaping', () => {
82
- it('escapes underscores', () => {
83
- expect(escapeMarkdownV2('hello_world')).toBe('hello\\_world')
84
- })
85
-
86
- it('escapes multiple special chars', () => {
87
- const result = escapeMarkdownV2('file.ts (line 42)')
88
- expect(result).toBe('file\\.ts \\(line 42\\)')
89
- })
90
-
91
- it('handles code blocks safely', () => {
92
- const result = escapeMarkdownV2('`code`')
93
- expect(result).toBe('\\`code\\`')
94
- })
95
- })
96
-
97
- describe('whitelist logic', () => {
98
- it('empty allowedUsers means allow all', () => {
99
- const allowedUsers: number[] = []
100
- const isAllowed = (userId: number) =>
101
- allowedUsers.length === 0 || allowedUsers.includes(userId)
102
- expect(isAllowed(12345)).toBe(true)
103
- expect(isAllowed(99999)).toBe(true)
104
- })
105
-
106
- it('non-empty allowedUsers filters correctly', () => {
107
- const allowedUsers = [111, 222]
108
- const isAllowed = (userId: number) =>
109
- allowedUsers.length === 0 || allowedUsers.includes(userId)
110
- expect(isAllowed(111)).toBe(true)
111
- expect(isAllowed(222)).toBe(true)
112
- expect(isAllowed(333)).toBe(false)
113
- })
114
- })
115
- })