@burdenoff/fe-libs 2026.1021.10 → 2026.1021.11
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 +2 -5
- package/dist/shared/assistant/api.js +21 -6
- package/dist/shared/assistant/conversation.d.ts +2 -5
- package/dist/shared/assistant/product.d.ts +2 -5
- package/dist/shared/assistant/turnProgress.d.ts +2 -5
- package/dist/shared/assistant/types.d.ts +10 -4
- package/dist/shared/assistant/usageReporting.d.ts +2 -4
- package/dist/shared/assistant/usageReporting.js +14 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AssistantUiCatalogue } from './uiActions/uiCatalogue';
|
|
2
|
-
import { AssistantMode, AssistantPromptPart, AssistantRawMessage, AssistantSandboxAuthContext, AssistantArtifact, AssistantSessionInfo, DownloadedAssistantArtifact, StreamAccess } from './types';
|
|
2
|
+
import { AssistantMode, AssistantPromptPart, AssistantRawMessage, AssistantTokenUsage, AssistantSandboxAuthContext, AssistantArtifact, AssistantSessionInfo, DownloadedAssistantArtifact, StreamAccess } from './types';
|
|
3
3
|
import { SandboxWriteCapabilities, WriteApprovalMode, WriteExecutionState } from './writeProposals';
|
|
4
4
|
import { WriteReplyKind, WriteReplyOrigin } from './writeReplyBinder';
|
|
5
5
|
/**
|
|
@@ -568,7 +568,4 @@ export declare function downloadAssistantArtifact(sandboxId: string, workspaceId
|
|
|
568
568
|
*/
|
|
569
569
|
mode: AssistantMode | undefined, authContext: AssistantSandboxAuthContext): Promise<DownloadedAssistantArtifact>;
|
|
570
570
|
export declare function checkAssistantAiCredits(workspaceId: string, authContext: AssistantSandboxAuthContext): Promise<boolean>;
|
|
571
|
-
export declare function reportAssistantAiTokenUsage(workspaceId: string, sessionId: string, messageId: string, model: string | undefined, tokens:
|
|
572
|
-
input: number;
|
|
573
|
-
output: number;
|
|
574
|
-
}, authContext: AssistantSandboxAuthContext): Promise<void>;
|
|
571
|
+
export declare function reportAssistantAiTokenUsage(workspaceId: string, sessionId: string, messageId: string, model: string | undefined, tokens: AssistantTokenUsage, authContext: AssistantSandboxAuthContext): Promise<void>;
|
|
@@ -594,20 +594,35 @@ async function We(e, t) {
|
|
|
594
594
|
authContext: t
|
|
595
595
|
})).checkAiCredits;
|
|
596
596
|
}
|
|
597
|
-
async function Ge(e, t, n, r,
|
|
598
|
-
let
|
|
599
|
-
|
|
597
|
+
async function Ge(e, t, n, r, o, s) {
|
|
598
|
+
let c = Math.max(0, Math.round(o.input ?? 0)), l = Math.max(0, Math.round(o.output ?? 0)), u = Math.max(0, Math.round(o.cache?.read ?? 0)), d = Math.max(0, Math.round(o.cache?.write ?? 0));
|
|
599
|
+
if (c + l + u + d === 0 || !r) return;
|
|
600
|
+
let f = !1;
|
|
601
|
+
if (o.cache) try {
|
|
602
|
+
f = (await i({
|
|
603
|
+
query: "query AiCacheTokensSupported { aiCacheTokensSupported }",
|
|
604
|
+
operationName: "AiCacheTokensSupported",
|
|
605
|
+
variables: {},
|
|
606
|
+
workspaceId: e,
|
|
607
|
+
authContext: s
|
|
608
|
+
})).aiCacheTokensSupported === !0;
|
|
609
|
+
} catch {}
|
|
610
|
+
await a({
|
|
600
611
|
query: ee,
|
|
601
612
|
operationName: "ReportAiTokenUsage",
|
|
602
613
|
variables: { input: {
|
|
603
614
|
sessionId: t,
|
|
604
615
|
messageId: n,
|
|
605
616
|
model: r,
|
|
606
|
-
inputTokens:
|
|
607
|
-
outputTokens:
|
|
617
|
+
inputTokens: c,
|
|
618
|
+
outputTokens: l,
|
|
619
|
+
...f ? {
|
|
620
|
+
cacheReadTokens: u,
|
|
621
|
+
cacheWriteTokens: d
|
|
622
|
+
} : {}
|
|
608
623
|
} },
|
|
609
624
|
workspaceId: e,
|
|
610
|
-
authContext:
|
|
625
|
+
authContext: s
|
|
611
626
|
});
|
|
612
627
|
}
|
|
613
628
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PendingWrite } from './pendingWrite';
|
|
2
2
|
import { WriteProposalMessageRef } from './writeProposalDiscovery';
|
|
3
3
|
import { AssistantMessageAttachment } from './attachments';
|
|
4
|
-
import { AssistantMode } from './types';
|
|
4
|
+
import { AssistantMode, AssistantTokenUsage } from './types';
|
|
5
5
|
export type AssistantSandboxStatus = "none" | "provisioning" | "running" | "stopping" | "error";
|
|
6
6
|
export type AssistantConversationStatus = "idle" | "provisioning" | "connecting" | "streaming" | "complete" | "error";
|
|
7
7
|
/**
|
|
@@ -259,10 +259,7 @@ export interface Message {
|
|
|
259
259
|
role: "user" | "assistant" | "system";
|
|
260
260
|
content: string;
|
|
261
261
|
timestamp: string;
|
|
262
|
-
tokens?:
|
|
263
|
-
input: number;
|
|
264
|
-
output: number;
|
|
265
|
-
};
|
|
262
|
+
tokens?: AssistantTokenUsage;
|
|
266
263
|
metadata?: AssistantMessageMetadata;
|
|
267
264
|
/**
|
|
268
265
|
* ★ BOFF-7335: where this message stands with server history — `pending`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LocalUiCommandOptions } from './localUiCommands';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { AssistantModeConfig } from './conversation';
|
|
4
|
-
import { AssistantMode, PageContext } from './types';
|
|
4
|
+
import { AssistantMode, AssistantTokenUsage, PageContext } from './types';
|
|
5
5
|
import { WriteApprovalMode, WriteProposalView } from './writeProposals';
|
|
6
6
|
/**
|
|
7
7
|
* The sixth argument of `buildPrompt` (BOFF-7803 5a, design §3.5): which write
|
|
@@ -100,10 +100,7 @@ export interface AssistantProductCapabilities {
|
|
|
100
100
|
sessionId: string;
|
|
101
101
|
messageId?: string;
|
|
102
102
|
model?: string;
|
|
103
|
-
tokens:
|
|
104
|
-
input: number;
|
|
105
|
-
output: number;
|
|
106
|
-
};
|
|
103
|
+
tokens: AssistantTokenUsage;
|
|
107
104
|
}) => Promise<void>;
|
|
108
105
|
/**
|
|
109
106
|
* Where the assistant's files land in the workspace file library.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PendingWrite } from './pendingWrite';
|
|
2
2
|
import { AssistantProgressOptions } from './progress';
|
|
3
|
-
import { AssistantRawMessage } from './types';
|
|
3
|
+
import { AssistantRawMessage, AssistantTokenUsage } from './types';
|
|
4
4
|
/** What one poll of the sandbox says this turn has produced so far. */
|
|
5
5
|
export interface AssistantTurnProgress {
|
|
6
6
|
/**
|
|
@@ -35,10 +35,7 @@ export interface AssistantTurnProgress {
|
|
|
35
35
|
*/
|
|
36
36
|
usedTools?: boolean;
|
|
37
37
|
done: boolean;
|
|
38
|
-
tokens?:
|
|
39
|
-
input: number;
|
|
40
|
-
output: number;
|
|
41
|
-
};
|
|
38
|
+
tokens?: AssistantTokenUsage;
|
|
42
39
|
/**
|
|
43
40
|
* Identity + model of the message these tokens came from, needed to charge the
|
|
44
41
|
* turn: `messageId` is half the server's idempotency hash and `model` selects the
|
|
@@ -104,6 +104,15 @@ export type AssistantPromptPart = {
|
|
|
104
104
|
data?: string;
|
|
105
105
|
name?: string;
|
|
106
106
|
};
|
|
107
|
+
/** Runtime input excludes the separately reported provider cache counts. */
|
|
108
|
+
export interface AssistantTokenUsage {
|
|
109
|
+
input: number;
|
|
110
|
+
output: number;
|
|
111
|
+
cache?: {
|
|
112
|
+
read?: number;
|
|
113
|
+
write?: number;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
107
116
|
export interface AssistantRawMessage {
|
|
108
117
|
info?: {
|
|
109
118
|
id?: string;
|
|
@@ -115,10 +124,7 @@ export interface AssistantRawMessage {
|
|
|
115
124
|
parentID?: string;
|
|
116
125
|
providerID?: string;
|
|
117
126
|
modelID?: string;
|
|
118
|
-
tokens?:
|
|
119
|
-
input: number;
|
|
120
|
-
output: number;
|
|
121
|
-
};
|
|
127
|
+
tokens?: AssistantTokenUsage;
|
|
122
128
|
time?: {
|
|
123
129
|
created?: number;
|
|
124
130
|
completed?: number;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { AssistantSendRefusal } from './turnOutcome';
|
|
2
|
+
import { AssistantTokenUsage } from './types';
|
|
2
3
|
/** One finished turn's charge, as a product's `reportTokenUsage` receives it. */
|
|
3
4
|
export interface UsageReport {
|
|
4
5
|
workspaceId: string;
|
|
5
6
|
sessionId: string;
|
|
6
7
|
messageId?: string;
|
|
7
8
|
model?: string;
|
|
8
|
-
tokens:
|
|
9
|
-
input: number;
|
|
10
|
-
output: number;
|
|
11
|
-
};
|
|
9
|
+
tokens: AssistantTokenUsage;
|
|
12
10
|
}
|
|
13
11
|
/** Sends one report to its ledger. Rejects when the ledger did not record it. */
|
|
14
12
|
export type UsageReporter = (report: UsageReport) => Promise<void>;
|
|
@@ -48,14 +48,26 @@ var v = (e) => typeof e == "number" && Number.isFinite(e) && e >= 0, y = (e) =>
|
|
|
48
48
|
function b(e, t) {
|
|
49
49
|
if (!e || typeof e != "object") return null;
|
|
50
50
|
let n = e, r = n.tokens;
|
|
51
|
-
|
|
51
|
+
if (n.workspaceId !== t || typeof n.sessionId != "string" || n.sessionId.length === 0 || !y(n.messageId) || !y(n.model) || !r || typeof r != "object" || !v(r.input) || !v(r.output)) return null;
|
|
52
|
+
let i;
|
|
53
|
+
if (r.cache !== void 0) {
|
|
54
|
+
if (!r.cache || typeof r.cache != "object" || Array.isArray(r.cache)) return null;
|
|
55
|
+
let e = r.cache;
|
|
56
|
+
if (e.read !== void 0 && !v(e.read) || e.write !== void 0 && !v(e.write)) return null;
|
|
57
|
+
i = {
|
|
58
|
+
...v(e.read) ? { read: e.read } : {},
|
|
59
|
+
...v(e.write) ? { write: e.write } : {}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
52
63
|
workspaceId: t,
|
|
53
64
|
sessionId: n.sessionId,
|
|
54
65
|
...typeof n.messageId == "string" ? { messageId: n.messageId } : {},
|
|
55
66
|
...typeof n.model == "string" ? { model: n.model } : {},
|
|
56
67
|
tokens: {
|
|
57
68
|
input: r.input,
|
|
58
|
-
output: r.output
|
|
69
|
+
output: r.output,
|
|
70
|
+
...i ? { cache: i } : {}
|
|
59
71
|
}
|
|
60
72
|
};
|
|
61
73
|
}
|