blun-king-cli 9.1.472 → 9.1.473

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.
@@ -271,6 +271,12 @@ function createAgentApiHttpAdapter(options = {}) {
271
271
  if (scopeOwners?.size === 0) owners.delete(key);
272
272
  }
273
273
 
274
+ function trackRunningScope(key, principalId, internalSessionId) {
275
+ const scopeOwners = owners.get(key) ?? new Map();
276
+ scopeOwners.set(principalId, internalSessionId);
277
+ owners.set(key, scopeOwners);
278
+ }
279
+
274
280
  async function handleStart(input, principalId) {
275
281
  const body = requireBody(input.body);
276
282
  requireKing(body.model);
@@ -295,20 +301,24 @@ function createAgentApiHttpAdapter(options = {}) {
295
301
  );
296
302
  }
297
303
  const internalSessionId = session.id.trim();
298
- const response = publicCompletion(await controller.startTurn({
299
- session,
300
- publicSessionId: sessionId,
301
- requestId,
302
- prompt: normalizePrompt(body.input),
303
- tools: normalizeTools(body.tools),
304
- }));
305
- trackScope(
306
- scopeKey(sessionId, requestId),
307
- principalId,
308
- internalSessionId,
309
- response,
310
- );
311
- return jsonResponse(200, response);
304
+ const prompt = normalizePrompt(body.input);
305
+ const tools = normalizeTools(body.tools);
306
+ const key = scopeKey(sessionId, requestId);
307
+ trackRunningScope(key, principalId, internalSessionId);
308
+ try {
309
+ const response = publicCompletion(await controller.startTurn({
310
+ session,
311
+ publicSessionId: sessionId,
312
+ requestId,
313
+ prompt,
314
+ tools,
315
+ }));
316
+ trackScope(key, principalId, internalSessionId, response);
317
+ return jsonResponse(200, response);
318
+ } catch (error) {
319
+ trackScope(key, principalId, internalSessionId, null);
320
+ throw error;
321
+ }
312
322
  }
313
323
 
314
324
  async function handleContinue(input, principalId, requestId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.472",
3
+ "version": "9.1.473",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {