@opengeni/contracts 3.2.2 → 3.4.0
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/atlassian.js +1 -1
- package/dist/billing-subscriptions.d.ts +59 -0
- package/dist/{chunk-B2G6NXLZ.js → chunk-J6VQQPIL.js} +6445 -6257
- package/dist/chunk-J6VQQPIL.js.map +1 -0
- package/dist/{chunk-KLG2MBAU.js → chunk-KA6B6I6O.js} +2 -2
- package/dist/connect.js +1 -1
- package/dist/connection-authority.js +2 -2
- package/dist/google-drive.js +1 -1
- package/dist/host-mcp-bindings.js +2 -2
- package/dist/index.d.ts +28 -0
- package/dist/index.js +29 -1
- package/dist/insights-usage.d.ts +57 -0
- package/dist/insights-usage.js +30 -0
- package/dist/insights-usage.js.map +1 -1
- package/dist/interaction.d.ts +270 -0
- package/dist/personal-github.js +1 -1
- package/dist/subscription-plans.d.ts +35 -0
- package/package.json +1 -1
- package/src/billing-subscriptions.ts +47 -0
- package/src/index.ts +19 -0
- package/src/insights-usage.ts +38 -0
- package/src/interaction.ts +142 -0
- package/src/subscription-plans.ts +43 -0
- package/dist/chunk-B2G6NXLZ.js.map +0 -1
- /package/dist/{chunk-KLG2MBAU.js.map → chunk-KA6B6I6O.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConnectionKind,
|
|
3
3
|
SessionTenancyVisibility
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-J6VQQPIL.js";
|
|
5
5
|
import {
|
|
6
6
|
defineSchema
|
|
7
7
|
} from "./chunk-56SNIMDO.js";
|
|
@@ -204,4 +204,4 @@ export {
|
|
|
204
204
|
ConnectionUseAuditFact,
|
|
205
205
|
ConnectionUseAuthorizationResult
|
|
206
206
|
};
|
|
207
|
-
//# sourceMappingURL=chunk-
|
|
207
|
+
//# sourceMappingURL=chunk-KA6B6I6O.js.map
|
package/dist/connect.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
ConnectionUseAuthorizationResult,
|
|
7
7
|
ConnectionUseDenialReason,
|
|
8
8
|
ConnectionUseSelectionSource
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-KA6B6I6O.js";
|
|
10
|
+
import "./chunk-J6VQQPIL.js";
|
|
11
11
|
import "./chunk-EFZYKUE2.js";
|
|
12
12
|
import "./chunk-Z7WEVGCL.js";
|
|
13
13
|
import "./chunk-LZ2LAHIX.js";
|
package/dist/google-drive.js
CHANGED
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
} from "./chunk-HABQ7ADB.js";
|
|
4
4
|
import {
|
|
5
5
|
ConnectionUseAuthoritySnapshot
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KA6B6I6O.js";
|
|
7
7
|
import {
|
|
8
8
|
HostMcpCreateSelections,
|
|
9
9
|
ManagedUserResourceGrantMode,
|
|
10
10
|
McpServerConnectionRef,
|
|
11
11
|
SessionTenancyVisibility,
|
|
12
12
|
stableJson
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-J6VQQPIL.js";
|
|
14
14
|
import "./chunk-EFZYKUE2.js";
|
|
15
15
|
import "./chunk-Z7WEVGCL.js";
|
|
16
16
|
import "./chunk-LZ2LAHIX.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -7442,6 +7442,8 @@ export declare const PromotionalCreditBalance: z.ZodObject<{
|
|
|
7442
7442
|
coversVoice: z.ZodOptional<z.ZodBoolean>;
|
|
7443
7443
|
}, z.core.$strip>;
|
|
7444
7444
|
export type PromotionalCreditBalance = z.infer<typeof PromotionalCreditBalance>;
|
|
7445
|
+
export { SubscriptionPlan, SubscriptionPlanCatalog, BillingPlanBalance, } from "./subscription-plans.js";
|
|
7446
|
+
export { BillingSubscriptionCatalog, CreateSubscriptionCheckoutRequest, CreateSubscriptionCheckoutResponse, ChangeBillingSubscriptionRequest, CancelBillingSubscriptionRequest, BillingSubscriptionChange, } from "./billing-subscriptions.js";
|
|
7445
7447
|
export declare const BillingBalance: z.ZodObject<{
|
|
7446
7448
|
accountId: z.ZodString;
|
|
7447
7449
|
balanceMicros: z.ZodNumber;
|
|
@@ -7455,6 +7457,18 @@ export declare const BillingBalance: z.ZodObject<{
|
|
|
7455
7457
|
remainingMicros: z.ZodNumber;
|
|
7456
7458
|
coversVoice: z.ZodOptional<z.ZodBoolean>;
|
|
7457
7459
|
}, z.core.$strip>>>;
|
|
7460
|
+
plan: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
7461
|
+
key: z.ZodString;
|
|
7462
|
+
label: z.ZodString;
|
|
7463
|
+
status: z.ZodString;
|
|
7464
|
+
creditGrantedMicros: z.ZodNumber;
|
|
7465
|
+
creditRemainingMicros: z.ZodNumber;
|
|
7466
|
+
creditPendingExpiryMicros: z.ZodOptional<z.ZodNumber>;
|
|
7467
|
+
periodResetAt: z.ZodNullable<z.ZodString>;
|
|
7468
|
+
seatLimit: z.ZodNullable<z.ZodNumber>;
|
|
7469
|
+
seatsUsed: z.ZodNumber;
|
|
7470
|
+
cancelAtPeriodEnd: z.ZodBoolean;
|
|
7471
|
+
}, z.core.$strip>>>;
|
|
7458
7472
|
}, z.core.$strip>;
|
|
7459
7473
|
export type BillingBalance = z.infer<typeof BillingBalance>;
|
|
7460
7474
|
export declare const CreateCheckoutRequest: z.ZodObject<{
|
|
@@ -7513,6 +7527,18 @@ export declare const BillingCheckoutStatus: z.ZodObject<{
|
|
|
7513
7527
|
remainingMicros: z.ZodNumber;
|
|
7514
7528
|
coversVoice: z.ZodOptional<z.ZodBoolean>;
|
|
7515
7529
|
}, z.core.$strip>>>;
|
|
7530
|
+
plan: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
7531
|
+
key: z.ZodString;
|
|
7532
|
+
label: z.ZodString;
|
|
7533
|
+
status: z.ZodString;
|
|
7534
|
+
creditGrantedMicros: z.ZodNumber;
|
|
7535
|
+
creditRemainingMicros: z.ZodNumber;
|
|
7536
|
+
creditPendingExpiryMicros: z.ZodOptional<z.ZodNumber>;
|
|
7537
|
+
periodResetAt: z.ZodNullable<z.ZodString>;
|
|
7538
|
+
seatLimit: z.ZodNullable<z.ZodNumber>;
|
|
7539
|
+
seatsUsed: z.ZodNumber;
|
|
7540
|
+
cancelAtPeriodEnd: z.ZodBoolean;
|
|
7541
|
+
}, z.core.$strip>>>;
|
|
7516
7542
|
}, z.core.$strip>>;
|
|
7517
7543
|
}, z.core.$strip>;
|
|
7518
7544
|
export type BillingCheckoutStatus = z.infer<typeof BillingCheckoutStatus>;
|
|
@@ -35652,6 +35678,7 @@ export declare const SessionListResponse: z.ZodObject<{
|
|
|
35652
35678
|
filtersApplied: z.ZodOptional<z.ZodLiteral<true>>;
|
|
35653
35679
|
needsYouOnly: z.ZodOptional<z.ZodLiteral<true>>;
|
|
35654
35680
|
contentArchivedOnly: z.ZodOptional<z.ZodLiteral<true>>;
|
|
35681
|
+
mineOnly: z.ZodOptional<z.ZodLiteral<true>>;
|
|
35655
35682
|
totals: z.ZodOptional<z.ZodObject<{
|
|
35656
35683
|
needsYouCount: z.ZodNumber;
|
|
35657
35684
|
groups: z.ZodArray<z.ZodObject<{
|
|
@@ -37030,6 +37057,7 @@ export declare const SessionListEntryResponse: z.ZodObject<{
|
|
|
37030
37057
|
filtersApplied: z.ZodOptional<z.ZodLiteral<true>>;
|
|
37031
37058
|
needsYouOnly: z.ZodOptional<z.ZodLiteral<true>>;
|
|
37032
37059
|
contentArchivedOnly: z.ZodOptional<z.ZodLiteral<true>>;
|
|
37060
|
+
mineOnly: z.ZodOptional<z.ZodLiteral<true>>;
|
|
37033
37061
|
totals: z.ZodOptional<z.ZodObject<{
|
|
37034
37062
|
needsYouCount: z.ZodNumber;
|
|
37035
37063
|
groups: z.ZodArray<z.ZodObject<{
|
package/dist/index.js
CHANGED
|
@@ -190,6 +190,9 @@ import {
|
|
|
190
190
|
BillingBalance,
|
|
191
191
|
BillingCheckoutStatus,
|
|
192
192
|
BillingMode,
|
|
193
|
+
BillingPlanBalance,
|
|
194
|
+
BillingSubscriptionCatalog,
|
|
195
|
+
BillingSubscriptionChange,
|
|
193
196
|
BrowserAction,
|
|
194
197
|
BrowserActionBatch,
|
|
195
198
|
BrowserActionCommand,
|
|
@@ -249,6 +252,11 @@ import {
|
|
|
249
252
|
BrowserTarget,
|
|
250
253
|
BrowserTargetListResponse,
|
|
251
254
|
BrowserTargetState,
|
|
255
|
+
BrowserWorkingCopyAdoption,
|
|
256
|
+
BrowserWorkingCopyAdoptionRequest,
|
|
257
|
+
BrowserWorkingCopyAdoptionResponse,
|
|
258
|
+
BrowserWorkingCopyInspection,
|
|
259
|
+
BrowserWorkingCopyRefusal,
|
|
252
260
|
BrowserWorkspaceFileAuthority,
|
|
253
261
|
BrowserWorkspaceFileStageRequest,
|
|
254
262
|
BrowserWorkspaceFileStageResponse,
|
|
@@ -301,6 +309,7 @@ import {
|
|
|
301
309
|
CUA_DESKTOP_TOOLS,
|
|
302
310
|
CUA_LINUX_DESKTOP_TOOLS,
|
|
303
311
|
CUA_WINDOWS_DESKTOP_TOOLS,
|
|
312
|
+
CancelBillingSubscriptionRequest,
|
|
304
313
|
CancelSessionBackgroundCommandResult,
|
|
305
314
|
CapabilityAction,
|
|
306
315
|
CapabilityCatalogAuthKind,
|
|
@@ -317,6 +326,7 @@ import {
|
|
|
317
326
|
CapabilityRuntime,
|
|
318
327
|
CapabilitySource,
|
|
319
328
|
CapabilityUnavailableReason,
|
|
329
|
+
ChangeBillingSubscriptionRequest,
|
|
320
330
|
ChangeMachineAudienceRequest,
|
|
321
331
|
ChangeMachineAudienceResponse,
|
|
322
332
|
ChangePreferenceRegistryScopeRequest,
|
|
@@ -513,6 +523,8 @@ import {
|
|
|
513
523
|
CreateSiteAuthConnectionRequest,
|
|
514
524
|
CreateSocialConnectionRequest,
|
|
515
525
|
CreateSocialPostRequest,
|
|
526
|
+
CreateSubscriptionCheckoutRequest,
|
|
527
|
+
CreateSubscriptionCheckoutResponse,
|
|
516
528
|
CreateTranscriptionRecordingRequest,
|
|
517
529
|
CreateVariableSetRequest,
|
|
518
530
|
CreateWorkspaceArtifactRequest,
|
|
@@ -1835,6 +1847,8 @@ import {
|
|
|
1835
1847
|
SubscriptionAccountSummary,
|
|
1836
1848
|
SubscriptionAccountToggleRequest,
|
|
1837
1849
|
SubscriptionConnectPollRequest,
|
|
1850
|
+
SubscriptionPlan,
|
|
1851
|
+
SubscriptionPlanCatalog,
|
|
1838
1852
|
SubscriptionPoolSettings,
|
|
1839
1853
|
SubscriptionRotationSettingsRequest,
|
|
1840
1854
|
SupergrokConnectStartRequest,
|
|
@@ -2541,7 +2555,7 @@ import {
|
|
|
2541
2555
|
workspaceModelCompactionThreshold,
|
|
2542
2556
|
workspaceSettingsAllowCreditModels,
|
|
2543
2557
|
workspaceSlackReactionChannelAllowed
|
|
2544
|
-
} from "./chunk-
|
|
2558
|
+
} from "./chunk-J6VQQPIL.js";
|
|
2545
2559
|
import {
|
|
2546
2560
|
COMPUTER_SCREENSHOT_MAX_BYTES,
|
|
2547
2561
|
COMPUTER_SCREENSHOT_MAX_DIMENSION,
|
|
@@ -3330,6 +3344,9 @@ export {
|
|
|
3330
3344
|
BillingBalance,
|
|
3331
3345
|
BillingCheckoutStatus,
|
|
3332
3346
|
BillingMode,
|
|
3347
|
+
BillingPlanBalance,
|
|
3348
|
+
BillingSubscriptionCatalog,
|
|
3349
|
+
BillingSubscriptionChange,
|
|
3333
3350
|
BrowserAction,
|
|
3334
3351
|
BrowserActionBatch,
|
|
3335
3352
|
BrowserActionCommand,
|
|
@@ -3389,6 +3406,11 @@ export {
|
|
|
3389
3406
|
BrowserTarget,
|
|
3390
3407
|
BrowserTargetListResponse,
|
|
3391
3408
|
BrowserTargetState,
|
|
3409
|
+
BrowserWorkingCopyAdoption,
|
|
3410
|
+
BrowserWorkingCopyAdoptionRequest,
|
|
3411
|
+
BrowserWorkingCopyAdoptionResponse,
|
|
3412
|
+
BrowserWorkingCopyInspection,
|
|
3413
|
+
BrowserWorkingCopyRefusal,
|
|
3392
3414
|
BrowserWorkspaceFileAuthority,
|
|
3393
3415
|
BrowserWorkspaceFileStageRequest,
|
|
3394
3416
|
BrowserWorkspaceFileStageResponse,
|
|
@@ -3459,6 +3481,7 @@ export {
|
|
|
3459
3481
|
CUA_DESKTOP_TOOLS,
|
|
3460
3482
|
CUA_LINUX_DESKTOP_TOOLS,
|
|
3461
3483
|
CUA_WINDOWS_DESKTOP_TOOLS,
|
|
3484
|
+
CancelBillingSubscriptionRequest,
|
|
3462
3485
|
CancelSessionBackgroundCommandResult,
|
|
3463
3486
|
CanonicalHumanBindingOperationRequest,
|
|
3464
3487
|
CanonicalHumanIdentityMutationOutcome,
|
|
@@ -3483,6 +3506,7 @@ export {
|
|
|
3483
3506
|
CapabilityRuntime,
|
|
3484
3507
|
CapabilitySource,
|
|
3485
3508
|
CapabilityUnavailableReason,
|
|
3509
|
+
ChangeBillingSubscriptionRequest,
|
|
3486
3510
|
ChangeMachineAudienceRequest,
|
|
3487
3511
|
ChangeMachineAudienceResponse,
|
|
3488
3512
|
ChangePreferenceRegistryScopeRequest,
|
|
@@ -3699,6 +3723,8 @@ export {
|
|
|
3699
3723
|
CreateSiteAuthConnectionRequest,
|
|
3700
3724
|
CreateSocialConnectionRequest,
|
|
3701
3725
|
CreateSocialPostRequest,
|
|
3726
|
+
CreateSubscriptionCheckoutRequest,
|
|
3727
|
+
CreateSubscriptionCheckoutResponse,
|
|
3702
3728
|
CreateTranscriptionRecordingRequest,
|
|
3703
3729
|
CreateVariableSetRequest,
|
|
3704
3730
|
CreateVaultItemRequest,
|
|
@@ -5274,6 +5300,8 @@ export {
|
|
|
5274
5300
|
SubscriptionAccountToggleRequest,
|
|
5275
5301
|
SubscriptionConnectPollRequest,
|
|
5276
5302
|
SubscriptionPersonalAuthorityV2,
|
|
5303
|
+
SubscriptionPlan,
|
|
5304
|
+
SubscriptionPlanCatalog,
|
|
5277
5305
|
SubscriptionPoolSettings,
|
|
5278
5306
|
SubscriptionRotationSettingsRequest,
|
|
5279
5307
|
SupergrokConnectStartRequest,
|
package/dist/insights-usage.d.ts
CHANGED
|
@@ -9,6 +9,63 @@ export declare const InsightsUsageRange: z.ZodEnum<{
|
|
|
9
9
|
ytd: "ytd";
|
|
10
10
|
}>;
|
|
11
11
|
export type InsightsUsageRange = z.infer<typeof InsightsUsageRange>;
|
|
12
|
+
/** Aggregate Site accounting only: no viewer, session, turn or prompt identities. */
|
|
13
|
+
export declare const InsightsSiteUsageQuery: z.ZodObject<{
|
|
14
|
+
range: z.ZodDefault<z.ZodEnum<{
|
|
15
|
+
"30d": "30d";
|
|
16
|
+
"90d": "90d";
|
|
17
|
+
month: "month";
|
|
18
|
+
today: "today";
|
|
19
|
+
week: "week";
|
|
20
|
+
ytd: "ytd";
|
|
21
|
+
}>>;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
export type InsightsSiteUsageQuery = z.infer<typeof InsightsSiteUsageQuery>;
|
|
24
|
+
export declare const InsightsSiteUsageRow: z.ZodObject<{
|
|
25
|
+
siteId: z.ZodNullable<z.ZodString>;
|
|
26
|
+
title: z.ZodString;
|
|
27
|
+
kind: z.ZodEnum<{
|
|
28
|
+
other: "other";
|
|
29
|
+
restricted: "restricted";
|
|
30
|
+
site: "site";
|
|
31
|
+
}>;
|
|
32
|
+
calls: z.ZodNumber;
|
|
33
|
+
pricedCalls: z.ZodNumber;
|
|
34
|
+
chargedMicros: z.ZodNumber;
|
|
35
|
+
apiEquivalentMicros: z.ZodNumber;
|
|
36
|
+
subscriptionApiEquivalentMicros: z.ZodNumber;
|
|
37
|
+
ownKeyApiEquivalentMicros: z.ZodNumber;
|
|
38
|
+
}, z.core.$strict>;
|
|
39
|
+
export type InsightsSiteUsageRow = z.infer<typeof InsightsSiteUsageRow>;
|
|
40
|
+
export declare const InsightsSiteUsageResponse: z.ZodObject<{
|
|
41
|
+
workspaceId: z.ZodString;
|
|
42
|
+
range: z.ZodDefault<z.ZodEnum<{
|
|
43
|
+
"30d": "30d";
|
|
44
|
+
"90d": "90d";
|
|
45
|
+
month: "month";
|
|
46
|
+
today: "today";
|
|
47
|
+
week: "week";
|
|
48
|
+
ytd: "ytd";
|
|
49
|
+
}>>;
|
|
50
|
+
windowStart: z.ZodString;
|
|
51
|
+
windowEnd: z.ZodString;
|
|
52
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
53
|
+
siteId: z.ZodNullable<z.ZodString>;
|
|
54
|
+
title: z.ZodString;
|
|
55
|
+
kind: z.ZodEnum<{
|
|
56
|
+
other: "other";
|
|
57
|
+
restricted: "restricted";
|
|
58
|
+
site: "site";
|
|
59
|
+
}>;
|
|
60
|
+
calls: z.ZodNumber;
|
|
61
|
+
pricedCalls: z.ZodNumber;
|
|
62
|
+
chargedMicros: z.ZodNumber;
|
|
63
|
+
apiEquivalentMicros: z.ZodNumber;
|
|
64
|
+
subscriptionApiEquivalentMicros: z.ZodNumber;
|
|
65
|
+
ownKeyApiEquivalentMicros: z.ZodNumber;
|
|
66
|
+
}, z.core.$strict>>;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
export type InsightsSiteUsageResponse = z.infer<typeof InsightsSiteUsageResponse>;
|
|
12
69
|
export declare const InsightsUsageGroupBy: z.ZodEnum<{
|
|
13
70
|
model: "model";
|
|
14
71
|
payer: "payer";
|
package/dist/insights-usage.js
CHANGED
|
@@ -13,6 +13,33 @@ var OpaqueKey = /* @__PURE__ */ defineSchema(() => z.string().min(1));
|
|
|
13
13
|
var InsightsUsageRange = /* @__PURE__ */ defineSchema(
|
|
14
14
|
() => z.enum(["today", "week", "month", "30d", "90d", "ytd", "custom"])
|
|
15
15
|
);
|
|
16
|
+
var InsightsSiteUsageQuery = /* @__PURE__ */ defineSchema(
|
|
17
|
+
() => z.object({ range: z.enum(["today", "week", "month", "30d", "90d", "ytd"]).default("month") }).strict()
|
|
18
|
+
);
|
|
19
|
+
var InsightsSiteUsageRow = /* @__PURE__ */ defineSchema(
|
|
20
|
+
() => z.object({
|
|
21
|
+
siteId: Identifier.nullable(),
|
|
22
|
+
title: z.string(),
|
|
23
|
+
kind: z.enum(["site", "restricted", "other"]),
|
|
24
|
+
calls: SafeCount,
|
|
25
|
+
pricedCalls: SafeCount,
|
|
26
|
+
/** Settled negative model-usage ledger entries, not a provider price. */
|
|
27
|
+
chargedMicros: SafeCount,
|
|
28
|
+
/** Recorded API-equivalent estimates across all payment paths. */
|
|
29
|
+
apiEquivalentMicros: SafeCount,
|
|
30
|
+
subscriptionApiEquivalentMicros: SafeCount,
|
|
31
|
+
ownKeyApiEquivalentMicros: SafeCount
|
|
32
|
+
}).strict()
|
|
33
|
+
);
|
|
34
|
+
var InsightsSiteUsageResponse = /* @__PURE__ */ defineSchema(
|
|
35
|
+
() => z.object({
|
|
36
|
+
workspaceId: Identifier,
|
|
37
|
+
range: InsightsSiteUsageQuery.shape.range,
|
|
38
|
+
windowStart: UtcDateTime,
|
|
39
|
+
windowEnd: UtcDateTime,
|
|
40
|
+
rows: z.array(InsightsSiteUsageRow).max(201)
|
|
41
|
+
}).strict()
|
|
42
|
+
);
|
|
16
43
|
var InsightsUsageGroupBy = /* @__PURE__ */ defineSchema(
|
|
17
44
|
() => z.enum([
|
|
18
45
|
"model",
|
|
@@ -536,6 +563,9 @@ export {
|
|
|
536
563
|
InsightsCall,
|
|
537
564
|
InsightsCallsQuery,
|
|
538
565
|
InsightsCallsResponse,
|
|
566
|
+
InsightsSiteUsageQuery,
|
|
567
|
+
InsightsSiteUsageResponse,
|
|
568
|
+
InsightsSiteUsageRow,
|
|
539
569
|
InsightsUsageClassMicros,
|
|
540
570
|
InsightsUsageFacets,
|
|
541
571
|
InsightsUsageGroup,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/insights-usage.ts"],"sourcesContent":["import { defineSchema } from \"./define-schema\";\n// Deliberately exported only from @opengeni/contracts/insights-usage. Importing\n// these schemas must not pull in the root contracts index or its browser graph.\nimport { z } from \"zod\";\n\nconst SafeCount = /* @__PURE__ */ defineSchema(() =>\n z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),\n);\nconst UtcDateTime = /* @__PURE__ */ defineSchema(() => z.string().datetime());\nconst Identifier = /* @__PURE__ */ defineSchema(() => z.string().uuid());\nconst OpaqueKey = /* @__PURE__ */ defineSchema(() => z.string().min(1));\n\nexport const InsightsUsageRange = /* @__PURE__ */ defineSchema(() =>\n z.enum([\"today\", \"week\", \"month\", \"30d\", \"90d\", \"ytd\", \"custom\"]),\n);\nexport type InsightsUsageRange = z.infer<typeof InsightsUsageRange>;\n\nexport const InsightsUsageGroupBy = /* @__PURE__ */ defineSchema(() =>\n z.enum([\n \"model\",\n \"provider\",\n \"payer\",\n \"plan\",\n \"workspace\",\n \"project\",\n \"session\",\n \"rootSession\",\n \"person\",\n \"schedule\",\n \"source\",\n ]),\n);\nexport type InsightsUsageGroupBy = z.infer<typeof InsightsUsageGroupBy>;\n\n/** Recorded entry surface only; API includes SDK/embed. Missing provenance is other. */\nexport const InsightsUsageSource = /* @__PURE__ */ defineSchema(() =>\n z.enum([\"web\", \"api\", \"slack\", \"schedule\", \"agent\", \"other\"]),\n);\nexport type InsightsUsageSource = z.infer<typeof InsightsUsageSource>;\n\nconst UtcDay = /* @__PURE__ */ defineSchema(() =>\n z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/)\n .refine((value) => {\n const instant = Date.parse(`${value}T00:00:00Z`);\n return (\n !value.startsWith(\"0000-\") &&\n Number.isFinite(instant) &&\n new Date(instant).toISOString().slice(0, 10) === value\n );\n }, \"Expected a real UTC calendar date in years 0001 through 9999 (YYYY-MM-DD)\"),\n);\nconst CustomUtcDateTime = /* @__PURE__ */ defineSchema(() =>\n UtcDateTime.refine(\n (value) => !value.startsWith(\"0000-\"),\n \"Custom UTC boundaries must use years 0001 through 9999\",\n ),\n);\nconst DAY_MS = 86_400_000;\nconst CUSTOM_MAX_DAYS = 370;\n\nfunction customWindow(from: string, to: string) {\n if (!UtcDay.safeParse(from).success || !UtcDay.safeParse(to).success) return undefined;\n const start = Date.parse(`${from}T00:00:00Z`);\n const end = Date.parse(`${to}T00:00:00Z`) + DAY_MS;\n if (start >= end || end - start > CUSTOM_MAX_DAYS * DAY_MS) return undefined;\n const priorStart = start - (end - start);\n const windows = {\n windowStart: new Date(start).toISOString(),\n windowEnd: new Date(end).toISOString(),\n priorWindowStart: new Date(priorStart).toISOString(),\n priorWindowEnd: new Date(start).toISOString(),\n };\n // Four-digit AD years must also represent the prior and exclusive end.\n // PostgreSQL has no year zero even though ISO/Zod datetime permits it.\n if (!Object.values(windows).every((value) => CustomUtcDateTime.safeParse(value).success))\n return undefined;\n return { ...windows, bucket: end - start <= 2 * DAY_MS ? (\"hour\" as const) : (\"day\" as const) };\n}\n\nconst CustomDates = /* @__PURE__ */ defineSchema(() =>\n z\n .object({ from: UtcDay, to: UtcDay })\n .strict()\n .refine(\n (value) => customWindow(value.from, value.to) !== undefined,\n \"Custom days must be ordered, span at most 370 days and have representable current/prior windows\",\n ),\n);\n\n/** At most 370 inclusive UTC days; exclusive end and equally long immediate prior. */\nexport function resolveInsightsUsageCustomWindow(dates: { from: string; to: string }) {\n const parsed = CustomDates.parse(dates);\n return customWindow(parsed.from, parsed.to)!;\n}\n\nfunction validateWindowQuery(\n value: { range: InsightsUsageRange; from?: string | undefined; to?: string | undefined },\n context: z.RefinementCtx,\n) {\n if (value.range === \"custom\") {\n if (value.from === undefined || value.to === undefined) {\n context.addIssue({\n code: \"custom\",\n path: [value.from === undefined ? \"from\" : \"to\"],\n message: \"Custom range requires both from and to\",\n });\n } else if (customWindow(value.from, value.to) === undefined) {\n context.addIssue({\n code: \"custom\",\n path: [\"to\"],\n message:\n \"Custom days must be ordered, span at most 370 days and have representable current/prior windows\",\n });\n }\n } else if (value.from !== undefined || value.to !== undefined) {\n context.addIssue({\n code: \"custom\",\n path: [\"range\"],\n message: \"from/to are only valid with range=custom\",\n });\n }\n}\n\n// Literal union avoids replacing existing, structurally identical named enum\n// fingerprints in the additive public-API inventory.\nexport const InsightsUsagePayer = /* @__PURE__ */ defineSchema(() =>\n z.union([z.literal(\"opengeni_credits\"), z.literal(\"subscription\"), z.literal(\"own_key\")]),\n);\nexport type InsightsUsagePayer = z.infer<typeof InsightsUsagePayer>;\n\n/** Split at the FIRST slash: model IDs themselves may contain slashes. */\nexport const InsightsUsageModelKey = /* @__PURE__ */ defineSchema(() =>\n z.string().regex(/^[^/\\s]+\\/\\S+$/),\n);\nexport type InsightsUsageModelKey = z.infer<typeof InsightsUsageModelKey>;\n\nfunction repeated<T extends z.ZodType>(item: T) {\n return z\n .union([z.string(), z.array(z.string()).min(1)])\n .transform((value, context) => {\n const entries = (Array.isArray(value) ? value : [value]).flatMap((part) =>\n part.split(\",\").map((entry) => entry.trim()),\n );\n const parsed = z.array(item).min(1).safeParse(entries);\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n context.addIssue({ code: \"custom\", path: issue.path, message: issue.message });\n }\n return z.NEVER;\n }\n return parsed.data;\n })\n .optional();\n}\n\nfunction queryLimit(max: number) {\n return z\n .union([z.number(), z.string().regex(/^\\d+$/).transform(Number)])\n .pipe(SafeCount.min(1).max(max))\n .default(50);\n}\n\nconst QueryBoolean = /* @__PURE__ */ defineSchema(() =>\n z\n .union([z.boolean(), z.enum([\"true\", \"false\"])])\n .transform((value) => value === true || value === \"true\"),\n);\n\n// Repeated, comma-separated, and mixed values: AND across fields, OR within a\n// field. Empty segments are rejected, never silently widened to all records.\nconst Filters = {\n range: InsightsUsageRange.default(\"week\"),\n from: UtcDay.optional(),\n to: UtcDay.optional(),\n /** At workspace scope this intersects the path workspace; it never expands scope. */\n workspaceId: repeated(Identifier),\n provider: repeated(OpaqueKey),\n model: repeated(InsightsUsageModelKey),\n payer: repeated(InsightsUsagePayer),\n /** Recorded opaque plan key; missing historical snapshots use unknown, not today's plan. */\n plan: repeated(OpaqueKey),\n source: repeated(InsightsUsageSource),\n projectId: repeated(z.union([Identifier, z.literal(\"unfiled\")])),\n /** Authorized owner/member facet key, not a hidden causal initiator. */\n person: repeated(OpaqueKey),\n /** Leaf session and root chat selectors are deliberately separate. */\n sessionId: repeated(Identifier),\n rootSessionId: repeated(Identifier),\n scheduleId: repeated(Identifier),\n};\n\nexport const WorkspaceInsightsUsageQuery = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n ...Filters,\n groupBy: InsightsUsageGroupBy.default(\"model\"),\n seriesGroups: QueryBoolean.optional(),\n limit: queryLimit(200),\n })\n .strict()\n .superRefine(validateWindowQuery),\n);\nexport type WorkspaceInsightsUsageQuery = z.infer<typeof WorkspaceInsightsUsageQuery>;\nexport type WorkspaceInsightsUsageQueryInput = z.input<typeof WorkspaceInsightsUsageQuery>;\n\nexport const OrganizationInsightsUsageQuery = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n ...Filters,\n groupBy: InsightsUsageGroupBy.default(\"model\"),\n seriesGroups: QueryBoolean.optional(),\n limit: queryLimit(200),\n })\n .strict()\n .superRefine(validateWindowQuery),\n);\nexport type OrganizationInsightsUsageQuery = z.infer<typeof OrganizationInsightsUsageQuery>;\nexport type OrganizationInsightsUsageQueryInput = z.input<typeof OrganizationInsightsUsageQuery>;\n\n/** Organization-capable shared shape; use the workspace parser at workspace scope. */\nexport const InsightsUsageQuery = OrganizationInsightsUsageQuery;\nexport type InsightsUsageQuery = OrganizationInsightsUsageQuery;\nexport type InsightsUsageQueryInput = OrganizationInsightsUsageQueryInput;\n\nexport const WorkspaceInsightsCallsQuery = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n ...Filters,\n cursor: OpaqueKey.optional(),\n limit: queryLimit(100),\n })\n .strict()\n .superRefine(validateWindowQuery),\n);\nexport type WorkspaceInsightsCallsQuery = z.infer<typeof WorkspaceInsightsCallsQuery>;\nexport type WorkspaceInsightsCallsQueryInput = z.input<typeof WorkspaceInsightsCallsQuery>;\n\nexport const OrganizationInsightsCallsQuery = WorkspaceInsightsCallsQuery;\nexport type OrganizationInsightsCallsQuery = z.infer<typeof OrganizationInsightsCallsQuery>;\nexport type OrganizationInsightsCallsQueryInput = z.input<typeof OrganizationInsightsCallsQuery>;\nexport const InsightsCallsQuery = OrganizationInsightsCallsQuery;\nexport type InsightsCallsQuery = OrganizationInsightsCallsQuery;\nexport type InsightsCallsQueryInput = OrganizationInsightsCallsQueryInput;\n\n/** Missing historical token classes are represented by known-call counters, not guessed zeroes. */\nexport const InsightsUsageTokens = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n uncachedInput: SafeCount,\n cacheRead: SafeCount,\n cacheWrite: SafeCount,\n output: SafeCount,\n reasoning: SafeCount,\n })\n .strict(),\n);\nexport type InsightsUsageTokens = z.infer<typeof InsightsUsageTokens>;\n\n/**\n * List-price classes only: exact write-time snapshots or flagged historical\n * allocations of each call's recorded total, never repricing that total.\n * chargedMicros is the actual debit-ledger total and has no class split.\n */\nexport const InsightsUsageClassMicros = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n uncachedInput: SafeCount,\n cacheRead: SafeCount,\n cacheWrite: SafeCount,\n output: SafeCount,\n })\n .strict(),\n);\nexport type InsightsUsageClassMicros = z.infer<typeof InsightsUsageClassMicros>;\n\nconst PayerMeasures = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n calls: SafeCount,\n chargedMicros: SafeCount,\n listMicros: SafeCount,\n })\n .strict(),\n);\n\nfunction classTotal(value: InsightsUsageClassMicros): bigint {\n return (\n BigInt(value.uncachedInput) +\n BigInt(value.cacheRead) +\n BigInt(value.cacheWrite) +\n BigInt(value.output)\n );\n}\n\nexport const InsightsUsageMeasures = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n calls: SafeCount,\n tokenKnownCalls: SafeCount,\n cacheKnownCalls: SafeCount,\n cacheWriteKnownCalls: SafeCount,\n /** Priced calls covered by exact snapshots OR flagged recorded-total allocations. */\n listClassKnownCalls: SafeCount,\n tokens: InsightsUsageTokens,\n /** Actual debit ledger, not a model price that may exceed a clipped debit. */\n chargedMicros: SafeCount,\n listMicros: SafeCount,\n listByClassMicros: InsightsUsageClassMicros.nullable(),\n /** True when any covered class values allocate a historical recorded total. */\n listByClassApprox: z.boolean(),\n pricedCalls: SafeCount,\n byPayer: z\n .object({\n opengeni_credits: PayerMeasures,\n subscription: PayerMeasures,\n own_key: PayerMeasures,\n })\n .strict(),\n })\n .strict()\n .superRefine((value, context) => {\n for (const field of [\n \"tokenKnownCalls\",\n \"cacheKnownCalls\",\n \"cacheWriteKnownCalls\",\n \"pricedCalls\",\n ] as const) {\n if (value[field] > value.calls) {\n context.addIssue({\n code: \"custom\",\n path: [field],\n message: \"Known calls cannot exceed calls\",\n });\n }\n }\n if (value.listClassKnownCalls > value.pricedCalls) {\n context.addIssue({\n code: \"custom\",\n path: [\"listClassKnownCalls\"],\n message: \"Class coverage cannot exceed priced calls\",\n });\n }\n if (value.listByClassMicros !== null) {\n const coveredTotal = classTotal(value.listByClassMicros);\n if (\n coveredTotal > BigInt(value.listMicros) ||\n (value.listClassKnownCalls === value.pricedCalls &&\n coveredTotal !== BigInt(value.listMicros))\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"listByClassMicros\"],\n message:\n \"Covered classes cannot exceed the recorded total; complete coverage must preserve it exactly\",\n });\n }\n }\n for (const field of [\"calls\", \"chargedMicros\", \"listMicros\"] as const) {\n const total = Object.values(value.byPayer).reduce(\n (sum, payer) => sum + BigInt(payer[field]),\n 0n,\n );\n if (total !== BigInt(value[field])) {\n context.addIssue({\n code: \"custom\",\n path: [\"byPayer\"],\n message: `Payer ${field} must sum to the total`,\n });\n }\n }\n }),\n);\nexport type InsightsUsageMeasures = z.infer<typeof InsightsUsageMeasures>;\n\nexport const InsightsUsageScope = /* @__PURE__ */ defineSchema(() =>\n z.discriminatedUnion(\"kind\", [\n z\n .object({ kind: z.literal(\"workspace\"), accountId: Identifier, workspaceId: Identifier })\n .strict(),\n z\n .object({ kind: z.literal(\"organization\"), accountId: Identifier, workspaceId: z.null() })\n .strict(),\n ]),\n);\nexport type InsightsUsageScope = z.infer<typeof InsightsUsageScope>;\n\nexport const InsightsUsageGroup = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n /** Private/personal keys remain kind-scoped; named source keys are the source value. */\n key: OpaqueKey,\n kind: z.enum([\n \"item\",\n \"other\",\n \"deleted\",\n \"private\",\n \"personal\",\n \"unfiled\",\n \"service\",\n \"restricted\",\n ]),\n label: z.string(),\n provider: OpaqueKey.optional(),\n model: OpaqueKey.optional(),\n workspaceId: Identifier.optional(),\n /** Only an already-authorized people facet key; permits person-only amount selection. */\n personKey: OpaqueKey.optional(),\n you: z.boolean().optional(),\n measures: InsightsUsageMeasures,\n })\n .strict(),\n);\nexport type InsightsUsageGroup = z.infer<typeof InsightsUsageGroup>;\n\nconst SeriesGroup = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n chargedMicros: SafeCount,\n listMicros: SafeCount,\n tokens: InsightsUsageTokens,\n calls: SafeCount,\n byPayer: InsightsUsageMeasures.shape.byPayer,\n })\n .strict()\n .superRefine((value, context) => {\n for (const field of [\"calls\", \"chargedMicros\", \"listMicros\"] as const) {\n const total = Object.values(value.byPayer).reduce(\n (sum, payer) => sum + BigInt(payer[field]),\n 0n,\n );\n if (total !== BigInt(value[field])) {\n context.addIssue({\n code: \"custom\",\n path: [\"byPayer\"],\n message: `Payer ${field} must sum to the total`,\n });\n }\n }\n }),\n);\n\nexport const InsightsUsageSeriesPoint = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n start: UtcDateTime,\n measures: InsightsUsageMeasures,\n /** Top six active groups plus remainder; source uses other:folded to avoid other collisions. */\n groups: z\n .record(z.string(), SeriesGroup)\n .refine(\n (value) =>\n Object.keys(value).length <= 7 &&\n Object.keys(value).filter((key) => key !== \"other\" && key !== \"other:folded\").length <=\n 6,\n {\n message: \"Series may include at most six groups plus other\",\n },\n )\n .optional(),\n })\n .strict(),\n);\nexport type InsightsUsageSeriesPoint = z.infer<typeof InsightsUsageSeriesPoint>;\n\n/** Range/scope-only authorized metadata, not hidden row IDs or unconditional profile hydration. */\nexport const InsightsUsageFacets = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n workspaces: z.array(\n z.object({ id: Identifier, name: z.string(), personal: z.boolean() }).strict(),\n ),\n providers: z.array(OpaqueKey),\n models: z.array(z.object({ provider: OpaqueKey, model: OpaqueKey }).strict()),\n payers: z.array(OpaqueKey),\n /** Recorded opaque plan keys, with unknown for absent snapshots. */\n plans: z.array(OpaqueKey).default([]),\n /** Capability marker: omit until source/custom support is actually implemented. */\n sources: z.array(InsightsUsageSource).optional(),\n projects: z.array(z.object({ id: Identifier, name: z.string() }).strict()),\n people: z.array(\n z.object({ key: OpaqueKey, name: z.string().nullable(), you: z.boolean() }).strict(),\n ),\n schedules: z.array(z.object({ id: Identifier, name: z.string() }).strict()),\n })\n .strict(),\n);\nexport type InsightsUsageFacets = z.infer<typeof InsightsUsageFacets>;\n\nexport const InsightsUsageResponse = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n scope: InsightsUsageScope,\n range: InsightsUsageRange,\n windowStart: UtcDateTime,\n windowEnd: UtcDateTime,\n priorWindowStart: UtcDateTime,\n priorWindowEnd: UtcDateTime,\n bucket: z.enum([\"hour\", \"day\"]),\n generatedAt: UtcDateTime,\n dataThrough: UtcDateTime.nullable(),\n totals: InsightsUsageMeasures,\n /** Null for truly empty prior windows; ledger-only money survives missing call facts. */\n prior: InsightsUsageMeasures.nullable(),\n groupBy: InsightsUsageGroupBy,\n groups: z.array(InsightsUsageGroup),\n groupCount: SafeCount,\n groupsTruncated: z.boolean(),\n series: z.array(InsightsUsageSeriesPoint),\n facets: InsightsUsageFacets,\n })\n .strict()\n .superRefine((value, context) => {\n const windowStart = Date.parse(value.windowStart);\n const windowEnd = Date.parse(value.windowEnd);\n const priorWindowStart = Date.parse(value.priorWindowStart);\n const priorWindowEnd = Date.parse(value.priorWindowEnd);\n if (windowStart > windowEnd) {\n context.addIssue({\n code: \"custom\",\n path: [\"windowEnd\"],\n message: \"Window end must not precede start\",\n });\n }\n if (priorWindowStart > priorWindowEnd) {\n context.addIssue({\n code: \"custom\",\n path: [\"priorWindowEnd\"],\n message: \"Prior window end must not precede start\",\n });\n }\n // At an exact UTC range boundary, elapsed current/prior windows can be\n // zero-length. Preserve that canonical window instead of inventing a future end.\n if (windowStart === windowEnd) {\n if (\n value.totals.calls !== 0 ||\n value.totals.chargedMicros !== 0 ||\n value.totals.listMicros !== 0 ||\n Object.values(value.totals.tokens).some((tokens) => tokens !== 0)\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"totals\"],\n message: \"Zero-length windows must have empty measures\",\n });\n }\n if (value.groups.length !== 0 || value.groupCount !== 0 || value.groupsTruncated) {\n context.addIssue({\n code: \"custom\",\n path: [\"groups\"],\n message: \"Zero-length windows must have no groups\",\n });\n }\n if (value.series.length !== 0) {\n context.addIssue({\n code: \"custom\",\n path: [\"series\"],\n message: \"Zero-length windows must have no series points\",\n });\n }\n }\n if (priorWindowStart === priorWindowEnd && value.prior !== null) {\n context.addIssue({\n code: \"custom\",\n path: [\"prior\"],\n message: \"Zero-length prior windows must have null measures\",\n });\n }\n const expectedBucket =\n value.range === \"custom\"\n ? windowEnd - windowStart <= 2 * DAY_MS\n ? \"hour\"\n : \"day\"\n : value.range === \"today\"\n ? \"hour\"\n : \"day\";\n if (value.bucket !== expectedBucket) {\n context.addIssue({\n code: \"custom\",\n path: [\"bucket\"],\n message: \"Bucket is automatic for the range\",\n });\n }\n // Model-call facts can soft-fail after money is recorded. Preserve those\n // amounts without inventing calls or known token/class coverage.\n if (\n value.prior?.calls === 0 &&\n value.prior.chargedMicros === 0 &&\n value.prior.listMicros === 0\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"prior\"],\n message: \"Prior without recorded calls or money must be null\",\n });\n }\n if (value.range === \"custom\") {\n for (const field of [\n \"windowStart\",\n \"windowEnd\",\n \"priorWindowStart\",\n \"priorWindowEnd\",\n ] as const) {\n if (!CustomUtcDateTime.safeParse(value[field]).success) {\n context.addIssue({\n code: \"custom\",\n path: [field],\n message: \"Custom UTC boundaries must use years 0001 through 9999\",\n });\n }\n }\n if (\n windowStart === windowEnd ||\n windowEnd - windowStart > CUSTOM_MAX_DAYS * DAY_MS ||\n windowStart % DAY_MS !== 0 ||\n windowEnd % DAY_MS !== 0 ||\n priorWindowStart !== windowStart - (windowEnd - windowStart) ||\n priorWindowEnd !== windowStart\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"windowEnd\"],\n message:\n \"Custom windows must span at most 370 complete UTC days with an immediate equal-duration prior\",\n });\n }\n }\n if (value.groupBy === \"source\") {\n for (const [index, group] of value.groups.entries()) {\n if (group.kind === \"item\" && !InsightsUsageSource.safeParse(group.key).success) {\n context.addIssue({\n code: \"custom\",\n path: [\"groups\", index, \"key\"],\n message: \"Named source keys must equal their source value\",\n });\n }\n if (group.kind === \"other\" && group.key !== \"other:folded\") {\n context.addIssue({\n code: \"custom\",\n path: [\"groups\", index, \"key\"],\n message: \"Source remainder must use other:folded, distinct from the other source\",\n });\n }\n }\n for (const [index, point] of value.series.entries()) {\n if (\n point.groups &&\n Object.keys(point.groups).filter((key) => key !== \"other:folded\").length > 6\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"series\", index, \"groups\"],\n message: \"Source series permits six named groups plus other:folded\",\n });\n }\n }\n }\n const peopleKeys = new Set(value.facets.people.map((person) => person.key));\n for (const [index, group] of value.groups.entries()) {\n if (group.personKey !== undefined && !peopleKeys.has(group.personKey)) {\n context.addIssue({\n code: \"custom\",\n path: [\"groups\", index, \"personKey\"],\n message: \"Person amount keys must come from the authorized people facets\",\n });\n }\n }\n }),\n);\nexport type InsightsUsageResponse = z.infer<typeof InsightsUsageResponse>;\n\n/** Backend must omit unreadable calls entirely; this schema grants no access. */\nexport const InsightsCall = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n id: Identifier,\n occurredAt: UtcDateTime,\n workspaceId: Identifier,\n sessionId: Identifier.nullable(),\n sessionTitle: z.string().nullable(),\n sessionKind: z.enum([\"visible\", \"private\", \"deleted\"]),\n personKey: OpaqueKey.nullable(),\n provider: OpaqueKey,\n model: OpaqueKey,\n payer: InsightsUsagePayer,\n tokens: InsightsUsageTokens.nullable(),\n chargedMicros: SafeCount,\n listMicros: SafeCount.nullable(),\n listByClassMicros: InsightsUsageClassMicros.nullable(),\n })\n .strict()\n .superRefine((value, context) => {\n if (\n value.sessionKind === \"private\" &&\n (value.sessionId !== null || value.sessionTitle !== null)\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"sessionKind\"],\n message: \"Private calls expose no session id or title\",\n });\n }\n if (\n value.listByClassMicros !== null &&\n (value.listMicros === null ||\n classTotal(value.listByClassMicros) !== BigInt(value.listMicros))\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"listByClassMicros\"],\n message: \"Call list classes must sum to its recorded listMicros\",\n });\n }\n }),\n);\nexport type InsightsCall = z.infer<typeof InsightsCall>;\n\nexport const InsightsCallsResponse = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n calls: z.array(InsightsCall).max(100),\n nextCursor: OpaqueKey.nullable(),\n })\n .strict(),\n);\nexport type InsightsCallsResponse = z.infer<typeof InsightsCallsResponse>;\n"],"mappings":";;;;;AAGA,SAAS,SAAS;AAElB,IAAM,YAA4B;AAAA,EAAa,MAC7C,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,OAAO,gBAAgB;AAC5D;AACA,IAAM,cAA8B,6BAAa,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC;AAC5E,IAAM,aAA6B,6BAAa,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;AACvE,IAAM,YAA4B,6BAAa,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAE/D,IAAM,qBAAqC;AAAA,EAAa,MAC7D,EAAE,KAAK,CAAC,SAAS,QAAQ,SAAS,OAAO,OAAO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AAS;AAAA,QACX,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF,CAAC;AACL;AAIO,IAAM,eAA+B;AAAA,EAAa,MACvD,EACG,OAAO;AAAA,IACN,IAAI;AAAA,IACJ,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,WAAW,WAAW,SAAS;AAAA,IAC/B,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,IAClC,aAAa,EAAE,KAAK,CAAC,WAAW,WAAW,SAAS,CAAC;AAAA,IACrD,WAAW,UAAU,SAAS;AAAA,IAC9B,UAAU;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ,oBAAoB,SAAS;AAAA,IACrC,eAAe;AAAA,IACf,YAAY,UAAU,SAAS;AAAA,IAC/B,mBAAmB,yBAAyB,SAAS;AAAA,EACvD,CAAC,EACA,OAAO,EACP,YAAY,CAAC,OAAO,YAAY;AAC/B,QACE,MAAM,gBAAgB,cACrB,MAAM,cAAc,QAAQ,MAAM,iBAAiB,OACpD;AACA,cAAQ,SAAS;AAAA,QACf,MAAM;AAAA,QACN,MAAM,CAAC,aAAa;AAAA,QACpB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AACA,QACE,MAAM,sBAAsB,SAC3B,MAAM,eAAe,QACpB,WAAW,MAAM,iBAAiB,MAAM,OAAO,MAAM,UAAU,IACjE;AACA,cAAQ,SAAS;AAAA,QACf,MAAM;AAAA,QACN,MAAM,CAAC,mBAAmB;AAAA,QAC1B,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACL;AAGO,IAAM,wBAAwC;AAAA,EAAa,MAChE,EACG,OAAO;AAAA,IACN,OAAO,EAAE,MAAM,YAAY,EAAE,IAAI,GAAG;AAAA,IACpC,YAAY,UAAU,SAAS;AAAA,EACjC,CAAC,EACA,OAAO;AACZ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/insights-usage.ts"],"sourcesContent":["import { defineSchema } from \"./define-schema\";\n// Deliberately exported only from @opengeni/contracts/insights-usage. Importing\n// these schemas must not pull in the root contracts index or its browser graph.\nimport { z } from \"zod\";\n\nconst SafeCount = /* @__PURE__ */ defineSchema(() =>\n z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),\n);\nconst UtcDateTime = /* @__PURE__ */ defineSchema(() => z.string().datetime());\nconst Identifier = /* @__PURE__ */ defineSchema(() => z.string().uuid());\nconst OpaqueKey = /* @__PURE__ */ defineSchema(() => z.string().min(1));\n\nexport const InsightsUsageRange = /* @__PURE__ */ defineSchema(() =>\n z.enum([\"today\", \"week\", \"month\", \"30d\", \"90d\", \"ytd\", \"custom\"]),\n);\nexport type InsightsUsageRange = z.infer<typeof InsightsUsageRange>;\n\n/** Aggregate Site accounting only: no viewer, session, turn or prompt identities. */\nexport const InsightsSiteUsageQuery = /* @__PURE__ */ defineSchema(() =>\n z\n .object({ range: z.enum([\"today\", \"week\", \"month\", \"30d\", \"90d\", \"ytd\"]).default(\"month\") })\n .strict(),\n);\nexport type InsightsSiteUsageQuery = z.infer<typeof InsightsSiteUsageQuery>;\nexport const InsightsSiteUsageRow = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n siteId: Identifier.nullable(),\n title: z.string(),\n kind: z.enum([\"site\", \"restricted\", \"other\"]),\n calls: SafeCount,\n pricedCalls: SafeCount,\n /** Settled negative model-usage ledger entries, not a provider price. */\n chargedMicros: SafeCount,\n /** Recorded API-equivalent estimates across all payment paths. */\n apiEquivalentMicros: SafeCount,\n subscriptionApiEquivalentMicros: SafeCount,\n ownKeyApiEquivalentMicros: SafeCount,\n })\n .strict(),\n);\nexport type InsightsSiteUsageRow = z.infer<typeof InsightsSiteUsageRow>;\nexport const InsightsSiteUsageResponse = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n workspaceId: Identifier,\n range: InsightsSiteUsageQuery.shape.range,\n windowStart: UtcDateTime,\n windowEnd: UtcDateTime,\n rows: z.array(InsightsSiteUsageRow).max(201),\n })\n .strict(),\n);\nexport type InsightsSiteUsageResponse = z.infer<typeof InsightsSiteUsageResponse>;\n\nexport const InsightsUsageGroupBy = /* @__PURE__ */ defineSchema(() =>\n z.enum([\n \"model\",\n \"provider\",\n \"payer\",\n \"plan\",\n \"workspace\",\n \"project\",\n \"session\",\n \"rootSession\",\n \"person\",\n \"schedule\",\n \"source\",\n ]),\n);\nexport type InsightsUsageGroupBy = z.infer<typeof InsightsUsageGroupBy>;\n\n/** Recorded entry surface only; API includes SDK/embed. Missing provenance is other. */\nexport const InsightsUsageSource = /* @__PURE__ */ defineSchema(() =>\n z.enum([\"web\", \"api\", \"slack\", \"schedule\", \"agent\", \"other\"]),\n);\nexport type InsightsUsageSource = z.infer<typeof InsightsUsageSource>;\n\nconst UtcDay = /* @__PURE__ */ defineSchema(() =>\n z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/)\n .refine((value) => {\n const instant = Date.parse(`${value}T00:00:00Z`);\n return (\n !value.startsWith(\"0000-\") &&\n Number.isFinite(instant) &&\n new Date(instant).toISOString().slice(0, 10) === value\n );\n }, \"Expected a real UTC calendar date in years 0001 through 9999 (YYYY-MM-DD)\"),\n);\nconst CustomUtcDateTime = /* @__PURE__ */ defineSchema(() =>\n UtcDateTime.refine(\n (value) => !value.startsWith(\"0000-\"),\n \"Custom UTC boundaries must use years 0001 through 9999\",\n ),\n);\nconst DAY_MS = 86_400_000;\nconst CUSTOM_MAX_DAYS = 370;\n\nfunction customWindow(from: string, to: string) {\n if (!UtcDay.safeParse(from).success || !UtcDay.safeParse(to).success) return undefined;\n const start = Date.parse(`${from}T00:00:00Z`);\n const end = Date.parse(`${to}T00:00:00Z`) + DAY_MS;\n if (start >= end || end - start > CUSTOM_MAX_DAYS * DAY_MS) return undefined;\n const priorStart = start - (end - start);\n const windows = {\n windowStart: new Date(start).toISOString(),\n windowEnd: new Date(end).toISOString(),\n priorWindowStart: new Date(priorStart).toISOString(),\n priorWindowEnd: new Date(start).toISOString(),\n };\n // Four-digit AD years must also represent the prior and exclusive end.\n // PostgreSQL has no year zero even though ISO/Zod datetime permits it.\n if (!Object.values(windows).every((value) => CustomUtcDateTime.safeParse(value).success))\n return undefined;\n return { ...windows, bucket: end - start <= 2 * DAY_MS ? (\"hour\" as const) : (\"day\" as const) };\n}\n\nconst CustomDates = /* @__PURE__ */ defineSchema(() =>\n z\n .object({ from: UtcDay, to: UtcDay })\n .strict()\n .refine(\n (value) => customWindow(value.from, value.to) !== undefined,\n \"Custom days must be ordered, span at most 370 days and have representable current/prior windows\",\n ),\n);\n\n/** At most 370 inclusive UTC days; exclusive end and equally long immediate prior. */\nexport function resolveInsightsUsageCustomWindow(dates: { from: string; to: string }) {\n const parsed = CustomDates.parse(dates);\n return customWindow(parsed.from, parsed.to)!;\n}\n\nfunction validateWindowQuery(\n value: { range: InsightsUsageRange; from?: string | undefined; to?: string | undefined },\n context: z.RefinementCtx,\n) {\n if (value.range === \"custom\") {\n if (value.from === undefined || value.to === undefined) {\n context.addIssue({\n code: \"custom\",\n path: [value.from === undefined ? \"from\" : \"to\"],\n message: \"Custom range requires both from and to\",\n });\n } else if (customWindow(value.from, value.to) === undefined) {\n context.addIssue({\n code: \"custom\",\n path: [\"to\"],\n message:\n \"Custom days must be ordered, span at most 370 days and have representable current/prior windows\",\n });\n }\n } else if (value.from !== undefined || value.to !== undefined) {\n context.addIssue({\n code: \"custom\",\n path: [\"range\"],\n message: \"from/to are only valid with range=custom\",\n });\n }\n}\n\n// Literal union avoids replacing existing, structurally identical named enum\n// fingerprints in the additive public-API inventory.\nexport const InsightsUsagePayer = /* @__PURE__ */ defineSchema(() =>\n z.union([z.literal(\"opengeni_credits\"), z.literal(\"subscription\"), z.literal(\"own_key\")]),\n);\nexport type InsightsUsagePayer = z.infer<typeof InsightsUsagePayer>;\n\n/** Split at the FIRST slash: model IDs themselves may contain slashes. */\nexport const InsightsUsageModelKey = /* @__PURE__ */ defineSchema(() =>\n z.string().regex(/^[^/\\s]+\\/\\S+$/),\n);\nexport type InsightsUsageModelKey = z.infer<typeof InsightsUsageModelKey>;\n\nfunction repeated<T extends z.ZodType>(item: T) {\n return z\n .union([z.string(), z.array(z.string()).min(1)])\n .transform((value, context) => {\n const entries = (Array.isArray(value) ? value : [value]).flatMap((part) =>\n part.split(\",\").map((entry) => entry.trim()),\n );\n const parsed = z.array(item).min(1).safeParse(entries);\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n context.addIssue({ code: \"custom\", path: issue.path, message: issue.message });\n }\n return z.NEVER;\n }\n return parsed.data;\n })\n .optional();\n}\n\nfunction queryLimit(max: number) {\n return z\n .union([z.number(), z.string().regex(/^\\d+$/).transform(Number)])\n .pipe(SafeCount.min(1).max(max))\n .default(50);\n}\n\nconst QueryBoolean = /* @__PURE__ */ defineSchema(() =>\n z\n .union([z.boolean(), z.enum([\"true\", \"false\"])])\n .transform((value) => value === true || value === \"true\"),\n);\n\n// Repeated, comma-separated, and mixed values: AND across fields, OR within a\n// field. Empty segments are rejected, never silently widened to all records.\nconst Filters = {\n range: InsightsUsageRange.default(\"week\"),\n from: UtcDay.optional(),\n to: UtcDay.optional(),\n /** At workspace scope this intersects the path workspace; it never expands scope. */\n workspaceId: repeated(Identifier),\n provider: repeated(OpaqueKey),\n model: repeated(InsightsUsageModelKey),\n payer: repeated(InsightsUsagePayer),\n /** Recorded opaque plan key; missing historical snapshots use unknown, not today's plan. */\n plan: repeated(OpaqueKey),\n source: repeated(InsightsUsageSource),\n projectId: repeated(z.union([Identifier, z.literal(\"unfiled\")])),\n /** Authorized owner/member facet key, not a hidden causal initiator. */\n person: repeated(OpaqueKey),\n /** Leaf session and root chat selectors are deliberately separate. */\n sessionId: repeated(Identifier),\n rootSessionId: repeated(Identifier),\n scheduleId: repeated(Identifier),\n};\n\nexport const WorkspaceInsightsUsageQuery = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n ...Filters,\n groupBy: InsightsUsageGroupBy.default(\"model\"),\n seriesGroups: QueryBoolean.optional(),\n limit: queryLimit(200),\n })\n .strict()\n .superRefine(validateWindowQuery),\n);\nexport type WorkspaceInsightsUsageQuery = z.infer<typeof WorkspaceInsightsUsageQuery>;\nexport type WorkspaceInsightsUsageQueryInput = z.input<typeof WorkspaceInsightsUsageQuery>;\n\nexport const OrganizationInsightsUsageQuery = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n ...Filters,\n groupBy: InsightsUsageGroupBy.default(\"model\"),\n seriesGroups: QueryBoolean.optional(),\n limit: queryLimit(200),\n })\n .strict()\n .superRefine(validateWindowQuery),\n);\nexport type OrganizationInsightsUsageQuery = z.infer<typeof OrganizationInsightsUsageQuery>;\nexport type OrganizationInsightsUsageQueryInput = z.input<typeof OrganizationInsightsUsageQuery>;\n\n/** Organization-capable shared shape; use the workspace parser at workspace scope. */\nexport const InsightsUsageQuery = OrganizationInsightsUsageQuery;\nexport type InsightsUsageQuery = OrganizationInsightsUsageQuery;\nexport type InsightsUsageQueryInput = OrganizationInsightsUsageQueryInput;\n\nexport const WorkspaceInsightsCallsQuery = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n ...Filters,\n cursor: OpaqueKey.optional(),\n limit: queryLimit(100),\n })\n .strict()\n .superRefine(validateWindowQuery),\n);\nexport type WorkspaceInsightsCallsQuery = z.infer<typeof WorkspaceInsightsCallsQuery>;\nexport type WorkspaceInsightsCallsQueryInput = z.input<typeof WorkspaceInsightsCallsQuery>;\n\nexport const OrganizationInsightsCallsQuery = WorkspaceInsightsCallsQuery;\nexport type OrganizationInsightsCallsQuery = z.infer<typeof OrganizationInsightsCallsQuery>;\nexport type OrganizationInsightsCallsQueryInput = z.input<typeof OrganizationInsightsCallsQuery>;\nexport const InsightsCallsQuery = OrganizationInsightsCallsQuery;\nexport type InsightsCallsQuery = OrganizationInsightsCallsQuery;\nexport type InsightsCallsQueryInput = OrganizationInsightsCallsQueryInput;\n\n/** Missing historical token classes are represented by known-call counters, not guessed zeroes. */\nexport const InsightsUsageTokens = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n uncachedInput: SafeCount,\n cacheRead: SafeCount,\n cacheWrite: SafeCount,\n output: SafeCount,\n reasoning: SafeCount,\n })\n .strict(),\n);\nexport type InsightsUsageTokens = z.infer<typeof InsightsUsageTokens>;\n\n/**\n * List-price classes only: exact write-time snapshots or flagged historical\n * allocations of each call's recorded total, never repricing that total.\n * chargedMicros is the actual debit-ledger total and has no class split.\n */\nexport const InsightsUsageClassMicros = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n uncachedInput: SafeCount,\n cacheRead: SafeCount,\n cacheWrite: SafeCount,\n output: SafeCount,\n })\n .strict(),\n);\nexport type InsightsUsageClassMicros = z.infer<typeof InsightsUsageClassMicros>;\n\nconst PayerMeasures = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n calls: SafeCount,\n chargedMicros: SafeCount,\n listMicros: SafeCount,\n })\n .strict(),\n);\n\nfunction classTotal(value: InsightsUsageClassMicros): bigint {\n return (\n BigInt(value.uncachedInput) +\n BigInt(value.cacheRead) +\n BigInt(value.cacheWrite) +\n BigInt(value.output)\n );\n}\n\nexport const InsightsUsageMeasures = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n calls: SafeCount,\n tokenKnownCalls: SafeCount,\n cacheKnownCalls: SafeCount,\n cacheWriteKnownCalls: SafeCount,\n /** Priced calls covered by exact snapshots OR flagged recorded-total allocations. */\n listClassKnownCalls: SafeCount,\n tokens: InsightsUsageTokens,\n /** Actual debit ledger, not a model price that may exceed a clipped debit. */\n chargedMicros: SafeCount,\n listMicros: SafeCount,\n listByClassMicros: InsightsUsageClassMicros.nullable(),\n /** True when any covered class values allocate a historical recorded total. */\n listByClassApprox: z.boolean(),\n pricedCalls: SafeCount,\n byPayer: z\n .object({\n opengeni_credits: PayerMeasures,\n subscription: PayerMeasures,\n own_key: PayerMeasures,\n })\n .strict(),\n })\n .strict()\n .superRefine((value, context) => {\n for (const field of [\n \"tokenKnownCalls\",\n \"cacheKnownCalls\",\n \"cacheWriteKnownCalls\",\n \"pricedCalls\",\n ] as const) {\n if (value[field] > value.calls) {\n context.addIssue({\n code: \"custom\",\n path: [field],\n message: \"Known calls cannot exceed calls\",\n });\n }\n }\n if (value.listClassKnownCalls > value.pricedCalls) {\n context.addIssue({\n code: \"custom\",\n path: [\"listClassKnownCalls\"],\n message: \"Class coverage cannot exceed priced calls\",\n });\n }\n if (value.listByClassMicros !== null) {\n const coveredTotal = classTotal(value.listByClassMicros);\n if (\n coveredTotal > BigInt(value.listMicros) ||\n (value.listClassKnownCalls === value.pricedCalls &&\n coveredTotal !== BigInt(value.listMicros))\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"listByClassMicros\"],\n message:\n \"Covered classes cannot exceed the recorded total; complete coverage must preserve it exactly\",\n });\n }\n }\n for (const field of [\"calls\", \"chargedMicros\", \"listMicros\"] as const) {\n const total = Object.values(value.byPayer).reduce(\n (sum, payer) => sum + BigInt(payer[field]),\n 0n,\n );\n if (total !== BigInt(value[field])) {\n context.addIssue({\n code: \"custom\",\n path: [\"byPayer\"],\n message: `Payer ${field} must sum to the total`,\n });\n }\n }\n }),\n);\nexport type InsightsUsageMeasures = z.infer<typeof InsightsUsageMeasures>;\n\nexport const InsightsUsageScope = /* @__PURE__ */ defineSchema(() =>\n z.discriminatedUnion(\"kind\", [\n z\n .object({ kind: z.literal(\"workspace\"), accountId: Identifier, workspaceId: Identifier })\n .strict(),\n z\n .object({ kind: z.literal(\"organization\"), accountId: Identifier, workspaceId: z.null() })\n .strict(),\n ]),\n);\nexport type InsightsUsageScope = z.infer<typeof InsightsUsageScope>;\n\nexport const InsightsUsageGroup = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n /** Private/personal keys remain kind-scoped; named source keys are the source value. */\n key: OpaqueKey,\n kind: z.enum([\n \"item\",\n \"other\",\n \"deleted\",\n \"private\",\n \"personal\",\n \"unfiled\",\n \"service\",\n \"restricted\",\n ]),\n label: z.string(),\n provider: OpaqueKey.optional(),\n model: OpaqueKey.optional(),\n workspaceId: Identifier.optional(),\n /** Only an already-authorized people facet key; permits person-only amount selection. */\n personKey: OpaqueKey.optional(),\n you: z.boolean().optional(),\n measures: InsightsUsageMeasures,\n })\n .strict(),\n);\nexport type InsightsUsageGroup = z.infer<typeof InsightsUsageGroup>;\n\nconst SeriesGroup = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n chargedMicros: SafeCount,\n listMicros: SafeCount,\n tokens: InsightsUsageTokens,\n calls: SafeCount,\n byPayer: InsightsUsageMeasures.shape.byPayer,\n })\n .strict()\n .superRefine((value, context) => {\n for (const field of [\"calls\", \"chargedMicros\", \"listMicros\"] as const) {\n const total = Object.values(value.byPayer).reduce(\n (sum, payer) => sum + BigInt(payer[field]),\n 0n,\n );\n if (total !== BigInt(value[field])) {\n context.addIssue({\n code: \"custom\",\n path: [\"byPayer\"],\n message: `Payer ${field} must sum to the total`,\n });\n }\n }\n }),\n);\n\nexport const InsightsUsageSeriesPoint = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n start: UtcDateTime,\n measures: InsightsUsageMeasures,\n /** Top six active groups plus remainder; source uses other:folded to avoid other collisions. */\n groups: z\n .record(z.string(), SeriesGroup)\n .refine(\n (value) =>\n Object.keys(value).length <= 7 &&\n Object.keys(value).filter((key) => key !== \"other\" && key !== \"other:folded\").length <=\n 6,\n {\n message: \"Series may include at most six groups plus other\",\n },\n )\n .optional(),\n })\n .strict(),\n);\nexport type InsightsUsageSeriesPoint = z.infer<typeof InsightsUsageSeriesPoint>;\n\n/** Range/scope-only authorized metadata, not hidden row IDs or unconditional profile hydration. */\nexport const InsightsUsageFacets = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n workspaces: z.array(\n z.object({ id: Identifier, name: z.string(), personal: z.boolean() }).strict(),\n ),\n providers: z.array(OpaqueKey),\n models: z.array(z.object({ provider: OpaqueKey, model: OpaqueKey }).strict()),\n payers: z.array(OpaqueKey),\n /** Recorded opaque plan keys, with unknown for absent snapshots. */\n plans: z.array(OpaqueKey).default([]),\n /** Capability marker: omit until source/custom support is actually implemented. */\n sources: z.array(InsightsUsageSource).optional(),\n projects: z.array(z.object({ id: Identifier, name: z.string() }).strict()),\n people: z.array(\n z.object({ key: OpaqueKey, name: z.string().nullable(), you: z.boolean() }).strict(),\n ),\n schedules: z.array(z.object({ id: Identifier, name: z.string() }).strict()),\n })\n .strict(),\n);\nexport type InsightsUsageFacets = z.infer<typeof InsightsUsageFacets>;\n\nexport const InsightsUsageResponse = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n scope: InsightsUsageScope,\n range: InsightsUsageRange,\n windowStart: UtcDateTime,\n windowEnd: UtcDateTime,\n priorWindowStart: UtcDateTime,\n priorWindowEnd: UtcDateTime,\n bucket: z.enum([\"hour\", \"day\"]),\n generatedAt: UtcDateTime,\n dataThrough: UtcDateTime.nullable(),\n totals: InsightsUsageMeasures,\n /** Null for truly empty prior windows; ledger-only money survives missing call facts. */\n prior: InsightsUsageMeasures.nullable(),\n groupBy: InsightsUsageGroupBy,\n groups: z.array(InsightsUsageGroup),\n groupCount: SafeCount,\n groupsTruncated: z.boolean(),\n series: z.array(InsightsUsageSeriesPoint),\n facets: InsightsUsageFacets,\n })\n .strict()\n .superRefine((value, context) => {\n const windowStart = Date.parse(value.windowStart);\n const windowEnd = Date.parse(value.windowEnd);\n const priorWindowStart = Date.parse(value.priorWindowStart);\n const priorWindowEnd = Date.parse(value.priorWindowEnd);\n if (windowStart > windowEnd) {\n context.addIssue({\n code: \"custom\",\n path: [\"windowEnd\"],\n message: \"Window end must not precede start\",\n });\n }\n if (priorWindowStart > priorWindowEnd) {\n context.addIssue({\n code: \"custom\",\n path: [\"priorWindowEnd\"],\n message: \"Prior window end must not precede start\",\n });\n }\n // At an exact UTC range boundary, elapsed current/prior windows can be\n // zero-length. Preserve that canonical window instead of inventing a future end.\n if (windowStart === windowEnd) {\n if (\n value.totals.calls !== 0 ||\n value.totals.chargedMicros !== 0 ||\n value.totals.listMicros !== 0 ||\n Object.values(value.totals.tokens).some((tokens) => tokens !== 0)\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"totals\"],\n message: \"Zero-length windows must have empty measures\",\n });\n }\n if (value.groups.length !== 0 || value.groupCount !== 0 || value.groupsTruncated) {\n context.addIssue({\n code: \"custom\",\n path: [\"groups\"],\n message: \"Zero-length windows must have no groups\",\n });\n }\n if (value.series.length !== 0) {\n context.addIssue({\n code: \"custom\",\n path: [\"series\"],\n message: \"Zero-length windows must have no series points\",\n });\n }\n }\n if (priorWindowStart === priorWindowEnd && value.prior !== null) {\n context.addIssue({\n code: \"custom\",\n path: [\"prior\"],\n message: \"Zero-length prior windows must have null measures\",\n });\n }\n const expectedBucket =\n value.range === \"custom\"\n ? windowEnd - windowStart <= 2 * DAY_MS\n ? \"hour\"\n : \"day\"\n : value.range === \"today\"\n ? \"hour\"\n : \"day\";\n if (value.bucket !== expectedBucket) {\n context.addIssue({\n code: \"custom\",\n path: [\"bucket\"],\n message: \"Bucket is automatic for the range\",\n });\n }\n // Model-call facts can soft-fail after money is recorded. Preserve those\n // amounts without inventing calls or known token/class coverage.\n if (\n value.prior?.calls === 0 &&\n value.prior.chargedMicros === 0 &&\n value.prior.listMicros === 0\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"prior\"],\n message: \"Prior without recorded calls or money must be null\",\n });\n }\n if (value.range === \"custom\") {\n for (const field of [\n \"windowStart\",\n \"windowEnd\",\n \"priorWindowStart\",\n \"priorWindowEnd\",\n ] as const) {\n if (!CustomUtcDateTime.safeParse(value[field]).success) {\n context.addIssue({\n code: \"custom\",\n path: [field],\n message: \"Custom UTC boundaries must use years 0001 through 9999\",\n });\n }\n }\n if (\n windowStart === windowEnd ||\n windowEnd - windowStart > CUSTOM_MAX_DAYS * DAY_MS ||\n windowStart % DAY_MS !== 0 ||\n windowEnd % DAY_MS !== 0 ||\n priorWindowStart !== windowStart - (windowEnd - windowStart) ||\n priorWindowEnd !== windowStart\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"windowEnd\"],\n message:\n \"Custom windows must span at most 370 complete UTC days with an immediate equal-duration prior\",\n });\n }\n }\n if (value.groupBy === \"source\") {\n for (const [index, group] of value.groups.entries()) {\n if (group.kind === \"item\" && !InsightsUsageSource.safeParse(group.key).success) {\n context.addIssue({\n code: \"custom\",\n path: [\"groups\", index, \"key\"],\n message: \"Named source keys must equal their source value\",\n });\n }\n if (group.kind === \"other\" && group.key !== \"other:folded\") {\n context.addIssue({\n code: \"custom\",\n path: [\"groups\", index, \"key\"],\n message: \"Source remainder must use other:folded, distinct from the other source\",\n });\n }\n }\n for (const [index, point] of value.series.entries()) {\n if (\n point.groups &&\n Object.keys(point.groups).filter((key) => key !== \"other:folded\").length > 6\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"series\", index, \"groups\"],\n message: \"Source series permits six named groups plus other:folded\",\n });\n }\n }\n }\n const peopleKeys = new Set(value.facets.people.map((person) => person.key));\n for (const [index, group] of value.groups.entries()) {\n if (group.personKey !== undefined && !peopleKeys.has(group.personKey)) {\n context.addIssue({\n code: \"custom\",\n path: [\"groups\", index, \"personKey\"],\n message: \"Person amount keys must come from the authorized people facets\",\n });\n }\n }\n }),\n);\nexport type InsightsUsageResponse = z.infer<typeof InsightsUsageResponse>;\n\n/** Backend must omit unreadable calls entirely; this schema grants no access. */\nexport const InsightsCall = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n id: Identifier,\n occurredAt: UtcDateTime,\n workspaceId: Identifier,\n sessionId: Identifier.nullable(),\n sessionTitle: z.string().nullable(),\n sessionKind: z.enum([\"visible\", \"private\", \"deleted\"]),\n personKey: OpaqueKey.nullable(),\n provider: OpaqueKey,\n model: OpaqueKey,\n payer: InsightsUsagePayer,\n tokens: InsightsUsageTokens.nullable(),\n chargedMicros: SafeCount,\n listMicros: SafeCount.nullable(),\n listByClassMicros: InsightsUsageClassMicros.nullable(),\n })\n .strict()\n .superRefine((value, context) => {\n if (\n value.sessionKind === \"private\" &&\n (value.sessionId !== null || value.sessionTitle !== null)\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"sessionKind\"],\n message: \"Private calls expose no session id or title\",\n });\n }\n if (\n value.listByClassMicros !== null &&\n (value.listMicros === null ||\n classTotal(value.listByClassMicros) !== BigInt(value.listMicros))\n ) {\n context.addIssue({\n code: \"custom\",\n path: [\"listByClassMicros\"],\n message: \"Call list classes must sum to its recorded listMicros\",\n });\n }\n }),\n);\nexport type InsightsCall = z.infer<typeof InsightsCall>;\n\nexport const InsightsCallsResponse = /* @__PURE__ */ defineSchema(() =>\n z\n .object({\n calls: z.array(InsightsCall).max(100),\n nextCursor: OpaqueKey.nullable(),\n })\n .strict(),\n);\nexport type InsightsCallsResponse = z.infer<typeof InsightsCallsResponse>;\n"],"mappings":";;;;;AAGA,SAAS,SAAS;AAElB,IAAM,YAA4B;AAAA,EAAa,MAC7C,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,OAAO,gBAAgB;AAC5D;AACA,IAAM,cAA8B,6BAAa,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC;AAC5E,IAAM,aAA6B,6BAAa,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;AACvE,IAAM,YAA4B,6BAAa,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAE/D,IAAM,qBAAqC;AAAA,EAAa,MAC7D,EAAE,KAAK,CAAC,SAAS,QAAQ,SAAS,OAAO,OAAO,OAAO,QAAQ,CAAC;AAClE;AAIO,IAAM,yBAAyC;AAAA,EAAa,MACjE,EACG,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,SAAS,QAAQ,SAAS,OAAO,OAAO,KAAK,CAAC,EAAE,QAAQ,OAAO,EAAE,CAAC,EAC1F,OAAO;AACZ;AAEO,IAAM,uBAAuC;AAAA,EAAa,MAC/D,EACG,OAAO;AAAA,IACN,QAAQ,WAAW,SAAS;AAAA,IAC5B,OAAO,EAAE,OAAO;AAAA,IAChB,MAAM,EAAE,KAAK,CAAC,QAAQ,cAAc,OAAO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