@tangle-network/agent-app 0.60.59 → 0.60.61
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 +2 -2
- package/dist/brand-extraction/index.js +89 -2
- package/dist/brand-extraction/index.js.map +1 -1
- package/dist/chat-react/index.js +1 -1
- package/dist/chat-routes/index.js +2 -2
- package/dist/chat-routes/turn-routes.d.ts +9 -0
- package/dist/{chunk-6LPQRKH7.js → chunk-4WJREKXX.js} +222 -190
- package/dist/chunk-4WJREKXX.js.map +1 -0
- package/dist/{chunk-CZ7KLS7N.js → chunk-FWLCPAST.js} +10 -1
- package/dist/chunk-FWLCPAST.js.map +1 -0
- package/dist/{chunk-EQ6CGOZK.js → chunk-GNA5I5NM.js} +3 -1
- package/dist/chunk-GNA5I5NM.js.map +1 -0
- package/dist/{chunk-WMCROSA4.js → chunk-TZD35SBQ.js} +82 -1
- package/dist/chunk-TZD35SBQ.js.map +1 -0
- package/dist/platform/index.d.ts +1 -0
- package/dist/platform/index.js +155 -5
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/sso-identity-store.d.ts +69 -0
- package/dist/public-consultation/index.d.ts +2 -2
- package/dist/public-consultation/index.js +1 -1
- package/dist/sandbox/index.d.ts +1 -0
- package/dist/sandbox/index.js +5 -1
- package/dist/sandbox/prewarm-route.d.ts +100 -0
- package/dist/turn-stream/adapters.d.ts +17 -0
- package/dist/turn-stream/core.d.ts +2 -0
- package/dist/turn-stream/index.js +16 -0
- package/dist/turn-stream/index.js.map +1 -1
- package/dist/web-react/chat-composer.d.ts +5 -1
- package/dist/web-react/command-palette.d.ts +6 -3
- package/dist/web-react/index.d.ts +1 -0
- package/dist/web-react/index.js +6 -2
- package/dist/web-react/workspace-prewarm.d.ts +36 -0
- package/package.json +1 -1
- package/dist/chunk-6LPQRKH7.js.map +0 -1
- package/dist/chunk-CZ7KLS7N.js.map +0 -1
- package/dist/chunk-EQ6CGOZK.js.map +0 -1
- package/dist/chunk-WMCROSA4.js.map +0 -1
|
@@ -468,6 +468,85 @@ WHERE key = ?1 AND expires_at = ?2`;
|
|
|
468
468
|
};
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
+
// src/sandbox/prewarm-route.ts
|
|
472
|
+
var AUTOMATED_AGENT = /bot\b|crawler|spider|slurp|facebookexternalhit|embedly|preview|whatsapp|curl\/|wget\/|python-requests|go-http-client/i;
|
|
473
|
+
function isAutomatedPrewarmRequest(request) {
|
|
474
|
+
const purpose = `${request.headers.get("sec-purpose") ?? ""} ${request.headers.get("purpose") ?? ""}`;
|
|
475
|
+
if (/prefetch|prerender/i.test(purpose)) return true;
|
|
476
|
+
return AUTOMATED_AGENT.test(request.headers.get("user-agent") ?? "");
|
|
477
|
+
}
|
|
478
|
+
var RECENT_LIMIT = 1e3;
|
|
479
|
+
function reply(body, status = 200) {
|
|
480
|
+
return Response.json(body, { status, headers: { "Cache-Control": "private, no-store" } });
|
|
481
|
+
}
|
|
482
|
+
function createWorkspacePrewarmRoute(options) {
|
|
483
|
+
const recentMs = options.recentMs ?? 3e4;
|
|
484
|
+
const now = options.now ?? (() => Date.now());
|
|
485
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
486
|
+
const recent = /* @__PURE__ */ new Map();
|
|
487
|
+
const emit = (event) => {
|
|
488
|
+
try {
|
|
489
|
+
options.onEvent?.(event);
|
|
490
|
+
} catch {
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
const remember = (key, at) => {
|
|
494
|
+
recent.delete(key);
|
|
495
|
+
recent.set(key, at);
|
|
496
|
+
for (const old of recent.keys()) {
|
|
497
|
+
if (recent.size <= RECENT_LIMIT) break;
|
|
498
|
+
recent.delete(old);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
async function run(key, warm) {
|
|
502
|
+
const started = now();
|
|
503
|
+
try {
|
|
504
|
+
const report = await warm() ?? void 0;
|
|
505
|
+
const ms = now() - started;
|
|
506
|
+
remember(key, now());
|
|
507
|
+
emit({ type: "warmed", key, ms, ...report ? { report } : {} });
|
|
508
|
+
return { outcome: "warmed", ms, ...report ? { report } : {} };
|
|
509
|
+
} catch (err) {
|
|
510
|
+
const ms = now() - started;
|
|
511
|
+
emit({ type: "failed", key, ms, error: err instanceof Error ? err.message : String(err) });
|
|
512
|
+
return { outcome: "failed", ms };
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return async function prewarm(request, context) {
|
|
516
|
+
const started = now();
|
|
517
|
+
if (request.method !== "POST") {
|
|
518
|
+
return new Response(null, { status: 405, headers: { Allow: "POST" } });
|
|
519
|
+
}
|
|
520
|
+
if (isAutomatedPrewarmRequest(request)) return reply({ outcome: "automated", ms: 0 });
|
|
521
|
+
let auth;
|
|
522
|
+
try {
|
|
523
|
+
auth = await options.authorize({ request, context });
|
|
524
|
+
} catch (err) {
|
|
525
|
+
emit({ type: "failed", key: "", ms: now() - started, error: err instanceof Error ? err.message : String(err) });
|
|
526
|
+
return reply({ outcome: "failed", ms: now() - started });
|
|
527
|
+
}
|
|
528
|
+
if (auth.status === "denied") return auth.response;
|
|
529
|
+
if (auth.status === "declined") return reply({ outcome: "declined", ms: now() - started, reason: auth.reason });
|
|
530
|
+
const { key } = auth;
|
|
531
|
+
const running = inFlight.get(key);
|
|
532
|
+
if (running) {
|
|
533
|
+
const result2 = await running;
|
|
534
|
+
return reply({ ...result2, outcome: result2.outcome === "warmed" ? "joined" : result2.outcome, ms: now() - started });
|
|
535
|
+
}
|
|
536
|
+
const warmedAt = recent.get(key);
|
|
537
|
+
if (warmedAt !== void 0 && now() - warmedAt < recentMs) {
|
|
538
|
+
return reply({ outcome: "recent", ms: now() - started });
|
|
539
|
+
}
|
|
540
|
+
const result = run(key, auth.warm);
|
|
541
|
+
inFlight.set(key, result);
|
|
542
|
+
try {
|
|
543
|
+
return reply({ ...await result, ms: now() - started });
|
|
544
|
+
} finally {
|
|
545
|
+
if (inFlight.get(key) === result) inFlight.delete(key);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
|
|
471
550
|
// src/sandbox/foreground-single-flight.ts
|
|
472
551
|
var DEFAULT_FOREGROUND_PROVISION_CLAIM_TTL_SECONDS = 180;
|
|
473
552
|
var DEFAULT_FOREGROUND_PROVISION_POLL_INTERVAL_MS = 5e3;
|
|
@@ -2455,6 +2534,8 @@ export {
|
|
|
2455
2534
|
DEFAULT_PREWARM_CLAIM_TABLE,
|
|
2456
2535
|
PREWARM_CLAIM_TABLE_DDL,
|
|
2457
2536
|
createD1PrewarmClaimStore,
|
|
2537
|
+
isAutomatedPrewarmRequest,
|
|
2538
|
+
createWorkspacePrewarmRoute,
|
|
2458
2539
|
DEFAULT_FOREGROUND_PROVISION_CLAIM_TTL_SECONDS,
|
|
2459
2540
|
DEFAULT_FOREGROUND_PROVISION_POLL_INTERVAL_MS,
|
|
2460
2541
|
SandboxProvisioningFailedElsewhereError,
|
|
@@ -2513,4 +2594,4 @@ export {
|
|
|
2513
2594
|
isTerminalPromptEvent,
|
|
2514
2595
|
detectInteractiveQuestion
|
|
2515
2596
|
};
|
|
2516
|
-
//# sourceMappingURL=chunk-
|
|
2597
|
+
//# sourceMappingURL=chunk-TZD35SBQ.js.map
|