@tangle-network/agent-app 0.60.80 → 0.60.81
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/assistant/index.js +1 -1
- package/dist/chat-routes/index.js +1 -1
- package/dist/{chunk-OUW5AI2G.js → chunk-A2TCZVW4.js} +3 -3
- package/dist/chunk-A2TCZVW4.js.map +1 -0
- package/dist/{chunk-MBEJPQW6.js → chunk-A5CZ2X6C.js} +18 -9
- package/dist/{chunk-MBEJPQW6.js.map → chunk-A5CZ2X6C.js.map} +1 -1
- package/dist/sandbox/index.js +1 -1
- package/dist/sandbox/prewarm-route.d.ts +19 -6
- package/dist/web-react/index.js +1 -1
- package/dist/web-react/workspace-prewarm.d.ts +2 -0
- package/dist/workspace-export/react.js +4 -3
- package/dist/workspace-export/react.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-OUW5AI2G.js.map +0 -1
|
@@ -476,12 +476,22 @@ function isAutomatedPrewarmRequest(request) {
|
|
|
476
476
|
return AUTOMATED_AGENT.test(request.headers.get("user-agent") ?? "");
|
|
477
477
|
}
|
|
478
478
|
var RECENT_LIMIT = 1e3;
|
|
479
|
+
async function requestReason(request) {
|
|
480
|
+
if (Number(request.headers.get("content-length") ?? 0) > 1024) return "page-open";
|
|
481
|
+
try {
|
|
482
|
+
const body = await request.clone().json();
|
|
483
|
+
return body?.reason === "composer-focus" ? "composer-focus" : "page-open";
|
|
484
|
+
} catch {
|
|
485
|
+
return "page-open";
|
|
486
|
+
}
|
|
487
|
+
}
|
|
479
488
|
function reply(body, status = 200) {
|
|
480
489
|
return Response.json(body, { status, headers: { "Cache-Control": "private, no-store" } });
|
|
481
490
|
}
|
|
482
491
|
function createWorkspacePrewarmRoute(options) {
|
|
483
492
|
const recentMs = options.recentMs ?? 3e4;
|
|
484
493
|
const now = options.now ?? (() => Date.now());
|
|
494
|
+
const staleMs = options.staleMs ?? 45e3;
|
|
485
495
|
const inFlight = /* @__PURE__ */ new Map();
|
|
486
496
|
const recent = /* @__PURE__ */ new Map();
|
|
487
497
|
const emit = (event) => {
|
|
@@ -520,7 +530,7 @@ function createWorkspacePrewarmRoute(options) {
|
|
|
520
530
|
if (isAutomatedPrewarmRequest(request)) return reply({ outcome: "automated", ms: 0 });
|
|
521
531
|
let auth;
|
|
522
532
|
try {
|
|
523
|
-
auth = await options.authorize({ request, context });
|
|
533
|
+
auth = await options.authorize({ request, context, reason: await requestReason(request) });
|
|
524
534
|
} catch (err) {
|
|
525
535
|
emit({ type: "failed", key: "", ms: now() - started, error: err instanceof Error ? err.message : String(err) });
|
|
526
536
|
return reply({ outcome: "failed", ms: now() - started });
|
|
@@ -529,20 +539,19 @@ function createWorkspacePrewarmRoute(options) {
|
|
|
529
539
|
if (auth.status === "declined") return reply({ outcome: "declined", ms: now() - started, reason: auth.reason });
|
|
530
540
|
const { key } = auth;
|
|
531
541
|
const running = inFlight.get(key);
|
|
532
|
-
if (running) {
|
|
533
|
-
|
|
534
|
-
return reply({ ...result2, outcome: result2.outcome === "warmed" ? "joined" : result2.outcome, ms: now() - started });
|
|
542
|
+
if (running && now() - running.at < staleMs) {
|
|
543
|
+
return reply({ outcome: "joined", ms: now() - started });
|
|
535
544
|
}
|
|
536
545
|
const warmedAt = recent.get(key);
|
|
537
546
|
if (warmedAt !== void 0 && now() - warmedAt < recentMs) {
|
|
538
547
|
return reply({ outcome: "recent", ms: now() - started });
|
|
539
548
|
}
|
|
540
|
-
const
|
|
541
|
-
inFlight.set(key,
|
|
549
|
+
const mark = { at: now() };
|
|
550
|
+
inFlight.set(key, mark);
|
|
542
551
|
try {
|
|
543
|
-
return reply({ ...await
|
|
552
|
+
return reply({ ...await run(key, auth.warm), ms: now() - started });
|
|
544
553
|
} finally {
|
|
545
|
-
if (inFlight.get(key) ===
|
|
554
|
+
if (inFlight.get(key) === mark) inFlight.delete(key);
|
|
546
555
|
}
|
|
547
556
|
};
|
|
548
557
|
}
|
|
@@ -2918,4 +2927,4 @@ export {
|
|
|
2918
2927
|
isTerminalPromptEvent,
|
|
2919
2928
|
detectInteractiveQuestion
|
|
2920
2929
|
};
|
|
2921
|
-
//# sourceMappingURL=chunk-
|
|
2930
|
+
//# sourceMappingURL=chunk-A5CZ2X6C.js.map
|