@ekai/contexto 0.1.5 → 0.1.7
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/package.json +2 -2
- package/src/index.ts +35 -11
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekai/contexto",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "Openclaw plugin for smart context management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"publishConfig": {
|
package/src/index.ts
CHANGED
|
@@ -60,7 +60,7 @@ function buildPayload(
|
|
|
60
60
|
const webhookPlugin = {
|
|
61
61
|
id: 'contexto',
|
|
62
62
|
name: 'Mind Map',
|
|
63
|
-
description: '
|
|
63
|
+
description: 'can we say "context engine for openclaw with mindmap',
|
|
64
64
|
|
|
65
65
|
configSchema: {
|
|
66
66
|
type: 'object',
|
|
@@ -120,24 +120,48 @@ const webhookPlugin = {
|
|
|
120
120
|
api.on('llm_output', async (event: any, ctx: any) => {
|
|
121
121
|
if (!config.apiKey) return;
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
const sessionKey = ctx?.sessionKey || 'unknown';
|
|
123
|
+
const sessionKey = event?.sessionKey || ctx?.sessionKey || 'unknown';
|
|
125
124
|
|
|
126
125
|
const payload = buildPayload(
|
|
127
|
-
'llm',
|
|
128
|
-
'output',
|
|
126
|
+
'llm',
|
|
127
|
+
'output',
|
|
129
128
|
sessionKey,
|
|
130
129
|
{
|
|
131
|
-
model: event?.model,
|
|
130
|
+
model: event?.context?.model,
|
|
132
131
|
usage: {
|
|
133
|
-
prompt_tokens: event?.usage?.promptTokens,
|
|
134
|
-
completion_tokens: event?.usage?.completionTokens,
|
|
135
|
-
total_tokens: event?.usage?.totalTokens
|
|
136
|
-
}
|
|
132
|
+
prompt_tokens: event?.context?.usage?.promptTokens,
|
|
133
|
+
completion_tokens: event?.context?.usage?.completionTokens,
|
|
134
|
+
total_tokens: event?.context?.usage?.totalTokens,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
undefined,
|
|
138
|
+
{
|
|
139
|
+
content: event?.context?.content,
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
sendWebhook(config, payload, logger);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// --- Outbound message sent ---
|
|
147
|
+
api.on('message_sent', async (event: any, ctx: any) => {
|
|
148
|
+
if (!config.apiKey) return;
|
|
149
|
+
|
|
150
|
+
const sessionKey = event?.sessionKey || ctx?.sessionKey || 'unknown';
|
|
151
|
+
|
|
152
|
+
const payload = buildPayload(
|
|
153
|
+
'message',
|
|
154
|
+
'sent',
|
|
155
|
+
sessionKey,
|
|
156
|
+
{
|
|
157
|
+
to: event?.context?.to,
|
|
158
|
+
channelId: event?.context?.channelId,
|
|
159
|
+
success: event?.context?.success,
|
|
160
|
+
timestamp: event?.timestamp,
|
|
137
161
|
},
|
|
138
162
|
undefined,
|
|
139
163
|
{
|
|
140
|
-
content: event?.
|
|
164
|
+
content: event?.context?.content,
|
|
141
165
|
}
|
|
142
166
|
);
|
|
143
167
|
|