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.
- package/bin/agent-api-http-adapter.mjs +24 -14
- package/package.json +1 -1
|
@@ -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
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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) {
|