@maincode-ai/channel-base 0.18.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.
@@ -0,0 +1,101 @@
1
+ import type { AcpBridge } from './AcpBridge.js';
2
+ import type { ChannelBase, ChannelBaseOptions } from './ChannelBase.js';
3
+ export type SenderPolicy = 'allowlist' | 'pairing' | 'open';
4
+ export type SessionScope = 'user' | 'thread' | 'single';
5
+ export type ChannelType = string;
6
+ export type GroupPolicy = 'disabled' | 'allowlist' | 'open';
7
+ export type DispatchMode = 'collect' | 'steer' | 'followup';
8
+ export interface GroupConfig {
9
+ requireMention?: boolean;
10
+ dispatchMode?: DispatchMode;
11
+ }
12
+ export interface BlockStreamingChunkConfig {
13
+ /** Minimum characters before emitting a block. Default: 400. */
14
+ minChars?: number;
15
+ /** Force-emit when buffer exceeds this size. Default: 1000. */
16
+ maxChars?: number;
17
+ }
18
+ export interface BlockStreamingCoalesceConfig {
19
+ /** Emit buffered text after this many ms of inactivity. Default: 1500. */
20
+ idleMs?: number;
21
+ }
22
+ export interface ChannelConfig {
23
+ type: ChannelType;
24
+ token: string;
25
+ clientId?: string;
26
+ clientSecret?: string;
27
+ senderPolicy: SenderPolicy;
28
+ allowedUsers: string[];
29
+ sessionScope: SessionScope;
30
+ cwd: string;
31
+ approvalMode?: string;
32
+ instructions?: string;
33
+ model?: string;
34
+ groupPolicy: GroupPolicy;
35
+ groups: Record<string, GroupConfig>;
36
+ /** Dispatch mode for concurrent messages. Default: 'collect'. */
37
+ dispatchMode?: DispatchMode;
38
+ /** Enable block streaming — emit completed blocks as separate messages. */
39
+ blockStreaming?: 'on' | 'off';
40
+ /** Chunk size bounds for block streaming. */
41
+ blockStreamingChunk?: BlockStreamingChunkConfig;
42
+ /** Idle coalescing for block streaming. */
43
+ blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
44
+ }
45
+ export interface Attachment {
46
+ /** Content category. */
47
+ type: 'image' | 'file' | 'audio' | 'video';
48
+ /** Base64-encoded data (for images or small files). */
49
+ data?: string;
50
+ /** Absolute path to a local file (for large files saved to disk). */
51
+ filePath?: string;
52
+ /** MIME type (e.g. "image/jpeg", "application/pdf"). */
53
+ mimeType: string;
54
+ /** Original file name from the platform. */
55
+ fileName?: string;
56
+ }
57
+ export interface Envelope {
58
+ channelName: string;
59
+ senderId: string;
60
+ senderName: string;
61
+ chatId: string;
62
+ text: string;
63
+ threadId?: string;
64
+ /** Platform-specific message ID for response correlation. */
65
+ messageId?: string;
66
+ isGroup: boolean;
67
+ isMentioned: boolean;
68
+ isReplyToBot: boolean;
69
+ /** Text of the message being replied to (quoted/referenced message). */
70
+ referencedText?: string;
71
+ /** Base64-encoded image data (e.g. from WeChat CDN download). */
72
+ imageBase64?: string;
73
+ /** MIME type for the image (e.g. "image/jpeg", "image/png"). */
74
+ imageMimeType?: string;
75
+ /** Structured attachments (images, files, audio, video). */
76
+ attachments?: Attachment[];
77
+ }
78
+ export interface SessionTarget {
79
+ channelName: string;
80
+ senderId: string;
81
+ chatId: string;
82
+ threadId?: string;
83
+ }
84
+ /**
85
+ * A channel plugin registers a channel type and provides a factory
86
+ * to create adapter instances. Both built-in adapters and external
87
+ * plugins conform to this interface.
88
+ */
89
+ export interface ChannelPlugin {
90
+ /** Unique channel type ID (e.g., "telegram", "tmcp-dingtalk"). */
91
+ channelType: string;
92
+ /** Human-readable name for CLI output. */
93
+ displayName: string;
94
+ /**
95
+ * Config fields required by this channel type, beyond the shared
96
+ * ChannelConfig fields. Validated at startup.
97
+ */
98
+ requiredConfigFields?: string[];
99
+ /** Create a channel adapter instance. */
100
+ createChannel(name: string, config: ChannelConfig & Record<string, unknown>, bridge: AcpBridge, options?: ChannelBaseOptions): ChannelBase;
101
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@maincode-ai/channel-base",
3
+ "version": "0.18.3",
4
+ "description": "Base channel infrastructure for Matilda Code",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc --build"
19
+ },
20
+ "dependencies": {
21
+ "@agentclientprotocol/sdk": "^0.14.1"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "^5.0.0"
25
+ }
26
+ }