@ekai/contexto 0.1.7 → 0.1.8
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 +1 -1
- package/src/index.ts +27 -3
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -136,7 +136,31 @@ const webhookPlugin = {
|
|
|
136
136
|
},
|
|
137
137
|
undefined,
|
|
138
138
|
{
|
|
139
|
-
content: event
|
|
139
|
+
content: event,
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
sendWebhook(config, payload, logger);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// --- Agent turn completed ---
|
|
147
|
+
api.on('agent_end', 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
|
+
'agent',
|
|
154
|
+
'end',
|
|
155
|
+
sessionKey,
|
|
156
|
+
{
|
|
157
|
+
model: event?.context?.model,
|
|
158
|
+
usage: event?.context?.usage,
|
|
159
|
+
},
|
|
160
|
+
undefined,
|
|
161
|
+
{
|
|
162
|
+
raw_event: JSON.parse(JSON.stringify(event ?? {})),
|
|
163
|
+
raw_ctx: JSON.parse(JSON.stringify(ctx ?? {})),
|
|
140
164
|
}
|
|
141
165
|
);
|
|
142
166
|
|
|
@@ -144,7 +168,7 @@ const webhookPlugin = {
|
|
|
144
168
|
});
|
|
145
169
|
|
|
146
170
|
// --- Outbound message sent ---
|
|
147
|
-
api.on('
|
|
171
|
+
api.on('message_sending', async (event: any, ctx: any) => {
|
|
148
172
|
if (!config.apiKey) return;
|
|
149
173
|
|
|
150
174
|
const sessionKey = event?.sessionKey || ctx?.sessionKey || 'unknown';
|
|
@@ -161,7 +185,7 @@ const webhookPlugin = {
|
|
|
161
185
|
},
|
|
162
186
|
undefined,
|
|
163
187
|
{
|
|
164
|
-
content: event
|
|
188
|
+
content: event,
|
|
165
189
|
}
|
|
166
190
|
);
|
|
167
191
|
|