@burdenoff/fe-libs 2026.1112.3 → 2026.1112.5
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/shared/assistant/api.d.ts +7 -0
- package/dist/shared/assistant/api.js +47 -45
- package/dist/shared/assistant/createSandboxAssistantTransport.js +2 -1
- package/dist/shared/assistant/gatewayClient.js +1 -0
- package/dist/shared/assistant/index.d.ts +4 -0
- package/dist/shared/assistant/keepAlive.d.ts +74 -0
- package/dist/shared/assistant/keepAlive.js +77 -0
- package/dist/shared/assistant/prewarm.d.ts +20 -0
- package/dist/shared/assistant/prewarm.js +25 -4
- package/dist/shared/assistant/runtime.d.ts +7 -2
- package/dist/shared/assistant/runtime.js +23 -22
- package/dist/shared/assistant/signInWarm.d.ts +60 -0
- package/dist/shared/assistant/signInWarm.js +111 -0
- package/dist/shared/assistant/snapshotPoller.d.ts +16 -0
- package/dist/shared/assistant/snapshotPoller.js +29 -22
- package/dist/shared/assistant/staleSession.d.ts +27 -0
- package/dist/shared/assistant/staleSession.js +15 -0
- package/dist/shared/assistant/turnProgress.d.ts +16 -0
- package/dist/shared/assistant/turnProgress.js +30 -4
- package/dist/shared/assistant/ui/AssistantChatArea.js +1286 -1271
- package/dist/shared/assistant/ui/AssistantOverlay.d.ts +7 -0
- package/dist/shared/assistant/ui/AssistantOverlay.js +256 -248
- package/dist/shared/assistant/usageReporting.d.ts +18 -0
- package/dist/shared/assistant/usageReporting.js +17 -5
- package/dist/shared/assistant/useAssistantHeartbeat.d.ts +24 -4
- package/dist/shared/assistant/useAssistantHeartbeat.js +43 -24
- package/dist/shared/assistant/useAssistantSignInWarm.d.ts +19 -0
- package/dist/shared/assistant/useAssistantSignInWarm.js +55 -0
- package/dist/shared/assistant/writeProposals.d.ts +9 -0
- package/dist/shared/components/assistantWidget/AssistantWidget.d.ts +7 -0
- package/dist/shared/components/assistantWidget/AssistantWidget.js +289 -285
- package/dist/shared/providers/shell/AuthTokenProvider.d.ts +6 -0
- package/dist/shared/providers/shell/AuthTokenProvider.js +4 -1
- package/dist/shared/providers/shell/index.d.ts +1 -1
- package/dist/shared-assistant.js +374 -370
- package/dist/shared-providers-shell.js +12 -12
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +6 -5
- package/dist/storage/uploadBlob.d.ts +3 -0
- package/dist/storage/uploadBlob.js +39 -37
- package/dist/storage/uploadVisibility.d.ts +3 -0
- package/dist/storage/uploadVisibility.js +6 -0
- package/dist/storage/useSaveToFiles.d.ts +3 -0
- package/dist/storage/useSaveToFiles.js +57 -53
- package/package.json +1 -1
|
@@ -262,6 +262,13 @@ options?: {
|
|
|
262
262
|
* older gateway that field errors → falls back to 2s getSandbox polling. Keeps
|
|
263
263
|
* the same terminal-error strings either way.
|
|
264
264
|
*/
|
|
265
|
+
/**
|
|
266
|
+
* Seconds one readiness long-poll may hold its request (BOFF-12187). Below the
|
|
267
|
+
* public gateway's 20 s subgraph timeout: at 25 s a poll that waited its full
|
|
268
|
+
* budget was cut off by the gateway and arrived as an error, not as "not ready
|
|
269
|
+
* yet". The service clamps to the same value.
|
|
270
|
+
*/
|
|
271
|
+
export declare const SANDBOX_LONG_POLL_SECONDS = 15;
|
|
265
272
|
export declare function waitForSandboxRunning(sandboxId: string, workspaceId: string, authContext: AssistantSandboxAuthContext, maxWaitMs?: number): Promise<void>;
|
|
266
273
|
export declare function waitForAssistantServiceReady(sandboxId: string, workspaceId: string, mode: AssistantMode, authContext: AssistantSandboxAuthContext, maxWaitMs?: number,
|
|
267
274
|
/**
|
|
@@ -278,7 +278,8 @@ async function Ee(e, t, r) {
|
|
|
278
278
|
function De(e, t) {
|
|
279
279
|
if (e === "FAILED" || e === "STOPPED" || e === "EXPIRED") throw Error(t ? `Sandbox ${e.toLowerCase()}: ${t}` : `Sandbox ${e.toLowerCase()}`);
|
|
280
280
|
}
|
|
281
|
-
|
|
281
|
+
var Oe = 15;
|
|
282
|
+
async function ke(e, t, r, a = 3e5) {
|
|
282
283
|
let o = Date.now();
|
|
283
284
|
if (S("waitForSandboxRunning") !== "unsupported") for (; Date.now() - o < a;) try {
|
|
284
285
|
let a = await i({
|
|
@@ -286,7 +287,7 @@ async function Oe(e, t, r, a = 3e5) {
|
|
|
286
287
|
operationName: "WaitForSandboxRunning",
|
|
287
288
|
variables: {
|
|
288
289
|
id: e,
|
|
289
|
-
timeoutSeconds:
|
|
290
|
+
timeoutSeconds: 15,
|
|
290
291
|
context: n(t, r)
|
|
291
292
|
},
|
|
292
293
|
workspaceId: t,
|
|
@@ -310,7 +311,7 @@ async function Oe(e, t, r, a = 3e5) {
|
|
|
310
311
|
}
|
|
311
312
|
throw Error("Sandbox startup timed out");
|
|
312
313
|
}
|
|
313
|
-
async function
|
|
314
|
+
async function Ae(e, t, r, a, o = 9e4, s) {
|
|
314
315
|
let c = Date.now(), l = (t) => (E.getState().setSandboxWriteCapabilities(e, Z(t)), t), u = S("waitForAssistantReady") === "unsupported";
|
|
315
316
|
if (!u) for (; Date.now() - c < o;) {
|
|
316
317
|
let r = Date.now(), d = o - (r - c);
|
|
@@ -321,7 +322,7 @@ async function ke(e, t, r, a, o = 9e4, s) {
|
|
|
321
322
|
operationName: "WaitForAssistantReady",
|
|
322
323
|
variables: {
|
|
323
324
|
id: e,
|
|
324
|
-
timeoutSeconds: Math.min(
|
|
325
|
+
timeoutSeconds: Math.min(15, Math.floor(d / 1e3)),
|
|
325
326
|
context: n(t, a)
|
|
326
327
|
},
|
|
327
328
|
workspaceId: t,
|
|
@@ -353,10 +354,10 @@ async function ke(e, t, r, a, o = 9e4, s) {
|
|
|
353
354
|
function X(e) {
|
|
354
355
|
return e === "proposal-v1" ? "proposal-v1" : "legacy";
|
|
355
356
|
}
|
|
356
|
-
function
|
|
357
|
+
function je(e, t) {
|
|
357
358
|
return e === "enabled" || e === void 0 && !t ? "enabled" : "fenced";
|
|
358
359
|
}
|
|
359
|
-
var
|
|
360
|
+
var Me = /* @__PURE__ */ new Set([
|
|
360
361
|
"relay",
|
|
361
362
|
"delegated",
|
|
362
363
|
"direct",
|
|
@@ -367,15 +368,16 @@ function Z(e) {
|
|
|
367
368
|
return {
|
|
368
369
|
proposals: n.writeProposals === "v1",
|
|
369
370
|
writeApprovalMode: X(n.writeApprovalMode),
|
|
370
|
-
writeExecution:
|
|
371
|
+
writeExecution: je(n.writeExecution, r),
|
|
371
372
|
replyApproval: "off",
|
|
372
373
|
...typeof i == "string" && i ? { writeRiskVersion: i } : {},
|
|
373
|
-
...typeof a == "string" &&
|
|
374
|
+
...typeof a == "string" && Me.has(a) ? { sessionCredentials: a } : {},
|
|
374
375
|
...n.uiOffers === 1 ? { uiOffers: !0 } : {},
|
|
375
|
-
...n.clientTools === 1 ? { clientTools: !0 } : {}
|
|
376
|
+
...n.clientTools === 1 ? { clientTools: !0 } : {},
|
|
377
|
+
...n.promptRejectsUnknownSession === !0 ? { promptRejectsUnknownSession: !0 } : {}
|
|
376
378
|
};
|
|
377
379
|
}
|
|
378
|
-
async function
|
|
380
|
+
async function Ne(e, t, n, r) {
|
|
379
381
|
let i;
|
|
380
382
|
try {
|
|
381
383
|
i = await N(e, t, "/health", "GET", void 0, n, r);
|
|
@@ -387,19 +389,19 @@ async function Me(e, t, n, r) {
|
|
|
387
389
|
let o = Z(a);
|
|
388
390
|
return E.getState().setSandboxWriteCapabilities(e, o), o;
|
|
389
391
|
}
|
|
390
|
-
async function
|
|
392
|
+
async function Pe(e, t, n, r) {
|
|
391
393
|
let i = (await M(e, t, "/sessions", "POST", { mode: n }, n, r, "never")).session, a = typeof i == "object" && i ? i.id : void 0;
|
|
392
394
|
if (!A(a)) throw Error("The assistant could not open a session. Please try again.");
|
|
393
395
|
return { sessionId: a };
|
|
394
396
|
}
|
|
395
|
-
async function
|
|
397
|
+
async function Fe(e, t, n, r, i) {
|
|
396
398
|
let a = await M(e, t, `/write-confirmations/${encodeURIComponent(n)}/approve`, "POST", {}, r, i, "never");
|
|
397
399
|
if (a?.approved !== !0) throw Error(typeof a?.error == "string" ? a.error : "The change could not be approved. It may have expired — ask the assistant to try again.");
|
|
398
400
|
}
|
|
399
|
-
function
|
|
401
|
+
function Ie(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
|
|
400
402
|
return i.userId ? e.filter((e) => e.metadata?.authStrategy === "sandbox-app-client-headers-v1" && e.createdBy === i.userId && !(!a.has(e.id) && e.metadata?.assistantProduct === t && y(e, [n]) === n && (!B(n) || z(e.metadata, o)) && L(e, n, o))).map((e) => e.id) : [];
|
|
401
403
|
}
|
|
402
|
-
async function
|
|
404
|
+
async function Le(e, t, r, a, o, s = /* @__PURE__ */ new Set(), c = "legacy") {
|
|
403
405
|
let l, u = /* @__PURE__ */ new Set();
|
|
404
406
|
try {
|
|
405
407
|
let d = (await i({
|
|
@@ -411,7 +413,7 @@ async function Ie(e, t, r, a, o, s = /* @__PURE__ */ new Set(), c = "legacy") {
|
|
|
411
413
|
})).getActiveSandboxes ?? [];
|
|
412
414
|
W(d);
|
|
413
415
|
let f = q(c);
|
|
414
|
-
if (l =
|
|
416
|
+
if (l = Ie(d, t, r, a, o, s, f), f === "proposal-v1") {
|
|
415
417
|
let e = new Set(l);
|
|
416
418
|
for (let t of d) {
|
|
417
419
|
let n = y(t);
|
|
@@ -423,13 +425,13 @@ async function Ie(e, t, r, a, o, s = /* @__PURE__ */ new Set(), c = "legacy") {
|
|
|
423
425
|
}
|
|
424
426
|
return (await Promise.all(l.map(async (t) => {
|
|
425
427
|
try {
|
|
426
|
-
return await
|
|
428
|
+
return await Re(t, e, o, { ownerScoped: u.has(t) }), t;
|
|
427
429
|
} catch {
|
|
428
430
|
return null;
|
|
429
431
|
}
|
|
430
432
|
}))).filter((e) => e !== null);
|
|
431
433
|
}
|
|
432
|
-
async function
|
|
434
|
+
async function Re(t, r, a, o = {}) {
|
|
433
435
|
if (e(t), (o.ownerScoped === !0 || G(t)) && S("stopMyAssistantSandbox") !== "unsupported") try {
|
|
434
436
|
await i({
|
|
435
437
|
query: g,
|
|
@@ -457,23 +459,23 @@ async function Le(t, r, a, o = {}) {
|
|
|
457
459
|
authContext: a
|
|
458
460
|
});
|
|
459
461
|
}
|
|
460
|
-
var
|
|
462
|
+
var ze = /^[A-Za-z0-9_-]{1,128}$/, Be = /* @__PURE__ */ new Set([
|
|
461
463
|
"affirm",
|
|
462
464
|
"decline",
|
|
463
465
|
"other"
|
|
464
|
-
]),
|
|
466
|
+
]), Ve = /* @__PURE__ */ new Set([
|
|
465
467
|
"typed",
|
|
466
468
|
"spoken",
|
|
467
469
|
"chip",
|
|
468
470
|
"host_queued",
|
|
469
471
|
"retry",
|
|
470
472
|
"proposal_result"
|
|
471
|
-
]),
|
|
472
|
-
function
|
|
473
|
-
return !e || !
|
|
473
|
+
]), He = /^wp_[0-9a-f]{32}$/;
|
|
474
|
+
function Ue(e) {
|
|
475
|
+
return !e || !Be.has(e.kind) || !Ve.has(e.origin) ? null : e.proposalId === void 0 ? {
|
|
474
476
|
kind: e.kind,
|
|
475
477
|
origin: e.origin
|
|
476
|
-
} :
|
|
478
|
+
} : He.test(e.proposalId) ? {
|
|
477
479
|
kind: e.kind,
|
|
478
480
|
origin: e.origin,
|
|
479
481
|
proposalId: e.proposalId
|
|
@@ -485,18 +487,18 @@ function Q(e) {
|
|
|
485
487
|
prompt: n,
|
|
486
488
|
pageContext: ue(e.pageContext)
|
|
487
489
|
};
|
|
488
|
-
r && r.length > 0 && (i.parts = r), typeof e.conversationId == "string" &&
|
|
489
|
-
let a =
|
|
490
|
+
r && r.length > 0 && (i.parts = r), typeof e.conversationId == "string" && ze.test(e.conversationId) && (i.conversationId = e.conversationId);
|
|
491
|
+
let a = Ue(e.writeReply);
|
|
490
492
|
return a && (i.writeReply = a), e.uiCatalogue && (i.uiCatalogue = e.uiCatalogue), e.clientTools && e.clientTools.length > 0 && (i.clientTools = e.clientTools), i;
|
|
491
493
|
}
|
|
492
|
-
function
|
|
494
|
+
function We(e) {
|
|
493
495
|
return O(e.sandboxId, e.workspaceId, j(e.sessionId, "/prompt-async"), "POST", Q(e), e.mode, e.authContext);
|
|
494
496
|
}
|
|
495
|
-
function
|
|
496
|
-
return new TextEncoder().encode(JSON.stringify(
|
|
497
|
+
function Ge(e) {
|
|
498
|
+
return new TextEncoder().encode(JSON.stringify(We(e))).byteLength;
|
|
497
499
|
}
|
|
498
|
-
async function
|
|
499
|
-
if (
|
|
500
|
+
async function Ke(e, t, n, r, i, a, o, s) {
|
|
501
|
+
if (Ge({
|
|
500
502
|
sandboxId: e,
|
|
501
503
|
workspaceId: t,
|
|
502
504
|
sessionId: n,
|
|
@@ -522,7 +524,7 @@ async function Ge(e, t, n, r, i, a, o, s) {
|
|
|
522
524
|
}), i, o, "never");
|
|
523
525
|
return { messageID: typeof c.messageID == "string" ? c.messageID : void 0 };
|
|
524
526
|
}
|
|
525
|
-
async function
|
|
527
|
+
async function qe(e, t, n, r, i, a) {
|
|
526
528
|
let o = j(n, `/messages?limit=${a?.limit ?? 50}`), s = Number.isFinite(a?.sinceMs) && (a?.sinceMs ?? 0) > 0 && S("sinceParam") !== "unsupported", c = s, l = (n) => M(e, t, n, "GET", void 0, r, i, "transport"), u;
|
|
527
529
|
try {
|
|
528
530
|
u = await l(s ? `${o}&since=${a?.sinceMs}` : o);
|
|
@@ -543,7 +545,7 @@ async function Ke(e, t, n, r, i, a) {
|
|
|
543
545
|
}
|
|
544
546
|
return u.messages ?? [];
|
|
545
547
|
}
|
|
546
|
-
async function
|
|
548
|
+
async function Je(e, t, n, r, i, a, o) {
|
|
547
549
|
try {
|
|
548
550
|
await M(e, t, j(n, `/client-tools/${r}/result`), "POST", { result: i }, a, o, "never");
|
|
549
551
|
} catch (e) {
|
|
@@ -551,7 +553,7 @@ async function qe(e, t, n, r, i, a, o) {
|
|
|
551
553
|
throw e;
|
|
552
554
|
}
|
|
553
555
|
}
|
|
554
|
-
async function
|
|
556
|
+
async function Ye(e, t, n, r, i) {
|
|
555
557
|
if (S("sse") === "unsupported") return null;
|
|
556
558
|
try {
|
|
557
559
|
let a = await M(e, t, j(n, "/stream-url"), "GET", void 0, r, i, "transport");
|
|
@@ -563,13 +565,13 @@ async function Je(e, t, n, r, i) {
|
|
|
563
565
|
return T("sse"), null;
|
|
564
566
|
}
|
|
565
567
|
}
|
|
566
|
-
async function
|
|
568
|
+
async function Xe(e, t, n, r, i, a = Date.now) {
|
|
567
569
|
if (ce(a())) return null;
|
|
568
570
|
try {
|
|
569
571
|
let { status: o, body: s } = await N(e, t, j(n, "/stream-url"), "GET", void 0, r, i);
|
|
570
572
|
if (o === 404) return x(ae, a()), null;
|
|
571
573
|
let c = o >= 200 && o < 300 && typeof s == "object" && s ? s : null;
|
|
572
|
-
return c && c.transport === "relay" && typeof c.url == "string" && typeof c.expiresAt == "number" &&
|
|
574
|
+
return c && c.transport === "relay" && typeof c.url == "string" && typeof c.expiresAt == "number" && Ze(c.url) ? (oe(), {
|
|
573
575
|
url: c.url,
|
|
574
576
|
expiresAt: c.expiresAt
|
|
575
577
|
}) : (x(c ? ae : b, a()), null);
|
|
@@ -577,7 +579,7 @@ async function Ye(e, t, n, r, i, a = Date.now) {
|
|
|
577
579
|
return x(b, a()), null;
|
|
578
580
|
}
|
|
579
581
|
}
|
|
580
|
-
function
|
|
582
|
+
function Ze(e) {
|
|
581
583
|
try {
|
|
582
584
|
let { protocol: t } = new URL(e);
|
|
583
585
|
return t === "https:" || t === "http:";
|
|
@@ -585,7 +587,7 @@ function Xe(e) {
|
|
|
585
587
|
return !1;
|
|
586
588
|
}
|
|
587
589
|
}
|
|
588
|
-
async function
|
|
590
|
+
async function Qe(e, t, r, a) {
|
|
589
591
|
if (G(e) && S("extendMyAssistantSandboxTTL") !== "unsupported") try {
|
|
590
592
|
await i({
|
|
591
593
|
query: l,
|
|
@@ -617,27 +619,27 @@ async function Ze(e, t, r, a) {
|
|
|
617
619
|
deadlineMs: k
|
|
618
620
|
});
|
|
619
621
|
}
|
|
620
|
-
async function
|
|
622
|
+
async function $e(e, t, n, r, i) {
|
|
621
623
|
await M(e, t, j(n, "/heartbeat"), "POST", void 0, r, i, "transport").catch(() => void 0);
|
|
622
624
|
}
|
|
623
|
-
async function
|
|
625
|
+
async function et(e, t, n, r, i) {
|
|
624
626
|
try {
|
|
625
627
|
return (await M(e, t, j(n, "/abort"), "POST", void 0, r, i, "never"))?.aborted === !0;
|
|
626
628
|
} catch {
|
|
627
629
|
return !1;
|
|
628
630
|
}
|
|
629
631
|
}
|
|
630
|
-
async function
|
|
632
|
+
async function tt(e, t, n, r, i) {
|
|
631
633
|
return ((await M(e, t, j(n, "/artifacts"), "GET", void 0, r, i, "transport")).artifacts ?? []).filter((e) => !e.name.startsWith("."));
|
|
632
634
|
}
|
|
633
|
-
async function
|
|
635
|
+
async function nt(e, t, n, r, i) {
|
|
634
636
|
let a = await M(e, t, j(n), "GET", void 0, r, i, "transport");
|
|
635
637
|
return {
|
|
636
638
|
id: a.session?.id ?? n,
|
|
637
639
|
mode: a.mode ?? "unknown"
|
|
638
640
|
};
|
|
639
641
|
}
|
|
640
|
-
async function
|
|
642
|
+
async function rt(e, t, n, r, i, a) {
|
|
641
643
|
let o = (await M(e, t, j(n, `/artifacts/download?path=${encodeURIComponent(r)}`), "GET", void 0, i, a, "transport")).artifact;
|
|
642
644
|
if (!o) throw Error("Artifact download returned an empty response");
|
|
643
645
|
return {
|
|
@@ -649,7 +651,7 @@ async function nt(e, t, n, r, i, a) {
|
|
|
649
651
|
function $(e, t) {
|
|
650
652
|
return !e || t === "product-service" ? null : e;
|
|
651
653
|
}
|
|
652
|
-
async function
|
|
654
|
+
async function it(e, t, n, r) {
|
|
653
655
|
let a = $(n, r);
|
|
654
656
|
return a ? !(await i({
|
|
655
657
|
query: s,
|
|
@@ -665,7 +667,7 @@ async function rt(e, t, n, r) {
|
|
|
665
667
|
authContext: t
|
|
666
668
|
})).checkAiCredits;
|
|
667
669
|
}
|
|
668
|
-
async function
|
|
670
|
+
async function at(e, t, n, o, s, c, l, u) {
|
|
669
671
|
let d = Math.max(0, Math.round(s.input ?? 0)), f = Math.max(0, Math.round(s.output ?? 0)), p = Math.max(0, Math.round(s.cache?.read ?? 0)), h = Math.max(0, Math.round(s.cache?.write ?? 0));
|
|
670
672
|
if (d + f + p + h === 0 || !o) return;
|
|
671
673
|
let g = $(l, u);
|
|
@@ -717,4 +719,4 @@ async function it(e, t, n, o, s, c, l, u) {
|
|
|
717
719
|
authContext: c
|
|
718
720
|
});
|
|
719
721
|
}
|
|
720
|
-
export {
|
|
722
|
+
export { ze as PROMPT_CONVERSATION_ID_PATTERN, Oe as SANDBOX_LONG_POLL_SECONDS, k as SANDBOX_READ_DEADLINE_MS, et as abortAssistantTurn, Fe as approvePendingWrite, L as askReuseMatchesProvisioning, j as assistantSessionPath, V as buildAssistantSandboxEnv, We as buildPromptGatewayRequest, Q as buildPromptRequestBody, be as buildProvisionAssistantSandboxInput, it as checkAssistantAiCredits, we as createAssistantSandbox, Pe as createAssistantSession, rt as downloadAssistantArtifact, Qe as extendAssistantSandboxTTL, ge as findExistingSandbox, P as findExistingSandboxWithStatus, D as forwardsUserTokensToSandbox, tt as getAssistantArtifacts, qe as getAssistantMessages, nt as getAssistantSession, Ye as getAssistantStreamAccess, J as isAssistantProvisioningUnavailable, A as isAssistantSessionId, G as isDedicatedAssistantSandbox, U as isDedicatedAssistantSandboxRow, Xe as mintAssistantTurnStream, B as modeRequiresConfirmWrites, Je as postClientToolResult, Ge as promptGatewayRequestBytes, N as proxySandboxRaw, Z as readSandboxWriteCapabilities, Ne as readSandboxWriteCapabilitiesOnce, Le as releaseSupersededAssistantSandboxes, at as reportAssistantAiTokenUsage, F as sandboxStatusOf, I as selectExistingAssistantSandbox, Ie as selectSupersededAssistantSandboxes, Ke as sendAssistantPromptAsync, $e as sendHeartbeat, $ as sharedAiCreditProduct, Re as stopReapedAssistantSandbox, K as usesDedicatedAssistantProvisioning, Ae as waitForAssistantServiceReady, ke as waitForSandboxRunning, X as writeApprovalModeOf, z as writeApprovalReuseMatches, je as writeExecutionOf };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./keepAlive.js";
|
|
1
2
|
import { checkAssistantAiCredits as e, getAssistantMessages as t, getAssistantStreamAccess as n, reportAssistantAiTokenUsage as r, sendAssistantPromptAsync as i, sharedAiCreditProduct as a, stopReapedAssistantSandbox as o } from "./api.js";
|
|
2
3
|
import { AssistantRuntimeManager as s } from "./runtime.js";
|
|
3
4
|
import { AssistantPromptDelivery as c, trackAssistantSandboxTurn as l } from "./promptDelivery.js";
|
|
@@ -29,7 +30,7 @@ function P(e, t) {
|
|
|
29
30
|
return e.filter((e) => r.has(`${e.turnId} ${e.assistantMessageId}`));
|
|
30
31
|
}
|
|
31
32
|
function F(F, I) {
|
|
32
|
-
let L = F.mode ?? "assistant", R = F.streamBudgetMs ?? O, z = { accumulateNarration: F.accumulateNarration === !0 }, B = F.ttlSeconds ??
|
|
33
|
+
let L = F.mode ?? "assistant", R = F.streamBudgetMs ?? O, z = { accumulateNarration: F.accumulateNarration === !0 }, B = F.ttlSeconds ?? 300, V = F.isProdRuntime ?? (() => !1), H = F.enableCredits ?? !1, U = C("transport", F.product), W = (e) => async (t) => {
|
|
33
34
|
t.messageId && await r(t.workspaceId, t.sessionId, t.messageId, t.model, t.tokens, e, F.product, F.aiCreditLedger);
|
|
34
35
|
}, G = new s({
|
|
35
36
|
product: F.product,
|
|
@@ -338,6 +338,10 @@ export * from './ui/composer/AssistantComposer';
|
|
|
338
338
|
export * from './ui/composer/AssistantCompactFooter';
|
|
339
339
|
export * from './env';
|
|
340
340
|
export * from './useAssistantHeartbeat';
|
|
341
|
+
export * from './keepAlive';
|
|
342
|
+
export * from './signInWarm';
|
|
343
|
+
export * from './useAssistantSignInWarm';
|
|
344
|
+
export * from './staleSession';
|
|
341
345
|
export * from './useAssistantKeyboardShortcuts';
|
|
342
346
|
export * from './ui/AssistantApiCallsConsentDialog';
|
|
343
347
|
export * from './ui/AssistantChatArea';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ★★ BOFF-12187 — how long an assistant sandbox lives, and what keeps it alive.
|
|
3
|
+
*
|
|
4
|
+
* Operator decision (2026-11-11): the assistant must answer fast, so a sandbox
|
|
5
|
+
* is warmed as soon as a signed-in person loads the app — but it must not be
|
|
6
|
+
* kept warm for long. It lives while the person is ACTIVE and expires after
|
|
7
|
+
* five minutes without activity.
|
|
8
|
+
*
|
|
9
|
+
* Three rules make that true everywhere a sandbox is created or extended:
|
|
10
|
+
*
|
|
11
|
+
* 1. Every sandbox is created with `ASSISTANT_IDLE_TTL_SECONDS` (300 s).
|
|
12
|
+
* 2. Every extension asks for the same 300 s from now. The service and the
|
|
13
|
+
* Worker both treat it as "at least this long from now" and never shorten
|
|
14
|
+
* an expiry, so an extension only ever buys the next five minutes.
|
|
15
|
+
* 3. Nothing extends a sandbox unless the person was active SINCE THE LAST
|
|
16
|
+
* EXTENSION (`assistantActivitySince`): they touched the visible page
|
|
17
|
+
* (pointer, key, wheel, touch, focus), or a turn is running. A panel left
|
|
18
|
+
* open on an idle tab no longer keeps its sandbox alive.
|
|
19
|
+
*
|
|
20
|
+
* Extensions run once a minute, so the last one lands at most a minute after
|
|
21
|
+
* the last activity, and the sandbox dies roughly five to six minutes after it
|
|
22
|
+
* (the Worker reaps expired records once a minute, and persists an extension
|
|
23
|
+
* only when less than four minutes are left). When the person comes back, the
|
|
24
|
+
* first activity re-warms it while they are still reading or typing.
|
|
25
|
+
*
|
|
26
|
+
* The tracker is module state, installed once on first use, because the panel
|
|
27
|
+
* unmounts on minimise and the overlay and the widget each need the same view.
|
|
28
|
+
*/
|
|
29
|
+
/** TTL every assistant sandbox is created and extended with. */
|
|
30
|
+
export declare const ASSISTANT_IDLE_TTL_SECONDS = 300;
|
|
31
|
+
/** No activity for this long and nothing extends the sandbox any more. */
|
|
32
|
+
export declare const ASSISTANT_IDLE_WINDOW_MS: number;
|
|
33
|
+
/**
|
|
34
|
+
* How often a live sandbox is extended while the person is active. Well under
|
|
35
|
+
* the Worker's 4-minute refresh floor, so an active sandbox is never reaped.
|
|
36
|
+
*/
|
|
37
|
+
export declare const ASSISTANT_KEEP_ALIVE_INTERVAL_MS = 60000;
|
|
38
|
+
/** Activity events closer together than this are one event. */
|
|
39
|
+
export declare const ACTIVITY_THROTTLE_MS = 5000;
|
|
40
|
+
type ActivityListener = (event: {
|
|
41
|
+
resumed: boolean;
|
|
42
|
+
at: number;
|
|
43
|
+
}) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Record activity now. Listeners hear about it at most once per
|
|
46
|
+
* `ACTIVITY_THROTTLE_MS`; `resumed` is true when the person had been idle for
|
|
47
|
+
* the whole idle window, which is when a sandbox has to be warmed again.
|
|
48
|
+
*/
|
|
49
|
+
export declare function noteAssistantUserActivity(now?: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Is the person active? Visible page and activity inside the idle window, or a
|
|
52
|
+
* turn running (`holdAssistantActivity`): a person waiting for an answer is
|
|
53
|
+
* not idle, even with their hands off the keyboard.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isAssistantUserActive(now?: number): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Was the person active after `at`? True while a turn runs. The keep-alive asks
|
|
58
|
+
* this with the time of its previous extension, so an idle person stops
|
|
59
|
+
* extending at once instead of a full idle window later.
|
|
60
|
+
*/
|
|
61
|
+
export declare function assistantActivitySince(at: number): boolean;
|
|
62
|
+
/** When the person was last active (ms since epoch). */
|
|
63
|
+
export declare function lastAssistantUserActivityAt(): number;
|
|
64
|
+
/**
|
|
65
|
+
* Count the person as active until the returned function is called — for the
|
|
66
|
+
* length of a turn. Idempotent release. Releasing records activity, so the
|
|
67
|
+
* idle window starts when the answer arrives, not when the question was sent.
|
|
68
|
+
*/
|
|
69
|
+
export declare function holdAssistantActivity(): () => void;
|
|
70
|
+
/** Hear about activity. The DOM listeners live only while someone listens. */
|
|
71
|
+
export declare function subscribeAssistantActivity(listener: ActivityListener): () => void;
|
|
72
|
+
/** Tests only: start from a known state. */
|
|
73
|
+
export declare function resetAssistantActivityForTest(now?: number): void;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/shared/assistant/keepAlive.ts
|
|
2
|
+
var e = 300, t = 3e5, n = 6e4, r = 5e3, i = [
|
|
3
|
+
"pointerdown",
|
|
4
|
+
"keydown",
|
|
5
|
+
"wheel",
|
|
6
|
+
"touchstart",
|
|
7
|
+
"focus"
|
|
8
|
+
], a = {
|
|
9
|
+
lastActivityAt: Date.now(),
|
|
10
|
+
lastNotifiedAt: 0,
|
|
11
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
12
|
+
installed: !1,
|
|
13
|
+
holds: 0
|
|
14
|
+
};
|
|
15
|
+
function o() {
|
|
16
|
+
return typeof document > "u" || document.visibilityState !== "hidden";
|
|
17
|
+
}
|
|
18
|
+
function s(e = Date.now()) {
|
|
19
|
+
let n = e - a.lastActivityAt >= t;
|
|
20
|
+
if (a.lastActivityAt = Math.max(a.lastActivityAt, e), !(!n && e - a.lastNotifiedAt < 5e3)) {
|
|
21
|
+
a.lastNotifiedAt = e;
|
|
22
|
+
for (let t of [...a.listeners]) try {
|
|
23
|
+
t({
|
|
24
|
+
resumed: n,
|
|
25
|
+
at: e
|
|
26
|
+
});
|
|
27
|
+
} catch {}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function c(e = Date.now()) {
|
|
31
|
+
return a.holds > 0 || o() && e - a.lastActivityAt < 3e5;
|
|
32
|
+
}
|
|
33
|
+
function l(e) {
|
|
34
|
+
return a.holds > 0 || o() && a.lastActivityAt > e;
|
|
35
|
+
}
|
|
36
|
+
function u() {
|
|
37
|
+
return a.lastActivityAt;
|
|
38
|
+
}
|
|
39
|
+
function d() {
|
|
40
|
+
a.holds += 1;
|
|
41
|
+
let e = !1;
|
|
42
|
+
return () => {
|
|
43
|
+
e || (e = !0, a.holds = Math.max(0, a.holds - 1), s());
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function f() {
|
|
47
|
+
s();
|
|
48
|
+
}
|
|
49
|
+
function p() {
|
|
50
|
+
o() && s();
|
|
51
|
+
}
|
|
52
|
+
function m() {
|
|
53
|
+
if (!(a.installed || typeof window > "u")) {
|
|
54
|
+
a.installed = !0;
|
|
55
|
+
for (let e of i) window.addEventListener(e, f, {
|
|
56
|
+
capture: !0,
|
|
57
|
+
passive: !0
|
|
58
|
+
});
|
|
59
|
+
typeof document < "u" && document.addEventListener("visibilitychange", p);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function h() {
|
|
63
|
+
if (a.installed && typeof window < "u") {
|
|
64
|
+
a.installed = !1;
|
|
65
|
+
for (let e of i) window.removeEventListener(e, f, { capture: !0 });
|
|
66
|
+
typeof document < "u" && document.removeEventListener("visibilitychange", p);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function g(e) {
|
|
70
|
+
return a.listeners.add(e), m(), () => {
|
|
71
|
+
a.listeners.delete(e), a.listeners.size === 0 && h();
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function _(e = Date.now()) {
|
|
75
|
+
h(), a.lastActivityAt = e, a.lastNotifiedAt = 0, a.listeners.clear(), a.holds = 0;
|
|
76
|
+
}
|
|
77
|
+
export { r as ACTIVITY_THROTTLE_MS, e as ASSISTANT_IDLE_TTL_SECONDS, t as ASSISTANT_IDLE_WINDOW_MS, n as ASSISTANT_KEEP_ALIVE_INTERVAL_MS, l as assistantActivitySince, d as holdAssistantActivity, c as isAssistantUserActive, u as lastAssistantUserActivityAt, s as noteAssistantUserActivity, _ as resetAssistantActivityForTest, g as subscribeAssistantActivity };
|
|
@@ -229,6 +229,26 @@ export declare function claimPreopenedSession(key: string, now: number): {
|
|
|
229
229
|
} | null;
|
|
230
230
|
/** A sandbox was proved dead, cleared or retired: nothing opened on it is adopted. */
|
|
231
231
|
export declare function dropPreopenedFor(sandboxId: string): void;
|
|
232
|
+
/**
|
|
233
|
+
* Longer than the panel's own 60 s window because the keep-alive renews it
|
|
234
|
+
* every minute while the person is active; a sandbox it vouches for has at
|
|
235
|
+
* least four minutes of TTL left.
|
|
236
|
+
*/
|
|
237
|
+
export declare const WARM_PROOF_TTL_MS = 90000;
|
|
238
|
+
/** The sandbox answered its `/health` now. */
|
|
239
|
+
export declare function recordWarmProof(sandboxId: string, now?: number): void;
|
|
240
|
+
/** A warm or keep-alive proved this sandbox within `WARM_PROOF_TTL_MS`. */
|
|
241
|
+
export declare function hasFreshWarmProof(sandboxId: string, now?: number): boolean;
|
|
242
|
+
export declare function dropWarmProof(sandboxId: string | null | undefined): void;
|
|
243
|
+
/**
|
|
244
|
+
* The panel's readiness record, also trusting warm proofs. A proof never
|
|
245
|
+
* outranks a failure: invalidating drops both, so a sandbox that failed a turn
|
|
246
|
+
* is probed again whoever vouched for it.
|
|
247
|
+
*/
|
|
248
|
+
export declare function withWarmProofs<T extends {
|
|
249
|
+
isFresh(sandboxId: string): boolean;
|
|
250
|
+
invalidate(sandboxId: string | null | undefined): void;
|
|
251
|
+
}>(tracker: T): T;
|
|
232
252
|
/**
|
|
233
253
|
* The sandboxes a panel has proved dead (`deadSandboxIds`), which it never
|
|
234
254
|
* selects again. Adding one ALSO drops every session pre-opened on it, so that
|
|
@@ -110,7 +110,7 @@ function p(e, t, n) {
|
|
|
110
110
|
}
|
|
111
111
|
function m() {
|
|
112
112
|
for (let e of a.values()) e.controller.abort();
|
|
113
|
-
a.clear(), o.clear(), s.clear(), c.clear(), _.clear();
|
|
113
|
+
a.clear(), o.clear(), s.clear(), c.clear(), _.clear(), T.clear();
|
|
114
114
|
}
|
|
115
115
|
var h = 6e5, g = 8, _ = /* @__PURE__ */ new Map();
|
|
116
116
|
function v(e) {
|
|
@@ -150,13 +150,34 @@ function S(e, t) {
|
|
|
150
150
|
}
|
|
151
151
|
function C(e) {
|
|
152
152
|
for (let t of [..._.keys()]) t.split("\0")[2] === e && _.delete(t);
|
|
153
|
+
T.delete(e);
|
|
153
154
|
}
|
|
154
|
-
var w =
|
|
155
|
+
var w = 9e4, T = /* @__PURE__ */ new Map();
|
|
156
|
+
function E(e, t = Date.now()) {
|
|
157
|
+
T.size >= 32 && !T.has(e) && T.clear(), T.set(e, t);
|
|
158
|
+
}
|
|
159
|
+
function D(e, t = Date.now()) {
|
|
160
|
+
let n = T.get(e);
|
|
161
|
+
return n !== void 0 && n <= t && t - n < 9e4;
|
|
162
|
+
}
|
|
163
|
+
function O(e) {
|
|
164
|
+
e && T.delete(e);
|
|
165
|
+
}
|
|
166
|
+
function k(e) {
|
|
167
|
+
return {
|
|
168
|
+
...e,
|
|
169
|
+
isFresh: (t) => e.isFresh(t) || D(t),
|
|
170
|
+
invalidate: (t) => {
|
|
171
|
+
e.invalidate(t), O(t);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
var A = class extends Set {
|
|
155
176
|
add(e) {
|
|
156
177
|
return C(e), super.add(e);
|
|
157
178
|
}
|
|
158
179
|
};
|
|
159
|
-
function
|
|
180
|
+
function j() {
|
|
160
181
|
return _.size;
|
|
161
182
|
}
|
|
162
|
-
export { h as PREOPEN_MAX_AGE_MS, g as PREOPEN_MAX_ENTRIES, n as PREWARM_COOLDOWN_MS,
|
|
183
|
+
export { h as PREOPEN_MAX_AGE_MS, g as PREOPEN_MAX_ENTRIES, n as PREWARM_COOLDOWN_MS, A as QuarantineSet, w as WARM_PROOF_TTL_MS, i as WarmCancelled, S as claimPreopenedSession, p as consumeWarm, C as dropPreopenedFor, O as dropWarmProof, D as hasFreshWarmProof, v as preopenKey, y as preopenWanted, j as preopenedCountForTest, r as prewarmTarget, E as recordWarmProof, m as resetWarmsForTest, f as settleWarmBeforeSend, x as startPreopen, d as startWarm, u as warmState, k as withWarmProofs };
|
|
@@ -15,7 +15,7 @@ export declare class AssistantRuntimeManager {
|
|
|
15
15
|
private readonly quarantinedSandboxIds;
|
|
16
16
|
private inFlight;
|
|
17
17
|
private keepWarmTimer;
|
|
18
|
-
private
|
|
18
|
+
private stopActivity;
|
|
19
19
|
constructor(deps: RuntimeDeps);
|
|
20
20
|
private key;
|
|
21
21
|
private persist;
|
|
@@ -30,7 +30,12 @@ export declare class AssistantRuntimeManager {
|
|
|
30
30
|
}>;
|
|
31
31
|
/** Intent pre-warm. 'probe' never creates a paid sandbox; 'full' provisions. */
|
|
32
32
|
prewarm(level?: PrewarmLevel): void;
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Keep the runtime alive while the person is active (BOFF-12187): once a
|
|
35
|
+
* minute, and at once when they come back to the page, but only after
|
|
36
|
+
* activity since the last extension (`keepAssistantSandboxAlive`). An idle
|
|
37
|
+
* page stops extending, and the sandbox lapses five minutes later.
|
|
38
|
+
*/
|
|
34
39
|
startKeepWarm(): void;
|
|
35
40
|
stopKeepWarm(): void;
|
|
36
41
|
getSandboxId(): string | null;
|