@miradorlabs/web-grpc 3.38.0 → 3.39.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.
Files changed (32) hide show
  1. package/google/api/field_behavior.ts +3 -1
  2. package/google/protobuf/descriptor.ts +3 -1
  3. package/google/protobuf/duration.ts +3 -1
  4. package/google/protobuf/timestamp.ts +3 -1
  5. package/package.json +1 -1
  6. package/proto/gateway/common/v1/attribute_value.ts +3 -1
  7. package/proto/gateway/common/v1/status.ts +3 -1
  8. package/proto/gateway/common/v1/types.ts +3 -1
  9. package/proto/gateway/web/v1/account_gateway.ts +3 -1
  10. package/proto/gateway/web/v1/admin_gateway.ts +1138 -88
  11. package/proto/gateway/web/v1/admin_gateway_grpc_pb.js +36 -0
  12. package/proto/gateway/web/v1/admin_gateway_pb.js +1752 -90
  13. package/proto/gateway/web/v1/ai_gateway.ts +3 -1
  14. package/proto/gateway/web/v1/attribute_value.ts +3 -1
  15. package/proto/gateway/web/v1/beta_gateway.ts +3 -1
  16. package/proto/gateway/web/v1/chain_gateway.ts +3 -1
  17. package/proto/gateway/web/v1/common.ts +3 -1
  18. package/proto/gateway/web/v1/derived_metric_gateway.ts +3 -1
  19. package/proto/gateway/web/v1/github_connector.ts +3 -1
  20. package/proto/gateway/web/v1/integration_gateway.ts +3 -1
  21. package/proto/gateway/web/v1/log_gateway.ts +3 -1
  22. package/proto/gateway/web/v1/market_gateway.ts +3 -1
  23. package/proto/gateway/web/v1/metric_gateway.ts +3 -1
  24. package/proto/gateway/web/v1/oauth_gateway.ts +3 -1
  25. package/proto/gateway/web/v1/plan_gateway.ts +3 -1
  26. package/proto/gateway/web/v1/policy_gateway.ts +3 -1
  27. package/proto/gateway/web/v1/reference_gateway.ts +16 -9
  28. package/proto/gateway/web/v1/reference_gateway_grpc_pb.js +7 -5
  29. package/proto/gateway/web/v1/rule_gateway.ts +3 -1
  30. package/proto/gateway/web/v1/slo_gateway.ts +3 -1
  31. package/proto/gateway/web/v1/trace_gateway.ts +3 -1
  32. package/proto/gateway/web/v1/trace_measure_gateway.ts +3 -1
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.15.3
3
+ // protoc-gen-ts_proto v2.18.0
4
4
  // protoc v3.21.12
5
5
  // source: proto/gateway/web/v1/admin_gateway.proto
6
6
 
@@ -16,10 +16,135 @@ import {
16
16
  relayHeartbeatSortToJSON,
17
17
  } from "./ai_gateway";
18
18
  import { InviteCodeState, inviteCodeStateFromJSON, inviteCodeStateToJSON } from "./beta_gateway";
19
- import { AIReferenceGroupFilter, AIReferenceName } from "./reference_gateway";
19
+ import {
20
+ AIPrincipalKind,
21
+ aIPrincipalKindFromJSON,
22
+ aIPrincipalKindToJSON,
23
+ AIReferenceGroupFilter,
24
+ AIReferenceName,
25
+ } from "./reference_gateway";
26
+ import { Pagination } from "./trace_gateway";
20
27
 
21
28
  export const protobufPackage = "gateway.web.v1";
22
29
 
30
+ export const protobufFileName = "proto/gateway/web/v1/admin_gateway.proto";
31
+
32
+ /** AdminUsageDimension mirrors ai.api.v1.AdminUsageDimension: one dimension a usage group is keyed by. */
33
+ export enum AdminUsageDimension {
34
+ ADMIN_USAGE_DIMENSION_UNSPECIFIED = 0,
35
+ ADMIN_USAGE_DIMENSION_ORGANIZATION = 1,
36
+ /** ADMIN_USAGE_DIMENSION_PRINCIPAL - The usage's principal as reported: its user id, else its api key id, else unattributed. */
37
+ ADMIN_USAGE_DIMENSION_PRINCIPAL = 2,
38
+ /** ADMIN_USAGE_DIMENSION_SOURCE - The source system (harness) as stored. */
39
+ ADMIN_USAGE_DIMENSION_SOURCE = 3,
40
+ /** ADMIN_USAGE_DIMENSION_MODEL - The model as stored, not its display name. */
41
+ ADMIN_USAGE_DIMENSION_MODEL = 4,
42
+ /** ADMIN_USAGE_DIMENSION_DAY - The UTC day. */
43
+ ADMIN_USAGE_DIMENSION_DAY = 5,
44
+ UNRECOGNIZED = -1,
45
+ }
46
+
47
+ export function adminUsageDimensionFromJSON(object: any): AdminUsageDimension {
48
+ switch (object) {
49
+ case 0:
50
+ case "ADMIN_USAGE_DIMENSION_UNSPECIFIED":
51
+ return AdminUsageDimension.ADMIN_USAGE_DIMENSION_UNSPECIFIED;
52
+ case 1:
53
+ case "ADMIN_USAGE_DIMENSION_ORGANIZATION":
54
+ return AdminUsageDimension.ADMIN_USAGE_DIMENSION_ORGANIZATION;
55
+ case 2:
56
+ case "ADMIN_USAGE_DIMENSION_PRINCIPAL":
57
+ return AdminUsageDimension.ADMIN_USAGE_DIMENSION_PRINCIPAL;
58
+ case 3:
59
+ case "ADMIN_USAGE_DIMENSION_SOURCE":
60
+ return AdminUsageDimension.ADMIN_USAGE_DIMENSION_SOURCE;
61
+ case 4:
62
+ case "ADMIN_USAGE_DIMENSION_MODEL":
63
+ return AdminUsageDimension.ADMIN_USAGE_DIMENSION_MODEL;
64
+ case 5:
65
+ case "ADMIN_USAGE_DIMENSION_DAY":
66
+ return AdminUsageDimension.ADMIN_USAGE_DIMENSION_DAY;
67
+ case -1:
68
+ case "UNRECOGNIZED":
69
+ default:
70
+ return AdminUsageDimension.UNRECOGNIZED;
71
+ }
72
+ }
73
+
74
+ export function adminUsageDimensionToJSON(object: AdminUsageDimension): string {
75
+ switch (object) {
76
+ case AdminUsageDimension.ADMIN_USAGE_DIMENSION_UNSPECIFIED:
77
+ return "ADMIN_USAGE_DIMENSION_UNSPECIFIED";
78
+ case AdminUsageDimension.ADMIN_USAGE_DIMENSION_ORGANIZATION:
79
+ return "ADMIN_USAGE_DIMENSION_ORGANIZATION";
80
+ case AdminUsageDimension.ADMIN_USAGE_DIMENSION_PRINCIPAL:
81
+ return "ADMIN_USAGE_DIMENSION_PRINCIPAL";
82
+ case AdminUsageDimension.ADMIN_USAGE_DIMENSION_SOURCE:
83
+ return "ADMIN_USAGE_DIMENSION_SOURCE";
84
+ case AdminUsageDimension.ADMIN_USAGE_DIMENSION_MODEL:
85
+ return "ADMIN_USAGE_DIMENSION_MODEL";
86
+ case AdminUsageDimension.ADMIN_USAGE_DIMENSION_DAY:
87
+ return "ADMIN_USAGE_DIMENSION_DAY";
88
+ case AdminUsageDimension.UNRECOGNIZED:
89
+ default:
90
+ return "UNRECOGNIZED";
91
+ }
92
+ }
93
+
94
+ /** AdminUsageGroupSort mirrors ai.api.v1.AdminUsageGroupSort; ties break on the group key ascending. */
95
+ export enum AdminUsageGroupSort {
96
+ ADMIN_USAGE_GROUP_SORT_UNSPECIFIED = 0,
97
+ ADMIN_USAGE_GROUP_SORT_COST_DESC = 1,
98
+ /** ADMIN_USAGE_GROUP_SORT_TOKENS_DESC - input_tokens + output_tokens, so cache reads and writes count (they are part of input). */
99
+ ADMIN_USAGE_GROUP_SORT_TOKENS_DESC = 2,
100
+ ADMIN_USAGE_GROUP_SORT_CALLS_DESC = 3,
101
+ /** ADMIN_USAGE_GROUP_SORT_GROUP_ASC - The group key ascending, in group_by order: a day series reads in date order. */
102
+ ADMIN_USAGE_GROUP_SORT_GROUP_ASC = 4,
103
+ UNRECOGNIZED = -1,
104
+ }
105
+
106
+ export function adminUsageGroupSortFromJSON(object: any): AdminUsageGroupSort {
107
+ switch (object) {
108
+ case 0:
109
+ case "ADMIN_USAGE_GROUP_SORT_UNSPECIFIED":
110
+ return AdminUsageGroupSort.ADMIN_USAGE_GROUP_SORT_UNSPECIFIED;
111
+ case 1:
112
+ case "ADMIN_USAGE_GROUP_SORT_COST_DESC":
113
+ return AdminUsageGroupSort.ADMIN_USAGE_GROUP_SORT_COST_DESC;
114
+ case 2:
115
+ case "ADMIN_USAGE_GROUP_SORT_TOKENS_DESC":
116
+ return AdminUsageGroupSort.ADMIN_USAGE_GROUP_SORT_TOKENS_DESC;
117
+ case 3:
118
+ case "ADMIN_USAGE_GROUP_SORT_CALLS_DESC":
119
+ return AdminUsageGroupSort.ADMIN_USAGE_GROUP_SORT_CALLS_DESC;
120
+ case 4:
121
+ case "ADMIN_USAGE_GROUP_SORT_GROUP_ASC":
122
+ return AdminUsageGroupSort.ADMIN_USAGE_GROUP_SORT_GROUP_ASC;
123
+ case -1:
124
+ case "UNRECOGNIZED":
125
+ default:
126
+ return AdminUsageGroupSort.UNRECOGNIZED;
127
+ }
128
+ }
129
+
130
+ export function adminUsageGroupSortToJSON(object: AdminUsageGroupSort): string {
131
+ switch (object) {
132
+ case AdminUsageGroupSort.ADMIN_USAGE_GROUP_SORT_UNSPECIFIED:
133
+ return "ADMIN_USAGE_GROUP_SORT_UNSPECIFIED";
134
+ case AdminUsageGroupSort.ADMIN_USAGE_GROUP_SORT_COST_DESC:
135
+ return "ADMIN_USAGE_GROUP_SORT_COST_DESC";
136
+ case AdminUsageGroupSort.ADMIN_USAGE_GROUP_SORT_TOKENS_DESC:
137
+ return "ADMIN_USAGE_GROUP_SORT_TOKENS_DESC";
138
+ case AdminUsageGroupSort.ADMIN_USAGE_GROUP_SORT_CALLS_DESC:
139
+ return "ADMIN_USAGE_GROUP_SORT_CALLS_DESC";
140
+ case AdminUsageGroupSort.ADMIN_USAGE_GROUP_SORT_GROUP_ASC:
141
+ return "ADMIN_USAGE_GROUP_SORT_GROUP_ASC";
142
+ case AdminUsageGroupSort.UNRECOGNIZED:
143
+ default:
144
+ return "UNRECOGNIZED";
145
+ }
146
+ }
147
+
23
148
  export interface GetAdminStatusRequest {
24
149
  }
