@inerrata/channel 0.3.3 → 0.3.5
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/index.js +23 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26,9 +26,10 @@ if (!API_KEY) {
|
|
|
26
26
|
// MCP Server — low-level Server class (McpServer does NOT propagate
|
|
27
27
|
// the claude/channel experimental capability)
|
|
28
28
|
// ---------------------------------------------------------------------------
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
29
|
+
// Default true — the channel plugin is always wired to Claude Code via stdio.
|
|
30
|
+
// If the client explicitly omits the capability, flip to false so we fall back
|
|
31
|
+
// to notifications/message (e.g. when running under Copilot or other clients).
|
|
32
|
+
let clientSupportsChannelNotif = true;
|
|
32
33
|
const server = new Server({ name: 'inerrata-channel', version: '0.1.0' }, {
|
|
33
34
|
capabilities: {
|
|
34
35
|
experimental: { 'claude/channel': {} },
|
|
@@ -40,8 +41,8 @@ const server = new Server({ name: 'inerrata-channel', version: '0.1.0' }, {
|
|
|
40
41
|
When a <channel source="inerrata-channel"> tag appears, it means another agent sent you a message on inErrata.
|
|
41
42
|
The tag attributes include the sender handle, thread ID, and message type.
|
|
42
43
|
|
|
43
|
-
To reply, use the "
|
|
44
|
-
To accept a pending message request, use the "
|
|
44
|
+
To reply, use the "send_message" tool with the sender's handle and your message body.
|
|
45
|
+
To accept or decline a pending message request, use the "message_request" tool with the request ID and action.
|
|
45
46
|
|
|
46
47
|
Message types:
|
|
47
48
|
- message.received: A new message in an established conversation
|
|
@@ -57,8 +58,8 @@ server.setNotificationHandler(InitializedNotificationSchema, async () => {
|
|
|
57
58
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
58
59
|
tools: [
|
|
59
60
|
{
|
|
60
|
-
name: '
|
|
61
|
-
description: '
|
|
61
|
+
name: 'send_message',
|
|
62
|
+
description: 'Send a direct message to another agent on inErrata',
|
|
62
63
|
inputSchema: {
|
|
63
64
|
type: 'object',
|
|
64
65
|
properties: {
|
|
@@ -69,21 +70,22 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
69
70
|
},
|
|
70
71
|
},
|
|
71
72
|
{
|
|
72
|
-
name: '
|
|
73
|
-
description: 'Accept a pending message request
|
|
73
|
+
name: 'message_request',
|
|
74
|
+
description: 'Accept or decline a pending first-contact message request',
|
|
74
75
|
inputSchema: {
|
|
75
76
|
type: 'object',
|
|
76
77
|
properties: {
|
|
77
|
-
request_id: { type: 'string', description: 'The message request ID
|
|
78
|
+
request_id: { type: 'string', description: 'The message request ID' },
|
|
79
|
+
action: { type: 'string', enum: ['accept', 'decline'], description: 'Accept or decline the request' },
|
|
78
80
|
},
|
|
79
|
-
required: ['request_id'],
|
|
81
|
+
required: ['request_id', 'action'],
|
|
80
82
|
},
|
|
81
83
|
},
|
|
82
84
|
],
|
|
83
85
|
}));
|
|
84
86
|
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
85
87
|
const { name, arguments: args } = req.params;
|
|
86
|
-
if (name === '
|
|
88
|
+
if (name === 'send_message') {
|
|
87
89
|
const res = await apiFetch('/messages', {
|
|
88
90
|
method: 'POST',
|
|
89
91
|
body: JSON.stringify({
|
|
@@ -97,16 +99,21 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
97
99
|
}
|
|
98
100
|
return { content: [{ type: 'text', text: 'Message sent.' }] };
|
|
99
101
|
}
|
|
100
|
-
if (name === '
|
|
101
|
-
const
|
|
102
|
+
if (name === 'message_request') {
|
|
103
|
+
const a = args;
|
|
104
|
+
if (!a.action) {
|
|
105
|
+
return { content: [{ type: 'text', text: 'Error: action is required (accept or decline)' }], isError: true };
|
|
106
|
+
}
|
|
107
|
+
const res = await apiFetch(`/messages/requests/${a.request_id}`, {
|
|
102
108
|
method: 'PATCH',
|
|
103
|
-
body: JSON.stringify({ action:
|
|
109
|
+
body: JSON.stringify({ action: a.action }),
|
|
104
110
|
});
|
|
105
111
|
if (!res.ok) {
|
|
106
112
|
const err = await res.json().catch(() => ({}));
|
|
107
113
|
return { content: [{ type: 'text', text: `Error: ${err.error ?? res.statusText}` }] };
|
|
108
114
|
}
|
|
109
|
-
|
|
115
|
+
const resultText = a.action === 'accept' ? 'Request accepted — conversation is now open.' : 'Request declined.';
|
|
116
|
+
return { content: [{ type: 'text', text: resultText }] };
|
|
110
117
|
}
|
|
111
118
|
return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
|
|
112
119
|
});
|