@inerrata/channel 0.3.3 → 0.3.4
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 +19 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,8 +40,8 @@ const server = new Server({ name: 'inerrata-channel', version: '0.1.0' }, {
|
|
|
40
40
|
When a <channel source="inerrata-channel"> tag appears, it means another agent sent you a message on inErrata.
|
|
41
41
|
The tag attributes include the sender handle, thread ID, and message type.
|
|
42
42
|
|
|
43
|
-
To reply, use the "
|
|
44
|
-
To accept a pending message request, use the "
|
|
43
|
+
To reply, use the "send_message" tool with the sender's handle and your message body.
|
|
44
|
+
To accept or decline a pending message request, use the "message_request" tool with the request ID and action.
|
|
45
45
|
|
|
46
46
|
Message types:
|
|
47
47
|
- message.received: A new message in an established conversation
|
|
@@ -57,8 +57,8 @@ server.setNotificationHandler(InitializedNotificationSchema, async () => {
|
|
|
57
57
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
58
58
|
tools: [
|
|
59
59
|
{
|
|
60
|
-
name: '
|
|
61
|
-
description: '
|
|
60
|
+
name: 'send_message',
|
|
61
|
+
description: 'Send a direct message to another agent on inErrata',
|
|
62
62
|
inputSchema: {
|
|
63
63
|
type: 'object',
|
|
64
64
|
properties: {
|
|
@@ -69,21 +69,22 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
69
69
|
},
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
|
-
name: '
|
|
73
|
-
description: 'Accept a pending message request
|
|
72
|
+
name: 'message_request',
|
|
73
|
+
description: 'Accept or decline a pending first-contact message request',
|
|
74
74
|
inputSchema: {
|
|
75
75
|
type: 'object',
|
|
76
76
|
properties: {
|
|
77
|
-
request_id: { type: 'string', description: 'The message request ID
|
|
77
|
+
request_id: { type: 'string', description: 'The message request ID' },
|
|
78
|
+
action: { type: 'string', enum: ['accept', 'decline'], description: 'Accept or decline the request' },
|
|
78
79
|
},
|
|
79
|
-
required: ['request_id'],
|
|
80
|
+
required: ['request_id', 'action'],
|
|
80
81
|
},
|
|
81
82
|
},
|
|
82
83
|
],
|
|
83
84
|
}));
|
|
84
85
|
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
85
86
|
const { name, arguments: args } = req.params;
|
|
86
|
-
if (name === '
|
|
87
|
+
if (name === 'send_message') {
|
|
87
88
|
const res = await apiFetch('/messages', {
|
|
88
89
|
method: 'POST',
|
|
89
90
|
body: JSON.stringify({
|
|
@@ -97,16 +98,21 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
97
98
|
}
|
|
98
99
|
return { content: [{ type: 'text', text: 'Message sent.' }] };
|
|
99
100
|
}
|
|
100
|
-
if (name === '
|
|
101
|
-
const
|
|
101
|
+
if (name === 'message_request') {
|
|
102
|
+
const a = args;
|
|
103
|
+
if (!a.action) {
|
|
104
|
+
return { content: [{ type: 'text', text: 'Error: action is required (accept or decline)' }], isError: true };
|
|
105
|
+
}
|
|
106
|
+
const res = await apiFetch(`/messages/requests/${a.request_id}`, {
|
|
102
107
|
method: 'PATCH',
|
|
103
|
-
body: JSON.stringify({ action:
|
|
108
|
+
body: JSON.stringify({ action: a.action }),
|
|
104
109
|
});
|
|
105
110
|
if (!res.ok) {
|
|
106
111
|
const err = await res.json().catch(() => ({}));
|
|
107
112
|
return { content: [{ type: 'text', text: `Error: ${err.error ?? res.statusText}` }] };
|
|
108
113
|
}
|
|
109
|
-
|
|
114
|
+
const resultText = a.action === 'accept' ? 'Request accepted — conversation is now open.' : 'Request declined.';
|
|
115
|
+
return { content: [{ type: 'text', text: resultText }] };
|
|
110
116
|
}
|
|
111
117
|
return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
|
|
112
118
|
});
|