25
150
 
@@ -262,6 +387,103 @@ export interface AdminRelayHeartbeat_CountersEntry {
262
387
  value: number;
263
388
  }
264
389
 
390
+ export interface ListAdminUsageGroupsRequest {
391
+ /**
392
+ * The window is [start_time, end_time) in whole UTC days: both UTC midnights, end after start, at most 92 days
393
+ * apart, within 1970-01-01 to 2149-06-06; anything else is a validation error.
394
+ */
395
+ startTime: Date | undefined;
396
+ endTime:
397
+ | Date
398
+ | undefined;
399
+ /**
400
+ * The dimensions a row is grouped by, each at most once; empty is one row, the totals. UNSPECIFIED, an unknown
401
+ * value or a repeat is a validation error.
402
+ */
403
+ groupBy: AdminUsageDimension[];
404
+ filter:
405
+ | AdminUsageGroupFilter
406
+ | undefined;
407
+ /** Unspecified is ADMIN_USAGE_GROUP_SORT_COST_DESC; an unknown value is a validation error. */
408
+ sort: AdminUsageGroupSort;
409
+ /** 1-indexed; below 1 = 1. A page past the last returns the last page: read pagination.page. */
410
+ page: number;
411
+ /** The server default (50) when 0, coerced to 1000 above it; negative is a validation error. */
412
+ perPage: number;
413
+ }
414
+
415
+ export interface ListAdminUsageGroupsResponse {
416
+ status: ResponseStatus | undefined;
417
+ groups: AdminUsageGroup[];
418
+ /**
419
+ * total_count is the groups the window and filter hold, exact, computed on every request (a refresh between two
420
+ * pages can move groups across them); anchor_timestamp is unset.
421
+ */
422
+ pagination:
423
+ | Pagination
424
+ | undefined;
425
+ /**
426
+ * The newest daily-activity refresh among the slices read (its run's start), whatever the page. It is no
427
+ * completeness mark: a day the job no longer refreshes keeps its last run's figures. Unset when no slice matched.
428
+ */
429
+ refreshedAt: Date | undefined;
430
+ }
431
+
432
+ /**
433
+ * AdminUsageGroupFilter mirrors ai.api.v1.AdminUsageGroupFilter: fields AND, a repeated field matches any of its
434
+ * values, and an unset or empty field does not filter.
435
+ */
436
+ export interface AdminUsageGroupFilter {
437
+ /** Canonical UUIDs, at most 100; a malformed id is a validation error. */
438
+ organizationIds: string[];
439
+ /**
440
+ * Stored user ids, matched exactly, at most 100, each non-empty and at most 256 bytes. For a session the Terma CLI
441
+ * relayed this is the Mirador account user id the CLI claims (the relay's account_user_id); otherwise it is the
442
+ * harness's own id.
443
+ */
444
+ userIds: string[];
445
+ }
446
+
447
+ /**
448
+ * AdminUsageGroup mirrors ai.api.v1.AdminUsageGroup. A key field is set only for a dimension in group_by, where ''
449
+ * means the slices reported none (no model). Distinct counts are not additive across groups. A group can hold no
450
+ * tokens or cost: usage that is only sessions, files or git activity still counts.
451
+ */
452
+ export interface AdminUsageGroup {
453
+ organizationId: string;
454
+ /** USER for a user id, API_KEY for an api key id, UNSPECIFIED (with principal_id '') for unattributed usage. */
455
+ principalKind: AIPrincipalKind;
456
+ /**
457
+ * As reported, for display: a Mirador account user id is client-claimed through the Terma CLI, and a harness's
458
+ * own id names no Mirador user.
459
+ */
460
+ principalId: string;
461
+ sourceSystem: string;
462
+ model: string;
463
+ /** the UTC midnight */
464
+ day:
465
+ | Date
466
+ | undefined;
467
+ /** includes cache reads and writes */
468
+ inputTokens: number;
469
+ outputTokens: number;
470
+ cacheReadTokens: number;
471
+ cacheWriteTokens: number;
472
+ costUsd: number;
473
+ /** The part of cost_usd billed to a subscription. */
474
+ subscriptionCostUsd: number;
475
+ modelCalls: number;
476
+ toolCalls: number;
477
+ userMessages: number;
478
+ /**
479
+ * Distinct (source system, session) pairs across the fleet: a session reported to two projects counts once.
480
+ * Approximate past a few thousand (about 0.5%).
481
+ */
482
+ sessions: number;
483
+ /** Distinct stored user ids among the group's usage, exact; ids, not people. */
484
+ userIdCount: number;
485
+ }
486
+
265
487
  export interface ResolveOrgDetailsRequest {
266
488
  /** UUIDs, at most 1000; a malformed id is a validation error. */
267
489
  organizationIds: string[];
@@ -3322,19 +3544,37 @@ export const AdminRelayHeartbeat_CountersEntry: MessageFns<AdminRelayHeartbeat_C
3322
3544
  },
3323
3545
  };
3324
3546
 
