@framers/agentos-ext-channel-webchat 0.1.0
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/dist/WebChatChannelAdapter.d.ts +27 -0
- package/dist/WebChatChannelAdapter.d.ts.map +1 -0
- package/dist/WebChatChannelAdapter.js +108 -0
- package/dist/WebChatChannelAdapter.js.map +1 -0
- package/dist/WebChatService.d.ts +94 -0
- package/dist/WebChatService.d.ts.map +1 -0
- package/dist/WebChatService.js +98 -0
- package/dist/WebChatService.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/sendMessage.d.ts +52 -0
- package/dist/tools/sendMessage.d.ts.map +1 -0
- package/dist/tools/sendMessage.js +57 -0
- package/dist/tools/sendMessage.js.map +1 -0
- package/manifest.json +30 -0
- package/package.json +28 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview IChannelAdapter implementation for the built-in WebChat widget.
|
|
3
|
+
*
|
|
4
|
+
* This is the simplest channel adapter — no external SDK, no authentication.
|
|
5
|
+
* It bridges between the AgentOS channel system and the WebChatService,
|
|
6
|
+
* which in turn delegates to the WunderlandGateway for Socket.IO transport.
|
|
7
|
+
*/
|
|
8
|
+
import type { IChannelAdapter, ChannelPlatform, ChannelCapability, ChannelAuthConfig, ChannelConnectionInfo, ChannelSendResult, MessageContent, ChannelEventHandler, ChannelEventType } from '@framers/agentos';
|
|
9
|
+
import { WebChatService } from './WebChatService';
|
|
10
|
+
export declare class WebChatChannelAdapter implements IChannelAdapter {
|
|
11
|
+
private readonly service;
|
|
12
|
+
readonly platform: ChannelPlatform;
|
|
13
|
+
readonly displayName = "WebChat";
|
|
14
|
+
readonly capabilities: readonly ChannelCapability[];
|
|
15
|
+
private handlers;
|
|
16
|
+
private inboundHandler;
|
|
17
|
+
constructor(service: WebChatService);
|
|
18
|
+
initialize(_auth: ChannelAuthConfig): Promise<void>;
|
|
19
|
+
shutdown(): Promise<void>;
|
|
20
|
+
getConnectionInfo(): ChannelConnectionInfo;
|
|
21
|
+
sendMessage(conversationId: string, content: MessageContent): Promise<ChannelSendResult>;
|
|
22
|
+
sendTypingIndicator(conversationId: string, isTyping: boolean): Promise<void>;
|
|
23
|
+
on(handler: ChannelEventHandler, eventTypes?: ChannelEventType[]): () => void;
|
|
24
|
+
private handleInboundMessage;
|
|
25
|
+
private emit;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=WebChatChannelAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebChatChannelAdapter.d.ts","sourceRoot":"","sources":["../src/WebChatChannelAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAIjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAalD,qBAAa,qBAAsB,YAAW,eAAe;IAa/C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAZpC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAa;IAC/C,QAAQ,CAAC,WAAW,aAAa;IACjC,QAAQ,CAAC,YAAY,EAAE,SAAS,iBAAiB,EAAE,CAKxC;IAEX,OAAO,CAAC,QAAQ,CAAkE;IAClF,OAAO,CAAC,cAAc,CAAuD;gBAEhD,OAAO,EAAE,cAAc;IAE9C,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMnD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ/B,iBAAiB,IAAI,qBAAqB;IAQpC,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAUxF,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAInF,EAAE,CAAC,OAAO,EAAE,mBAAmB,EAAE,UAAU,CAAC,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAI;IAS7E,OAAO,CAAC,oBAAoB;IA+B5B,OAAO,CAAC,IAAI;CASb"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview IChannelAdapter implementation for the built-in WebChat widget.
|
|
4
|
+
*
|
|
5
|
+
* This is the simplest channel adapter — no external SDK, no authentication.
|
|
6
|
+
* It bridges between the AgentOS channel system and the WebChatService,
|
|
7
|
+
* which in turn delegates to the WunderlandGateway for Socket.IO transport.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.WebChatChannelAdapter = void 0;
|
|
11
|
+
/** Counter-based UUID fallback for environments without crypto.randomUUID. */
|
|
12
|
+
let messageCounter = 0;
|
|
13
|
+
function generateMessageId() {
|
|
14
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
15
|
+
return crypto.randomUUID();
|
|
16
|
+
}
|
|
17
|
+
messageCounter++;
|
|
18
|
+
return `webchat-msg-${Date.now()}-${messageCounter}`;
|
|
19
|
+
}
|
|
20
|
+
class WebChatChannelAdapter {
|
|
21
|
+
constructor(service) {
|
|
22
|
+
this.service = service;
|
|
23
|
+
this.platform = 'webchat';
|
|
24
|
+
this.displayName = 'WebChat';
|
|
25
|
+
this.capabilities = [
|
|
26
|
+
'text',
|
|
27
|
+
'images',
|
|
28
|
+
'typing_indicator',
|
|
29
|
+
'read_receipts',
|
|
30
|
+
];
|
|
31
|
+
this.handlers = new Map();
|
|
32
|
+
this.inboundHandler = null;
|
|
33
|
+
}
|
|
34
|
+
async initialize(_auth) {
|
|
35
|
+
// Wire up the inbound message bridge from WebChatService
|
|
36
|
+
this.inboundHandler = (msg) => this.handleInboundMessage(msg);
|
|
37
|
+
this.service.onInbound(this.inboundHandler);
|
|
38
|
+
}
|
|
39
|
+
async shutdown() {
|
|
40
|
+
if (this.inboundHandler) {
|
|
41
|
+
this.service.offInbound(this.inboundHandler);
|
|
42
|
+
this.inboundHandler = null;
|
|
43
|
+
}
|
|
44
|
+
this.handlers.clear();
|
|
45
|
+
}
|
|
46
|
+
getConnectionInfo() {
|
|
47
|
+
// WebChat is always "connected" when the service is running —
|
|
48
|
+
// there's no external connection to establish or maintain.
|
|
49
|
+
return {
|
|
50
|
+
status: this.service.isRunning ? 'connected' : 'disconnected',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async sendMessage(conversationId, content) {
|
|
54
|
+
const textBlock = content.blocks.find((b) => b.type === 'text');
|
|
55
|
+
const text = textBlock && textBlock.type === 'text' ? textBlock.text : '';
|
|
56
|
+
await this.service.sendMessage(conversationId, text);
|
|
57
|
+
const messageId = generateMessageId();
|
|
58
|
+
return { messageId, timestamp: new Date().toISOString() };
|
|
59
|
+
}
|
|
60
|
+
async sendTypingIndicator(conversationId, isTyping) {
|
|
61
|
+
await this.service.sendMessage(conversationId, '', { typing: isTyping });
|
|
62
|
+
}
|
|
63
|
+
on(handler, eventTypes) {
|
|
64
|
+
this.handlers.set(handler, eventTypes);
|
|
65
|
+
return () => {
|
|
66
|
+
this.handlers.delete(handler);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// ── Private ──
|
|
70
|
+
handleInboundMessage(msg) {
|
|
71
|
+
const sender = {
|
|
72
|
+
id: msg.sender.id,
|
|
73
|
+
displayName: msg.sender.displayName,
|
|
74
|
+
username: msg.sender.username,
|
|
75
|
+
avatarUrl: msg.sender.avatarUrl,
|
|
76
|
+
};
|
|
77
|
+
const channelMessage = {
|
|
78
|
+
messageId: msg.messageId,
|
|
79
|
+
platform: 'webchat',
|
|
80
|
+
conversationId: msg.conversationId,
|
|
81
|
+
conversationType: 'direct',
|
|
82
|
+
sender,
|
|
83
|
+
content: [{ type: 'text', text: msg.text }],
|
|
84
|
+
text: msg.text,
|
|
85
|
+
timestamp: msg.timestamp,
|
|
86
|
+
rawEvent: msg,
|
|
87
|
+
};
|
|
88
|
+
const event = {
|
|
89
|
+
type: 'message',
|
|
90
|
+
platform: 'webchat',
|
|
91
|
+
conversationId: msg.conversationId,
|
|
92
|
+
timestamp: msg.timestamp,
|
|
93
|
+
data: channelMessage,
|
|
94
|
+
};
|
|
95
|
+
this.emit(event);
|
|
96
|
+
}
|
|
97
|
+
emit(event) {
|
|
98
|
+
for (const [handler, filter] of this.handlers) {
|
|
99
|
+
if (!filter || filter.includes(event.type)) {
|
|
100
|
+
Promise.resolve(handler(event)).catch((err) => {
|
|
101
|
+
console.error('[WebChatChannelAdapter] Handler error:', err);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.WebChatChannelAdapter = WebChatChannelAdapter;
|
|
108
|
+
//# sourceMappingURL=WebChatChannelAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebChatChannelAdapter.js","sourceRoot":"","sources":["../src/WebChatChannelAdapter.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAmBH,8EAA8E;AAC9E,IAAI,cAAc,GAAG,CAAC,CAAC;AACvB,SAAS,iBAAiB;IACxB,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QAC7E,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;IACD,cAAc,EAAE,CAAC;IACjB,OAAO,eAAe,IAAI,CAAC,GAAG,EAAE,IAAI,cAAc,EAAE,CAAC;AACvD,CAAC;AAED,MAAa,qBAAqB;IAahC,YAA6B,OAAuB;QAAvB,Y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EAAE,GAAG,CAAC,SAAS;YACxB,QAAQ,EAAE,GAAG;SACd,CAAC;QAEF,MAAM,KAAK,GAAiC;YAC1C,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,SAAS;YACnB,cAAc,EAAE,GAAG,CAAC,cAAc;YAClC,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,IAAI,EAAE,cAAc;SACrB,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAEO,IAAI,CAAC,KAAmB;QAC9B,KAAK,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3C,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;oBAC5C,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,GAAG,CAAC,CAAC;gBAC/D,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF;AApGD,sDAoGC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Lightweight WebChat message broker.
|
|
3
|
+
*
|
|
4
|
+
* Unlike Telegram or Discord, WebChat does NOT use an external SDK.
|
|
5
|
+
* It acts as a thin event broker between the AgentOS channel system and
|
|
6
|
+
* the WunderlandGateway (Socket.IO), which handles the actual transport.
|
|
7
|
+
*
|
|
8
|
+
* The backend wires the `onSend` callback to `gateway.broadcastChannelMessage`
|
|
9
|
+
* and calls `injectMessage()` when `channel:send:internal` events arrive.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Inbound message shape injected by the gateway bridge.
|
|
13
|
+
*/
|
|
14
|
+
export interface WebChatInboundMessage {
|
|
15
|
+
/** Unique message ID from the client. */
|
|
16
|
+
messageId: string;
|
|
17
|
+
/** Conversation/room ID. */
|
|
18
|
+
conversationId: string;
|
|
19
|
+
/** Sender info. */
|
|
20
|
+
sender: {
|
|
21
|
+
id: string;
|
|
22
|
+
displayName?: string;
|
|
23
|
+
username?: string;
|
|
24
|
+
avatarUrl?: string;
|
|
25
|
+
};
|
|
26
|
+
/** Plain text content. */
|
|
27
|
+
text: string;
|
|
28
|
+
/** ISO timestamp. */
|
|
29
|
+
timestamp: string;
|
|
30
|
+
/** Optional metadata (e.g., client version, device info). */
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Outbound message metadata passed alongside text.
|
|
35
|
+
*/
|
|
36
|
+
export interface WebChatSendMetadata {
|
|
37
|
+
/** Typing indicator state. */
|
|
38
|
+
typing?: boolean;
|
|
39
|
+
/** Read receipt for a specific messageId. */
|
|
40
|
+
readReceipt?: string;
|
|
41
|
+
/** Any additional platform-specific data. */
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
/** Handler for inbound messages from the gateway. */
|
|
45
|
+
export type InboundHandler = (message: WebChatInboundMessage) => void | Promise<void>;
|
|
46
|
+
/** Callback wired by the backend to bridge outbound messages to the gateway. */
|
|
47
|
+
export type OnSendCallback = (conversationId: string, text: string, metadata?: WebChatSendMetadata) => void | Promise<void>;
|
|
48
|
+
export declare class WebChatService {
|
|
49
|
+
private running;
|
|
50
|
+
private inboundHandlers;
|
|
51
|
+
private sendCallback;
|
|
52
|
+
/**
|
|
53
|
+
* Register the outbound send callback. The backend sets this to bridge
|
|
54
|
+
* messages to WunderlandGateway's `broadcastChannelMessage`.
|
|
55
|
+
*/
|
|
56
|
+
set onSend(callback: OnSendCallback | null);
|
|
57
|
+
get onSend(): OnSendCallback | null;
|
|
58
|
+
/** Whether the service is currently active. */
|
|
59
|
+
get isRunning(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Mark the service as running. No external connections to establish.
|
|
62
|
+
*/
|
|
63
|
+
initialize(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Shut down the service, clearing all handlers.
|
|
66
|
+
*/
|
|
67
|
+
shutdown(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Send an outbound message via the registered callback.
|
|
70
|
+
* If no callback is registered, the message is silently dropped.
|
|
71
|
+
*
|
|
72
|
+
* @param conversationId - Target conversation/room ID.
|
|
73
|
+
* @param text - Message text to send.
|
|
74
|
+
* @param metadata - Optional metadata (typing indicators, read receipts, etc.).
|
|
75
|
+
*/
|
|
76
|
+
sendMessage(conversationId: string, text: string, metadata?: WebChatSendMetadata): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Register a handler for inbound messages from the gateway.
|
|
79
|
+
*/
|
|
80
|
+
onInbound(handler: InboundHandler): void;
|
|
81
|
+
/**
|
|
82
|
+
* Remove a previously registered inbound handler.
|
|
83
|
+
*/
|
|
84
|
+
offInbound(handler: InboundHandler): void;
|
|
85
|
+
/**
|
|
86
|
+
* Inject an inbound message from the gateway bridge.
|
|
87
|
+
* Called by the backend when `channel:send:internal` events arrive
|
|
88
|
+
* from the WunderlandGateway (Socket.IO).
|
|
89
|
+
*
|
|
90
|
+
* Dispatches the message to all registered inbound handlers.
|
|
91
|
+
*/
|
|
92
|
+
injectMessage(message: WebChatInboundMessage): void;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=WebChatService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebChatService.d.ts","sourceRoot":"","sources":["../src/WebChatService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB;IACnB,MAAM,EAAE;QACN,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,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c,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,mBAAmB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAUhB;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAIxC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAKzC;;;;;;OAMG;IACH,aAAa,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;CAOpD"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Lightweight WebChat message broker.
|
|
4
|
+
*
|
|
5
|
+
* Unlike Telegram or Discord, WebChat does NOT use an external SDK.
|
|
6
|
+
* It acts as a thin event broker between the AgentOS channel system and
|
|
7
|
+
* the WunderlandGateway (Socket.IO), which handles the actual transport.
|
|
8
|
+
*
|
|
9
|
+
* The backend wires the `onSend` callback to `gateway.broadcastChannelMessage`
|
|
10
|
+
* and calls `injectMessage()` when `channel:send:internal` events arrive.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.WebChatService = void 0;
|
|
14
|
+
class WebChatService {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.running = false;
|
|
17
|
+
this.inboundHandlers = [];
|
|
18
|
+
this.sendCallback = null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Register the outbound send callback. The backend sets this to bridge
|
|
22
|
+
* messages to WunderlandGateway's `broadcastChannelMessage`.
|
|
23
|
+
*/
|
|
24
|
+
set onSend(callback) {
|
|
25
|
+
this.sendCallback = callback;
|
|
26
|
+
}
|
|
27
|
+
get onSend() {
|
|
28
|
+
return this.sendCallback;
|
|
29
|
+
}
|
|
30
|
+
/** Whether the service is currently active. */
|
|
31
|
+
get isRunning() {
|
|
32
|
+
return this.running;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Mark the service as running. No external connections to establish.
|
|
36
|
+
*/
|
|
37
|
+
async initialize() {
|
|
38
|
+
if (this.running)
|
|
39
|
+
return;
|
|
40
|
+
this.running = true;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Shut down the service, clearing all handlers.
|
|
44
|
+
*/
|
|
45
|
+
async shutdown() {
|
|
46
|
+
if (!this.running)
|
|
47
|
+
return;
|
|
48
|
+
this.running = false;
|
|
49
|
+
this.inboundHandlers = [];
|
|
50
|
+
this.sendCallback = null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Send an outbound message via the registered callback.
|
|
54
|
+
* If no callback is registered, the message is silently dropped.
|
|
55
|
+
*
|
|
56
|
+
* @param conversationId - Target conversation/room ID.
|
|
57
|
+
* @param text - Message text to send.
|
|
58
|
+
* @param metadata - Optional metadata (typing indicators, read receipts, etc.).
|
|
59
|
+
*/
|
|
60
|
+
async sendMessage(conversationId, text, metadata) {
|
|
61
|
+
if (!this.running) {
|
|
62
|
+
throw new Error('WebChatService is not running');
|
|
63
|
+
}
|
|
64
|
+
if (this.sendCallback) {
|
|
65
|
+
await this.sendCallback(conversationId, text, metadata);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Register a handler for inbound messages from the gateway.
|
|
70
|
+
*/
|
|
71
|
+
onInbound(handler) {
|
|
72
|
+
this.inboundHandlers.push(handler);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Remove a previously registered inbound handler.
|
|
76
|
+
*/
|
|
77
|
+
offInbound(handler) {
|
|
78
|
+
const idx = this.inboundHandlers.indexOf(handler);
|
|
79
|
+
if (idx >= 0)
|
|
80
|
+
this.inboundHandlers.splice(idx, 1);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Inject an inbound message from the gateway bridge.
|
|
84
|
+
* Called by the backend when `channel:send:internal` events arrive
|
|
85
|
+
* from the WunderlandGateway (Socket.IO).
|
|
86
|
+
*
|
|
87
|
+
* Dispatches the message to all registered inbound handlers.
|
|
88
|
+
*/
|
|
89
|
+
injectMessage(message) {
|
|
90
|
+
for (const handler of this.inboundHandlers) {
|
|
91
|
+
Promise.resolve(handler(message)).catch((err) => {
|
|
92
|
+
console.error('[WebChatService] Inbound handler error:', err);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.WebChatService = WebChatService;
|
|
98
|
+
//# sourceMappingURL=WebChatService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebChatService.js","sourceRoot":"","sources":["../src/WebChatService.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AA+CH,MAAa,cAAc;IAA3B;QACU,YAAO,GAAG,KAAK,CAAC;QAChB,oBAAe,GAAqB,EAAE,CAAC;QACvC,iBAAY,GAA0B,IAAI,CAAC;IAwFrD,CAAC;IAtFC;;;OAGG;IACH,IAAI,MAAM,CAAC,QAA+B;QACxC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,+CAA+C;IAC/C,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO;QAC1B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW,CACf,cAAsB,EACtB,IAAY,EACZ,QAA8B;QAE9B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,OAAuB;QAC/B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAuB;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,GAAG,IAAI,CAAC;YAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,OAA8B;QAC1C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAC3C,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC9C,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,GAAG,CAAC,CAAC;YAChE,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AA3FD,wCA2FC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview WebChat Channel Extension for AgentOS.
|
|
3
|
+
*
|
|
4
|
+
* Provides a lightweight messaging channel adapter for the built-in web chat
|
|
5
|
+
* widget. Unlike other channel extensions, WebChat does NOT use an external
|
|
6
|
+
* SDK — it delegates transport to the existing WunderlandGateway (Socket.IO).
|
|
7
|
+
*
|
|
8
|
+
* The backend wires:
|
|
9
|
+
* - `service.onSend` → `gateway.broadcastChannelMessage` (outbound)
|
|
10
|
+
* - `gateway.on('channel:send:internal')` → `service.injectMessage()` (inbound)
|
|
11
|
+
*
|
|
12
|
+
* @module @framers/agentos-ext-channel-webchat
|
|
13
|
+
*/
|
|
14
|
+
import type { ExtensionContext, ExtensionPack } from '@framers/agentos';
|
|
15
|
+
import { WebChatService } from './WebChatService';
|
|
16
|
+
import { WebChatChannelAdapter } from './WebChatChannelAdapter';
|
|
17
|
+
import { WebChatSendMessageTool } from './tools/sendMessage';
|
|
18
|
+
export interface WebChatChannelOptions {
|
|
19
|
+
/** Optional priority for extension descriptors. Defaults to 50. */
|
|
20
|
+
priority?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Optional onSend callback. Normally the backend sets this after
|
|
23
|
+
* extension activation to bridge to the WunderlandGateway.
|
|
24
|
+
*/
|
|
25
|
+
onSend?: (conversationId: string, text: string, metadata?: Record<string, unknown>) => void | Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createExtensionPack(context: ExtensionContext): ExtensionPack;
|
|
28
|
+
export { WebChatService, WebChatChannelAdapter, WebChatSendMessageTool };
|
|
29
|
+
export type { WebChatInboundMessage, WebChatSendMetadata, InboundHandler, OnSendCallback, } from './WebChatService';
|
|
30
|
+
export default createExtensionPack;
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,WAAW,qBAAqB;IACpC,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7G;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAmC5E;AAED,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,CAAC;AACzE,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,eAAe,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview WebChat Channel Extension for AgentOS.
|
|
4
|
+
*
|
|
5
|
+
* Provides a lightweight messaging channel adapter for the built-in web chat
|
|
6
|
+
* widget. Unlike other channel extensions, WebChat does NOT use an external
|
|
7
|
+
* SDK — it delegates transport to the existing WunderlandGateway (Socket.IO).
|
|
8
|
+
*
|
|
9
|
+
* The backend wires:
|
|
10
|
+
* - `service.onSend` → `gateway.broadcastChannelMessage` (outbound)
|
|
11
|
+
* - `gateway.on('channel:send:internal')` → `service.injectMessage()` (inbound)
|
|
12
|
+
*
|
|
13
|
+
* @module @framers/agentos-ext-channel-webchat
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.WebChatSendMessageTool = exports.WebChatChannelAdapter = exports.WebChatService = void 0;
|
|
17
|
+
exports.createExtensionPack = createExtensionPack;
|
|
18
|
+
const WebChatService_1 = require("./WebChatService");
|
|
19
|
+
Object.defineProperty(exports, "WebChatService", { enumerable: true, get: function () { return WebChatService_1.WebChatService; } });
|
|
20
|
+
const WebChatChannelAdapter_1 = require("./WebChatChannelAdapter");
|
|
21
|
+
Object.defineProperty(exports, "WebChatChannelAdapter", { enumerable: true, get: function () { return WebChatChannelAdapter_1.WebChatChannelAdapter; } });
|
|
22
|
+
const sendMessage_1 = require("./tools/sendMessage");
|
|
23
|
+
Object.defineProperty(exports, "WebChatSendMessageTool", { enumerable: true, get: function () { return sendMessage_1.WebChatSendMessageTool; } });
|
|
24
|
+
function createExtensionPack(context) {
|
|
25
|
+
const options = (context.options ?? {});
|
|
26
|
+
// No secret resolution needed — WebChat uses gateway auth, not its own credentials.
|
|
27
|
+
const service = new WebChatService_1.WebChatService();
|
|
28
|
+
const adapter = new WebChatChannelAdapter_1.WebChatChannelAdapter(service);
|
|
29
|
+
const sendMessageTool = new sendMessage_1.WebChatSendMessageTool(service);
|
|
30
|
+
// If an onSend callback was provided via options, wire it immediately.
|
|
31
|
+
if (options.onSend) {
|
|
32
|
+
service.onSend = options.onSend;
|
|
33
|
+
}
|
|
34
|
+
const priority = options.priority ?? 50;
|
|
35
|
+
return {
|
|
36
|
+
name: '@framers/agentos-ext-channel-webchat',
|
|
37
|
+
version: '0.1.0',
|
|
38
|
+
descriptors: [
|
|
39
|
+
{ id: 'webchatChannelSendMessage', kind: 'tool', priority, payload: sendMessageTool },
|
|
40
|
+
{ id: 'webchatChannel', kind: 'messaging-channel', priority, payload: adapter },
|
|
41
|
+
],
|
|
42
|
+
onActivate: async () => {
|
|
43
|
+
await service.initialize();
|
|
44
|
+
// Wire adapter event listeners after service is running.
|
|
45
|
+
// No credential needed — pass empty string since webchat uses gateway auth.
|
|
46
|
+
await adapter.initialize({ platform: 'webchat', credential: '' });
|
|
47
|
+
context.logger?.info('[WebChatChannel] Extension activated');
|
|
48
|
+
},
|
|
49
|
+
onDeactivate: async () => {
|
|
50
|
+
await adapter.shutdown();
|
|
51
|
+
await service.shutdown();
|
|
52
|
+
context.logger?.info('[WebChatChannel] Extension deactivated');
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
exports.default = createExtensionPack;
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAiBH,kDAmCC;AAjDD,qDAAkD;AAmDzC,+FAnDA,+BAAc,OAmDA;AAlDvB,mEAAgE;AAkDvC,sGAlDhB,6CAAqB,OAkDgB;AAjD9C,qDAA6D;AAiDb,uGAjDvC,oCAAsB,OAiDuC;AArCtE,SAAgB,mBAAmB,CAAC,OAAyB;IAC3D,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAA0B,CAAC;IAEjE,oFAAoF;IACpF,MAAM,OAAO,GAAG,IAAI,+BAAc,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,6CAAqB,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,eAAe,GAAG,IAAI,oCAAsB,CAAC,OAAO,CAAC,CAAC;IAE5D,uEAAuE;IACvE,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IAExC,OAAO;QACL,IAAI,EAAE,sCAAsC;QAC5C,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE;YACX,EAAE,EAAE,EAAE,2BAA2B,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE;YACrF,EAAE,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE;SAChF;QACD,UAAU,EAAE,KAAK,IAAI,EAAE;YACrB,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;YAC3B,yDAAyD;YACzD,4EAA4E;YAC5E,MAAM,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;YAClE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,sCAAsC,CAAC,CAAC;QAC/D,CAAC;QACD,YAAY,EAAE,KAAK,IAAI,EAAE;YACvB,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;YACzB,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;YACzB,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC;AASD,kBAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview ITool for sending text messages via the WebChat channel adapter.
|
|
3
|
+
*/
|
|
4
|
+
import type { ITool, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
5
|
+
import type { WebChatService } from '../WebChatService';
|
|
6
|
+
export declare class WebChatSendMessageTool implements ITool {
|
|
7
|
+
private readonly service;
|
|
8
|
+
readonly id = "webchatChannelSendMessage";
|
|
9
|
+
readonly name = "webchatChannelSendMessage";
|
|
10
|
+
readonly displayName = "Send WebChat Message";
|
|
11
|
+
readonly description = "Send a text message to a web chat conversation via the WebChat channel adapter.";
|
|
12
|
+
readonly category = "communication";
|
|
13
|
+
readonly version = "0.1.0";
|
|
14
|
+
readonly hasSideEffects = true;
|
|
15
|
+
readonly inputSchema: {
|
|
16
|
+
type: "object";
|
|
17
|
+
required: readonly ["conversationId", "text"];
|
|
18
|
+
properties: {
|
|
19
|
+
conversationId: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
text: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
readonly outputSchema: {
|
|
30
|
+
type: "object";
|
|
31
|
+
properties: {
|
|
32
|
+
conversationId: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
sent: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
constructor(service: WebChatService);
|
|
43
|
+
execute(args: {
|
|
44
|
+
conversationId: string;
|
|
45
|
+
text: string;
|
|
46
|
+
}, _context: ToolExecutionContext): Promise<ToolExecutionResult>;
|
|
47
|
+
validateArgs(args: Record<string, any>): {
|
|
48
|
+
isValid: boolean;
|
|
49
|
+
errors?: string[];
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=sendMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../src/tools/sendMessage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,qBAAa,sBAAuB,YAAW,KAAK;IA0BtC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAzBpC,SAAgB,EAAE,+BAA+B;IACjD,SAAgB,IAAI,+BAA+B;IACnD,SAAgB,WAAW,0BAA0B;IACrD,SAAgB,WAAW,qFAAqF;IAChH,SAAgB,QAAQ,mBAAmB;IAC3C,SAAgB,OAAO,WAAW;IAClC,SAAgB,cAAc,QAAQ;IAEtC,SAAgB,WAAW;;;;;;;;;;;;;MAOzB;IAEF,SAAgB,YAAY;;;;;;;;;;;;MAM1B;gBAE2B,OAAO,EAAE,cAAc;IAE9C,OAAO,CACX,IAAI,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAC9C,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC;IAa/B,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;CAOjF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview ITool for sending text messages via the WebChat channel adapter.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WebChatSendMessageTool = void 0;
|
|
7
|
+
class WebChatSendMessageTool {
|
|
8
|
+
constructor(service) {
|
|
9
|
+
this.service = service;
|
|
10
|
+
this.id = 'webchatChannelSendMessage';
|
|
11
|
+
this.name = 'webchatChannelSendMessage';
|
|
12
|
+
this.displayName = 'Send WebChat Message';
|
|
13
|
+
this.description = 'Send a text message to a web chat conversation via the WebChat channel adapter.';
|
|
14
|
+
this.category = 'communication';
|
|
15
|
+
this.version = '0.1.0';
|
|
16
|
+
this.hasSideEffects = true;
|
|
17
|
+
this.inputSchema = {
|
|
18
|
+
type: 'object',
|
|
19
|
+
required: ['conversationId', 'text'],
|
|
20
|
+
properties: {
|
|
21
|
+
conversationId: { type: 'string', description: 'Target conversation/room ID' },
|
|
22
|
+
text: { type: 'string', description: 'Message text to send' },
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
this.outputSchema = {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
conversationId: { type: 'string', description: 'Target conversation ID' },
|
|
29
|
+
sent: { type: 'boolean', description: 'Whether the message was sent successfully' },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async execute(args, _context) {
|
|
34
|
+
try {
|
|
35
|
+
await this.service.sendMessage(args.conversationId, args.text);
|
|
36
|
+
return {
|
|
37
|
+
success: true,
|
|
38
|
+
output: { conversationId: args.conversationId, sent: true },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return { success: false, error: error.message };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
validateArgs(args) {
|
|
46
|
+
const errors = [];
|
|
47
|
+
if (!args.conversationId)
|
|
48
|
+
errors.push('conversationId is required');
|
|
49
|
+
if (!args.text)
|
|
50
|
+
errors.push('text is required');
|
|
51
|
+
else if (typeof args.text !== 'string')
|
|
52
|
+
errors.push('text must be a string');
|
|
53
|
+
return { isValid: errors.length === 0, errors };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.WebChatSendMessageTool = WebChatSendMessageTool;
|
|
57
|
+
//# sourceMappingURL=sendMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendMessage.js","sourceRoot":"","sources":["../../src/tools/sendMessage.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAKH,MAAa,sBAAsB;IA0BjC,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAzBpC,OAAE,GAAG,2BAA2B,CAAC;QACjC,SAAI,GAAG,2BAA2B,CAAC;QACnC,gBAAW,GAAG,sBAAsB,CAAC;QACrC,gBAAW,GAAG,iFAAiF,CAAC;QAChG,aAAQ,GAAG,eAAe,CAAC;QAC3B,YAAO,GAAG,OAAO,CAAC;QAClB,mBAAc,GAAG,IAAI,CAAC;QAEtB,gBAAW,GAAG;YAC5B,IAAI,EAAE,QAAiB;YACvB,QAAQ,EAAE,CAAC,gBAAgB,EAAE,MAAM,CAAU;YAC7C,UAAU,EAAE;gBACV,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6BAA6B,EAAE;gBAC9E,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE;aAC9D;SACF,CAAC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"https://agentos.sh/schemas/extension-manifest-v1.json",
|
|
3
|
+
"id": "com.framers.channels.webchat",
|
|
4
|
+
"name": "WebChat Channel Extension",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"description": "Lightweight web chat channel adapter — delegates to WunderlandGateway (Socket.IO) for transport. No external SDK required.",
|
|
7
|
+
"categories": ["channel", "communication"],
|
|
8
|
+
"platforms": ["webchat"],
|
|
9
|
+
"extensions": [
|
|
10
|
+
{
|
|
11
|
+
"kind": "tool",
|
|
12
|
+
"id": "webchatChannelSendMessage",
|
|
13
|
+
"displayName": "Send WebChat Message"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"kind": "messaging-channel",
|
|
17
|
+
"id": "webchatChannel",
|
|
18
|
+
"displayName": "WebChat Channel Adapter"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"requiredSecrets": [],
|
|
22
|
+
"features": [
|
|
23
|
+
"Text messages",
|
|
24
|
+
"Image attachments",
|
|
25
|
+
"Typing indicators",
|
|
26
|
+
"Read receipts",
|
|
27
|
+
"Gateway-bridged transport via WunderlandGateway",
|
|
28
|
+
"No external SDK dependencies"
|
|
29
|
+
]
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@framers/agentos-ext-channel-webchat",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "WebChat messaging channel adapter for AgentOS — lightweight bridge to WunderlandGateway (Socket.IO)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:watch": "vitest watch",
|
|
12
|
+
"clean": "rm -rf dist"
|
|
13
|
+
},
|
|
14
|
+
"keywords": ["agentos", "extension", "channel", "webchat", "messaging", "socket.io"],
|
|
15
|
+
"author": { "name": "Framers AI", "url": "https://frame.dev" },
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"files": ["dist", "manifest.json"],
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@framers/agentos": "^0.1.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@framers/agentos": "workspace:*",
|
|
23
|
+
"@types/node": "^20.0.0",
|
|
24
|
+
"typescript": "^5.0.0",
|
|
25
|
+
"vitest": "^1.0.0"
|
|
26
|
+
},
|
|
27
|
+
"engines": { "node": ">=18.0.0" }
|
|
28
|
+
}
|