3325
- function createBaseResolveOrgDetailsRequest(): ResolveOrgDetailsRequest {
3326
- return { organizationIds: [] };
3547
+ function createBaseListAdminUsageGroupsRequest(): ListAdminUsageGroupsRequest {
3548
+ return { startTime: undefined, endTime: undefined, groupBy: [], filter: undefined, sort: 0, page: 0, perPage: 0 };
3327
3549
  }
3328
3550
 
3329
- export const ResolveOrgDetailsRequest: MessageFns<ResolveOrgDetailsRequest> = {
3330
- encode(message: ResolveOrgDetailsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3331
- for (const v of message.organizationIds) {
3332
- writer.uint32(10).string(v!);
3551
+ export const ListAdminUsageGroupsRequest: MessageFns<ListAdminUsageGroupsRequest> = {
3552
+ encode(message: ListAdminUsageGroupsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3553
+ if (message.startTime !== undefined) {
3554
+ Timestamp.encode(toTimestamp(message.startTime), writer.uint32(10).fork()).join();
3555
+ }
3556
+ if (message.endTime !== undefined) {
3557
+ Timestamp.encode(toTimestamp(message.endTime), writer.uint32(18).fork()).join();
3558
+ }
3559
+ for (const v of message.groupBy) {
3560
+ writer.uint32(24).int32(v!);
3561
+ }
3562
+ if (message.filter !== undefined) {
3563
+ AdminUsageGroupFilter.encode(message.filter, writer.uint32(34).fork()).join();
3564
+ }
3565
+ if (message.sort !== 0) {
3566
+ writer.uint32(40).int32(message.sort);
3567
+ }
3568
+ if (message.page !== 0) {
3569
+ writer.uint32(48).int32(message.page);
3570
+ }
3571
+ if (message.perPage !== 0) {
3572
+ writer.uint32(56).int32(message.perPage);
3333
3573
  }
3334
3574
  return writer;
3335
3575
  },
3336
3576
 
3337
- decode(input: BinaryReader | Uint8Array, length?: number): ResolveOrgDetailsRequest {
3577
+ decode(input: BinaryReader | Uint8Array, length?: number): ListAdminUsageGroupsRequest {
3338
3578
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3339
3579
  const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
3340
3580
  if (previousRecursionDepth >= 100) {
@@ -3343,7 +3583,7 @@ export const ResolveOrgDetailsRequest: MessageFns<ResolveOrgDetailsRequest> = {
3343
3583
  (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
3344
3584
  try {
3345
3585
  const end = length === undefined ? reader.len : reader.pos + length;
3346
- const message = createBaseResolveOrgDetailsRequest();
3586
+ const message = createBaseListAdminUsageGroupsRequest();
3347
3587
  while (reader.pos < end) {
3348
3588
  const tag = reader.uint32();
3349
3589
  switch (tag >>> 3) {
@@ -3352,7 +3592,65 @@ export const ResolveOrgDetailsRequest: MessageFns<ResolveOrgDetailsRequest> = {
3352
3592
  break;
3353
3593
  }
3354
3594
 
3355
- message.organizationIds.push(reader.string());
3595
+ message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
3596
+ continue;
3597
+ }
3598
+ case 2: {
3599
+ if (tag !== 18) {
3600
+ break;
3601
+ }
3602
+
3603
+ message.endTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
3604
+ continue;
3605
+ }
3606
+ case 3: {
3607
+ if (tag === 24) {
3608
+ message.groupBy.push(reader.int32() as any);
3609
+
3610
+ continue;
3611
+ }
3612
+
3613
+ if (tag === 26) {
3614
+ const end2 = reader.uint32() + reader.pos;
3615
+ while (reader.pos < end2) {
3616
+ message.groupBy.push(reader.int32() as any);
3617
+ }
3618
+
3619
+ continue;
3620
+ }
3621
+
3622
+ break;
3623
+ }
3624
+ case 4: {
3625
+ if (tag !== 34) {
3626
+ break;
3627
+ }
3628
+
3629
+ message.filter = AdminUsageGroupFilter.decode(reader, reader.uint32());
3630
+ continue;
3631
+ }
3632
+ case 5: {
3633
+ if (tag !== 40) {
3634
+ break;
3635
+ }
3636
+
3637
+ message.sort = reader.int32() as any;
3638
+ continue;
3639
+ }
3640
+ case 6: {
3641
+ if (tag !== 48) {
3642
+ break;
3643
+ }
3644
+
3645
+ message.page = reader.int32();
3646
+ continue;
3647
+ }
3648
+ case 7: {
3649
+ if (tag !== 56) {
3650
+ break;
3651
+ }
3652
+
3653
+ message.perPage = reader.int32();
3356
3654
  continue;
3357
3655
  }
3358
3656
  }
@@ -3367,50 +3665,100 @@ export const ResolveOrgDetailsRequest: MessageFns<ResolveOrgDetailsRequest> = {
3367
3665
  }
3368
3666
  },
3369
3667
 
3370
- fromJSON(object: any): ResolveOrgDetailsRequest {
3668
+ fromJSON(object: any): ListAdminUsageGroupsRequest {
3371
3669
  return {
3372
- organizationIds: globalThis.Array.isArray(object?.organizationIds)
3373
- ? object.organizationIds.map((e: any) => globalThis.String(e))
3374
- : globalThis.Array.isArray(object?.organization_ids)
3375
- ? object.organization_ids.map((e: any) => globalThis.String(e))
3670
+ startTime: isSet(object.startTime)
3671
+ ? fromJsonTimestamp(object.startTime)
3672
+ : isSet(object.start_time)
3673
+ ? fromJsonTimestamp(object.start_time)
3674
+ : undefined,
3675
+ endTime: isSet(object.endTime)
3676
+ ? fromJsonTimestamp(object.endTime)
3677
+ : isSet(object.end_time)
3678
+ ? fromJsonTimestamp(object.end_time)
3679
+ : undefined,
3680
+ groupBy: globalThis.Array.isArray(object?.groupBy)
3681
+ ? object.groupBy.map((e: any) => adminUsageDimensionFromJSON(e))
3682
+ : globalThis.Array.isArray(object?.group_by)
3683
+ ? object.group_by.map((e: any) => adminUsageDimensionFromJSON(e))
3376
3684
  : [],
3685
+ filter: isSet(object.filter) ? AdminUsageGroupFilter.fromJSON(object.filter) : undefined,
3686
+ sort: isSet(object.sort) ? adminUsageGroupSortFromJSON(object.sort) : 0,
3687
+ page: isSet(object.page) ? globalThis.Number(object.page) : 0,
3688
+ perPage: isSet(object.perPage)
3689
+ ? globalThis.Number(object.perPage)
3690
+ : isSet(object.per_page)
3691
+ ? globalThis.Number(object.per_page)
3692
+ : 0,
3377
3693
  };
3378
3694
  },
3379
3695
 
3380
- toJSON(message: ResolveOrgDetailsRequest): unknown {
3696
+ toJSON(message: ListAdminUsageGroupsRequest): unknown {
3381
3697
  const obj: any = {};
3382
- if (message.organizationIds?.length) {
3383
- obj.organizationIds = message.organizationIds;
3698
+ if (message.startTime !== undefined) {
3699
+ obj.startTime = message.startTime.toISOString();
3700
+ }
3701
+ if (message.endTime !== undefined) {
3702
+ obj.endTime = message.endTime.toISOString();
3703
+ }
3704
+ if (message.groupBy?.length) {
3705
+ obj.groupBy = message.groupBy.map((e) => adminUsageDimensionToJSON(e));
3706
+ }
3707
+ if (message.filter !== undefined) {
3708
+ obj.filter = AdminUsageGroupFilter.toJSON(message.filter);
3709
+ }
3710
+ if (message.sort !== 0) {
3711
+ obj.sort = adminUsageGroupSortToJSON(message.sort);
3712
+ }
3713
+ if (message.page !== 0) {
3714
+ obj.page = Math.round(message.page);
3715
+ }
3716
+ if (message.perPage !== 0) {
3717
+ obj.perPage = Math.round(message.perPage);
3384
3718
  }
3385
3719
  return obj;
3386
3720
  },
3387
3721
 
3388
- create<I extends Exact<DeepPartial<ResolveOrgDetailsRequest>, I>>(base?: I): ResolveOrgDetailsRequest {
3389
- return ResolveOrgDetailsRequest.fromPartial(base ?? ({} as any));
3722
+ create<I extends Exact<DeepPartial<ListAdminUsageGroupsRequest>, I>>(base?: I): ListAdminUsageGroupsRequest {
3723
+ return ListAdminUsageGroupsRequest.fromPartial(base ?? ({} as any));
3390
3724
  },
3391
- fromPartial<I extends Exact<DeepPartial<ResolveOrgDetailsRequest>, I>>(object: I): ResolveOrgDetailsRequest {
3392
- const message = createBaseResolveOrgDetailsRequest();
3393
- message.organizationIds = object.organizationIds?.map((e) => e) || [];
3725
+ fromPartial<I extends Exact<DeepPartial<ListAdminUsageGroupsRequest>, I>>(object: I): ListAdminUsageGroupsRequest {
3726
+ const message = createBaseListAdminUsageGroupsRequest();
3727
+ message.startTime = object.startTime ?? undefined;
3728
+ message.endTime = object.endTime ?? undefined;
3729
+ message.groupBy = object.groupBy?.map((e) => e) || [];
3730
+ message.filter = (object.filter !== undefined && object.filter !== null)
3731
+ ? AdminUsageGroupFilter.fromPartial(object.filter)
3732
+ : undefined;
3733
+ message.sort = object.sort ?? 0;
3734
+ message.page = object.page ?? 0;
3735
+ message.perPage = object.perPage ?? 0;
3394
3736
  return message;
3395
3737
  },
3396
3738
  };
3397
3739
 
3398
- function createBaseResolveOrgDetailsResponse(): ResolveOrgDetailsResponse {
3399
- return { status: undefined, organizations: [] };
3740
+ function createBaseListAdminUsageGroupsResponse(): ListAdminUsageGroupsResponse {
3741
+ return { status: undefined, groups: [], pagination: undefined, refreshedAt: undefined };
3400
3742
  }
3401
3743
 
3402
- export const ResolveOrgDetailsResponse: MessageFns<ResolveOrgDetailsResponse> = {
3403
- encode(message: ResolveOrgDetailsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3744
+ export const ListAdminUsageGroupsResponse: MessageFns<ListAdminUsageGroupsResponse> = {
3745
+ encode(message: ListAdminUsageGroupsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3404
3746
  if (message.status !== undefined) {
3405
3747
  ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
3406
3748
  }
3407
- for (const v of message.organizations) {
3408
- OrgDetails.encode(v!, writer.uint32(18).fork()).join();
3749
+ for (const v of message.groups) {
3750
+ AdminUsageGroup.encode(v!, writer.uint32(18).fork()).join();
3751
+ }
3752
+ if (message.pagination !== undefined) {
3753
+ Pagination.encode(message.pagination, writer.uint32(26).fork()).join();
3754
+ }
3755
+ if (message.refreshedAt !== undefined) {
3756
+ Timestamp.encode(toTimestamp(message.refreshedAt), writer.uint32(34).fork()).join();
3409
3757
  }
3410
3758
  return writer;
3411
3759
  },
3412
3760
 
3413
- decode(input: BinaryReader | Uint8Array, length?: number): ResolveOrgDetailsResponse {
3761
+ decode(input: BinaryReader | Uint8Array, length?: number): ListAdminUsageGroupsResponse {
3414
3762
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3415
3763
  const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
3416
3764
  if (previousRecursionDepth >= 100) {
@@ -3419,7 +3767,7 @@ export const ResolveOrgDetailsResponse: MessageFns<ResolveOrgDetailsResponse> =
3419
3767
  (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
3420
3768
  try {
3421
3769
  const end = length === undefined ? reader.len : reader.pos + length;
3422
- const message = createBaseResolveOrgDetailsResponse();
3770
+ const message = createBaseListAdminUsageGroupsResponse();
3423
3771
  while (reader.pos < end) {
3424
3772
  const tag = reader.uint32();
3425
3773
  switch (tag >>> 3) {
@@ -3436,7 +3784,23 @@ export const ResolveOrgDetailsResponse: MessageFns<ResolveOrgDetailsResponse> =
3436
3784
  break;
3437
3785
  }
3438
3786
 
3439
- message.organizations.push(OrgDetails.decode(reader, reader.uint32()));
3787
+ message.groups.push(AdminUsageGroup.decode(reader, reader.uint32()));
3788
+ continue;
3789
+ }
3790
+ case 3: {
3791
+ if (tag !== 26) {
3792
+ break;
3793
+ }
3794
+
3795
+ message.pagination = Pagination.decode(reader, reader.uint32());
3796
+ continue;
3797
+ }
3798
+ case 4: {
3799
+ if (tag !== 34) {
3800
+ break;
3801
+ }
3802
+
3803
+ message.refreshedAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
3440
3804
  continue;
3441
3805
  }
3442
3806
  }
@@ -3451,55 +3815,71 @@ export const ResolveOrgDetailsResponse: MessageFns<ResolveOrgDetailsResponse> =
3451
3815
  }
3452
3816
  },
3453
3817
 
3454
- fromJSON(object: any): ResolveOrgDetailsResponse {
3818
+ fromJSON(object: any): ListAdminUsageGroupsResponse {
3455
3819
  return {
3456
3820
  status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
3457
- organizations: globalThis.Array.isArray(object?.organizations)
3458
- ? object.organizations.map((e: any) => OrgDetails.fromJSON(e))
3821
+ groups: globalThis.Array.isArray(object?.groups)
3822
+ ? object.groups.map((e: any) => AdminUsageGroup.fromJSON(e))
3459
3823
  : [],
3824
+ pagination: isSet(object.pagination) ? Pagination.fromJSON(object.pagination) : undefined,
3825
+ refreshedAt: isSet(object.refreshedAt)
3826
+ ? fromJsonTimestamp(object.refreshedAt)
3827
+ : isSet(object.refreshed_at)
3828
+ ? fromJsonTimestamp(object.refreshed_at)
3829
+ : undefined,
3460
3830
  };
3461
3831
  },
3462
3832
 
3463
- toJSON(message: ResolveOrgDetailsResponse): unknown {
3833
+ toJSON(message: ListAdminUsageGroupsResponse): unknown {
3464
3834
  const obj: any = {};
3465
3835
  if (message.status !== undefined) {
3466
3836
  obj.status = ResponseStatus.toJSON(message.status);
3467
3837
  }
3468
- if (message.organizations?.length) {
3469
- obj.organizations = message.organizations.map((e) => OrgDetails.toJSON(e));
3838
+ if (message.groups?.length) {
3839
+ obj.groups = message.groups.map((e) => AdminUsageGroup.toJSON(e));
3840
+ }
3841
+ if (message.pagination !== undefined) {
3842
+ obj.pagination = Pagination.toJSON(message.pagination);
3843
+ }
3844
+ if (message.refreshedAt !== undefined) {
3845
+ obj.refreshedAt = message.refreshedAt.toISOString();
3470
3846
  }
3471
3847
  return obj;
3472
3848
  },
3473
3849
 
3474
- create<I extends Exact<DeepPartial<ResolveOrgDetailsResponse>, I>>(base?: I): ResolveOrgDetailsResponse {
3475
- return ResolveOrgDetailsResponse.fromPartial(base ?? ({} as any));
3850
+ create<I extends Exact<DeepPartial<ListAdminUsageGroupsResponse>, I>>(base?: I): ListAdminUsageGroupsResponse {
3851
+ return ListAdminUsageGroupsResponse.fromPartial(base ?? ({} as any));
3476
3852
  },
3477
- fromPartial<I extends Exact<DeepPartial<ResolveOrgDetailsResponse>, I>>(object: I): ResolveOrgDetailsResponse {
3478
- const message = createBaseResolveOrgDetailsResponse();
3853
+ fromPartial<I extends Exact<DeepPartial<ListAdminUsageGroupsResponse>, I>>(object: I): ListAdminUsageGroupsResponse {
3854
+ const message = createBaseListAdminUsageGroupsResponse();
3479
3855
  message.status = (object.status !== undefined && object.status !== null)
3480
3856
  ? ResponseStatus.fromPartial(object.status)
3481
3857
  : undefined;
3482
- message.organizations = object.organizations?.map((e) => OrgDetails.fromPartial(e)) || [];
3858
+ message.groups = object.groups?.map((e) => AdminUsageGroup.fromPartial(e)) || [];
3859
+ message.pagination = (object.pagination !== undefined && object.pagination !== null)
3860
+ ? Pagination.fromPartial(object.pagination)
3861
+ : undefined;
3862
+ message.refreshedAt = object.refreshedAt ?? undefined;
3483
3863
  return message;
3484
3864
  },
3485
3865
  };
3486
3866
 
3487
- function createBaseOrgDetails(): OrgDetails {
3488
- return { organizationId: "", name: "" };
3867
+ function createBaseAdminUsageGroupFilter(): AdminUsageGroupFilter {
3868
+ return { organizationIds: [], userIds: [] };
3489
3869
  }
3490
3870
 
3491
- export const OrgDetails: MessageFns<OrgDetails> = {
3492
- encode(message: OrgDetails, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3493
- if (message.organizationId !== "") {
3494
- writer.uint32(10).string(message.organizationId);
3871
+ export const AdminUsageGroupFilter: MessageFns<AdminUsageGroupFilter> = {
3872
+ encode(message: AdminUsageGroupFilter, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3873
+ for (const v of message.organizationIds) {
3874
+ writer.uint32(10).string(v!);
3495
3875
  }
3496
- if (message.name !== "") {
3497
- writer.uint32(18).string(message.name);
3876
+ for (const v of message.userIds) {
3877
+ writer.uint32(18).string(v!);
3498
3878
  }
3499
3879
  return writer;
3500
3880
  },
3501
3881
 
3502
- decode(input: BinaryReader | Uint8Array, length?: number): OrgDetails {
3882
+ decode(input: BinaryReader | Uint8Array, length?: number): AdminUsageGroupFilter {
3503
3883
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3504
3884
  const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
3505
3885
  if (previousRecursionDepth >= 100) {
@@ -3508,7 +3888,7 @@ export const OrgDetails: MessageFns<OrgDetails> = {
3508
3888
  (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
3509
3889
  try {
3510
3890
  const end = length === undefined ? reader.len : reader.pos + length;
3511
- const message = createBaseOrgDetails();
3891
+ const message = createBaseAdminUsageGroupFilter();
3512
3892
  while (reader.pos < end) {
3513
3893
  const tag = reader.uint32();
3514
3894
  switch (tag >>> 3) {
@@ -3517,7 +3897,7 @@ export const OrgDetails: MessageFns<OrgDetails> = {
3517
3897
  break;
3518
3898
  }
3519
3899
 
3520
- message.organizationId = reader.string();
3900
+ message.organizationIds.push(reader.string());
3521
3901
  continue;
3522
3902
  }
3523
3903
  case 2: {
@@ -3525,7 +3905,7 @@ export const OrgDetails: MessageFns<OrgDetails> = {
3525
3905
  break;
3526
3906
  }
3527
3907
 
3528
- message.name = reader.string();
3908
+ message.userIds.push(reader.string());
3529
3909
  continue;
3530
3910
  }
3531
3911
  }
@@ -3540,52 +3920,122 @@ export const OrgDetails: MessageFns<OrgDetails> = {
3540
3920
  }
3541
3921
  },
3542
3922
 
3543
- fromJSON(object: any): OrgDetails {
3923
+ fromJSON(object: any): AdminUsageGroupFilter {
3544
3924
  return {
3545
- organizationId: isSet(object.organizationId)
3546
- ? globalThis.String(object.organizationId)
3547
- : isSet(object.organization_id)
3548
- ? globalThis.String(object.organization_id)
3549
- : "",
3550
- name: isSet(object.name) ? globalThis.String(object.name) : "",
3925
+ organizationIds: globalThis.Array.isArray(object?.organizationIds)
3926
+ ? object.organizationIds.map((e: any) => globalThis.String(e))
3927
+ : globalThis.Array.isArray(object?.organization_ids)
3928
+ ? object.organization_ids.map((e: any) => globalThis.String(e))
3929
+ : [],
3930
+ userIds: globalThis.Array.isArray(object?.userIds)
3931
+ ? object.userIds.map((e: any) => globalThis.String(e))
3932
+ : globalThis.Array.isArray(object?.user_ids)
3933
+ ? object.user_ids.map((e: any) => globalThis.String(e))
3934
+ : [],
3551
3935
  };
3552
3936
  },
3553
3937
 
3554
- toJSON(message: OrgDetails): unknown {
3938
+ toJSON(message: AdminUsageGroupFilter): unknown {
3555
3939
  const obj: any = {};
3556
- if (message.organizationId !== "") {
3557
- obj.organizationId = message.organizationId;
3940
+ if (message.organizationIds?.length) {
3941
+ obj.organizationIds = message.organizationIds;
3558
3942
  }
3559
- if (message.name !== "") {
3560
- obj.name = message.name;
3943
+ if (message.userIds?.length) {
3944
+ obj.userIds = message.userIds;
3561
3945
  }
3562
3946
  return obj;
3563
3947
  },
3564
3948
 
3565
- create<I extends Exact<DeepPartial<OrgDetails>, I>>(base?: I): OrgDetails {
3566
- return OrgDetails.fromPartial(base ?? ({} as any));
3949
+ create<I extends Exact<DeepPartial<AdminUsageGroupFilter>, I>>(base?: I): AdminUsageGroupFilter {
3950
+ return AdminUsageGroupFilter.fromPartial(base ?? ({} as any));
3567
3951
  },
3568
- fromPartial<I extends Exact<DeepPartial<OrgDetails>, I>>(object: I): OrgDetails {
3569
- const message = createBaseOrgDetails();
3570
- message.organizationId = object.organizationId ?? "";
3571
- message.name = object.name ?? "";
3952
+ fromPartial<I extends Exact<DeepPartial<AdminUsageGroupFilter>, I>>(object: I): AdminUsageGroupFilter {
3953
+ const message = createBaseAdminUsageGroupFilter();
3954
+ message.organizationIds = object.organizationIds?.map((e) => e) || [];
3955
+ message.userIds = object.userIds?.map((e) => e) || [];
3572
3956
  return message;
3573
3957
  },
3574
3958
  };
3575
3959
 
3576
- function createBaseResolveProjectDetailsRequest(): ResolveProjectDetailsRequest {
3577
- return { projectIds: [] };
3960
+ function createBaseAdminUsageGroup(): AdminUsageGroup {
3961
+ return {
3962
+ organizationId: "",
3963
+ principalKind: 0,
3964
+ principalId: "",
3965
+ sourceSystem: "",
3966
+ model: "",
3967
+ day: undefined,
3968
+ inputTokens: 0,
3969
+ outputTokens: 0,
3970
+ cacheReadTokens: 0,
3971
+ cacheWriteTokens: 0,
3972
+ costUsd: 0,
3973
+ subscriptionCostUsd: 0,
3974
+ modelCalls: 0,
3975
+ toolCalls: 0,
3976
+ userMessages: 0,
3977
+ sessions: 0,
3978
+ userIdCount: 0,
3979
+ };
3578
3980
  }
3579
3981
 
3580
- export const ResolveProjectDetailsRequest: MessageFns<ResolveProjectDetailsRequest> = {
3581
- encode(message: ResolveProjectDetailsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3582
- for (const v of message.projectIds) {
3583
- writer.uint32(10).string(v!);
3982
+ export const AdminUsageGroup: MessageFns<AdminUsageGroup> = {
3983
+ encode(message: AdminUsageGroup, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3984
+ if (message.organizationId !== "") {
3985
+ writer.uint32(10).string(message.organizationId);
3986
+ }
3987
+ if (message.principalKind !== 0) {
3988
+ writer.uint32(16).int32(message.principalKind);
3989
+ }
3990
+ if (message.principalId !== "") {
3991
+ writer.uint32(26).string(message.principalId);
3992
+ }
3993
+ if (message.sourceSystem !== "") {
3994
+ writer.uint32(34).string(message.sourceSystem);
3995
+ }
3996
+ if (message.model !== "") {
3997
+ writer.uint32(42).string(message.model);
3998
+ }
3999
+ if (message.day !== undefined) {
4000
+ Timestamp.encode(toTimestamp(message.day), writer.uint32(50).fork()).join();
4001
+ }
4002
+ if (message.inputTokens !== 0) {
4003
+ writer.uint32(56).uint64(message.inputTokens);
4004
+ }
4005
+ if (message.outputTokens !== 0) {
4006
+ writer.uint32(64).uint64(message.outputTokens);
4007
+ }
4008
+ if (message.cacheReadTokens !== 0) {
4009
+ writer.uint32(72).uint64(message.cacheReadTokens);
4010
+ }
4011
+ if (message.cacheWriteTokens !== 0) {
4012
+ writer.uint32(80).uint64(message.cacheWriteTokens);
4013
+ }
4014
+ if (message.costUsd !== 0) {
4015
+ writer.uint32(89).double(message.costUsd);
4016
+ }
4017
+ if (message.subscriptionCostUsd !== 0) {
4018
+ writer.uint32(97).double(message.subscriptionCostUsd);
4019
+ }
4020
+ if (message.modelCalls !== 0) {
4021
+ writer.uint32(104).uint64(message.modelCalls);
4022
+ }
4023
+ if (message.toolCalls !== 0) {
4024
+ writer.uint32(112).uint64(message.toolCalls);
4025
+ }
4026
+ if (message.userMessages !== 0) {
4027
+ writer.uint32(120).uint64(message.userMessages);
4028
+ }
4029
+ if (message.sessions !== 0) {
4030
+ writer.uint32(128).uint64(message.sessions);
4031
+ }
4032
+ if (message.userIdCount !== 0) {
4033
+ writer.uint32(136).uint64(message.userIdCount);
3584
4034
  }
3585
4035
  return writer;
3586
4036
  },
3587
4037
 
3588
- decode(input: BinaryReader | Uint8Array, length?: number): ResolveProjectDetailsRequest {
4038
+ decode(input: BinaryReader | Uint8Array, length?: number): AdminUsageGroup {
3589
4039
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3590
4040
  const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
3591
4041
  if (previousRecursionDepth >= 100) {
@@ -3594,7 +4044,7 @@ export const ResolveProjectDetailsRequest: MessageFns<ResolveProjectDetailsReque
3594
4044
  (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
3595
4045
  try {
3596
4046
  const end = length === undefined ? reader.len : reader.pos + length;
3597
- const message = createBaseResolveProjectDetailsRequest();
4047
+ const message = createBaseAdminUsageGroup();
3598
4048
  while (reader.pos < end) {
3599
4049
  const tag = reader.uint32();
3600
4050
  switch (tag >>> 3) {
@@ -3603,14 +4053,598 @@ export const ResolveProjectDetailsRequest: MessageFns<ResolveProjectDetailsReque
3603
4053
  break;
3604
4054
  }
3605
4055
 
3606
- message.projectIds.push(reader.string());
4056
+ message.organizationId = reader.string();
3607
4057
  continue;
3608
4058
  }
3609
- }
3610
- if ((tag & 7) === 4 || tag === 0) {
3611
- break;
3612
- }
3613
- reader.skip(tag & 7);
4059
+ case 2: {
4060
+ if (tag !== 16) {
4061
+ break;
4062
+ }
4063
+
4064
+ message.principalKind = reader.int32() as any;
4065
+ continue;
4066
+ }
4067
+ case 3: {
4068
+ if (tag !== 26) {
4069
+ break;
4070
+ }
4071
+
4072
+ message.principalId = reader.string();
4073
+ continue;
4074
+ }
4075
+ case 4: {
4076
+ if (tag !== 34) {
4077
+ break;
4078
+ }
4079
+
4080
+ message.sourceSystem = reader.string();
4081
+ continue;
4082
+ }
4083
+ case 5: {
4084
+ if (tag !== 42) {
4085
+ break;
4086
+ }
4087
+
4088
+ message.model = reader.string();
4089
+ continue;
4090
+ }
4091
+ case 6: {
4092
+ if (tag !== 50) {
4093
+ break;
4094
+ }
4095
+
4096
+ message.day = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
4097
+ continue;
4098
+ }
4099
+ case 7: {
4100
+ if (tag !== 56) {
4101
+ break;
4102
+ }
4103
+
4104
+ message.inputTokens = longToNumber(reader.uint64());
4105
+ continue;
4106
+ }
4107
+ case 8: {
4108
+ if (tag !== 64) {
4109
+ break;
4110
+ }
4111
+
4112
+ message.outputTokens = longToNumber(reader.uint64());
4113
+ continue;
4114
+ }
4115
+ case 9: {
4116
+ if (tag !== 72) {
4117
+ break;
4118
+ }
4119
+
4120
+ message.cacheReadTokens = longToNumber(reader.uint64());
4121
+ continue;
4122
+ }
4123
+ case 10: {
4124
+ if (tag !== 80) {
4125
+ break;
4126
+ }
4127
+
4128
+ message.cacheWriteTokens = longToNumber(reader.uint64());
4129
+ continue;
4130
+ }
4131
+ case 11: {
4132
+ if (tag !== 89) {
4133
+ break;
4134
+ }
4135
+
4136
+ message.costUsd = reader.double();
4137
+ continue;
4138
+ }
4139
+ case 12: {
4140
+ if (tag !== 97) {
4141
+ break;
4142
+ }
4143
+
4144
+ message.subscriptionCostUsd = reader.double();
4145
+ continue;
4146
+ }
4147
+ case 13: {
4148
+ if (tag !== 104) {
4149
+ break;
4150
+ }
4151
+
4152
+ message.modelCalls = longToNumber(reader.uint64());
4153
+ continue;
4154
+ }
4155
+ case 14: {
4156
+ if (tag !== 112) {
4157
+ break;
4158
+ }
4159
+
4160
+ message.toolCalls = longToNumber(reader.uint64());
4161
+ continue;
4162
+ }
4163
+ case 15: {
4164
+ if (tag !== 120) {
4165
+ break;
4166
+ }
4167
+
4168
+ message.userMessages = longToNumber(reader.uint64());
4169
+ continue;
4170
+ }
4171
+ case 16: {
4172
+ if (tag !== 128) {
4173
+ break;
4174
+ }
4175
+
4176
+ message.sessions = longToNumber(reader.uint64());
4177
+ continue;
4178
+ }
4179
+ case 17: {
4180
+ if (tag !== 136) {
4181
+ break;
4182
+ }
4183
+
4184
+ message.userIdCount = longToNumber(reader.uint64());
4185
+ continue;
4186
+ }
4187
+ }
4188
+ if ((tag & 7) === 4 || tag === 0) {
4189
+ break;
4190
+ }
4191
+ reader.skip(tag & 7);
4192
+ }
4193
+ return message;
4194
+ } finally {
4195
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
4196
+ }
4197
+ },
4198
+
4199
+ fromJSON(object: any): AdminUsageGroup {
4200
+ return {
4201
+ organizationId: isSet(object.organizationId)
4202
+ ? globalThis.String(object.organizationId)
4203
+ : isSet(object.organization_id)
4204
+ ? globalThis.String(object.organization_id)
4205
+ : "",
4206
+ principalKind: isSet(object.principalKind)
4207
+ ? aIPrincipalKindFromJSON(object.principalKind)
4208
+ : isSet(object.principal_kind)
4209
+ ? aIPrincipalKindFromJSON(object.principal_kind)
4210
+ : 0,
4211
+ principalId: isSet(object.principalId)
4212
+ ? globalThis.String(object.principalId)
4213
+ : isSet(object.principal_id)
4214
+ ? globalThis.String(object.principal_id)
4215
+ : "",
4216
+ sourceSystem: isSet(object.sourceSystem)
4217
+ ? globalThis.String(object.sourceSystem)
4218
+ : isSet(object.source_system)
4219
+ ? globalThis.String(object.source_system)
4220
+ : "",
4221
+ model: isSet(object.model) ? globalThis.String(object.model) : "",
4222
+ day: isSet(object.day) ? fromJsonTimestamp(object.day) : undefined,
4223
+ inputTokens: isSet(object.inputTokens)
4224
+ ? globalThis.Number(object.inputTokens)
4225
+ : isSet(object.input_tokens)
4226
+ ? globalThis.Number(object.input_tokens)
4227
+ : 0,
4228
+ outputTokens: isSet(object.outputTokens)
4229
+ ? globalThis.Number(object.outputTokens)
4230
+ : isSet(object.output_tokens)
4231
+ ? globalThis.Number(object.output_tokens)
4232
+ : 0,
4233
+ cacheReadTokens: isSet(object.cacheReadTokens)
4234
+ ? globalThis.Number(object.cacheReadTokens)
4235
+ : isSet(object.cache_read_tokens)
4236
+ ? globalThis.Number(object.cache_read_tokens)
4237
+ : 0,
4238
+ cacheWriteTokens: isSet(object.cacheWriteTokens)
4239
+ ? globalThis.Number(object.cacheWriteTokens)
4240
+ : isSet(object.cache_write_tokens)
4241
+ ? globalThis.Number(object.cache_write_tokens)
4242
+ : 0,
4243
+ costUsd: isSet(object.costUsd)
4244
+ ? globalThis.Number(object.costUsd)
4245
+ : isSet(object.cost_usd)
4246
+ ? globalThis.Number(object.cost_usd)
4247
+ : 0,
4248
+ subscriptionCostUsd: isSet(object.subscriptionCostUsd)
4249
+ ? globalThis.Number(object.subscriptionCostUsd)
4250
+ : isSet(object.subscription_cost_usd)
4251
+ ? globalThis.Number(object.subscription_cost_usd)
4252
+ : 0,
4253
+ modelCalls: isSet(object.modelCalls)
4254
+ ? globalThis.Number(object.modelCalls)
4255
+ : isSet(object.model_calls)
4256
+ ? globalThis.Number(object.model_calls)
4257
+ : 0,
4258
+ toolCalls: isSet(object.toolCalls)
4259
+ ? globalThis.Number(object.toolCalls)
4260
+ : isSet(object.tool_calls)
4261
+ ? globalThis.Number(object.tool_calls)
4262
+ : 0,
4263
+ userMessages: isSet(object.userMessages)
4264
+ ? globalThis.Number(object.userMessages)
4265
+ : isSet(object.user_messages)
4266
+ ? globalThis.Number(object.user_messages)
4267
+ : 0,
4268
+ sessions: isSet(object.sessions) ? globalThis.Number(object.sessions) : 0,
4269
+ userIdCount: isSet(object.userIdCount)
4270
+ ? globalThis.Number(object.userIdCount)
4271
+ : isSet(object.user_id_count)
4272
+ ? globalThis.Number(object.user_id_count)
4273
+ : 0,
4274
+ };
4275
+ },
4276
+
4277
+ toJSON(message: AdminUsageGroup): unknown {
4278
+ const obj: any = {};
4279
+ if (message.organizationId !== "") {
4280
+ obj.organizationId = message.organizationId;
4281
+ }
4282
+ if (message.principalKind !== 0) {
4283
+ obj.principalKind = aIPrincipalKindToJSON(message.principalKind);
4284
+ }
4285
+ if (message.principalId !== "") {
4286
+ obj.principalId = message.principalId;
4287
+ }
4288
+ if (message.sourceSystem !== "") {
4289
+ obj.sourceSystem = message.sourceSystem;
4290
+ }
4291
+ if (message.model !== "") {
4292
+ obj.model = message.model;
4293
+ }
4294
+ if (message.day !== undefined) {
4295
+ obj.day = message.day.toISOString();
4296
+ }
4297
+ if (message.inputTokens !== 0) {
4298
+ obj.inputTokens = Math.round(message.inputTokens);
4299
+ }
4300
+ if (message.outputTokens !== 0) {
4301
+ obj.outputTokens = Math.round(message.outputTokens);
4302
+ }
4303
+ if (message.cacheReadTokens !== 0) {
4304
+ obj.cacheReadTokens = Math.round(message.cacheReadTokens);
4305
+ }
4306
+ if (message.cacheWriteTokens !== 0) {
4307
+ obj.cacheWriteTokens = Math.round(message.cacheWriteTokens);
4308
+ }
4309
+ if (message.costUsd !== 0) {
4310
+ obj.costUsd = floatToJson(message.costUsd);
4311
+ }
4312
+ if (message.subscriptionCostUsd !== 0) {
4313
+ obj.subscriptionCostUsd = floatToJson(message.subscriptionCostUsd);
4314
+ }
4315
+ if (message.modelCalls !== 0) {
4316
+ obj.modelCalls = Math.round(message.modelCalls);
4317
+ }
4318
+ if (message.toolCalls !== 0) {
4319
+ obj.toolCalls = Math.round(message.toolCalls);
4320
+ }
4321
+ if (message.userMessages !== 0) {
4322
+ obj.userMessages = Math.round(message.userMessages);
4323
+ }
4324
+ if (message.sessions !== 0) {
4325
+ obj.sessions = Math.round(message.sessions);
4326
+ }
4327
+ if (message.userIdCount !== 0) {
4328
+ obj.userIdCount = Math.round(message.userIdCount);
4329
+ }
4330
+ return obj;
4331
+ },
4332
+
4333
+ create<I extends Exact<DeepPartial<AdminUsageGroup>, I>>(base?: I): AdminUsageGroup {
4334
+ return AdminUsageGroup.fromPartial(base ?? ({} as any));
4335
+ },
4336
+ fromPartial<I extends Exact<DeepPartial<AdminUsageGroup>, I>>(object: I): AdminUsageGroup {
4337
+ const message = createBaseAdminUsageGroup();
4338
+ message.organizationId = object.organizationId ?? "";
4339
+ message.principalKind = object.principalKind ?? 0;
4340
+ message.principalId = object.principalId ?? "";
4341
+ message.sourceSystem = object.sourceSystem ?? "";
4342
+ message.model = object.model ?? "";
4343
+ message.day = object.day ?? undefined;
4344
+ message.inputTokens = object.inputTokens ?? 0;
4345
+ message.outputTokens = object.outputTokens ?? 0;
4346
+ message.cacheReadTokens = object.cacheReadTokens ?? 0;
4347
+ message.cacheWriteTokens = object.cacheWriteTokens ?? 0;
4348
+ message.costUsd = object.costUsd ?? 0;
4349
+ message.subscriptionCostUsd = object.subscriptionCostUsd ?? 0;
4350
+ message.modelCalls = object.modelCalls ?? 0;
4351
+ message.toolCalls = object.toolCalls ?? 0;
4352
+ message.userMessages = object.userMessages ?? 0;
4353
+ message.sessions = object.sessions ?? 0;
4354
+ message.userIdCount = object.userIdCount ?? 0;
4355
+ return message;
4356
+ },
4357
+ };
4358
+
4359
+ function createBaseResolveOrgDetailsRequest(): ResolveOrgDetailsRequest {
4360
+ return { organizationIds: [] };
4361
+ }
4362
+
4363
+ export const ResolveOrgDetailsRequest: MessageFns<ResolveOrgDetailsRequest> = {
4364
+ encode(message: ResolveOrgDetailsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
4365
+ for (const v of message.organizationIds) {
4366
+ writer.uint32(10).string(v!);
4367
+ }
4368
+ return writer;
4369
+ },
4370
+
4371
+ decode(input: BinaryReader | Uint8Array, length?: number): ResolveOrgDetailsRequest {
4372
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
4373
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
4374
+ if (previousRecursionDepth >= 100) {
4375
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
4376
+ }
4377
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
4378
+ try {
4379
+ const end = length === undefined ? reader.len : reader.pos + length;
4380
+ const message = createBaseResolveOrgDetailsRequest();
4381
+ while (reader.pos < end) {
4382
+ const tag = reader.uint32();
4383
+ switch (tag >>> 3) {
4384
+ case 1: {
4385
+ if (tag !== 10) {
4386
+ break;
4387
+ }
4388
+
4389
+ message.organizationIds.push(reader.string());
4390
+ continue;
4391
+ }
4392
+ }
4393
+ if ((tag & 7) === 4 || tag === 0) {
4394
+ break;
4395
+ }
4396
+ reader.skip(tag & 7);
4397
+ }
4398
+ return message;
4399
+ } finally {
4400
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
4401
+ }
4402
+ },
4403
+
4404
+ fromJSON(object: any): ResolveOrgDetailsRequest {
4405
+ return {
4406
+ organizationIds: globalThis.Array.isArray(object?.organizationIds)
4407
+ ? object.organizationIds.map((e: any) => globalThis.String(e))
4408
+ : globalThis.Array.isArray(object?.organization_ids)
4409
+ ? object.organization_ids.map((e: any) => globalThis.String(e))
4410
+ : [],
4411
+ };
4412
+ },
4413
+
4414
+ toJSON(message: ResolveOrgDetailsRequest): unknown {
4415
+ const obj: any = {};
4416
+ if (message.organizationIds?.length) {
4417
+ obj.organizationIds = message.organizationIds;
4418
+ }
4419
+ return obj;
4420
+ },
4421
+
4422
+ create<I extends Exact<DeepPartial<ResolveOrgDetailsRequest>, I>>(base?: I): ResolveOrgDetailsRequest {
4423
+ return ResolveOrgDetailsRequest.fromPartial(base ?? ({} as any));
4424
+ },
4425
+ fromPartial<I extends Exact<DeepPartial<ResolveOrgDetailsRequest>, I>>(object: I): ResolveOrgDetailsRequest {
4426
+ const message = createBaseResolveOrgDetailsRequest();
4427
+ message.organizationIds = object.organizationIds?.map((e) => e) || [];
4428
+ return message;
4429
+ },
4430
+ };
4431
+
4432
+ function createBaseResolveOrgDetailsResponse(): ResolveOrgDetailsResponse {
4433
+ return { status: undefined, organizations: [] };
4434
+ }
4435
+
4436
+ export const ResolveOrgDetailsResponse: MessageFns<ResolveOrgDetailsResponse> = {
4437
+ encode(message: ResolveOrgDetailsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
4438
+ if (message.status !== undefined) {
4439
+ ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
4440
+ }
4441
+ for (const v of message.organizations) {
4442
+ OrgDetails.encode(v!, writer.uint32(18).fork()).join();
4443
+ }
4444
+ return writer;
4445
+ },
4446
+
4447
+ decode(input: BinaryReader | Uint8Array, length?: number): ResolveOrgDetailsResponse {
4448
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
4449
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
4450
+ if (previousRecursionDepth >= 100) {
4451
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
4452
+ }
4453
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
4454
+ try {
4455
+ const end = length === undefined ? reader.len : reader.pos + length;
4456
+ const message = createBaseResolveOrgDetailsResponse();
4457
+ while (reader.pos < end) {
4458
+ const tag = reader.uint32();
4459
+ switch (tag >>> 3) {
4460
+ case 1: {
4461
+ if (tag !== 10) {
4462
+ break;
4463
+ }
4464
+
4465
+ message.status = ResponseStatus.decode(reader, reader.uint32());
4466
+ continue;
4467
+ }
4468
+ case 2: {
4469
+ if (tag !== 18) {
4470
+ break;
4471
+ }
4472
+
4473
+ message.organizations.push(OrgDetails.decode(reader, reader.uint32()));
4474
+ continue;
4475
+ }
4476
+ }
4477
+ if ((tag & 7) === 4 || tag === 0) {
4478
+ break;
4479
+ }
4480
+ reader.skip(tag & 7);
4481
+ }
4482
+ return message;
4483
+ } finally {
4484
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
4485
+ }
4486
+ },
4487
+
4488
+ fromJSON(object: any): ResolveOrgDetailsResponse {
4489
+ return {
4490
+ status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
4491
+ organizations: globalThis.Array.isArray(object?.organizations)
4492
+ ? object.organizations.map((e: any) => OrgDetails.fromJSON(e))
4493
+ : [],
4494
+ };
4495
+ },
4496
+
4497
+ toJSON(message: ResolveOrgDetailsResponse): unknown {
4498
+ const obj: any = {};
4499
+ if (message.status !== undefined) {
4500
+ obj.status = ResponseStatus.toJSON(message.status);
4501
+ }
4502
+ if (message.organizations?.length) {
4503
+ obj.organizations = message.organizations.map((e) => OrgDetails.toJSON(e));
4504
+ }
4505
+ return obj;
4506
+ },
4507
+
4508
+ create<I extends Exact<DeepPartial<ResolveOrgDetailsResponse>, I>>(base?: I): ResolveOrgDetailsResponse {
4509
+ return ResolveOrgDetailsResponse.fromPartial(base ?? ({} as any));
4510
+ },
4511
+ fromPartial<I extends Exact<DeepPartial<ResolveOrgDetailsResponse>, I>>(object: I): ResolveOrgDetailsResponse {
4512
+ const message = createBaseResolveOrgDetailsResponse();
4513
+ message.status = (object.status !== undefined && object.status !== null)
4514
+ ? ResponseStatus.fromPartial(object.status)
4515
+ : undefined;
4516
+ message.organizations = object.organizations?.map((e) => OrgDetails.fromPartial(e)) || [];
4517
+ return message;
4518
+ },
4519
+ };
4520
+
4521
+ function createBaseOrgDetails(): OrgDetails {
4522
+ return { organizationId: "", name: "" };
4523
+ }
4524
+
4525
+ export const OrgDetails: MessageFns<OrgDetails> = {
4526
+ encode(message: OrgDetails, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
4527
+ if (message.organizationId !== "") {
4528
+ writer.uint32(10).string(message.organizationId);
4529
+ }
4530
+ if (message.name !== "") {
4531
+ writer.uint32(18).string(message.name);
4532
+ }
4533
+ return writer;
4534
+ },
4535
+
4536
+ decode(input: BinaryReader | Uint8Array, length?: number): OrgDetails {
4537
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
4538
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
4539
+ if (previousRecursionDepth >= 100) {
4540
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
4541
+ }
4542
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
4543
+ try {
4544
+ const end = length === undefined ? reader.len : reader.pos + length;
4545
+ const message = createBaseOrgDetails();
4546
+ while (reader.pos < end) {
4547
+ const tag = reader.uint32();
4548
+ switch (tag >>> 3) {
4549
+ case 1: {
4550
+ if (tag !== 10) {
4551
+ break;
4552
+ }
4553
+
4554
+ message.organizationId = reader.string();
4555
+ continue;
4556
+ }
4557
+ case 2: {
4558
+ if (tag !== 18) {
4559
+ break;
4560
+ }
4561
+
4562
+ message.name = reader.string();
4563
+ continue;
4564
+ }
4565
+ }
4566
+ if ((tag & 7) === 4 || tag === 0) {
4567
+ break;
4568
+ }
4569
+ reader.skip(tag & 7);
4570
+ }
4571
+ return message;
4572
+ } finally {
4573
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
4574
+ }
4575
+ },
4576
+
4577
+ fromJSON(object: any): OrgDetails {
4578
+ return {
4579
+ organizationId: isSet(object.organizationId)
4580
+ ? globalThis.String(object.organizationId)
4581
+ : isSet(object.organization_id)
4582
+ ? globalThis.String(object.organization_id)
4583
+ : "",
4584
+ name: isSet(object.name) ? globalThis.String(object.name) : "",
4585
+ };
4586
+ },
4587
+
4588
+ toJSON(message: OrgDetails): unknown {
4589
+ const obj: any = {};
4590
+ if (message.organizationId !== "") {
4591
+ obj.organizationId = message.organizationId;
4592
+ }
4593
+ if (message.name !== "") {
4594
+ obj.name = message.name;
4595
+ }
4596
+ return obj;
4597
+ },
4598
+
4599
+ create<I extends Exact<DeepPartial<OrgDetails>, I>>(base?: I): OrgDetails {
4600
+ return OrgDetails.fromPartial(base ?? ({} as any));
4601
+ },
4602
+ fromPartial<I extends Exact<DeepPartial<OrgDetails>, I>>(object: I): OrgDetails {
4603
+ const message = createBaseOrgDetails();
4604
+ message.organizationId = object.organizationId ?? "";
4605
+ message.name = object.name ?? "";
4606
+ return message;
4607
+ },
4608
+ };
4609
+
4610
+ function createBaseResolveProjectDetailsRequest(): ResolveProjectDetailsRequest {
4611
+ return { projectIds: [] };
4612
+ }
4613
+
4614
+ export const ResolveProjectDetailsRequest: MessageFns<ResolveProjectDetailsRequest> = {
4615
+ encode(message: ResolveProjectDetailsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
4616
+ for (const v of message.projectIds) {
4617
+ writer.uint32(10).string(v!);
4618
+ }
4619
+ return writer;
4620
+ },
4621
+
4622
+ decode(input: BinaryReader | Uint8Array, length?: number): ResolveProjectDetailsRequest {
4623
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
4624
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
4625
+ if (previousRecursionDepth >= 100) {
4626
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
4627
+ }
4628
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
4629
+ try {
4630
+ const end = length === undefined ? reader.len : reader.pos + length;
4631
+ const message = createBaseResolveProjectDetailsRequest();
4632
+ while (reader.pos < end) {
4633
+ const tag = reader.uint32();
4634
+ switch (tag >>> 3) {
4635
+ case 1: {
4636
+ if (tag !== 10) {
4637
+ break;
4638
+ }
4639
+
4640
+ message.projectIds.push(reader.string());
4641
+ continue;
4642
+ }
4643
+ }
4644
+ if ((tag & 7) === 4 || tag === 0) {
4645
+ break;
4646
+ }
4647
+ reader.skip(tag & 7);
3614
4648
  }
3615
4649
  return message;
3616
4650
  } finally {
@@ -4155,6 +5189,11 @@ export interface AdminGatewayService {
4155
5189
  request: ListAdminRelayHeartbeatsRequest,
4156
5190
  metadata?: Metadata,
4157
5191
  ): Promise<ListAdminRelayHeartbeatsResponse>;
5192
+ /**
5193
+ * AI usage summed across every organization over whole UTC days, grouped by the dimensions asked for (none is one
5194
+ * row, the totals), numbered pages; it proxies ai.api.v1.AIAdminService.ListUsageGroups. Rows carry ids, not names.
5195
+ */
5196
+ ListUsageGroups(request: ListAdminUsageGroupsRequest, metadata?: Metadata): Promise<ListAdminUsageGroupsResponse>;
4158
5197
  /**
4159
5198
  * ResolveOrgDetails resolves organization ids to their names, in batch, across every organization of this gateway's
4160
5199
  * product. Unknown ids, and ids of another product, are left out; it never errors on them. A malformed id, or more
@@ -4199,6 +5238,7 @@ export class AdminGatewayServiceClientImpl implements AdminGatewayService {
4199
5238
  this.ConfirmAIEfforts = this.ConfirmAIEfforts.bind(this);
4200
5239
  this.ConfirmAIBillers = this.ConfirmAIBillers.bind(this);
4201
5240
  this.ListRelayHeartbeats = this.ListRelayHeartbeats.bind(this);
5241
+ this.ListUsageGroups = this.ListUsageGroups.bind(this);
4202
5242
  this.ResolveOrgDetails = this.ResolveOrgDetails.bind(this);
4203
5243
  this.ResolveProjectDetails = this.ResolveProjectDetails.bind(this);
4204
5244
  this.ResolveUserDetails = this.ResolveUserDetails.bind(this);
@@ -4284,6 +5324,12 @@ export class AdminGatewayServiceClientImpl implements AdminGatewayService {
4284
5324
  return promise.then((data) => ListAdminRelayHeartbeatsResponse.decode(new BinaryReader(data)));
4285
5325
  }
4286
5326
 
5327
+ ListUsageGroups(request: ListAdminUsageGroupsRequest, metadata?: Metadata): Promise<ListAdminUsageGroupsResponse> {
5328
+ const data = ListAdminUsageGroupsRequest.encode(request).finish();
5329
+ const promise = this.rpc.request(this.service, "ListUsageGroups", data, metadata);
5330
+ return promise.then((data) => ListAdminUsageGroupsResponse.decode(new BinaryReader(data)));
5331
+ }
5332
+
4287
5333
  ResolveOrgDetails(request: ResolveOrgDetailsRequest, metadata?: Metadata): Promise<ResolveOrgDetailsResponse> {
4288
5334
  const data = ResolveOrgDetailsRequest.encode(request).finish();
4289
5335
  const promise = this.rpc.request(this.service, "ResolveOrgDetails", data, metadata);
@@ -4310,6 +5356,10 @@ interface Rpc {
4310
5356
  request(service: string, method: string, data: Uint8Array, metadata?: Metadata): Promise<Uint8Array>;
4311
5357
  }
4312
5358
 
5359
+ function floatToJson(value: number | null | undefined): number | string | null | undefined {
5360
+ return typeof value === "number" && !globalThis.Number.isFinite(value) ? globalThis.String(value) : value;
5361
+ }
5362
+
4313
5363
  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
4314
5364
 
4315
5365
  export type DeepPartial<T> = T extends Builtin ? T