@miradorlabs/web-grpc 2.38.0 → 2.40.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.
@@ -0,0 +1,3934 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.12.2
4
+ // protoc v3.21.12
5
+ // source: proto/gateway/web/v1/ai_gateway.proto
6
+
7
+ /* eslint-disable */
8
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
9
+ import type { Metadata } from "@grpc/grpc-js";
10
+ import { Observable } from "rxjs";
11
+ import { map } from "rxjs/operators";
12
+ import { Timestamp } from "../../../../google/protobuf/timestamp";
13
+ import { ResponseStatus } from "../../common/v1/status";
14
+
15
+ export const protobufPackage = "gateway.web.v1";
16
+
17
+ export enum AISessionEventKind {
18
+ AI_SESSION_EVENT_KIND_UNSPECIFIED = 0,
19
+ AI_SESSION_EVENT_KIND_SESSION_START = 1,
20
+ AI_SESSION_EVENT_KIND_TURN_START = 2,
21
+ AI_SESSION_EVENT_KIND_USER_MESSAGE = 3,
22
+ AI_SESSION_EVENT_KIND_ASSISTANT_MESSAGE = 4,
23
+ AI_SESSION_EVENT_KIND_MODEL_CALL = 5,
24
+ AI_SESSION_EVENT_KIND_TOOL_CALL = 6,
25
+ AI_SESSION_EVENT_KIND_TOOL_RESULT = 7,
26
+ AI_SESSION_EVENT_KIND_TOOL_DECISION = 8,
27
+ AI_SESSION_EVENT_KIND_COMPACTION = 9,
28
+ AI_SESSION_EVENT_KIND_ERROR = 10,
29
+ UNRECOGNIZED = -1,
30
+ }
31
+
32
+ export function aISessionEventKindFromJSON(object: any): AISessionEventKind {
33
+ switch (object) {
34
+ case 0:
35
+ case "AI_SESSION_EVENT_KIND_UNSPECIFIED":
36
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_UNSPECIFIED;
37
+ case 1:
38
+ case "AI_SESSION_EVENT_KIND_SESSION_START":
39
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_SESSION_START;
40
+ case 2:
41
+ case "AI_SESSION_EVENT_KIND_TURN_START":
42
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_TURN_START;
43
+ case 3:
44
+ case "AI_SESSION_EVENT_KIND_USER_MESSAGE":
45
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_USER_MESSAGE;
46
+ case 4:
47
+ case "AI_SESSION_EVENT_KIND_ASSISTANT_MESSAGE":
48
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_ASSISTANT_MESSAGE;
49
+ case 5:
50
+ case "AI_SESSION_EVENT_KIND_MODEL_CALL":
51
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_MODEL_CALL;
52
+ case 6:
53
+ case "AI_SESSION_EVENT_KIND_TOOL_CALL":
54
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_TOOL_CALL;
55
+ case 7:
56
+ case "AI_SESSION_EVENT_KIND_TOOL_RESULT":
57
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_TOOL_RESULT;
58
+ case 8:
59
+ case "AI_SESSION_EVENT_KIND_TOOL_DECISION":
60
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_TOOL_DECISION;
61
+ case 9:
62
+ case "AI_SESSION_EVENT_KIND_COMPACTION":
63
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_COMPACTION;
64
+ case 10:
65
+ case "AI_SESSION_EVENT_KIND_ERROR":
66
+ return AISessionEventKind.AI_SESSION_EVENT_KIND_ERROR;
67
+ case -1:
68
+ case "UNRECOGNIZED":
69
+ default:
70
+ return AISessionEventKind.UNRECOGNIZED;
71
+ }
72
+ }
73
+
74
+ export function aISessionEventKindToJSON(object: AISessionEventKind): string {
75
+ switch (object) {
76
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_UNSPECIFIED:
77
+ return "AI_SESSION_EVENT_KIND_UNSPECIFIED";
78
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_SESSION_START:
79
+ return "AI_SESSION_EVENT_KIND_SESSION_START";
80
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_TURN_START:
81
+ return "AI_SESSION_EVENT_KIND_TURN_START";
82
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_USER_MESSAGE:
83
+ return "AI_SESSION_EVENT_KIND_USER_MESSAGE";
84
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_ASSISTANT_MESSAGE:
85
+ return "AI_SESSION_EVENT_KIND_ASSISTANT_MESSAGE";
86
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_MODEL_CALL:
87
+ return "AI_SESSION_EVENT_KIND_MODEL_CALL";
88
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_TOOL_CALL:
89
+ return "AI_SESSION_EVENT_KIND_TOOL_CALL";
90
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_TOOL_RESULT:
91
+ return "AI_SESSION_EVENT_KIND_TOOL_RESULT";
92
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_TOOL_DECISION:
93
+ return "AI_SESSION_EVENT_KIND_TOOL_DECISION";
94
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_COMPACTION:
95
+ return "AI_SESSION_EVENT_KIND_COMPACTION";
96
+ case AISessionEventKind.AI_SESSION_EVENT_KIND_ERROR:
97
+ return "AI_SESSION_EVENT_KIND_ERROR";
98
+ case AISessionEventKind.UNRECOGNIZED:
99
+ default:
100
+ return "UNRECOGNIZED";
101
+ }
102
+ }
103
+
104
+ export enum AIPrincipalKind {
105
+ AI_PRINCIPAL_KIND_UNSPECIFIED = 0,
106
+ AI_PRINCIPAL_KIND_USER = 1,
107
+ AI_PRINCIPAL_KIND_API_KEY = 2,
108
+ UNRECOGNIZED = -1,
109
+ }
110
+
111
+ export function aIPrincipalKindFromJSON(object: any): AIPrincipalKind {
112
+ switch (object) {
113
+ case 0:
114
+ case "AI_PRINCIPAL_KIND_UNSPECIFIED":
115
+ return AIPrincipalKind.AI_PRINCIPAL_KIND_UNSPECIFIED;
116
+ case 1:
117
+ case "AI_PRINCIPAL_KIND_USER":
118
+ return AIPrincipalKind.AI_PRINCIPAL_KIND_USER;
119
+ case 2:
120
+ case "AI_PRINCIPAL_KIND_API_KEY":
121
+ return AIPrincipalKind.AI_PRINCIPAL_KIND_API_KEY;
122
+ case -1:
123
+ case "UNRECOGNIZED":
124
+ default:
125
+ return AIPrincipalKind.UNRECOGNIZED;
126
+ }
127
+ }
128
+
129
+ export function aIPrincipalKindToJSON(object: AIPrincipalKind): string {
130
+ switch (object) {
131
+ case AIPrincipalKind.AI_PRINCIPAL_KIND_UNSPECIFIED:
132
+ return "AI_PRINCIPAL_KIND_UNSPECIFIED";
133
+ case AIPrincipalKind.AI_PRINCIPAL_KIND_USER:
134
+ return "AI_PRINCIPAL_KIND_USER";
135
+ case AIPrincipalKind.AI_PRINCIPAL_KIND_API_KEY:
136
+ return "AI_PRINCIPAL_KIND_API_KEY";
137
+ case AIPrincipalKind.UNRECOGNIZED:
138
+ default:
139
+ return "UNRECOGNIZED";
140
+ }
141
+ }
142
+
143
+ export enum AIGitAction {
144
+ AI_GIT_ACTION_UNSPECIFIED = 0,
145
+ AI_GIT_ACTION_BRANCH_CREATE = 1,
146
+ AI_GIT_ACTION_COMMIT = 2,
147
+ AI_GIT_ACTION_PUSH = 3,
148
+ AI_GIT_ACTION_PULL_REQUEST_CREATE = 4,
149
+ AI_GIT_ACTION_PULL_REQUEST_MERGE = 5,
150
+ AI_GIT_ACTION_PULL_REQUEST_COMMENT = 6,
151
+ AI_GIT_ACTION_OTHER = 7,
152
+ UNRECOGNIZED = -1,
153
+ }
154
+
155
+ export function aIGitActionFromJSON(object: any): AIGitAction {
156
+ switch (object) {
157
+ case 0:
158
+ case "AI_GIT_ACTION_UNSPECIFIED":
159
+ return AIGitAction.AI_GIT_ACTION_UNSPECIFIED;
160
+ case 1:
161
+ case "AI_GIT_ACTION_BRANCH_CREATE":
162
+ return AIGitAction.AI_GIT_ACTION_BRANCH_CREATE;
163
+ case 2:
164
+ case "AI_GIT_ACTION_COMMIT":
165
+ return AIGitAction.AI_GIT_ACTION_COMMIT;
166
+ case 3:
167
+ case "AI_GIT_ACTION_PUSH":
168
+ return AIGitAction.AI_GIT_ACTION_PUSH;
169
+ case 4:
170
+ case "AI_GIT_ACTION_PULL_REQUEST_CREATE":
171
+ return AIGitAction.AI_GIT_ACTION_PULL_REQUEST_CREATE;
172
+ case 5:
173
+ case "AI_GIT_ACTION_PULL_REQUEST_MERGE":
174
+ return AIGitAction.AI_GIT_ACTION_PULL_REQUEST_MERGE;
175
+ case 6:
176
+ case "AI_GIT_ACTION_PULL_REQUEST_COMMENT":
177
+ return AIGitAction.AI_GIT_ACTION_PULL_REQUEST_COMMENT;
178
+ case 7:
179
+ case "AI_GIT_ACTION_OTHER":
180
+ return AIGitAction.AI_GIT_ACTION_OTHER;
181
+ case -1:
182
+ case "UNRECOGNIZED":
183
+ default:
184
+ return AIGitAction.UNRECOGNIZED;
185
+ }
186
+ }
187
+
188
+ export function aIGitActionToJSON(object: AIGitAction): string {
189
+ switch (object) {
190
+ case AIGitAction.AI_GIT_ACTION_UNSPECIFIED:
191
+ return "AI_GIT_ACTION_UNSPECIFIED";
192
+ case AIGitAction.AI_GIT_ACTION_BRANCH_CREATE:
193
+ return "AI_GIT_ACTION_BRANCH_CREATE";
194
+ case AIGitAction.AI_GIT_ACTION_COMMIT:
195
+ return "AI_GIT_ACTION_COMMIT";
196
+ case AIGitAction.AI_GIT_ACTION_PUSH:
197
+ return "AI_GIT_ACTION_PUSH";
198
+ case AIGitAction.AI_GIT_ACTION_PULL_REQUEST_CREATE:
199
+ return "AI_GIT_ACTION_PULL_REQUEST_CREATE";
200
+ case AIGitAction.AI_GIT_ACTION_PULL_REQUEST_MERGE:
201
+ return "AI_GIT_ACTION_PULL_REQUEST_MERGE";
202
+ case AIGitAction.AI_GIT_ACTION_PULL_REQUEST_COMMENT:
203
+ return "AI_GIT_ACTION_PULL_REQUEST_COMMENT";
204
+ case AIGitAction.AI_GIT_ACTION_OTHER:
205
+ return "AI_GIT_ACTION_OTHER";
206
+ case AIGitAction.UNRECOGNIZED:
207
+ default:
208
+ return "UNRECOGNIZED";
209
+ }
210
+ }
211
+
212
+ export enum AIGitOutcome {
213
+ AI_GIT_OUTCOME_UNSPECIFIED = 0,
214
+ AI_GIT_OUTCOME_ATTEMPTED = 1,
215
+ AI_GIT_OUTCOME_CONFIRMED = 2,
216
+ AI_GIT_OUTCOME_FAILED = 3,
217
+ UNRECOGNIZED = -1,
218
+ }
219
+
220
+ export function aIGitOutcomeFromJSON(object: any): AIGitOutcome {
221
+ switch (object) {
222
+ case 0:
223
+ case "AI_GIT_OUTCOME_UNSPECIFIED":
224
+ return AIGitOutcome.AI_GIT_OUTCOME_UNSPECIFIED;
225
+ case 1:
226
+ case "AI_GIT_OUTCOME_ATTEMPTED":
227
+ return AIGitOutcome.AI_GIT_OUTCOME_ATTEMPTED;
228
+ case 2:
229
+ case "AI_GIT_OUTCOME_CONFIRMED":
230
+ return AIGitOutcome.AI_GIT_OUTCOME_CONFIRMED;
231
+ case 3:
232
+ case "AI_GIT_OUTCOME_FAILED":
233
+ return AIGitOutcome.AI_GIT_OUTCOME_FAILED;
234
+ case -1:
235
+ case "UNRECOGNIZED":
236
+ default:
237
+ return AIGitOutcome.UNRECOGNIZED;
238
+ }
239
+ }
240
+
241
+ export function aIGitOutcomeToJSON(object: AIGitOutcome): string {
242
+ switch (object) {
243
+ case AIGitOutcome.AI_GIT_OUTCOME_UNSPECIFIED:
244
+ return "AI_GIT_OUTCOME_UNSPECIFIED";
245
+ case AIGitOutcome.AI_GIT_OUTCOME_ATTEMPTED:
246
+ return "AI_GIT_OUTCOME_ATTEMPTED";
247
+ case AIGitOutcome.AI_GIT_OUTCOME_CONFIRMED:
248
+ return "AI_GIT_OUTCOME_CONFIRMED";
249
+ case AIGitOutcome.AI_GIT_OUTCOME_FAILED:
250
+ return "AI_GIT_OUTCOME_FAILED";
251
+ case AIGitOutcome.UNRECOGNIZED:
252
+ default:
253
+ return "UNRECOGNIZED";
254
+ }
255
+ }
256
+
257
+ export interface ListSessionsRequest {
258
+ organizationId: string;
259
+ projectId: string;
260
+ filter: AISessionFilter | undefined;
261
+ pageSize: number;
262
+ pageToken: string;
263
+ }
264
+
265
+ export interface AISessionFilter {
266
+ sourceSystem: string[];
267
+ userId: string[];
268
+ apiKeyId: string[];
269
+ model: string[];
270
+ startedAfter?: Date | undefined;
271
+ startedBefore?: Date | undefined;
272
+ }
273
+
274
+ export interface ListSessionsResponse {
275
+ status: ResponseStatus | undefined;
276
+ sessions: AISession[];
277
+ nextPageToken: string;
278
+ totalCount?: number | undefined;
279
+ }
280
+
281
+ export interface AISession {
282
+ routingKey: string;
283
+ sourceSystem: string;
284
+ sessionId: string;
285
+ userId: string;
286
+ apiKeyId: string;
287
+ subjectOrganizationId: string;
288
+ firstSessionTime: Date | undefined;
289
+ lastActivityAt: Date | undefined;
290
+ turns: number;
291
+ modelCalls: number;
292
+ toolCalls: number;
293
+ userMessages: number;
294
+ usage: AITokenUsage | undefined;
295
+ models: string[];
296
+ providers: string[];
297
+ branchesCreated: number;
298
+ commits: number;
299
+ gitPushes: number;
300
+ pullRequestsCreated: number;
301
+ pullRequestsMerged: number;
302
+ gitOrgs: string[];
303
+ repositories: string[];
304
+ filesTouched: number;
305
+ }
306
+
307
+ export interface StreamSessionRequest {
308
+ organizationId: string;
309
+ projectId: string;
310
+ routingKey: string;
311
+ sourceSystem: string;
312
+ }
313
+
314
+ export interface AISessionEventEnvelope {
315
+ event?: AISessionEvent | undefined;
316
+ completed?: ReplayCompleted | undefined;
317
+ }
318
+
319
+ export interface ReplayCompleted {
320
+ }
321
+
322
+ export interface AISessionEvent {
323
+ kind: AISessionEventKind;
324
+ sequence?: number | undefined;
325
+ eventTime: Date | undefined;
326
+ turnId: string;
327
+ content: AIContentPart[];
328
+ usage: AITokenUsage | undefined;
329
+ model: string;
330
+ provider: string;
331
+ toolName: string;
332
+ status: string;
333
+ finishReason: string;
334
+ durationMs?: number | undefined;
335
+ ttftMs?: number | undefined;
336
+ modelCallId: string;
337
+ toolCallId: string;
338
+ }
339
+
340
+ export interface AIContentPart {
341
+ partIndex: number;
342
+ contentType: string;
343
+ content: string;
344
+ }
345
+
346
+ export interface ListPrincipalsRequest {
347
+ organizationId: string;
348
+ projectId: string;
349
+ kind?: AIPrincipalKind | undefined;
350
+ sourceSystem: string;
351
+ pageSize: number;
352
+ pageToken: string;
353
+ }
354
+
355
+ export interface ListPrincipalsResponse {
356
+ status: ResponseStatus | undefined;
357
+ principals: AIPrincipal[];
358
+ nextPageToken: string;
359
+ }
360
+
361
+ export interface AIPrincipal {
362
+ kind: AIPrincipalKind;
363
+ id: string;
364
+ name: string;
365
+ sourceSystem: string;
366
+ alias: string;
367
+ }
368
+
369
+ export interface UpdatePrincipalRequest {
370
+ organizationId: string;
371
+ projectId: string;
372
+ kind: AIPrincipalKind;
373
+ id: string;
374
+ sourceSystem: string;
375
+ alias: string;
376
+ }
377
+
378
+ export interface UpdatePrincipalResponse {
379
+ status: ResponseStatus | undefined;
380
+ principal: AIPrincipal | undefined;
381
+ }
382
+
383
+ export interface ListGitActivitiesRequest {
384
+ organizationId: string;
385
+ projectId: string;
386
+ routingKey: string;
387
+ sourceSystem: string;
388
+ }
389
+
390
+ export interface ListGitActivitiesResponse {
391
+ status: ResponseStatus | undefined;
392
+ activities: AIGitActivity[];
393
+ }
394
+
395
+ export interface AIGitActivity {
396
+ eventTime: Date | undefined;
397
+ sourceSystem: string;
398
+ sessionId: string;
399
+ toolCallId: string;
400
+ action: AIGitAction;
401
+ outcome: AIGitOutcome;
402
+ ownerKey: string;
403
+ repositoryKey: string;
404
+ remoteName: string;
405
+ remoteUrl: string;
406
+ sourceRef: string;
407
+ destRef: string;
408
+ stdoutCommitSha: string;
409
+ structuredCommitId: string;
410
+ pushOldSha: string;
411
+ pushNewSha: string;
412
+ messageHeadline: string;
413
+ filesChanged: number;
414
+ insertions: number;
415
+ deletions: number;
416
+ flags: string[];
417
+ aiCoAuthored: boolean;
418
+ pullRequestNumber: number;
419
+ pullRequestUrl: string;
420
+ prState: string;
421
+ prBaseRef: string;
422
+ prHeadRef: string;
423
+ mergeCommitSha: string;
424
+ }
425
+
426
+ export interface AITokenUsage {
427
+ inputTokens: number;
428
+ outputTokens: number;
429
+ cacheReadTokens: number;
430
+ cacheWriteTokens: number;
431
+ providerCostUsdNano: number;
432
+ }
433
+
434
+ function createBaseListSessionsRequest(): ListSessionsRequest {
435
+ return { organizationId: "", projectId: "", filter: undefined, pageSize: 0, pageToken: "" };
436
+ }
437
+
438
+ export const ListSessionsRequest: MessageFns<ListSessionsRequest> = {
439
+ encode(message: ListSessionsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
440
+ if (message.organizationId !== "") {
441
+ writer.uint32(10).string(message.organizationId);
442
+ }
443
+ if (message.projectId !== "") {
444
+ writer.uint32(18).string(message.projectId);
445
+ }
446
+ if (message.filter !== undefined) {
447
+ AISessionFilter.encode(message.filter, writer.uint32(26).fork()).join();
448
+ }
449
+ if (message.pageSize !== 0) {
450
+ writer.uint32(32).int32(message.pageSize);
451
+ }
452
+ if (message.pageToken !== "") {
453
+ writer.uint32(42).string(message.pageToken);
454
+ }
455
+ return writer;
456
+ },
457
+
458
+ decode(input: BinaryReader | Uint8Array, length?: number): ListSessionsRequest {
459
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
460
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
461
+ if (previousRecursionDepth >= 100) {
462
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
463
+ }
464
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
465
+ try {
466
+ const end = length === undefined ? reader.len : reader.pos + length;
467
+ const message = createBaseListSessionsRequest();
468
+ while (reader.pos < end) {
469
+ const tag = reader.uint32();
470
+ switch (tag >>> 3) {
471
+ case 1: {
472
+ if (tag !== 10) {
473
+ break;
474
+ }
475
+
476
+ message.organizationId = reader.string();
477
+ continue;
478
+ }
479
+ case 2: {
480
+ if (tag !== 18) {
481
+ break;
482
+ }
483
+
484
+ message.projectId = reader.string();
485
+ continue;
486
+ }
487
+ case 3: {
488
+ if (tag !== 26) {
489
+ break;
490
+ }
491
+
492
+ message.filter = AISessionFilter.decode(reader, reader.uint32());
493
+ continue;
494
+ }
495
+ case 4: {
496
+ if (tag !== 32) {
497
+ break;
498
+ }
499
+
500
+ message.pageSize = reader.int32();
501
+ continue;
502
+ }
503
+ case 5: {
504
+ if (tag !== 42) {
505
+ break;
506
+ }
507
+
508
+ message.pageToken = reader.string();
509
+ continue;
510
+ }
511
+ }
512
+ if ((tag & 7) === 4 || tag === 0) {
513
+ break;
514
+ }
515
+ reader.skip(tag & 7);
516
+ }
517
+ return message;
518
+ } finally {
519
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
520
+ }
521
+ },
522
+
523
+ fromJSON(object: any): ListSessionsRequest {
524
+ return {
525
+ organizationId: isSet(object.organizationId)
526
+ ? globalThis.String(object.organizationId)
527
+ : isSet(object.organization_id)
528
+ ? globalThis.String(object.organization_id)
529
+ : "",
530
+ projectId: isSet(object.projectId)
531
+ ? globalThis.String(object.projectId)
532
+ : isSet(object.project_id)
533
+ ? globalThis.String(object.project_id)
534
+ : "",
535
+ filter: isSet(object.filter) ? AISessionFilter.fromJSON(object.filter) : undefined,
536
+ pageSize: isSet(object.pageSize)
537
+ ? globalThis.Number(object.pageSize)
538
+ : isSet(object.page_size)
539
+ ? globalThis.Number(object.page_size)
540
+ : 0,
541
+ pageToken: isSet(object.pageToken)
542
+ ? globalThis.String(object.pageToken)
543
+ : isSet(object.page_token)
544
+ ? globalThis.String(object.page_token)
545
+ : "",
546
+ };
547
+ },
548
+
549
+ toJSON(message: ListSessionsRequest): unknown {
550
+ const obj: any = {};
551
+ if (message.organizationId !== "") {
552
+ obj.organizationId = message.organizationId;
553
+ }
554
+ if (message.projectId !== "") {
555
+ obj.projectId = message.projectId;
556
+ }
557
+ if (message.filter !== undefined) {
558
+ obj.filter = AISessionFilter.toJSON(message.filter);
559
+ }
560
+ if (message.pageSize !== 0) {
561
+ obj.pageSize = Math.round(message.pageSize);
562
+ }
563
+ if (message.pageToken !== "") {
564
+ obj.pageToken = message.pageToken;
565
+ }
566
+ return obj;
567
+ },
568
+
569
+ create<I extends Exact<DeepPartial<ListSessionsRequest>, I>>(base?: I): ListSessionsRequest {
570
+ return ListSessionsRequest.fromPartial(base ?? ({} as any));
571
+ },
572
+ fromPartial<I extends Exact<DeepPartial<ListSessionsRequest>, I>>(object: I): ListSessionsRequest {
573
+ const message = createBaseListSessionsRequest();
574
+ message.organizationId = object.organizationId ?? "";
575
+ message.projectId = object.projectId ?? "";
576
+ message.filter = (object.filter !== undefined && object.filter !== null)
577
+ ? AISessionFilter.fromPartial(object.filter)
578
+ : undefined;
579
+ message.pageSize = object.pageSize ?? 0;
580
+ message.pageToken = object.pageToken ?? "";
581
+ return message;
582
+ },
583
+ };
584
+
585
+ function createBaseAISessionFilter(): AISessionFilter {
586
+ return { sourceSystem: [], userId: [], apiKeyId: [], model: [], startedAfter: undefined, startedBefore: undefined };
587
+ }
588
+
589
+ export const AISessionFilter: MessageFns<AISessionFilter> = {
590
+ encode(message: AISessionFilter, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
591
+ for (const v of message.sourceSystem) {
592
+ writer.uint32(10).string(v!);
593
+ }
594
+ for (const v of message.userId) {
595
+ writer.uint32(18).string(v!);
596
+ }
597
+ for (const v of message.apiKeyId) {
598
+ writer.uint32(26).string(v!);
599
+ }
600
+ for (const v of message.model) {
601
+ writer.uint32(34).string(v!);
602
+ }
603
+ if (message.startedAfter !== undefined) {
604
+ Timestamp.encode(toTimestamp(message.startedAfter), writer.uint32(42).fork()).join();
605
+ }
606
+ if (message.startedBefore !== undefined) {
607
+ Timestamp.encode(toTimestamp(message.startedBefore), writer.uint32(50).fork()).join();
608
+ }
609
+ return writer;
610
+ },
611
+
612
+ decode(input: BinaryReader | Uint8Array, length?: number): AISessionFilter {
613
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
614
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
615
+ if (previousRecursionDepth >= 100) {
616
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
617
+ }
618
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
619
+ try {
620
+ const end = length === undefined ? reader.len : reader.pos + length;
621
+ const message = createBaseAISessionFilter();
622
+ while (reader.pos < end) {
623
+ const tag = reader.uint32();
624
+ switch (tag >>> 3) {
625
+ case 1: {
626
+ if (tag !== 10) {
627
+ break;
628
+ }
629
+
630
+ message.sourceSystem.push(reader.string());
631
+ continue;
632
+ }
633
+ case 2: {
634
+ if (tag !== 18) {
635
+ break;
636
+ }
637
+
638
+ message.userId.push(reader.string());
639
+ continue;
640
+ }
641
+ case 3: {
642
+ if (tag !== 26) {
643
+ break;
644
+ }
645
+
646
+ message.apiKeyId.push(reader.string());
647
+ continue;
648
+ }
649
+ case 4: {
650
+ if (tag !== 34) {
651
+ break;
652
+ }
653
+
654
+ message.model.push(reader.string());
655
+ continue;
656
+ }
657
+ case 5: {
658
+ if (tag !== 42) {
659
+ break;
660
+ }
661
+
662
+ message.startedAfter = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
663
+ continue;
664
+ }
665
+ case 6: {
666
+ if (tag !== 50) {
667
+ break;
668
+ }
669
+
670
+ message.startedBefore = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
671
+ continue;
672
+ }
673
+ }
674
+ if ((tag & 7) === 4 || tag === 0) {
675
+ break;
676
+ }
677
+ reader.skip(tag & 7);
678
+ }
679
+ return message;
680
+ } finally {
681
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
682
+ }
683
+ },
684
+
685
+ fromJSON(object: any): AISessionFilter {
686
+ return {
687
+ sourceSystem: globalThis.Array.isArray(object?.sourceSystem)
688
+ ? object.sourceSystem.map((e: any) => globalThis.String(e))
689
+ : globalThis.Array.isArray(object?.source_system)
690
+ ? object.source_system.map((e: any) => globalThis.String(e))
691
+ : [],
692
+ userId: globalThis.Array.isArray(object?.userId)
693
+ ? object.userId.map((e: any) => globalThis.String(e))
694
+ : globalThis.Array.isArray(object?.user_id)
695
+ ? object.user_id.map((e: any) => globalThis.String(e))
696
+ : [],
697
+ apiKeyId: globalThis.Array.isArray(object?.apiKeyId)
698
+ ? object.apiKeyId.map((e: any) => globalThis.String(e))
699
+ : globalThis.Array.isArray(object?.api_key_id)
700
+ ? object.api_key_id.map((e: any) => globalThis.String(e))
701
+ : [],
702
+ model: globalThis.Array.isArray(object?.model) ? object.model.map((e: any) => globalThis.String(e)) : [],
703
+ startedAfter: isSet(object.startedAfter)
704
+ ? fromJsonTimestamp(object.startedAfter)
705
+ : isSet(object.started_after)
706
+ ? fromJsonTimestamp(object.started_after)
707
+ : undefined,
708
+ startedBefore: isSet(object.startedBefore)
709
+ ? fromJsonTimestamp(object.startedBefore)
710
+ : isSet(object.started_before)
711
+ ? fromJsonTimestamp(object.started_before)
712
+ : undefined,
713
+ };
714
+ },
715
+
716
+ toJSON(message: AISessionFilter): unknown {
717
+ const obj: any = {};
718
+ if (message.sourceSystem?.length) {
719
+ obj.sourceSystem = message.sourceSystem;
720
+ }
721
+ if (message.userId?.length) {
722
+ obj.userId = message.userId;
723
+ }
724
+ if (message.apiKeyId?.length) {
725
+ obj.apiKeyId = message.apiKeyId;
726
+ }
727
+ if (message.model?.length) {
728
+ obj.model = message.model;
729
+ }
730
+ if (message.startedAfter !== undefined) {
731
+ obj.startedAfter = message.startedAfter.toISOString();
732
+ }
733
+ if (message.startedBefore !== undefined) {
734
+ obj.startedBefore = message.startedBefore.toISOString();
735
+ }
736
+ return obj;
737
+ },
738
+
739
+ create<I extends Exact<DeepPartial<AISessionFilter>, I>>(base?: I): AISessionFilter {
740
+ return AISessionFilter.fromPartial(base ?? ({} as any));
741
+ },
742
+ fromPartial<I extends Exact<DeepPartial<AISessionFilter>, I>>(object: I): AISessionFilter {
743
+ const message = createBaseAISessionFilter();
744
+ message.sourceSystem = object.sourceSystem?.map((e) => e) || [];
745
+ message.userId = object.userId?.map((e) => e) || [];
746
+ message.apiKeyId = object.apiKeyId?.map((e) => e) || [];
747
+ message.model = object.model?.map((e) => e) || [];
748
+ message.startedAfter = object.startedAfter ?? undefined;
749
+ message.startedBefore = object.startedBefore ?? undefined;
750
+ return message;
751
+ },
752
+ };
753
+
754
+ function createBaseListSessionsResponse(): ListSessionsResponse {
755
+ return { status: undefined, sessions: [], nextPageToken: "", totalCount: undefined };
756
+ }
757
+
758
+ export const ListSessionsResponse: MessageFns<ListSessionsResponse> = {
759
+ encode(message: ListSessionsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
760
+ if (message.status !== undefined) {
761
+ ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
762
+ }
763
+ for (const v of message.sessions) {
764
+ AISession.encode(v!, writer.uint32(18).fork()).join();
765
+ }
766
+ if (message.nextPageToken !== "") {
767
+ writer.uint32(26).string(message.nextPageToken);
768
+ }
769
+ if (message.totalCount !== undefined) {
770
+ writer.uint32(32).int64(message.totalCount);
771
+ }
772
+ return writer;
773
+ },
774
+
775
+ decode(input: BinaryReader | Uint8Array, length?: number): ListSessionsResponse {
776
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
777
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
778
+ if (previousRecursionDepth >= 100) {
779
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
780
+ }
781
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
782
+ try {
783
+ const end = length === undefined ? reader.len : reader.pos + length;
784
+ const message = createBaseListSessionsResponse();
785
+ while (reader.pos < end) {
786
+ const tag = reader.uint32();
787
+ switch (tag >>> 3) {
788
+ case 1: {
789
+ if (tag !== 10) {
790
+ break;
791
+ }
792
+
793
+ message.status = ResponseStatus.decode(reader, reader.uint32());
794
+ continue;
795
+ }
796
+ case 2: {
797
+ if (tag !== 18) {
798
+ break;
799
+ }
800
+
801
+ message.sessions.push(AISession.decode(reader, reader.uint32()));
802
+ continue;
803
+ }
804
+ case 3: {
805
+ if (tag !== 26) {
806
+ break;
807
+ }
808
+
809
+ message.nextPageToken = reader.string();
810
+ continue;
811
+ }
812
+ case 4: {
813
+ if (tag !== 32) {
814
+ break;
815
+ }
816
+
817
+ message.totalCount = longToNumber(reader.int64());
818
+ continue;
819
+ }
820
+ }
821
+ if ((tag & 7) === 4 || tag === 0) {
822
+ break;
823
+ }
824
+ reader.skip(tag & 7);
825
+ }
826
+ return message;
827
+ } finally {
828
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
829
+ }
830
+ },
831
+
832
+ fromJSON(object: any): ListSessionsResponse {
833
+ return {
834
+ status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
835
+ sessions: globalThis.Array.isArray(object?.sessions)
836
+ ? object.sessions.map((e: any) => AISession.fromJSON(e))
837
+ : [],
838
+ nextPageToken: isSet(object.nextPageToken)
839
+ ? globalThis.String(object.nextPageToken)
840
+ : isSet(object.next_page_token)
841
+ ? globalThis.String(object.next_page_token)
842
+ : "",
843
+ totalCount: isSet(object.totalCount)
844
+ ? globalThis.Number(object.totalCount)
845
+ : isSet(object.total_count)
846
+ ? globalThis.Number(object.total_count)
847
+ : undefined,
848
+ };
849
+ },
850
+
851
+ toJSON(message: ListSessionsResponse): unknown {
852
+ const obj: any = {};
853
+ if (message.status !== undefined) {
854
+ obj.status = ResponseStatus.toJSON(message.status);
855
+ }
856
+ if (message.sessions?.length) {
857
+ obj.sessions = message.sessions.map((e) => AISession.toJSON(e));
858
+ }
859
+ if (message.nextPageToken !== "") {
860
+ obj.nextPageToken = message.nextPageToken;
861
+ }
862
+ if (message.totalCount !== undefined) {
863
+ obj.totalCount = Math.round(message.totalCount);
864
+ }
865
+ return obj;
866
+ },
867
+
868
+ create<I extends Exact<DeepPartial<ListSessionsResponse>, I>>(base?: I): ListSessionsResponse {
869
+ return ListSessionsResponse.fromPartial(base ?? ({} as any));
870
+ },
871
+ fromPartial<I extends Exact<DeepPartial<ListSessionsResponse>, I>>(object: I): ListSessionsResponse {
872
+ const message = createBaseListSessionsResponse();
873
+ message.status = (object.status !== undefined && object.status !== null)
874
+ ? ResponseStatus.fromPartial(object.status)
875
+ : undefined;
876
+ message.sessions = object.sessions?.map((e) => AISession.fromPartial(e)) || [];
877
+ message.nextPageToken = object.nextPageToken ?? "";
878
+ message.totalCount = object.totalCount ?? undefined;
879
+ return message;
880
+ },
881
+ };
882
+
883
+ function createBaseAISession(): AISession {
884
+ return {
885
+ routingKey: "",
886
+ sourceSystem: "",
887
+ sessionId: "",
888
+ userId: "",
889
+ apiKeyId: "",
890
+ subjectOrganizationId: "",
891
+ firstSessionTime: undefined,
892
+ lastActivityAt: undefined,
893
+ turns: 0,
894
+ modelCalls: 0,
895
+ toolCalls: 0,
896
+ userMessages: 0,
897
+ usage: undefined,
898
+ models: [],
899
+ providers: [],
900
+ branchesCreated: 0,
901
+ commits: 0,
902
+ gitPushes: 0,
903
+ pullRequestsCreated: 0,
904
+ pullRequestsMerged: 0,
905
+ gitOrgs: [],
906
+ repositories: [],
907
+ filesTouched: 0,
908
+ };
909
+ }
910
+
911
+ export const AISession: MessageFns<AISession> = {
912
+ encode(message: AISession, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
913
+ if (message.routingKey !== "") {
914
+ writer.uint32(10).string(message.routingKey);
915
+ }
916
+ if (message.sourceSystem !== "") {
917
+ writer.uint32(18).string(message.sourceSystem);
918
+ }
919
+ if (message.sessionId !== "") {
920
+ writer.uint32(26).string(message.sessionId);
921
+ }
922
+ if (message.userId !== "") {
923
+ writer.uint32(34).string(message.userId);
924
+ }
925
+ if (message.apiKeyId !== "") {
926
+ writer.uint32(42).string(message.apiKeyId);
927
+ }
928
+ if (message.subjectOrganizationId !== "") {
929
+ writer.uint32(50).string(message.subjectOrganizationId);
930
+ }
931
+ if (message.firstSessionTime !== undefined) {
932
+ Timestamp.encode(toTimestamp(message.firstSessionTime), writer.uint32(58).fork()).join();
933
+ }
934
+ if (message.lastActivityAt !== undefined) {
935
+ Timestamp.encode(toTimestamp(message.lastActivityAt), writer.uint32(66).fork()).join();
936
+ }
937
+ if (message.turns !== 0) {
938
+ writer.uint32(72).uint64(message.turns);
939
+ }
940
+ if (message.modelCalls !== 0) {
941
+ writer.uint32(80).uint64(message.modelCalls);
942
+ }
943
+ if (message.toolCalls !== 0) {
944
+ writer.uint32(88).uint64(message.toolCalls);
945
+ }
946
+ if (message.userMessages !== 0) {
947
+ writer.uint32(96).uint64(message.userMessages);
948
+ }
949
+ if (message.usage !== undefined) {
950
+ AITokenUsage.encode(message.usage, writer.uint32(106).fork()).join();
951
+ }
952
+ for (const v of message.models) {
953
+ writer.uint32(114).string(v!);
954
+ }
955
+ for (const v of message.providers) {
956
+ writer.uint32(122).string(v!);
957
+ }
958
+ if (message.branchesCreated !== 0) {
959
+ writer.uint32(128).uint64(message.branchesCreated);
960
+ }
961
+ if (message.commits !== 0) {
962
+ writer.uint32(136).uint64(message.commits);
963
+ }
964
+ if (message.gitPushes !== 0) {
965
+ writer.uint32(144).uint64(message.gitPushes);
966
+ }
967
+ if (message.pullRequestsCreated !== 0) {
968
+ writer.uint32(152).uint64(message.pullRequestsCreated);
969
+ }
970
+ if (message.pullRequestsMerged !== 0) {
971
+ writer.uint32(160).uint64(message.pullRequestsMerged);
972
+ }
973
+ for (const v of message.gitOrgs) {
974
+ writer.uint32(170).string(v!);
975
+ }
976
+ for (const v of message.repositories) {
977
+ writer.uint32(178).string(v!);
978
+ }
979
+ if (message.filesTouched !== 0) {
980
+ writer.uint32(184).uint64(message.filesTouched);
981
+ }
982
+ return writer;
983
+ },
984
+
985
+ decode(input: BinaryReader | Uint8Array, length?: number): AISession {
986
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
987
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
988
+ if (previousRecursionDepth >= 100) {
989
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
990
+ }
991
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
992
+ try {
993
+ const end = length === undefined ? reader.len : reader.pos + length;
994
+ const message = createBaseAISession();
995
+ while (reader.pos < end) {
996
+ const tag = reader.uint32();
997
+ switch (tag >>> 3) {
998
+ case 1: {
999
+ if (tag !== 10) {
1000
+ break;
1001
+ }
1002
+
1003
+ message.routingKey = reader.string();
1004
+ continue;
1005
+ }
1006
+ case 2: {
1007
+ if (tag !== 18) {
1008
+ break;
1009
+ }
1010
+
1011
+ message.sourceSystem = reader.string();
1012
+ continue;
1013
+ }
1014
+ case 3: {
1015
+ if (tag !== 26) {
1016
+ break;
1017
+ }
1018
+
1019
+ message.sessionId = reader.string();
1020
+ continue;
1021
+ }
1022
+ case 4: {
1023
+ if (tag !== 34) {
1024
+ break;
1025
+ }
1026
+
1027
+ message.userId = reader.string();
1028
+ continue;
1029
+ }
1030
+ case 5: {
1031
+ if (tag !== 42) {
1032
+ break;
1033
+ }
1034
+
1035
+ message.apiKeyId = reader.string();
1036
+ continue;
1037
+ }
1038
+ case 6: {
1039
+ if (tag !== 50) {
1040
+ break;
1041
+ }
1042
+
1043
+ message.subjectOrganizationId = reader.string();
1044
+ continue;
1045
+ }
1046
+ case 7: {
1047
+ if (tag !== 58) {
1048
+ break;
1049
+ }
1050
+
1051
+ message.firstSessionTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
1052
+ continue;
1053
+ }
1054
+ case 8: {
1055
+ if (tag !== 66) {
1056
+ break;
1057
+ }
1058
+
1059
+ message.lastActivityAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
1060
+ continue;
1061
+ }
1062
+ case 9: {
1063
+ if (tag !== 72) {
1064
+ break;
1065
+ }
1066
+
1067
+ message.turns = longToNumber(reader.uint64());
1068
+ continue;
1069
+ }
1070
+ case 10: {
1071
+ if (tag !== 80) {
1072
+ break;
1073
+ }
1074
+
1075
+ message.modelCalls = longToNumber(reader.uint64());
1076
+ continue;
1077
+ }
1078
+ case 11: {
1079
+ if (tag !== 88) {
1080
+ break;
1081
+ }
1082
+
1083
+ message.toolCalls = longToNumber(reader.uint64());
1084
+ continue;
1085
+ }
1086
+ case 12: {
1087
+ if (tag !== 96) {
1088
+ break;
1089
+ }
1090
+
1091
+ message.userMessages = longToNumber(reader.uint64());
1092
+ continue;
1093
+ }
1094
+ case 13: {
1095
+ if (tag !== 106) {
1096
+ break;
1097
+ }
1098
+
1099
+ message.usage = AITokenUsage.decode(reader, reader.uint32());
1100
+ continue;
1101
+ }
1102
+ case 14: {
1103
+ if (tag !== 114) {
1104
+ break;
1105
+ }
1106
+
1107
+ message.models.push(reader.string());
1108
+ continue;
1109
+ }
1110
+ case 15: {
1111
+ if (tag !== 122) {
1112
+ break;
1113
+ }
1114
+
1115
+ message.providers.push(reader.string());
1116
+ continue;
1117
+ }
1118
+ case 16: {
1119
+ if (tag !== 128) {
1120
+ break;
1121
+ }
1122
+
1123
+ message.branchesCreated = longToNumber(reader.uint64());
1124
+ continue;
1125
+ }
1126
+ case 17: {
1127
+ if (tag !== 136) {
1128
+ break;
1129
+ }
1130
+
1131
+ message.commits = longToNumber(reader.uint64());
1132
+ continue;
1133
+ }
1134
+ case 18: {
1135
+ if (tag !== 144) {
1136
+ break;
1137
+ }
1138
+
1139
+ message.gitPushes = longToNumber(reader.uint64());
1140
+ continue;
1141
+ }
1142
+ case 19: {
1143
+ if (tag !== 152) {
1144
+ break;
1145
+ }
1146
+
1147
+ message.pullRequestsCreated = longToNumber(reader.uint64());
1148
+ continue;
1149
+ }
1150
+ case 20: {
1151
+ if (tag !== 160) {
1152
+ break;
1153
+ }
1154
+
1155
+ message.pullRequestsMerged = longToNumber(reader.uint64());
1156
+ continue;
1157
+ }
1158
+ case 21: {
1159
+ if (tag !== 170) {
1160
+ break;
1161
+ }
1162
+
1163
+ message.gitOrgs.push(reader.string());
1164
+ continue;
1165
+ }
1166
+ case 22: {
1167
+ if (tag !== 178) {
1168
+ break;
1169
+ }
1170
+
1171
+ message.repositories.push(reader.string());
1172
+ continue;
1173
+ }
1174
+ case 23: {
1175
+ if (tag !== 184) {
1176
+ break;
1177
+ }
1178
+
1179
+ message.filesTouched = longToNumber(reader.uint64());
1180
+ continue;
1181
+ }
1182
+ }
1183
+ if ((tag & 7) === 4 || tag === 0) {
1184
+ break;
1185
+ }
1186
+ reader.skip(tag & 7);
1187
+ }
1188
+ return message;
1189
+ } finally {
1190
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
1191
+ }
1192
+ },
1193
+
1194
+ fromJSON(object: any): AISession {
1195
+ return {
1196
+ routingKey: isSet(object.routingKey)
1197
+ ? globalThis.String(object.routingKey)
1198
+ : isSet(object.routing_key)
1199
+ ? globalThis.String(object.routing_key)
1200
+ : "",
1201
+ sourceSystem: isSet(object.sourceSystem)
1202
+ ? globalThis.String(object.sourceSystem)
1203
+ : isSet(object.source_system)
1204
+ ? globalThis.String(object.source_system)
1205
+ : "",
1206
+ sessionId: isSet(object.sessionId)
1207
+ ? globalThis.String(object.sessionId)
1208
+ : isSet(object.session_id)
1209
+ ? globalThis.String(object.session_id)
1210
+ : "",
1211
+ userId: isSet(object.userId)
1212
+ ? globalThis.String(object.userId)
1213
+ : isSet(object.user_id)
1214
+ ? globalThis.String(object.user_id)
1215
+ : "",
1216
+ apiKeyId: isSet(object.apiKeyId)
1217
+ ? globalThis.String(object.apiKeyId)
1218
+ : isSet(object.api_key_id)
1219
+ ? globalThis.String(object.api_key_id)
1220
+ : "",
1221
+ subjectOrganizationId: isSet(object.subjectOrganizationId)
1222
+ ? globalThis.String(object.subjectOrganizationId)
1223
+ : isSet(object.subject_organization_id)
1224
+ ? globalThis.String(object.subject_organization_id)
1225
+ : "",
1226
+ firstSessionTime: isSet(object.firstSessionTime)
1227
+ ? fromJsonTimestamp(object.firstSessionTime)
1228
+ : isSet(object.first_session_time)
1229
+ ? fromJsonTimestamp(object.first_session_time)
1230
+ : undefined,
1231
+ lastActivityAt: isSet(object.lastActivityAt)
1232
+ ? fromJsonTimestamp(object.lastActivityAt)
1233
+ : isSet(object.last_activity_at)
1234
+ ? fromJsonTimestamp(object.last_activity_at)
1235
+ : undefined,
1236
+ turns: isSet(object.turns) ? globalThis.Number(object.turns) : 0,
1237
+ modelCalls: isSet(object.modelCalls)
1238
+ ? globalThis.Number(object.modelCalls)
1239
+ : isSet(object.model_calls)
1240
+ ? globalThis.Number(object.model_calls)
1241
+ : 0,
1242
+ toolCalls: isSet(object.toolCalls)
1243
+ ? globalThis.Number(object.toolCalls)
1244
+ : isSet(object.tool_calls)
1245
+ ? globalThis.Number(object.tool_calls)
1246
+ : 0,
1247
+ userMessages: isSet(object.userMessages)
1248
+ ? globalThis.Number(object.userMessages)
1249
+ : isSet(object.user_messages)
1250
+ ? globalThis.Number(object.user_messages)
1251
+ : 0,
1252
+ usage: isSet(object.usage) ? AITokenUsage.fromJSON(object.usage) : undefined,
1253
+ models: globalThis.Array.isArray(object?.models)
1254
+ ? object.models.map((e: any) => globalThis.String(e))
1255
+ : [],
1256
+ providers: globalThis.Array.isArray(object?.providers)
1257
+ ? object.providers.map((e: any) => globalThis.String(e))
1258
+ : [],
1259
+ branchesCreated: isSet(object.branchesCreated)
1260
+ ? globalThis.Number(object.branchesCreated)
1261
+ : isSet(object.branches_created)
1262
+ ? globalThis.Number(object.branches_created)
1263
+ : 0,
1264
+ commits: isSet(object.commits) ? globalThis.Number(object.commits) : 0,
1265
+ gitPushes: isSet(object.gitPushes)
1266
+ ? globalThis.Number(object.gitPushes)
1267
+ : isSet(object.git_pushes)
1268
+ ? globalThis.Number(object.git_pushes)
1269
+ : 0,
1270
+ pullRequestsCreated: isSet(object.pullRequestsCreated)
1271
+ ? globalThis.Number(object.pullRequestsCreated)
1272
+ : isSet(object.pull_requests_created)
1273
+ ? globalThis.Number(object.pull_requests_created)
1274
+ : 0,
1275
+ pullRequestsMerged: isSet(object.pullRequestsMerged)
1276
+ ? globalThis.Number(object.pullRequestsMerged)
1277
+ : isSet(object.pull_requests_merged)
1278
+ ? globalThis.Number(object.pull_requests_merged)
1279
+ : 0,
1280
+ gitOrgs: globalThis.Array.isArray(object?.gitOrgs)
1281
+ ? object.gitOrgs.map((e: any) => globalThis.String(e))
1282
+ : globalThis.Array.isArray(object?.git_orgs)
1283
+ ? object.git_orgs.map((e: any) => globalThis.String(e))
1284
+ : [],
1285
+ repositories: globalThis.Array.isArray(object?.repositories)
1286
+ ? object.repositories.map((e: any) => globalThis.String(e))
1287
+ : [],
1288
+ filesTouched: isSet(object.filesTouched)
1289
+ ? globalThis.Number(object.filesTouched)
1290
+ : isSet(object.files_touched)
1291
+ ? globalThis.Number(object.files_touched)
1292
+ : 0,
1293
+ };
1294
+ },
1295
+
1296
+ toJSON(message: AISession): unknown {
1297
+ const obj: any = {};
1298
+ if (message.routingKey !== "") {
1299
+ obj.routingKey = message.routingKey;
1300
+ }
1301
+ if (message.sourceSystem !== "") {
1302
+ obj.sourceSystem = message.sourceSystem;
1303
+ }
1304
+ if (message.sessionId !== "") {
1305
+ obj.sessionId = message.sessionId;
1306
+ }
1307
+ if (message.userId !== "") {
1308
+ obj.userId = message.userId;
1309
+ }
1310
+ if (message.apiKeyId !== "") {
1311
+ obj.apiKeyId = message.apiKeyId;
1312
+ }
1313
+ if (message.subjectOrganizationId !== "") {
1314
+ obj.subjectOrganizationId = message.subjectOrganizationId;
1315
+ }
1316
+ if (message.firstSessionTime !== undefined) {
1317
+ obj.firstSessionTime = message.firstSessionTime.toISOString();
1318
+ }
1319
+ if (message.lastActivityAt !== undefined) {
1320
+ obj.lastActivityAt = message.lastActivityAt.toISOString();
1321
+ }
1322
+ if (message.turns !== 0) {
1323
+ obj.turns = Math.round(message.turns);
1324
+ }
1325
+ if (message.modelCalls !== 0) {
1326
+ obj.modelCalls = Math.round(message.modelCalls);
1327
+ }
1328
+ if (message.toolCalls !== 0) {
1329
+ obj.toolCalls = Math.round(message.toolCalls);
1330
+ }
1331
+ if (message.userMessages !== 0) {
1332
+ obj.userMessages = Math.round(message.userMessages);
1333
+ }
1334
+ if (message.usage !== undefined) {
1335
+ obj.usage = AITokenUsage.toJSON(message.usage);
1336
+ }
1337
+ if (message.models?.length) {
1338
+ obj.models = message.models;
1339
+ }
1340
+ if (message.providers?.length) {
1341
+ obj.providers = message.providers;
1342
+ }
1343
+ if (message.branchesCreated !== 0) {
1344
+ obj.branchesCreated = Math.round(message.branchesCreated);
1345
+ }
1346
+ if (message.commits !== 0) {
1347
+ obj.commits = Math.round(message.commits);
1348
+ }
1349
+ if (message.gitPushes !== 0) {
1350
+ obj.gitPushes = Math.round(message.gitPushes);
1351
+ }
1352
+ if (message.pullRequestsCreated !== 0) {
1353
+ obj.pullRequestsCreated = Math.round(message.pullRequestsCreated);
1354
+ }
1355
+ if (message.pullRequestsMerged !== 0) {
1356
+ obj.pullRequestsMerged = Math.round(message.pullRequestsMerged);
1357
+ }
1358
+ if (message.gitOrgs?.length) {
1359
+ obj.gitOrgs = message.gitOrgs;
1360
+ }
1361
+ if (message.repositories?.length) {
1362
+ obj.repositories = message.repositories;
1363
+ }
1364
+ if (message.filesTouched !== 0) {
1365
+ obj.filesTouched = Math.round(message.filesTouched);
1366
+ }
1367
+ return obj;
1368
+ },
1369
+
1370
+ create<I extends Exact<DeepPartial<AISession>, I>>(base?: I): AISession {
1371
+ return AISession.fromPartial(base ?? ({} as any));
1372
+ },
1373
+ fromPartial<I extends Exact<DeepPartial<AISession>, I>>(object: I): AISession {
1374
+ const message = createBaseAISession();
1375
+ message.routingKey = object.routingKey ?? "";
1376
+ message.sourceSystem = object.sourceSystem ?? "";
1377
+ message.sessionId = object.sessionId ?? "";
1378
+ message.userId = object.userId ?? "";
1379
+ message.apiKeyId = object.apiKeyId ?? "";
1380
+ message.subjectOrganizationId = object.subjectOrganizationId ?? "";
1381
+ message.firstSessionTime = object.firstSessionTime ?? undefined;
1382
+ message.lastActivityAt = object.lastActivityAt ?? undefined;
1383
+ message.turns = object.turns ?? 0;
1384
+ message.modelCalls = object.modelCalls ?? 0;
1385
+ message.toolCalls = object.toolCalls ?? 0;
1386
+ message.userMessages = object.userMessages ?? 0;
1387
+ message.usage = (object.usage !== undefined && object.usage !== null)
1388
+ ? AITokenUsage.fromPartial(object.usage)
1389
+ : undefined;
1390
+ message.models = object.models?.map((e) => e) || [];
1391
+ message.providers = object.providers?.map((e) => e) || [];
1392
+ message.branchesCreated = object.branchesCreated ?? 0;
1393
+ message.commits = object.commits ?? 0;
1394
+ message.gitPushes = object.gitPushes ?? 0;
1395
+ message.pullRequestsCreated = object.pullRequestsCreated ?? 0;
1396
+ message.pullRequestsMerged = object.pullRequestsMerged ?? 0;
1397
+ message.gitOrgs = object.gitOrgs?.map((e) => e) || [];
1398
+ message.repositories = object.repositories?.map((e) => e) || [];
1399
+ message.filesTouched = object.filesTouched ?? 0;
1400
+ return message;
1401
+ },
1402
+ };
1403
+
1404
+ function createBaseStreamSessionRequest(): StreamSessionRequest {
1405
+ return { organizationId: "", projectId: "", routingKey: "", sourceSystem: "" };
1406
+ }
1407
+
1408
+ export const StreamSessionRequest: MessageFns<StreamSessionRequest> = {
1409
+ encode(message: StreamSessionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1410
+ if (message.organizationId !== "") {
1411
+ writer.uint32(10).string(message.organizationId);
1412
+ }
1413
+ if (message.projectId !== "") {
1414
+ writer.uint32(18).string(message.projectId);
1415
+ }
1416
+ if (message.routingKey !== "") {
1417
+ writer.uint32(26).string(message.routingKey);
1418
+ }
1419
+ if (message.sourceSystem !== "") {
1420
+ writer.uint32(34).string(message.sourceSystem);
1421
+ }
1422
+ return writer;
1423
+ },
1424
+
1425
+ decode(input: BinaryReader | Uint8Array, length?: number): StreamSessionRequest {
1426
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1427
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
1428
+ if (previousRecursionDepth >= 100) {
1429
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
1430
+ }
1431
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
1432
+ try {
1433
+ const end = length === undefined ? reader.len : reader.pos + length;
1434
+ const message = createBaseStreamSessionRequest();
1435
+ while (reader.pos < end) {
1436
+ const tag = reader.uint32();
1437
+ switch (tag >>> 3) {
1438
+ case 1: {
1439
+ if (tag !== 10) {
1440
+ break;
1441
+ }
1442
+
1443
+ message.organizationId = reader.string();
1444
+ continue;
1445
+ }
1446
+ case 2: {
1447
+ if (tag !== 18) {
1448
+ break;
1449
+ }
1450
+
1451
+ message.projectId = reader.string();
1452
+ continue;
1453
+ }
1454
+ case 3: {
1455
+ if (tag !== 26) {
1456
+ break;
1457
+ }
1458
+
1459
+ message.routingKey = reader.string();
1460
+ continue;
1461
+ }
1462
+ case 4: {
1463
+ if (tag !== 34) {
1464
+ break;
1465
+ }
1466
+
1467
+ message.sourceSystem = reader.string();
1468
+ continue;
1469
+ }
1470
+ }
1471
+ if ((tag & 7) === 4 || tag === 0) {
1472
+ break;
1473
+ }
1474
+ reader.skip(tag & 7);
1475
+ }
1476
+ return message;
1477
+ } finally {
1478
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
1479
+ }
1480
+ },
1481
+
1482
+ fromJSON(object: any): StreamSessionRequest {
1483
+ return {
1484
+ organizationId: isSet(object.organizationId)
1485
+ ? globalThis.String(object.organizationId)
1486
+ : isSet(object.organization_id)
1487
+ ? globalThis.String(object.organization_id)
1488
+ : "",
1489
+ projectId: isSet(object.projectId)
1490
+ ? globalThis.String(object.projectId)
1491
+ : isSet(object.project_id)
1492
+ ? globalThis.String(object.project_id)
1493
+ : "",
1494
+ routingKey: isSet(object.routingKey)
1495
+ ? globalThis.String(object.routingKey)
1496
+ : isSet(object.routing_key)
1497
+ ? globalThis.String(object.routing_key)
1498
+ : "",
1499
+ sourceSystem: isSet(object.sourceSystem)
1500
+ ? globalThis.String(object.sourceSystem)
1501
+ : isSet(object.source_system)
1502
+ ? globalThis.String(object.source_system)
1503
+ : "",
1504
+ };
1505
+ },
1506
+
1507
+ toJSON(message: StreamSessionRequest): unknown {
1508
+ const obj: any = {};
1509
+ if (message.organizationId !== "") {
1510
+ obj.organizationId = message.organizationId;
1511
+ }
1512
+ if (message.projectId !== "") {
1513
+ obj.projectId = message.projectId;
1514
+ }
1515
+ if (message.routingKey !== "") {
1516
+ obj.routingKey = message.routingKey;
1517
+ }
1518
+ if (message.sourceSystem !== "") {
1519
+ obj.sourceSystem = message.sourceSystem;
1520
+ }
1521
+ return obj;
1522
+ },
1523
+
1524
+ create<I extends Exact<DeepPartial<StreamSessionRequest>, I>>(base?: I): StreamSessionRequest {
1525
+ return StreamSessionRequest.fromPartial(base ?? ({} as any));
1526
+ },
1527
+ fromPartial<I extends Exact<DeepPartial<StreamSessionRequest>, I>>(object: I): StreamSessionRequest {
1528
+ const message = createBaseStreamSessionRequest();
1529
+ message.organizationId = object.organizationId ?? "";
1530
+ message.projectId = object.projectId ?? "";
1531
+ message.routingKey = object.routingKey ?? "";
1532
+ message.sourceSystem = object.sourceSystem ?? "";
1533
+ return message;
1534
+ },
1535
+ };
1536
+
1537
+ function createBaseAISessionEventEnvelope(): AISessionEventEnvelope {
1538
+ return { event: undefined, completed: undefined };
1539
+ }
1540
+
1541
+ export const AISessionEventEnvelope: MessageFns<AISessionEventEnvelope> = {
1542
+ encode(message: AISessionEventEnvelope, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1543
+ if (message.event !== undefined) {
1544
+ AISessionEvent.encode(message.event, writer.uint32(10).fork()).join();
1545
+ }
1546
+ if (message.completed !== undefined) {
1547
+ ReplayCompleted.encode(message.completed, writer.uint32(18).fork()).join();
1548
+ }
1549
+ return writer;
1550
+ },
1551
+
1552
+ decode(input: BinaryReader | Uint8Array, length?: number): AISessionEventEnvelope {
1553
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1554
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
1555
+ if (previousRecursionDepth >= 100) {
1556
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
1557
+ }
1558
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
1559
+ try {
1560
+ const end = length === undefined ? reader.len : reader.pos + length;
1561
+ const message = createBaseAISessionEventEnvelope();
1562
+ while (reader.pos < end) {
1563
+ const tag = reader.uint32();
1564
+ switch (tag >>> 3) {
1565
+ case 1: {
1566
+ if (tag !== 10) {
1567
+ break;
1568
+ }
1569
+
1570
+ message.event = AISessionEvent.decode(reader, reader.uint32());
1571
+ continue;
1572
+ }
1573
+ case 2: {
1574
+ if (tag !== 18) {
1575
+ break;
1576
+ }
1577
+
1578
+ message.completed = ReplayCompleted.decode(reader, reader.uint32());
1579
+ continue;
1580
+ }
1581
+ }
1582
+ if ((tag & 7) === 4 || tag === 0) {
1583
+ break;
1584
+ }
1585
+ reader.skip(tag & 7);
1586
+ }
1587
+ return message;
1588
+ } finally {
1589
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
1590
+ }
1591
+ },
1592
+
1593
+ fromJSON(object: any): AISessionEventEnvelope {
1594
+ return {
1595
+ event: isSet(object.event) ? AISessionEvent.fromJSON(object.event) : undefined,
1596
+ completed: isSet(object.completed) ? ReplayCompleted.fromJSON(object.completed) : undefined,
1597
+ };
1598
+ },
1599
+
1600
+ toJSON(message: AISessionEventEnvelope): unknown {
1601
+ const obj: any = {};
1602
+ if (message.event !== undefined) {
1603
+ obj.event = AISessionEvent.toJSON(message.event);
1604
+ }
1605
+ if (message.completed !== undefined) {
1606
+ obj.completed = ReplayCompleted.toJSON(message.completed);
1607
+ }
1608
+ return obj;
1609
+ },
1610
+
1611
+ create<I extends Exact<DeepPartial<AISessionEventEnvelope>, I>>(base?: I): AISessionEventEnvelope {
1612
+ return AISessionEventEnvelope.fromPartial(base ?? ({} as any));
1613
+ },
1614
+ fromPartial<I extends Exact<DeepPartial<AISessionEventEnvelope>, I>>(object: I): AISessionEventEnvelope {
1615
+ const message = createBaseAISessionEventEnvelope();
1616
+ message.event = (object.event !== undefined && object.event !== null)
1617
+ ? AISessionEvent.fromPartial(object.event)
1618
+ : undefined;
1619
+ message.completed = (object.completed !== undefined && object.completed !== null)
1620
+ ? ReplayCompleted.fromPartial(object.completed)
1621
+ : undefined;
1622
+ return message;
1623
+ },
1624
+ };
1625
+
1626
+ function createBaseReplayCompleted(): ReplayCompleted {
1627
+ return {};
1628
+ }
1629
+
1630
+ export const ReplayCompleted: MessageFns<ReplayCompleted> = {
1631
+ encode(_: ReplayCompleted, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1632
+ return writer;
1633
+ },
1634
+
1635
+ decode(input: BinaryReader | Uint8Array, length?: number): ReplayCompleted {
1636
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1637
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
1638
+ if (previousRecursionDepth >= 100) {
1639
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
1640
+ }
1641
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
1642
+ try {
1643
+ const end = length === undefined ? reader.len : reader.pos + length;
1644
+ const message = createBaseReplayCompleted();
1645
+ while (reader.pos < end) {
1646
+ const tag = reader.uint32();
1647
+ switch (tag >>> 3) {
1648
+ }
1649
+ if ((tag & 7) === 4 || tag === 0) {
1650
+ break;
1651
+ }
1652
+ reader.skip(tag & 7);
1653
+ }
1654
+ return message;
1655
+ } finally {
1656
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
1657
+ }
1658
+ },
1659
+
1660
+ fromJSON(_: any): ReplayCompleted {
1661
+ return {};
1662
+ },
1663
+
1664
+ toJSON(_: ReplayCompleted): unknown {
1665
+ const obj: any = {};
1666
+ return obj;
1667
+ },
1668
+
1669
+ create<I extends Exact<DeepPartial<ReplayCompleted>, I>>(base?: I): ReplayCompleted {
1670
+ return ReplayCompleted.fromPartial(base ?? ({} as any));
1671
+ },
1672
+ fromPartial<I extends Exact<DeepPartial<ReplayCompleted>, I>>(_: I): ReplayCompleted {
1673
+ const message = createBaseReplayCompleted();
1674
+ return message;
1675
+ },
1676
+ };
1677
+
1678
+ function createBaseAISessionEvent(): AISessionEvent {
1679
+ return {
1680
+ kind: 0,
1681
+ sequence: undefined,
1682
+ eventTime: undefined,
1683
+ turnId: "",
1684
+ content: [],
1685
+ usage: undefined,
1686
+ model: "",
1687
+ provider: "",
1688
+ toolName: "",
1689
+ status: "",
1690
+ finishReason: "",
1691
+ durationMs: undefined,
1692
+ ttftMs: undefined,
1693
+ modelCallId: "",
1694
+ toolCallId: "",
1695
+ };
1696
+ }
1697
+
1698
+ export const AISessionEvent: MessageFns<AISessionEvent> = {
1699
+ encode(message: AISessionEvent, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1700
+ if (message.kind !== 0) {
1701
+ writer.uint32(8).int32(message.kind);
1702
+ }
1703
+ if (message.sequence !== undefined) {
1704
+ writer.uint32(16).int64(message.sequence);
1705
+ }
1706
+ if (message.eventTime !== undefined) {
1707
+ Timestamp.encode(toTimestamp(message.eventTime), writer.uint32(26).fork()).join();
1708
+ }
1709
+ if (message.turnId !== "") {
1710
+ writer.uint32(34).string(message.turnId);
1711
+ }
1712
+ for (const v of message.content) {
1713
+ AIContentPart.encode(v!, writer.uint32(42).fork()).join();
1714
+ }
1715
+ if (message.usage !== undefined) {
1716
+ AITokenUsage.encode(message.usage, writer.uint32(50).fork()).join();
1717
+ }
1718
+ if (message.model !== "") {
1719
+ writer.uint32(58).string(message.model);
1720
+ }
1721
+ if (message.provider !== "") {
1722
+ writer.uint32(66).string(message.provider);
1723
+ }
1724
+ if (message.toolName !== "") {
1725
+ writer.uint32(74).string(message.toolName);
1726
+ }
1727
+ if (message.status !== "") {
1728
+ writer.uint32(82).string(message.status);
1729
+ }
1730
+ if (message.finishReason !== "") {
1731
+ writer.uint32(90).string(message.finishReason);
1732
+ }
1733
+ if (message.durationMs !== undefined) {
1734
+ writer.uint32(96).int64(message.durationMs);
1735
+ }
1736
+ if (message.ttftMs !== undefined) {
1737
+ writer.uint32(104).uint64(message.ttftMs);
1738
+ }
1739
+ if (message.modelCallId !== "") {
1740
+ writer.uint32(114).string(message.modelCallId);
1741
+ }
1742
+ if (message.toolCallId !== "") {
1743
+ writer.uint32(122).string(message.toolCallId);
1744
+ }
1745
+ return writer;
1746
+ },
1747
+
1748
+ decode(input: BinaryReader | Uint8Array, length?: number): AISessionEvent {
1749
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1750
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
1751
+ if (previousRecursionDepth >= 100) {
1752
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
1753
+ }
1754
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
1755
+ try {
1756
+ const end = length === undefined ? reader.len : reader.pos + length;
1757
+ const message = createBaseAISessionEvent();
1758
+ while (reader.pos < end) {
1759
+ const tag = reader.uint32();
1760
+ switch (tag >>> 3) {
1761
+ case 1: {
1762
+ if (tag !== 8) {
1763
+ break;
1764
+ }
1765
+
1766
+ message.kind = reader.int32() as any;
1767
+ continue;
1768
+ }
1769
+ case 2: {
1770
+ if (tag !== 16) {
1771
+ break;
1772
+ }
1773
+
1774
+ message.sequence = longToNumber(reader.int64());
1775
+ continue;
1776
+ }
1777
+ case 3: {
1778
+ if (tag !== 26) {
1779
+ break;
1780
+ }
1781
+
1782
+ message.eventTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
1783
+ continue;
1784
+ }
1785
+ case 4: {
1786
+ if (tag !== 34) {
1787
+ break;
1788
+ }
1789
+
1790
+ message.turnId = reader.string();
1791
+ continue;
1792
+ }
1793
+ case 5: {
1794
+ if (tag !== 42) {
1795
+ break;
1796
+ }
1797
+
1798
+ message.content.push(AIContentPart.decode(reader, reader.uint32()));
1799
+ continue;
1800
+ }
1801
+ case 6: {
1802
+ if (tag !== 50) {
1803
+ break;
1804
+ }
1805
+
1806
+ message.usage = AITokenUsage.decode(reader, reader.uint32());
1807
+ continue;
1808
+ }
1809
+ case 7: {
1810
+ if (tag !== 58) {
1811
+ break;
1812
+ }
1813
+
1814
+ message.model = reader.string();
1815
+ continue;
1816
+ }
1817
+ case 8: {
1818
+ if (tag !== 66) {
1819
+ break;
1820
+ }
1821
+
1822
+ message.provider = reader.string();
1823
+ continue;
1824
+ }
1825
+ case 9: {
1826
+ if (tag !== 74) {
1827
+ break;
1828
+ }
1829
+
1830
+ message.toolName = reader.string();
1831
+ continue;
1832
+ }
1833
+ case 10: {
1834
+ if (tag !== 82) {
1835
+ break;
1836
+ }
1837
+
1838
+ message.status = reader.string();
1839
+ continue;
1840
+ }
1841
+ case 11: {
1842
+ if (tag !== 90) {
1843
+ break;
1844
+ }
1845
+
1846
+ message.finishReason = reader.string();
1847
+ continue;
1848
+ }
1849
+ case 12: {
1850
+ if (tag !== 96) {
1851
+ break;
1852
+ }
1853
+
1854
+ message.durationMs = longToNumber(reader.int64());
1855
+ continue;
1856
+ }
1857
+ case 13: {
1858
+ if (tag !== 104) {
1859
+ break;
1860
+ }
1861
+
1862
+ message.ttftMs = longToNumber(reader.uint64());
1863
+ continue;
1864
+ }
1865
+ case 14: {
1866
+ if (tag !== 114) {
1867
+ break;
1868
+ }
1869
+
1870
+ message.modelCallId = reader.string();
1871
+ continue;
1872
+ }
1873
+ case 15: {
1874
+ if (tag !== 122) {
1875
+ break;
1876
+ }
1877
+
1878
+ message.toolCallId = reader.string();
1879
+ continue;
1880
+ }
1881
+ }
1882
+ if ((tag & 7) === 4 || tag === 0) {
1883
+ break;
1884
+ }
1885
+ reader.skip(tag & 7);
1886
+ }
1887
+ return message;
1888
+ } finally {
1889
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
1890
+ }
1891
+ },
1892
+
1893
+ fromJSON(object: any): AISessionEvent {
1894
+ return {
1895
+ kind: isSet(object.kind) ? aISessionEventKindFromJSON(object.kind) : 0,
1896
+ sequence: isSet(object.sequence) ? globalThis.Number(object.sequence) : undefined,
1897
+ eventTime: isSet(object.eventTime)
1898
+ ? fromJsonTimestamp(object.eventTime)
1899
+ : isSet(object.event_time)
1900
+ ? fromJsonTimestamp(object.event_time)
1901
+ : undefined,
1902
+ turnId: isSet(object.turnId)
1903
+ ? globalThis.String(object.turnId)
1904
+ : isSet(object.turn_id)
1905
+ ? globalThis.String(object.turn_id)
1906
+ : "",
1907
+ content: globalThis.Array.isArray(object?.content)
1908
+ ? object.content.map((e: any) => AIContentPart.fromJSON(e))
1909
+ : [],
1910
+ usage: isSet(object.usage) ? AITokenUsage.fromJSON(object.usage) : undefined,
1911
+ model: isSet(object.model) ? globalThis.String(object.model) : "",
1912
+ provider: isSet(object.provider) ? globalThis.String(object.provider) : "",
1913
+ toolName: isSet(object.toolName)
1914
+ ? globalThis.String(object.toolName)
1915
+ : isSet(object.tool_name)
1916
+ ? globalThis.String(object.tool_name)
1917
+ : "",
1918
+ status: isSet(object.status) ? globalThis.String(object.status) : "",
1919
+ finishReason: isSet(object.finishReason)
1920
+ ? globalThis.String(object.finishReason)
1921
+ : isSet(object.finish_reason)
1922
+ ? globalThis.String(object.finish_reason)
1923
+ : "",
1924
+ durationMs: isSet(object.durationMs)
1925
+ ? globalThis.Number(object.durationMs)
1926
+ : isSet(object.duration_ms)
1927
+ ? globalThis.Number(object.duration_ms)
1928
+ : undefined,
1929
+ ttftMs: isSet(object.ttftMs)
1930
+ ? globalThis.Number(object.ttftMs)
1931
+ : isSet(object.ttft_ms)
1932
+ ? globalThis.Number(object.ttft_ms)
1933
+ : undefined,
1934
+ modelCallId: isSet(object.modelCallId)
1935
+ ? globalThis.String(object.modelCallId)
1936
+ : isSet(object.model_call_id)
1937
+ ? globalThis.String(object.model_call_id)
1938
+ : "",
1939
+ toolCallId: isSet(object.toolCallId)
1940
+ ? globalThis.String(object.toolCallId)
1941
+ : isSet(object.tool_call_id)
1942
+ ? globalThis.String(object.tool_call_id)
1943
+ : "",
1944
+ };
1945
+ },
1946
+
1947
+ toJSON(message: AISessionEvent): unknown {
1948
+ const obj: any = {};
1949
+ if (message.kind !== 0) {
1950
+ obj.kind = aISessionEventKindToJSON(message.kind);
1951
+ }
1952
+ if (message.sequence !== undefined) {
1953
+ obj.sequence = Math.round(message.sequence);
1954
+ }
1955
+ if (message.eventTime !== undefined) {
1956
+ obj.eventTime = message.eventTime.toISOString();
1957
+ }
1958
+ if (message.turnId !== "") {
1959
+ obj.turnId = message.turnId;
1960
+ }
1961
+ if (message.content?.length) {
1962
+ obj.content = message.content.map((e) => AIContentPart.toJSON(e));
1963
+ }
1964
+ if (message.usage !== undefined) {
1965
+ obj.usage = AITokenUsage.toJSON(message.usage);
1966
+ }
1967
+ if (message.model !== "") {
1968
+ obj.model = message.model;
1969
+ }
1970
+ if (message.provider !== "") {
1971
+ obj.provider = message.provider;
1972
+ }
1973
+ if (message.toolName !== "") {
1974
+ obj.toolName = message.toolName;
1975
+ }
1976
+ if (message.status !== "") {
1977
+ obj.status = message.status;
1978
+ }
1979
+ if (message.finishReason !== "") {
1980
+ obj.finishReason = message.finishReason;
1981
+ }
1982
+ if (message.durationMs !== undefined) {
1983
+ obj.durationMs = Math.round(message.durationMs);
1984
+ }
1985
+ if (message.ttftMs !== undefined) {
1986
+ obj.ttftMs = Math.round(message.ttftMs);
1987
+ }
1988
+ if (message.modelCallId !== "") {
1989
+ obj.modelCallId = message.modelCallId;
1990
+ }
1991
+ if (message.toolCallId !== "") {
1992
+ obj.toolCallId = message.toolCallId;
1993
+ }
1994
+ return obj;
1995
+ },
1996
+
1997
+ create<I extends Exact<DeepPartial<AISessionEvent>, I>>(base?: I): AISessionEvent {
1998
+ return AISessionEvent.fromPartial(base ?? ({} as any));
1999
+ },
2000
+ fromPartial<I extends Exact<DeepPartial<AISessionEvent>, I>>(object: I): AISessionEvent {
2001
+ const message = createBaseAISessionEvent();
2002
+ message.kind = object.kind ?? 0;
2003
+ message.sequence = object.sequence ?? undefined;
2004
+ message.eventTime = object.eventTime ?? undefined;
2005
+ message.turnId = object.turnId ?? "";
2006
+ message.content = object.content?.map((e) => AIContentPart.fromPartial(e)) || [];
2007
+ message.usage = (object.usage !== undefined && object.usage !== null)
2008
+ ? AITokenUsage.fromPartial(object.usage)
2009
+ : undefined;
2010
+ message.model = object.model ?? "";
2011
+ message.provider = object.provider ?? "";
2012
+ message.toolName = object.toolName ?? "";
2013
+ message.status = object.status ?? "";
2014
+ message.finishReason = object.finishReason ?? "";
2015
+ message.durationMs = object.durationMs ?? undefined;
2016
+ message.ttftMs = object.ttftMs ?? undefined;
2017
+ message.modelCallId = object.modelCallId ?? "";
2018
+ message.toolCallId = object.toolCallId ?? "";
2019
+ return message;
2020
+ },
2021
+ };
2022
+
2023
+ function createBaseAIContentPart(): AIContentPart {
2024
+ return { partIndex: 0, contentType: "", content: "" };
2025
+ }
2026
+
2027
+ export const AIContentPart: MessageFns<AIContentPart> = {
2028
+ encode(message: AIContentPart, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2029
+ if (message.partIndex !== 0) {
2030
+ writer.uint32(8).uint32(message.partIndex);
2031
+ }
2032
+ if (message.contentType !== "") {
2033
+ writer.uint32(18).string(message.contentType);
2034
+ }
2035
+ if (message.content !== "") {
2036
+ writer.uint32(26).string(message.content);
2037
+ }
2038
+ return writer;
2039
+ },
2040
+
2041
+ decode(input: BinaryReader | Uint8Array, length?: number): AIContentPart {
2042
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2043
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
2044
+ if (previousRecursionDepth >= 100) {
2045
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
2046
+ }
2047
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
2048
+ try {
2049
+ const end = length === undefined ? reader.len : reader.pos + length;
2050
+ const message = createBaseAIContentPart();
2051
+ while (reader.pos < end) {
2052
+ const tag = reader.uint32();
2053
+ switch (tag >>> 3) {
2054
+ case 1: {
2055
+ if (tag !== 8) {
2056
+ break;
2057
+ }
2058
+
2059
+ message.partIndex = reader.uint32();
2060
+ continue;
2061
+ }
2062
+ case 2: {
2063
+ if (tag !== 18) {
2064
+ break;
2065
+ }
2066
+
2067
+ message.contentType = reader.string();
2068
+ continue;
2069
+ }
2070
+ case 3: {
2071
+ if (tag !== 26) {
2072
+ break;
2073
+ }
2074
+
2075
+ message.content = reader.string();
2076
+ continue;
2077
+ }
2078
+ }
2079
+ if ((tag & 7) === 4 || tag === 0) {
2080
+ break;
2081
+ }
2082
+ reader.skip(tag & 7);
2083
+ }
2084
+ return message;
2085
+ } finally {
2086
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
2087
+ }
2088
+ },
2089
+
2090
+ fromJSON(object: any): AIContentPart {
2091
+ return {
2092
+ partIndex: isSet(object.partIndex)
2093
+ ? globalThis.Number(object.partIndex)
2094
+ : isSet(object.part_index)
2095
+ ? globalThis.Number(object.part_index)
2096
+ : 0,
2097
+ contentType: isSet(object.contentType)
2098
+ ? globalThis.String(object.contentType)
2099
+ : isSet(object.content_type)
2100
+ ? globalThis.String(object.content_type)
2101
+ : "",
2102
+ content: isSet(object.content) ? globalThis.String(object.content) : "",
2103
+ };
2104
+ },
2105
+
2106
+ toJSON(message: AIContentPart): unknown {
2107
+ const obj: any = {};
2108
+ if (message.partIndex !== 0) {
2109
+ obj.partIndex = Math.round(message.partIndex);
2110
+ }
2111
+ if (message.contentType !== "") {
2112
+ obj.contentType = message.contentType;
2113
+ }
2114
+ if (message.content !== "") {
2115
+ obj.content = message.content;
2116
+ }
2117
+ return obj;
2118
+ },
2119
+
2120
+ create<I extends Exact<DeepPartial<AIContentPart>, I>>(base?: I): AIContentPart {
2121
+ return AIContentPart.fromPartial(base ?? ({} as any));
2122
+ },
2123
+ fromPartial<I extends Exact<DeepPartial<AIContentPart>, I>>(object: I): AIContentPart {
2124
+ const message = createBaseAIContentPart();
2125
+ message.partIndex = object.partIndex ?? 0;
2126
+ message.contentType = object.contentType ?? "";
2127
+ message.content = object.content ?? "";
2128
+ return message;
2129
+ },
2130
+ };
2131
+
2132
+ function createBaseListPrincipalsRequest(): ListPrincipalsRequest {
2133
+ return { organizationId: "", projectId: "", kind: undefined, sourceSystem: "", pageSize: 0, pageToken: "" };
2134
+ }
2135
+
2136
+ export const ListPrincipalsRequest: MessageFns<ListPrincipalsRequest> = {
2137
+ encode(message: ListPrincipalsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2138
+ if (message.organizationId !== "") {
2139
+ writer.uint32(10).string(message.organizationId);
2140
+ }
2141
+ if (message.projectId !== "") {
2142
+ writer.uint32(18).string(message.projectId);
2143
+ }
2144
+ if (message.kind !== undefined) {
2145
+ writer.uint32(24).int32(message.kind);
2146
+ }
2147
+ if (message.sourceSystem !== "") {
2148
+ writer.uint32(34).string(message.sourceSystem);
2149
+ }
2150
+ if (message.pageSize !== 0) {
2151
+ writer.uint32(40).int32(message.pageSize);
2152
+ }
2153
+ if (message.pageToken !== "") {
2154
+ writer.uint32(50).string(message.pageToken);
2155
+ }
2156
+ return writer;
2157
+ },
2158
+
2159
+ decode(input: BinaryReader | Uint8Array, length?: number): ListPrincipalsRequest {
2160
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2161
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
2162
+ if (previousRecursionDepth >= 100) {
2163
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
2164
+ }
2165
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
2166
+ try {
2167
+ const end = length === undefined ? reader.len : reader.pos + length;
2168
+ const message = createBaseListPrincipalsRequest();
2169
+ while (reader.pos < end) {
2170
+ const tag = reader.uint32();
2171
+ switch (tag >>> 3) {
2172
+ case 1: {
2173
+ if (tag !== 10) {
2174
+ break;
2175
+ }
2176
+
2177
+ message.organizationId = reader.string();
2178
+ continue;
2179
+ }
2180
+ case 2: {
2181
+ if (tag !== 18) {
2182
+ break;
2183
+ }
2184
+
2185
+ message.projectId = reader.string();
2186
+ continue;
2187
+ }
2188
+ case 3: {
2189
+ if (tag !== 24) {
2190
+ break;
2191
+ }
2192
+
2193
+ message.kind = reader.int32() as any;
2194
+ continue;
2195
+ }
2196
+ case 4: {
2197
+ if (tag !== 34) {
2198
+ break;
2199
+ }
2200
+
2201
+ message.sourceSystem = reader.string();
2202
+ continue;
2203
+ }
2204
+ case 5: {
2205
+ if (tag !== 40) {
2206
+ break;
2207
+ }
2208
+
2209
+ message.pageSize = reader.int32();
2210
+ continue;
2211
+ }
2212
+ case 6: {
2213
+ if (tag !== 50) {
2214
+ break;
2215
+ }
2216
+
2217
+ message.pageToken = reader.string();
2218
+ continue;
2219
+ }
2220
+ }
2221
+ if ((tag & 7) === 4 || tag === 0) {
2222
+ break;
2223
+ }
2224
+ reader.skip(tag & 7);
2225
+ }
2226
+ return message;
2227
+ } finally {
2228
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
2229
+ }
2230
+ },
2231
+
2232
+ fromJSON(object: any): ListPrincipalsRequest {
2233
+ return {
2234
+ organizationId: isSet(object.organizationId)
2235
+ ? globalThis.String(object.organizationId)
2236
+ : isSet(object.organization_id)
2237
+ ? globalThis.String(object.organization_id)
2238
+ : "",
2239
+ projectId: isSet(object.projectId)
2240
+ ? globalThis.String(object.projectId)
2241
+ : isSet(object.project_id)
2242
+ ? globalThis.String(object.project_id)
2243
+ : "",
2244
+ kind: isSet(object.kind) ? aIPrincipalKindFromJSON(object.kind) : undefined,
2245
+ sourceSystem: isSet(object.sourceSystem)
2246
+ ? globalThis.String(object.sourceSystem)
2247
+ : isSet(object.source_system)
2248
+ ? globalThis.String(object.source_system)
2249
+ : "",
2250
+ pageSize: isSet(object.pageSize)
2251
+ ? globalThis.Number(object.pageSize)
2252
+ : isSet(object.page_size)
2253
+ ? globalThis.Number(object.page_size)
2254
+ : 0,
2255
+ pageToken: isSet(object.pageToken)
2256
+ ? globalThis.String(object.pageToken)
2257
+ : isSet(object.page_token)
2258
+ ? globalThis.String(object.page_token)
2259
+ : "",
2260
+ };
2261
+ },
2262
+
2263
+ toJSON(message: ListPrincipalsRequest): unknown {
2264
+ const obj: any = {};
2265
+ if (message.organizationId !== "") {
2266
+ obj.organizationId = message.organizationId;
2267
+ }
2268
+ if (message.projectId !== "") {
2269
+ obj.projectId = message.projectId;
2270
+ }
2271
+ if (message.kind !== undefined) {
2272
+ obj.kind = aIPrincipalKindToJSON(message.kind);
2273
+ }
2274
+ if (message.sourceSystem !== "") {
2275
+ obj.sourceSystem = message.sourceSystem;
2276
+ }
2277
+ if (message.pageSize !== 0) {
2278
+ obj.pageSize = Math.round(message.pageSize);
2279
+ }
2280
+ if (message.pageToken !== "") {
2281
+ obj.pageToken = message.pageToken;
2282
+ }
2283
+ return obj;
2284
+ },
2285
+
2286
+ create<I extends Exact<DeepPartial<ListPrincipalsRequest>, I>>(base?: I): ListPrincipalsRequest {
2287
+ return ListPrincipalsRequest.fromPartial(base ?? ({} as any));
2288
+ },
2289
+ fromPartial<I extends Exact<DeepPartial<ListPrincipalsRequest>, I>>(object: I): ListPrincipalsRequest {
2290
+ const message = createBaseListPrincipalsRequest();
2291
+ message.organizationId = object.organizationId ?? "";
2292
+ message.projectId = object.projectId ?? "";
2293
+ message.kind = object.kind ?? undefined;
2294
+ message.sourceSystem = object.sourceSystem ?? "";
2295
+ message.pageSize = object.pageSize ?? 0;
2296
+ message.pageToken = object.pageToken ?? "";
2297
+ return message;
2298
+ },
2299
+ };
2300
+
2301
+ function createBaseListPrincipalsResponse(): ListPrincipalsResponse {
2302
+ return { status: undefined, principals: [], nextPageToken: "" };
2303
+ }
2304
+
2305
+ export const ListPrincipalsResponse: MessageFns<ListPrincipalsResponse> = {
2306
+ encode(message: ListPrincipalsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2307
+ if (message.status !== undefined) {
2308
+ ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
2309
+ }
2310
+ for (const v of message.principals) {
2311
+ AIPrincipal.encode(v!, writer.uint32(18).fork()).join();
2312
+ }
2313
+ if (message.nextPageToken !== "") {
2314
+ writer.uint32(26).string(message.nextPageToken);
2315
+ }
2316
+ return writer;
2317
+ },
2318
+
2319
+ decode(input: BinaryReader | Uint8Array, length?: number): ListPrincipalsResponse {
2320
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2321
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
2322
+ if (previousRecursionDepth >= 100) {
2323
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
2324
+ }
2325
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
2326
+ try {
2327
+ const end = length === undefined ? reader.len : reader.pos + length;
2328
+ const message = createBaseListPrincipalsResponse();
2329
+ while (reader.pos < end) {
2330
+ const tag = reader.uint32();
2331
+ switch (tag >>> 3) {
2332
+ case 1: {
2333
+ if (tag !== 10) {
2334
+ break;
2335
+ }
2336
+
2337
+ message.status = ResponseStatus.decode(reader, reader.uint32());
2338
+ continue;
2339
+ }
2340
+ case 2: {
2341
+ if (tag !== 18) {
2342
+ break;
2343
+ }
2344
+
2345
+ message.principals.push(AIPrincipal.decode(reader, reader.uint32()));
2346
+ continue;
2347
+ }
2348
+ case 3: {
2349
+ if (tag !== 26) {
2350
+ break;
2351
+ }
2352
+
2353
+ message.nextPageToken = reader.string();
2354
+ continue;
2355
+ }
2356
+ }
2357
+ if ((tag & 7) === 4 || tag === 0) {
2358
+ break;
2359
+ }
2360
+ reader.skip(tag & 7);
2361
+ }
2362
+ return message;
2363
+ } finally {
2364
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
2365
+ }
2366
+ },
2367
+
2368
+ fromJSON(object: any): ListPrincipalsResponse {
2369
+ return {
2370
+ status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
2371
+ principals: globalThis.Array.isArray(object?.principals)
2372
+ ? object.principals.map((e: any) => AIPrincipal.fromJSON(e))
2373
+ : [],
2374
+ nextPageToken: isSet(object.nextPageToken)
2375
+ ? globalThis.String(object.nextPageToken)
2376
+ : isSet(object.next_page_token)
2377
+ ? globalThis.String(object.next_page_token)
2378
+ : "",
2379
+ };
2380
+ },
2381
+
2382
+ toJSON(message: ListPrincipalsResponse): unknown {
2383
+ const obj: any = {};
2384
+ if (message.status !== undefined) {
2385
+ obj.status = ResponseStatus.toJSON(message.status);
2386
+ }
2387
+ if (message.principals?.length) {
2388
+ obj.principals = message.principals.map((e) => AIPrincipal.toJSON(e));
2389
+ }
2390
+ if (message.nextPageToken !== "") {
2391
+ obj.nextPageToken = message.nextPageToken;
2392
+ }
2393
+ return obj;
2394
+ },
2395
+
2396
+ create<I extends Exact<DeepPartial<ListPrincipalsResponse>, I>>(base?: I): ListPrincipalsResponse {
2397
+ return ListPrincipalsResponse.fromPartial(base ?? ({} as any));
2398
+ },
2399
+ fromPartial<I extends Exact<DeepPartial<ListPrincipalsResponse>, I>>(object: I): ListPrincipalsResponse {
2400
+ const message = createBaseListPrincipalsResponse();
2401
+ message.status = (object.status !== undefined && object.status !== null)
2402
+ ? ResponseStatus.fromPartial(object.status)
2403
+ : undefined;
2404
+ message.principals = object.principals?.map((e) => AIPrincipal.fromPartial(e)) || [];
2405
+ message.nextPageToken = object.nextPageToken ?? "";
2406
+ return message;
2407
+ },
2408
+ };
2409
+
2410
+ function createBaseAIPrincipal(): AIPrincipal {
2411
+ return { kind: 0, id: "", name: "", sourceSystem: "", alias: "" };
2412
+ }
2413
+
2414
+ export const AIPrincipal: MessageFns<AIPrincipal> = {
2415
+ encode(message: AIPrincipal, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2416
+ if (message.kind !== 0) {
2417
+ writer.uint32(8).int32(message.kind);
2418
+ }
2419
+ if (message.id !== "") {
2420
+ writer.uint32(18).string(message.id);
2421
+ }
2422
+ if (message.name !== "") {
2423
+ writer.uint32(26).string(message.name);
2424
+ }
2425
+ if (message.sourceSystem !== "") {
2426
+ writer.uint32(34).string(message.sourceSystem);
2427
+ }
2428
+ if (message.alias !== "") {
2429
+ writer.uint32(42).string(message.alias);
2430
+ }
2431
+ return writer;
2432
+ },
2433
+
2434
+ decode(input: BinaryReader | Uint8Array, length?: number): AIPrincipal {
2435
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2436
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
2437
+ if (previousRecursionDepth >= 100) {
2438
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
2439
+ }
2440
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
2441
+ try {
2442
+ const end = length === undefined ? reader.len : reader.pos + length;
2443
+ const message = createBaseAIPrincipal();
2444
+ while (reader.pos < end) {
2445
+ const tag = reader.uint32();
2446
+ switch (tag >>> 3) {
2447
+ case 1: {
2448
+ if (tag !== 8) {
2449
+ break;
2450
+ }
2451
+
2452
+ message.kind = reader.int32() as any;
2453
+ continue;
2454
+ }
2455
+ case 2: {
2456
+ if (tag !== 18) {
2457
+ break;
2458
+ }
2459
+
2460
+ message.id = reader.string();
2461
+ continue;
2462
+ }
2463
+ case 3: {
2464
+ if (tag !== 26) {
2465
+ break;
2466
+ }
2467
+
2468
+ message.name = reader.string();
2469
+ continue;
2470
+ }
2471
+ case 4: {
2472
+ if (tag !== 34) {
2473
+ break;
2474
+ }
2475
+
2476
+ message.sourceSystem = reader.string();
2477
+ continue;
2478
+ }
2479
+ case 5: {
2480
+ if (tag !== 42) {
2481
+ break;
2482
+ }
2483
+
2484
+ message.alias = reader.string();
2485
+ continue;
2486
+ }
2487
+ }
2488
+ if ((tag & 7) === 4 || tag === 0) {
2489
+ break;
2490
+ }
2491
+ reader.skip(tag & 7);
2492
+ }
2493
+ return message;
2494
+ } finally {
2495
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
2496
+ }
2497
+ },
2498
+
2499
+ fromJSON(object: any): AIPrincipal {
2500
+ return {
2501
+ kind: isSet(object.kind) ? aIPrincipalKindFromJSON(object.kind) : 0,
2502
+ id: isSet(object.id) ? globalThis.String(object.id) : "",
2503
+ name: isSet(object.name) ? globalThis.String(object.name) : "",
2504
+ sourceSystem: isSet(object.sourceSystem)
2505
+ ? globalThis.String(object.sourceSystem)
2506
+ : isSet(object.source_system)
2507
+ ? globalThis.String(object.source_system)
2508
+ : "",
2509
+ alias: isSet(object.alias) ? globalThis.String(object.alias) : "",
2510
+ };
2511
+ },
2512
+
2513
+ toJSON(message: AIPrincipal): unknown {
2514
+ const obj: any = {};
2515
+ if (message.kind !== 0) {
2516
+ obj.kind = aIPrincipalKindToJSON(message.kind);
2517
+ }
2518
+ if (message.id !== "") {
2519
+ obj.id = message.id;
2520
+ }
2521
+ if (message.name !== "") {
2522
+ obj.name = message.name;
2523
+ }
2524
+ if (message.sourceSystem !== "") {
2525
+ obj.sourceSystem = message.sourceSystem;
2526
+ }
2527
+ if (message.alias !== "") {
2528
+ obj.alias = message.alias;
2529
+ }
2530
+ return obj;
2531
+ },
2532
+
2533
+ create<I extends Exact<DeepPartial<AIPrincipal>, I>>(base?: I): AIPrincipal {
2534
+ return AIPrincipal.fromPartial(base ?? ({} as any));
2535
+ },
2536
+ fromPartial<I extends Exact<DeepPartial<AIPrincipal>, I>>(object: I): AIPrincipal {
2537
+ const message = createBaseAIPrincipal();
2538
+ message.kind = object.kind ?? 0;
2539
+ message.id = object.id ?? "";
2540
+ message.name = object.name ?? "";
2541
+ message.sourceSystem = object.sourceSystem ?? "";
2542
+ message.alias = object.alias ?? "";
2543
+ return message;
2544
+ },
2545
+ };
2546
+
2547
+ function createBaseUpdatePrincipalRequest(): UpdatePrincipalRequest {
2548
+ return { organizationId: "", projectId: "", kind: 0, id: "", sourceSystem: "", alias: "" };
2549
+ }
2550
+
2551
+ export const UpdatePrincipalRequest: MessageFns<UpdatePrincipalRequest> = {
2552
+ encode(message: UpdatePrincipalRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2553
+ if (message.organizationId !== "") {
2554
+ writer.uint32(10).string(message.organizationId);
2555
+ }
2556
+ if (message.projectId !== "") {
2557
+ writer.uint32(18).string(message.projectId);
2558
+ }
2559
+ if (message.kind !== 0) {
2560
+ writer.uint32(24).int32(message.kind);
2561
+ }
2562
+ if (message.id !== "") {
2563
+ writer.uint32(34).string(message.id);
2564
+ }
2565
+ if (message.sourceSystem !== "") {
2566
+ writer.uint32(42).string(message.sourceSystem);
2567
+ }
2568
+ if (message.alias !== "") {
2569
+ writer.uint32(50).string(message.alias);
2570
+ }
2571
+ return writer;
2572
+ },
2573
+
2574
+ decode(input: BinaryReader | Uint8Array, length?: number): UpdatePrincipalRequest {
2575
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2576
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
2577
+ if (previousRecursionDepth >= 100) {
2578
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
2579
+ }
2580
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
2581
+ try {
2582
+ const end = length === undefined ? reader.len : reader.pos + length;
2583
+ const message = createBaseUpdatePrincipalRequest();
2584
+ while (reader.pos < end) {
2585
+ const tag = reader.uint32();
2586
+ switch (tag >>> 3) {
2587
+ case 1: {
2588
+ if (tag !== 10) {
2589
+ break;
2590
+ }
2591
+
2592
+ message.organizationId = reader.string();
2593
+ continue;
2594
+ }
2595
+ case 2: {
2596
+ if (tag !== 18) {
2597
+ break;
2598
+ }
2599
+
2600
+ message.projectId = reader.string();
2601
+ continue;
2602
+ }
2603
+ case 3: {
2604
+ if (tag !== 24) {
2605
+ break;
2606
+ }
2607
+
2608
+ message.kind = reader.int32() as any;
2609
+ continue;
2610
+ }
2611
+ case 4: {
2612
+ if (tag !== 34) {
2613
+ break;
2614
+ }
2615
+
2616
+ message.id = reader.string();
2617
+ continue;
2618
+ }
2619
+ case 5: {
2620
+ if (tag !== 42) {
2621
+ break;
2622
+ }
2623
+
2624
+ message.sourceSystem = reader.string();
2625
+ continue;
2626
+ }
2627
+ case 6: {
2628
+ if (tag !== 50) {
2629
+ break;
2630
+ }
2631
+
2632
+ message.alias = reader.string();
2633
+ continue;
2634
+ }
2635
+ }
2636
+ if ((tag & 7) === 4 || tag === 0) {
2637
+ break;
2638
+ }
2639
+ reader.skip(tag & 7);
2640
+ }
2641
+ return message;
2642
+ } finally {
2643
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
2644
+ }
2645
+ },
2646
+
2647
+ fromJSON(object: any): UpdatePrincipalRequest {
2648
+ return {
2649
+ organizationId: isSet(object.organizationId)
2650
+ ? globalThis.String(object.organizationId)
2651
+ : isSet(object.organization_id)
2652
+ ? globalThis.String(object.organization_id)
2653
+ : "",
2654
+ projectId: isSet(object.projectId)
2655
+ ? globalThis.String(object.projectId)
2656
+ : isSet(object.project_id)
2657
+ ? globalThis.String(object.project_id)
2658
+ : "",
2659
+ kind: isSet(object.kind) ? aIPrincipalKindFromJSON(object.kind) : 0,
2660
+ id: isSet(object.id) ? globalThis.String(object.id) : "",
2661
+ sourceSystem: isSet(object.sourceSystem)
2662
+ ? globalThis.String(object.sourceSystem)
2663
+ : isSet(object.source_system)
2664
+ ? globalThis.String(object.source_system)
2665
+ : "",
2666
+ alias: isSet(object.alias) ? globalThis.String(object.alias) : "",
2667
+ };
2668
+ },
2669
+
2670
+ toJSON(message: UpdatePrincipalRequest): unknown {
2671
+ const obj: any = {};
2672
+ if (message.organizationId !== "") {
2673
+ obj.organizationId = message.organizationId;
2674
+ }
2675
+ if (message.projectId !== "") {
2676
+ obj.projectId = message.projectId;
2677
+ }
2678
+ if (message.kind !== 0) {
2679
+ obj.kind = aIPrincipalKindToJSON(message.kind);
2680
+ }
2681
+ if (message.id !== "") {
2682
+ obj.id = message.id;
2683
+ }
2684
+ if (message.sourceSystem !== "") {
2685
+ obj.sourceSystem = message.sourceSystem;
2686
+ }
2687
+ if (message.alias !== "") {
2688
+ obj.alias = message.alias;
2689
+ }
2690
+ return obj;
2691
+ },
2692
+
2693
+ create<I extends Exact<DeepPartial<UpdatePrincipalRequest>, I>>(base?: I): UpdatePrincipalRequest {
2694
+ return UpdatePrincipalRequest.fromPartial(base ?? ({} as any));
2695
+ },
2696
+ fromPartial<I extends Exact<DeepPartial<UpdatePrincipalRequest>, I>>(object: I): UpdatePrincipalRequest {
2697
+ const message = createBaseUpdatePrincipalRequest();
2698
+ message.organizationId = object.organizationId ?? "";
2699
+ message.projectId = object.projectId ?? "";
2700
+ message.kind = object.kind ?? 0;
2701
+ message.id = object.id ?? "";
2702
+ message.sourceSystem = object.sourceSystem ?? "";
2703
+ message.alias = object.alias ?? "";
2704
+ return message;
2705
+ },
2706
+ };
2707
+
2708
+ function createBaseUpdatePrincipalResponse(): UpdatePrincipalResponse {
2709
+ return { status: undefined, principal: undefined };
2710
+ }
2711
+
2712
+ export const UpdatePrincipalResponse: MessageFns<UpdatePrincipalResponse> = {
2713
+ encode(message: UpdatePrincipalResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2714
+ if (message.status !== undefined) {
2715
+ ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
2716
+ }
2717
+ if (message.principal !== undefined) {
2718
+ AIPrincipal.encode(message.principal, writer.uint32(18).fork()).join();
2719
+ }
2720
+ return writer;
2721
+ },
2722
+
2723
+ decode(input: BinaryReader | Uint8Array, length?: number): UpdatePrincipalResponse {
2724
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2725
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
2726
+ if (previousRecursionDepth >= 100) {
2727
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
2728
+ }
2729
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
2730
+ try {
2731
+ const end = length === undefined ? reader.len : reader.pos + length;
2732
+ const message = createBaseUpdatePrincipalResponse();
2733
+ while (reader.pos < end) {
2734
+ const tag = reader.uint32();
2735
+ switch (tag >>> 3) {
2736
+ case 1: {
2737
+ if (tag !== 10) {
2738
+ break;
2739
+ }
2740
+
2741
+ message.status = ResponseStatus.decode(reader, reader.uint32());
2742
+ continue;
2743
+ }
2744
+ case 2: {
2745
+ if (tag !== 18) {
2746
+ break;
2747
+ }
2748
+
2749
+ message.principal = AIPrincipal.decode(reader, reader.uint32());
2750
+ continue;
2751
+ }
2752
+ }
2753
+ if ((tag & 7) === 4 || tag === 0) {
2754
+ break;
2755
+ }
2756
+ reader.skip(tag & 7);
2757
+ }
2758
+ return message;
2759
+ } finally {
2760
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
2761
+ }
2762
+ },
2763
+
2764
+ fromJSON(object: any): UpdatePrincipalResponse {
2765
+ return {
2766
+ status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
2767
+ principal: isSet(object.principal) ? AIPrincipal.fromJSON(object.principal) : undefined,
2768
+ };
2769
+ },
2770
+
2771
+ toJSON(message: UpdatePrincipalResponse): unknown {
2772
+ const obj: any = {};
2773
+ if (message.status !== undefined) {
2774
+ obj.status = ResponseStatus.toJSON(message.status);
2775
+ }
2776
+ if (message.principal !== undefined) {
2777
+ obj.principal = AIPrincipal.toJSON(message.principal);
2778
+ }
2779
+ return obj;
2780
+ },
2781
+
2782
+ create<I extends Exact<DeepPartial<UpdatePrincipalResponse>, I>>(base?: I): UpdatePrincipalResponse {
2783
+ return UpdatePrincipalResponse.fromPartial(base ?? ({} as any));
2784
+ },
2785
+ fromPartial<I extends Exact<DeepPartial<UpdatePrincipalResponse>, I>>(object: I): UpdatePrincipalResponse {
2786
+ const message = createBaseUpdatePrincipalResponse();
2787
+ message.status = (object.status !== undefined && object.status !== null)
2788
+ ? ResponseStatus.fromPartial(object.status)
2789
+ : undefined;
2790
+ message.principal = (object.principal !== undefined && object.principal !== null)
2791
+ ? AIPrincipal.fromPartial(object.principal)
2792
+ : undefined;
2793
+ return message;
2794
+ },
2795
+ };
2796
+
2797
+ function createBaseListGitActivitiesRequest(): ListGitActivitiesRequest {
2798
+ return { organizationId: "", projectId: "", routingKey: "", sourceSystem: "" };
2799
+ }
2800
+
2801
+ export const ListGitActivitiesRequest: MessageFns<ListGitActivitiesRequest> = {
2802
+ encode(message: ListGitActivitiesRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2803
+ if (message.organizationId !== "") {
2804
+ writer.uint32(10).string(message.organizationId);
2805
+ }
2806
+ if (message.projectId !== "") {
2807
+ writer.uint32(18).string(message.projectId);
2808
+ }
2809
+ if (message.routingKey !== "") {
2810
+ writer.uint32(26).string(message.routingKey);
2811
+ }
2812
+ if (message.sourceSystem !== "") {
2813
+ writer.uint32(34).string(message.sourceSystem);
2814
+ }
2815
+ return writer;
2816
+ },
2817
+
2818
+ decode(input: BinaryReader | Uint8Array, length?: number): ListGitActivitiesRequest {
2819
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2820
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
2821
+ if (previousRecursionDepth >= 100) {
2822
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
2823
+ }
2824
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
2825
+ try {
2826
+ const end = length === undefined ? reader.len : reader.pos + length;
2827
+ const message = createBaseListGitActivitiesRequest();
2828
+ while (reader.pos < end) {
2829
+ const tag = reader.uint32();
2830
+ switch (tag >>> 3) {
2831
+ case 1: {
2832
+ if (tag !== 10) {
2833
+ break;
2834
+ }
2835
+
2836
+ message.organizationId = reader.string();
2837
+ continue;
2838
+ }
2839
+ case 2: {
2840
+ if (tag !== 18) {
2841
+ break;
2842
+ }
2843
+
2844
+ message.projectId = reader.string();
2845
+ continue;
2846
+ }
2847
+ case 3: {
2848
+ if (tag !== 26) {
2849
+ break;
2850
+ }
2851
+
2852
+ message.routingKey = reader.string();
2853
+ continue;
2854
+ }
2855
+ case 4: {
2856
+ if (tag !== 34) {
2857
+ break;
2858
+ }
2859
+
2860
+ message.sourceSystem = reader.string();
2861
+ continue;
2862
+ }
2863
+ }
2864
+ if ((tag & 7) === 4 || tag === 0) {
2865
+ break;
2866
+ }
2867
+ reader.skip(tag & 7);
2868
+ }
2869
+ return message;
2870
+ } finally {
2871
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
2872
+ }
2873
+ },
2874
+
2875
+ fromJSON(object: any): ListGitActivitiesRequest {
2876
+ return {
2877
+ organizationId: isSet(object.organizationId)
2878
+ ? globalThis.String(object.organizationId)
2879
+ : isSet(object.organization_id)
2880
+ ? globalThis.String(object.organization_id)
2881
+ : "",
2882
+ projectId: isSet(object.projectId)
2883
+ ? globalThis.String(object.projectId)
2884
+ : isSet(object.project_id)
2885
+ ? globalThis.String(object.project_id)
2886
+ : "",
2887
+ routingKey: isSet(object.routingKey)
2888
+ ? globalThis.String(object.routingKey)
2889
+ : isSet(object.routing_key)
2890
+ ? globalThis.String(object.routing_key)
2891
+ : "",
2892
+ sourceSystem: isSet(object.sourceSystem)
2893
+ ? globalThis.String(object.sourceSystem)
2894
+ : isSet(object.source_system)
2895
+ ? globalThis.String(object.source_system)
2896
+ : "",
2897
+ };
2898
+ },
2899
+
2900
+ toJSON(message: ListGitActivitiesRequest): unknown {
2901
+ const obj: any = {};
2902
+ if (message.organizationId !== "") {
2903
+ obj.organizationId = message.organizationId;
2904
+ }
2905
+ if (message.projectId !== "") {
2906
+ obj.projectId = message.projectId;
2907
+ }
2908
+ if (message.routingKey !== "") {
2909
+ obj.routingKey = message.routingKey;
2910
+ }
2911
+ if (message.sourceSystem !== "") {
2912
+ obj.sourceSystem = message.sourceSystem;
2913
+ }
2914
+ return obj;
2915
+ },
2916
+
2917
+ create<I extends Exact<DeepPartial<ListGitActivitiesRequest>, I>>(base?: I): ListGitActivitiesRequest {
2918
+ return ListGitActivitiesRequest.fromPartial(base ?? ({} as any));
2919
+ },
2920
+ fromPartial<I extends Exact<DeepPartial<ListGitActivitiesRequest>, I>>(object: I): ListGitActivitiesRequest {
2921
+ const message = createBaseListGitActivitiesRequest();
2922
+ message.organizationId = object.organizationId ?? "";
2923
+ message.projectId = object.projectId ?? "";
2924
+ message.routingKey = object.routingKey ?? "";
2925
+ message.sourceSystem = object.sourceSystem ?? "";
2926
+ return message;
2927
+ },
2928
+ };
2929
+
2930
+ function createBaseListGitActivitiesResponse(): ListGitActivitiesResponse {
2931
+ return { status: undefined, activities: [] };
2932
+ }
2933
+
2934
+ export const ListGitActivitiesResponse: MessageFns<ListGitActivitiesResponse> = {
2935
+ encode(message: ListGitActivitiesResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2936
+ if (message.status !== undefined) {
2937
+ ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
2938
+ }
2939
+ for (const v of message.activities) {
2940
+ AIGitActivity.encode(v!, writer.uint32(18).fork()).join();
2941
+ }
2942
+ return writer;
2943
+ },
2944
+
2945
+ decode(input: BinaryReader | Uint8Array, length?: number): ListGitActivitiesResponse {
2946
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2947
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
2948
+ if (previousRecursionDepth >= 100) {
2949
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
2950
+ }
2951
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
2952
+ try {
2953
+ const end = length === undefined ? reader.len : reader.pos + length;
2954
+ const message = createBaseListGitActivitiesResponse();
2955
+ while (reader.pos < end) {
2956
+ const tag = reader.uint32();
2957
+ switch (tag >>> 3) {
2958
+ case 1: {
2959
+ if (tag !== 10) {
2960
+ break;
2961
+ }
2962
+
2963
+ message.status = ResponseStatus.decode(reader, reader.uint32());
2964
+ continue;
2965
+ }
2966
+ case 2: {
2967
+ if (tag !== 18) {
2968
+ break;
2969
+ }
2970
+
2971
+ message.activities.push(AIGitActivity.decode(reader, reader.uint32()));
2972
+ continue;
2973
+ }
2974
+ }
2975
+ if ((tag & 7) === 4 || tag === 0) {
2976
+ break;
2977
+ }
2978
+ reader.skip(tag & 7);
2979
+ }
2980
+ return message;
2981
+ } finally {
2982
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
2983
+ }
2984
+ },
2985
+
2986
+ fromJSON(object: any): ListGitActivitiesResponse {
2987
+ return {
2988
+ status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
2989
+ activities: globalThis.Array.isArray(object?.activities)
2990
+ ? object.activities.map((e: any) => AIGitActivity.fromJSON(e))
2991
+ : [],
2992
+ };
2993
+ },
2994
+
2995
+ toJSON(message: ListGitActivitiesResponse): unknown {
2996
+ const obj: any = {};
2997
+ if (message.status !== undefined) {
2998
+ obj.status = ResponseStatus.toJSON(message.status);
2999
+ }
3000
+ if (message.activities?.length) {
3001
+ obj.activities = message.activities.map((e) => AIGitActivity.toJSON(e));
3002
+ }
3003
+ return obj;
3004
+ },
3005
+
3006
+ create<I extends Exact<DeepPartial<ListGitActivitiesResponse>, I>>(base?: I): ListGitActivitiesResponse {
3007
+ return ListGitActivitiesResponse.fromPartial(base ?? ({} as any));
3008
+ },
3009
+ fromPartial<I extends Exact<DeepPartial<ListGitActivitiesResponse>, I>>(object: I): ListGitActivitiesResponse {
3010
+ const message = createBaseListGitActivitiesResponse();
3011
+ message.status = (object.status !== undefined && object.status !== null)
3012
+ ? ResponseStatus.fromPartial(object.status)
3013
+ : undefined;
3014
+ message.activities = object.activities?.map((e) => AIGitActivity.fromPartial(e)) || [];
3015
+ return message;
3016
+ },
3017
+ };
3018
+
3019
+ function createBaseAIGitActivity(): AIGitActivity {
3020
+ return {
3021
+ eventTime: undefined,
3022
+ sourceSystem: "",
3023
+ sessionId: "",
3024
+ toolCallId: "",
3025
+ action: 0,
3026
+ outcome: 0,
3027
+ ownerKey: "",
3028
+ repositoryKey: "",
3029
+ remoteName: "",
3030
+ remoteUrl: "",
3031
+ sourceRef: "",
3032
+ destRef: "",
3033
+ stdoutCommitSha: "",
3034
+ structuredCommitId: "",
3035
+ pushOldSha: "",
3036
+ pushNewSha: "",
3037
+ messageHeadline: "",
3038
+ filesChanged: 0,
3039
+ insertions: 0,
3040
+ deletions: 0,
3041
+ flags: [],
3042
+ aiCoAuthored: false,
3043
+ pullRequestNumber: 0,
3044
+ pullRequestUrl: "",
3045
+ prState: "",
3046
+ prBaseRef: "",
3047
+ prHeadRef: "",
3048
+ mergeCommitSha: "",
3049
+ };
3050
+ }
3051
+
3052
+ export const AIGitActivity: MessageFns<AIGitActivity> = {
3053
+ encode(message: AIGitActivity, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3054
+ if (message.eventTime !== undefined) {
3055
+ Timestamp.encode(toTimestamp(message.eventTime), writer.uint32(10).fork()).join();
3056
+ }
3057
+ if (message.sourceSystem !== "") {
3058
+ writer.uint32(18).string(message.sourceSystem);
3059
+ }
3060
+ if (message.sessionId !== "") {
3061
+ writer.uint32(26).string(message.sessionId);
3062
+ }
3063
+ if (message.toolCallId !== "") {
3064
+ writer.uint32(34).string(message.toolCallId);
3065
+ }
3066
+ if (message.action !== 0) {
3067
+ writer.uint32(40).int32(message.action);
3068
+ }
3069
+ if (message.outcome !== 0) {
3070
+ writer.uint32(48).int32(message.outcome);
3071
+ }
3072
+ if (message.ownerKey !== "") {
3073
+ writer.uint32(58).string(message.ownerKey);
3074
+ }
3075
+ if (message.repositoryKey !== "") {
3076
+ writer.uint32(66).string(message.repositoryKey);
3077
+ }
3078
+ if (message.remoteName !== "") {
3079
+ writer.uint32(74).string(message.remoteName);
3080
+ }
3081
+ if (message.remoteUrl !== "") {
3082
+ writer.uint32(82).string(message.remoteUrl);
3083
+ }
3084
+ if (message.sourceRef !== "") {
3085
+ writer.uint32(90).string(message.sourceRef);
3086
+ }
3087
+ if (message.destRef !== "") {
3088
+ writer.uint32(98).string(message.destRef);
3089
+ }
3090
+ if (message.stdoutCommitSha !== "") {
3091
+ writer.uint32(106).string(message.stdoutCommitSha);
3092
+ }
3093
+ if (message.structuredCommitId !== "") {
3094
+ writer.uint32(114).string(message.structuredCommitId);
3095
+ }
3096
+ if (message.pushOldSha !== "") {
3097
+ writer.uint32(122).string(message.pushOldSha);
3098
+ }
3099
+ if (message.pushNewSha !== "") {
3100
+ writer.uint32(130).string(message.pushNewSha);
3101
+ }
3102
+ if (message.messageHeadline !== "") {
3103
+ writer.uint32(138).string(message.messageHeadline);
3104
+ }
3105
+ if (message.filesChanged !== 0) {
3106
+ writer.uint32(144).uint32(message.filesChanged);
3107
+ }
3108
+ if (message.insertions !== 0) {
3109
+ writer.uint32(152).uint32(message.insertions);
3110
+ }
3111
+ if (message.deletions !== 0) {
3112
+ writer.uint32(160).uint32(message.deletions);
3113
+ }
3114
+ for (const v of message.flags) {
3115
+ writer.uint32(170).string(v!);
3116
+ }
3117
+ if (message.aiCoAuthored !== false) {
3118
+ writer.uint32(176).bool(message.aiCoAuthored);
3119
+ }
3120
+ if (message.pullRequestNumber !== 0) {
3121
+ writer.uint32(184).uint32(message.pullRequestNumber);
3122
+ }
3123
+ if (message.pullRequestUrl !== "") {
3124
+ writer.uint32(194).string(message.pullRequestUrl);
3125
+ }
3126
+ if (message.prState !== "") {
3127
+ writer.uint32(202).string(message.prState);
3128
+ }
3129
+ if (message.prBaseRef !== "") {
3130
+ writer.uint32(210).string(message.prBaseRef);
3131
+ }
3132
+ if (message.prHeadRef !== "") {
3133
+ writer.uint32(218).string(message.prHeadRef);
3134
+ }
3135
+ if (message.mergeCommitSha !== "") {
3136
+ writer.uint32(226).string(message.mergeCommitSha);
3137
+ }
3138
+ return writer;
3139
+ },
3140
+
3141
+ decode(input: BinaryReader | Uint8Array, length?: number): AIGitActivity {
3142
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3143
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
3144
+ if (previousRecursionDepth >= 100) {
3145
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
3146
+ }
3147
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
3148
+ try {
3149
+ const end = length === undefined ? reader.len : reader.pos + length;
3150
+ const message = createBaseAIGitActivity();
3151
+ while (reader.pos < end) {
3152
+ const tag = reader.uint32();
3153
+ switch (tag >>> 3) {
3154
+ case 1: {
3155
+ if (tag !== 10) {
3156
+ break;
3157
+ }
3158
+
3159
+ message.eventTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
3160
+ continue;
3161
+ }
3162
+ case 2: {
3163
+ if (tag !== 18) {
3164
+ break;
3165
+ }
3166
+
3167
+ message.sourceSystem = reader.string();
3168
+ continue;
3169
+ }
3170
+ case 3: {
3171
+ if (tag !== 26) {
3172
+ break;
3173
+ }
3174
+
3175
+ message.sessionId = reader.string();
3176
+ continue;
3177
+ }
3178
+ case 4: {
3179
+ if (tag !== 34) {
3180
+ break;
3181
+ }
3182
+
3183
+ message.toolCallId = reader.string();
3184
+ continue;
3185
+ }
3186
+ case 5: {
3187
+ if (tag !== 40) {
3188
+ break;
3189
+ }
3190
+
3191
+ message.action = reader.int32() as any;
3192
+ continue;
3193
+ }
3194
+ case 6: {
3195
+ if (tag !== 48) {
3196
+ break;
3197
+ }
3198
+
3199
+ message.outcome = reader.int32() as any;
3200
+ continue;
3201
+ }
3202
+ case 7: {
3203
+ if (tag !== 58) {
3204
+ break;
3205
+ }
3206
+
3207
+ message.ownerKey = reader.string();
3208
+ continue;
3209
+ }
3210
+ case 8: {
3211
+ if (tag !== 66) {
3212
+ break;
3213
+ }
3214
+
3215
+ message.repositoryKey = reader.string();
3216
+ continue;
3217
+ }
3218
+ case 9: {
3219
+ if (tag !== 74) {
3220
+ break;
3221
+ }
3222
+
3223
+ message.remoteName = reader.string();
3224
+ continue;
3225
+ }
3226
+ case 10: {
3227
+ if (tag !== 82) {
3228
+ break;
3229
+ }
3230
+
3231
+ message.remoteUrl = reader.string();
3232
+ continue;
3233
+ }
3234
+ case 11: {
3235
+ if (tag !== 90) {
3236
+ break;
3237
+ }
3238
+
3239
+ message.sourceRef = reader.string();
3240
+ continue;
3241
+ }
3242
+ case 12: {
3243
+ if (tag !== 98) {
3244
+ break;
3245
+ }
3246
+
3247
+ message.destRef = reader.string();
3248
+ continue;
3249
+ }
3250
+ case 13: {
3251
+ if (tag !== 106) {
3252
+ break;
3253
+ }
3254
+
3255
+ message.stdoutCommitSha = reader.string();
3256
+ continue;
3257
+ }
3258
+ case 14: {
3259
+ if (tag !== 114) {
3260
+ break;
3261
+ }
3262
+
3263
+ message.structuredCommitId = reader.string();
3264
+ continue;
3265
+ }
3266
+ case 15: {
3267
+ if (tag !== 122) {
3268
+ break;
3269
+ }
3270
+
3271
+ message.pushOldSha = reader.string();
3272
+ continue;
3273
+ }
3274
+ case 16: {
3275
+ if (tag !== 130) {
3276
+ break;
3277
+ }
3278
+
3279
+ message.pushNewSha = reader.string();
3280
+ continue;
3281
+ }
3282
+ case 17: {
3283
+ if (tag !== 138) {
3284
+ break;
3285
+ }
3286
+
3287
+ message.messageHeadline = reader.string();
3288
+ continue;
3289
+ }
3290
+ case 18: {
3291
+ if (tag !== 144) {
3292
+ break;
3293
+ }
3294
+
3295
+ message.filesChanged = reader.uint32();
3296
+ continue;
3297
+ }
3298
+ case 19: {
3299
+ if (tag !== 152) {
3300
+ break;
3301
+ }
3302
+
3303
+ message.insertions = reader.uint32();
3304
+ continue;
3305
+ }
3306
+ case 20: {
3307
+ if (tag !== 160) {
3308
+ break;
3309
+ }
3310
+
3311
+ message.deletions = reader.uint32();
3312
+ continue;
3313
+ }
3314
+ case 21: {
3315
+ if (tag !== 170) {
3316
+ break;
3317
+ }
3318
+
3319
+ message.flags.push(reader.string());
3320
+ continue;
3321
+ }
3322
+ case 22: {
3323
+ if (tag !== 176) {
3324
+ break;
3325
+ }
3326
+
3327
+ message.aiCoAuthored = reader.bool();
3328
+ continue;
3329
+ }
3330
+ case 23: {
3331
+ if (tag !== 184) {
3332
+ break;
3333
+ }
3334
+
3335
+ message.pullRequestNumber = reader.uint32();
3336
+ continue;
3337
+ }
3338
+ case 24: {
3339
+ if (tag !== 194) {
3340
+ break;
3341
+ }
3342
+
3343
+ message.pullRequestUrl = reader.string();
3344
+ continue;
3345
+ }
3346
+ case 25: {
3347
+ if (tag !== 202) {
3348
+ break;
3349
+ }
3350
+
3351
+ message.prState = reader.string();
3352
+ continue;
3353
+ }
3354
+ case 26: {
3355
+ if (tag !== 210) {
3356
+ break;
3357
+ }
3358
+
3359
+ message.prBaseRef = reader.string();
3360
+ continue;
3361
+ }
3362
+ case 27: {
3363
+ if (tag !== 218) {
3364
+ break;
3365
+ }
3366
+
3367
+ message.prHeadRef = reader.string();
3368
+ continue;
3369
+ }
3370
+ case 28: {
3371
+ if (tag !== 226) {
3372
+ break;
3373
+ }
3374
+
3375
+ message.mergeCommitSha = reader.string();
3376
+ continue;
3377
+ }
3378
+ }
3379
+ if ((tag & 7) === 4 || tag === 0) {
3380
+ break;
3381
+ }
3382
+ reader.skip(tag & 7);
3383
+ }
3384
+ return message;
3385
+ } finally {
3386
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
3387
+ }
3388
+ },
3389
+
3390
+ fromJSON(object: any): AIGitActivity {
3391
+ return {
3392
+ eventTime: isSet(object.eventTime)
3393
+ ? fromJsonTimestamp(object.eventTime)
3394
+ : isSet(object.event_time)
3395
+ ? fromJsonTimestamp(object.event_time)
3396
+ : undefined,
3397
+ sourceSystem: isSet(object.sourceSystem)
3398
+ ? globalThis.String(object.sourceSystem)
3399
+ : isSet(object.source_system)
3400
+ ? globalThis.String(object.source_system)
3401
+ : "",
3402
+ sessionId: isSet(object.sessionId)
3403
+ ? globalThis.String(object.sessionId)
3404
+ : isSet(object.session_id)
3405
+ ? globalThis.String(object.session_id)
3406
+ : "",
3407
+ toolCallId: isSet(object.toolCallId)
3408
+ ? globalThis.String(object.toolCallId)
3409
+ : isSet(object.tool_call_id)
3410
+ ? globalThis.String(object.tool_call_id)
3411
+ : "",
3412
+ action: isSet(object.action) ? aIGitActionFromJSON(object.action) : 0,
3413
+ outcome: isSet(object.outcome) ? aIGitOutcomeFromJSON(object.outcome) : 0,
3414
+ ownerKey: isSet(object.ownerKey)
3415
+ ? globalThis.String(object.ownerKey)
3416
+ : isSet(object.owner_key)
3417
+ ? globalThis.String(object.owner_key)
3418
+ : "",
3419
+ repositoryKey: isSet(object.repositoryKey)
3420
+ ? globalThis.String(object.repositoryKey)
3421
+ : isSet(object.repository_key)
3422
+ ? globalThis.String(object.repository_key)
3423
+ : "",
3424
+ remoteName: isSet(object.remoteName)
3425
+ ? globalThis.String(object.remoteName)
3426
+ : isSet(object.remote_name)
3427
+ ? globalThis.String(object.remote_name)
3428
+ : "",
3429
+ remoteUrl: isSet(object.remoteUrl)
3430
+ ? globalThis.String(object.remoteUrl)
3431
+ : isSet(object.remote_url)
3432
+ ? globalThis.String(object.remote_url)
3433
+ : "",
3434
+ sourceRef: isSet(object.sourceRef)
3435
+ ? globalThis.String(object.sourceRef)
3436
+ : isSet(object.source_ref)
3437
+ ? globalThis.String(object.source_ref)
3438
+ : "",
3439
+ destRef: isSet(object.destRef)
3440
+ ? globalThis.String(object.destRef)
3441
+ : isSet(object.dest_ref)
3442
+ ? globalThis.String(object.dest_ref)
3443
+ : "",
3444
+ stdoutCommitSha: isSet(object.stdoutCommitSha)
3445
+ ? globalThis.String(object.stdoutCommitSha)
3446
+ : isSet(object.stdout_commit_sha)
3447
+ ? globalThis.String(object.stdout_commit_sha)
3448
+ : "",
3449
+ structuredCommitId: isSet(object.structuredCommitId)
3450
+ ? globalThis.String(object.structuredCommitId)
3451
+ : isSet(object.structured_commit_id)
3452
+ ? globalThis.String(object.structured_commit_id)
3453
+ : "",
3454
+ pushOldSha: isSet(object.pushOldSha)
3455
+ ? globalThis.String(object.pushOldSha)
3456
+ : isSet(object.push_old_sha)
3457
+ ? globalThis.String(object.push_old_sha)
3458
+ : "",
3459
+ pushNewSha: isSet(object.pushNewSha)
3460
+ ? globalThis.String(object.pushNewSha)
3461
+ : isSet(object.push_new_sha)
3462
+ ? globalThis.String(object.push_new_sha)
3463
+ : "",
3464
+ messageHeadline: isSet(object.messageHeadline)
3465
+ ? globalThis.String(object.messageHeadline)
3466
+ : isSet(object.message_headline)
3467
+ ? globalThis.String(object.message_headline)
3468
+ : "",
3469
+ filesChanged: isSet(object.filesChanged)
3470
+ ? globalThis.Number(object.filesChanged)
3471
+ : isSet(object.files_changed)
3472
+ ? globalThis.Number(object.files_changed)
3473
+ : 0,
3474
+ insertions: isSet(object.insertions) ? globalThis.Number(object.insertions) : 0,
3475
+ deletions: isSet(object.deletions) ? globalThis.Number(object.deletions) : 0,
3476
+ flags: globalThis.Array.isArray(object?.flags)
3477
+ ? object.flags.map((e: any) => globalThis.String(e))
3478
+ : [],
3479
+ aiCoAuthored: isSet(object.aiCoAuthored)
3480
+ ? globalThis.Boolean(object.aiCoAuthored)
3481
+ : isSet(object.ai_co_authored)
3482
+ ? globalThis.Boolean(object.ai_co_authored)
3483
+ : false,
3484
+ pullRequestNumber: isSet(object.pullRequestNumber)
3485
+ ? globalThis.Number(object.pullRequestNumber)
3486
+ : isSet(object.pull_request_number)
3487
+ ? globalThis.Number(object.pull_request_number)
3488
+ : 0,
3489
+ pullRequestUrl: isSet(object.pullRequestUrl)
3490
+ ? globalThis.String(object.pullRequestUrl)
3491
+ : isSet(object.pull_request_url)
3492
+ ? globalThis.String(object.pull_request_url)
3493
+ : "",
3494
+ prState: isSet(object.prState)
3495
+ ? globalThis.String(object.prState)
3496
+ : isSet(object.pr_state)
3497
+ ? globalThis.String(object.pr_state)
3498
+ : "",
3499
+ prBaseRef: isSet(object.prBaseRef)
3500
+ ? globalThis.String(object.prBaseRef)
3501
+ : isSet(object.pr_base_ref)
3502
+ ? globalThis.String(object.pr_base_ref)
3503
+ : "",
3504
+ prHeadRef: isSet(object.prHeadRef)
3505
+ ? globalThis.String(object.prHeadRef)
3506
+ : isSet(object.pr_head_ref)
3507
+ ? globalThis.String(object.pr_head_ref)
3508
+ : "",
3509
+ mergeCommitSha: isSet(object.mergeCommitSha)
3510
+ ? globalThis.String(object.mergeCommitSha)
3511
+ : isSet(object.merge_commit_sha)
3512
+ ? globalThis.String(object.merge_commit_sha)
3513
+ : "",
3514
+ };
3515
+ },
3516
+
3517
+ toJSON(message: AIGitActivity): unknown {
3518
+ const obj: any = {};
3519
+ if (message.eventTime !== undefined) {
3520
+ obj.eventTime = message.eventTime.toISOString();
3521
+ }
3522
+ if (message.sourceSystem !== "") {
3523
+ obj.sourceSystem = message.sourceSystem;
3524
+ }
3525
+ if (message.sessionId !== "") {
3526
+ obj.sessionId = message.sessionId;
3527
+ }
3528
+ if (message.toolCallId !== "") {
3529
+ obj.toolCallId = message.toolCallId;
3530
+ }
3531
+ if (message.action !== 0) {
3532
+ obj.action = aIGitActionToJSON(message.action);
3533
+ }
3534
+ if (message.outcome !== 0) {
3535
+ obj.outcome = aIGitOutcomeToJSON(message.outcome);
3536
+ }
3537
+ if (message.ownerKey !== "") {
3538
+ obj.ownerKey = message.ownerKey;
3539
+ }
3540
+ if (message.repositoryKey !== "") {
3541
+ obj.repositoryKey = message.repositoryKey;
3542
+ }
3543
+ if (message.remoteName !== "") {
3544
+ obj.remoteName = message.remoteName;
3545
+ }
3546
+ if (message.remoteUrl !== "") {
3547
+ obj.remoteUrl = message.remoteUrl;
3548
+ }
3549
+ if (message.sourceRef !== "") {
3550
+ obj.sourceRef = message.sourceRef;
3551
+ }
3552
+ if (message.destRef !== "") {
3553
+ obj.destRef = message.destRef;
3554
+ }
3555
+ if (message.stdoutCommitSha !== "") {
3556
+ obj.stdoutCommitSha = message.stdoutCommitSha;
3557
+ }
3558
+ if (message.structuredCommitId !== "") {
3559
+ obj.structuredCommitId = message.structuredCommitId;
3560
+ }
3561
+ if (message.pushOldSha !== "") {
3562
+ obj.pushOldSha = message.pushOldSha;
3563
+ }
3564
+ if (message.pushNewSha !== "") {
3565
+ obj.pushNewSha = message.pushNewSha;
3566
+ }
3567
+ if (message.messageHeadline !== "") {
3568
+ obj.messageHeadline = message.messageHeadline;
3569
+ }
3570
+ if (message.filesChanged !== 0) {
3571
+ obj.filesChanged = Math.round(message.filesChanged);
3572
+ }
3573
+ if (message.insertions !== 0) {
3574
+ obj.insertions = Math.round(message.insertions);
3575
+ }
3576
+ if (message.deletions !== 0) {
3577
+ obj.deletions = Math.round(message.deletions);
3578
+ }
3579
+ if (message.flags?.length) {
3580
+ obj.flags = message.flags;
3581
+ }
3582
+ if (message.aiCoAuthored !== false) {
3583
+ obj.aiCoAuthored = message.aiCoAuthored;
3584
+ }
3585
+ if (message.pullRequestNumber !== 0) {
3586
+ obj.pullRequestNumber = Math.round(message.pullRequestNumber);
3587
+ }
3588
+ if (message.pullRequestUrl !== "") {
3589
+ obj.pullRequestUrl = message.pullRequestUrl;
3590
+ }
3591
+ if (message.prState !== "") {
3592
+ obj.prState = message.prState;
3593
+ }
3594
+ if (message.prBaseRef !== "") {
3595
+ obj.prBaseRef = message.prBaseRef;
3596
+ }
3597
+ if (message.prHeadRef !== "") {
3598
+ obj.prHeadRef = message.prHeadRef;
3599
+ }
3600
+ if (message.mergeCommitSha !== "") {
3601
+ obj.mergeCommitSha = message.mergeCommitSha;
3602
+ }
3603
+ return obj;
3604
+ },
3605
+
3606
+ create<I extends Exact<DeepPartial<AIGitActivity>, I>>(base?: I): AIGitActivity {
3607
+ return AIGitActivity.fromPartial(base ?? ({} as any));
3608
+ },
3609
+ fromPartial<I extends Exact<DeepPartial<AIGitActivity>, I>>(object: I): AIGitActivity {
3610
+ const message = createBaseAIGitActivity();
3611
+ message.eventTime = object.eventTime ?? undefined;
3612
+ message.sourceSystem = object.sourceSystem ?? "";
3613
+ message.sessionId = object.sessionId ?? "";
3614
+ message.toolCallId = object.toolCallId ?? "";
3615
+ message.action = object.action ?? 0;
3616
+ message.outcome = object.outcome ?? 0;
3617
+ message.ownerKey = object.ownerKey ?? "";
3618
+ message.repositoryKey = object.repositoryKey ?? "";
3619
+ message.remoteName = object.remoteName ?? "";
3620
+ message.remoteUrl = object.remoteUrl ?? "";
3621
+ message.sourceRef = object.sourceRef ?? "";
3622
+ message.destRef = object.destRef ?? "";
3623
+ message.stdoutCommitSha = object.stdoutCommitSha ?? "";
3624
+ message.structuredCommitId = object.structuredCommitId ?? "";
3625
+ message.pushOldSha = object.pushOldSha ?? "";
3626
+ message.pushNewSha = object.pushNewSha ?? "";
3627
+ message.messageHeadline = object.messageHeadline ?? "";
3628
+ message.filesChanged = object.filesChanged ?? 0;
3629
+ message.insertions = object.insertions ?? 0;
3630
+ message.deletions = object.deletions ?? 0;
3631
+ message.flags = object.flags?.map((e) => e) || [];
3632
+ message.aiCoAuthored = object.aiCoAuthored ?? false;
3633
+ message.pullRequestNumber = object.pullRequestNumber ?? 0;
3634
+ message.pullRequestUrl = object.pullRequestUrl ?? "";
3635
+ message.prState = object.prState ?? "";
3636
+ message.prBaseRef = object.prBaseRef ?? "";
3637
+ message.prHeadRef = object.prHeadRef ?? "";
3638
+ message.mergeCommitSha = object.mergeCommitSha ?? "";
3639
+ return message;
3640
+ },
3641
+ };
3642
+
3643
+ function createBaseAITokenUsage(): AITokenUsage {
3644
+ return { inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, providerCostUsdNano: 0 };
3645
+ }
3646
+
3647
+ export const AITokenUsage: MessageFns<AITokenUsage> = {
3648
+ encode(message: AITokenUsage, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3649
+ if (message.inputTokens !== 0) {
3650
+ writer.uint32(8).uint64(message.inputTokens);
3651
+ }
3652
+ if (message.outputTokens !== 0) {
3653
+ writer.uint32(16).uint64(message.outputTokens);
3654
+ }
3655
+ if (message.cacheReadTokens !== 0) {
3656
+ writer.uint32(24).uint64(message.cacheReadTokens);
3657
+ }
3658
+ if (message.cacheWriteTokens !== 0) {
3659
+ writer.uint32(32).uint64(message.cacheWriteTokens);
3660
+ }
3661
+ if (message.providerCostUsdNano !== 0) {
3662
+ writer.uint32(40).int64(message.providerCostUsdNano);
3663
+ }
3664
+ return writer;
3665
+ },
3666
+
3667
+ decode(input: BinaryReader | Uint8Array, length?: number): AITokenUsage {
3668
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3669
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
3670
+ if (previousRecursionDepth >= 100) {
3671
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
3672
+ }
3673
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
3674
+ try {
3675
+ const end = length === undefined ? reader.len : reader.pos + length;
3676
+ const message = createBaseAITokenUsage();
3677
+ while (reader.pos < end) {
3678
+ const tag = reader.uint32();
3679
+ switch (tag >>> 3) {
3680
+ case 1: {
3681
+ if (tag !== 8) {
3682
+ break;
3683
+ }
3684
+
3685
+ message.inputTokens = longToNumber(reader.uint64());
3686
+ continue;
3687
+ }
3688
+ case 2: {
3689
+ if (tag !== 16) {
3690
+ break;
3691
+ }
3692
+
3693
+ message.outputTokens = longToNumber(reader.uint64());
3694
+ continue;
3695
+ }
3696
+ case 3: {
3697
+ if (tag !== 24) {
3698
+ break;
3699
+ }
3700
+
3701
+ message.cacheReadTokens = longToNumber(reader.uint64());
3702
+ continue;
3703
+ }
3704
+ case 4: {
3705
+ if (tag !== 32) {
3706
+ break;
3707
+ }
3708
+
3709
+ message.cacheWriteTokens = longToNumber(reader.uint64());
3710
+ continue;
3711
+ }
3712
+ case 5: {
3713
+ if (tag !== 40) {
3714
+ break;
3715
+ }
3716
+
3717
+ message.providerCostUsdNano = longToNumber(reader.int64());
3718
+ continue;
3719
+ }
3720
+ }
3721
+ if ((tag & 7) === 4 || tag === 0) {
3722
+ break;
3723
+ }
3724
+ reader.skip(tag & 7);
3725
+ }
3726
+ return message;
3727
+ } finally {
3728
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
3729
+ }
3730
+ },
3731
+
3732
+ fromJSON(object: any): AITokenUsage {
3733
+ return {
3734
+ inputTokens: isSet(object.inputTokens)
3735
+ ? globalThis.Number(object.inputTokens)
3736
+ : isSet(object.input_tokens)
3737
+ ? globalThis.Number(object.input_tokens)
3738
+ : 0,
3739
+ outputTokens: isSet(object.outputTokens)
3740
+ ? globalThis.Number(object.outputTokens)
3741
+ : isSet(object.output_tokens)
3742
+ ? globalThis.Number(object.output_tokens)
3743
+ : 0,
3744
+ cacheReadTokens: isSet(object.cacheReadTokens)
3745
+ ? globalThis.Number(object.cacheReadTokens)
3746
+ : isSet(object.cache_read_tokens)
3747
+ ? globalThis.Number(object.cache_read_tokens)
3748
+ : 0,
3749
+ cacheWriteTokens: isSet(object.cacheWriteTokens)
3750
+ ? globalThis.Number(object.cacheWriteTokens)
3751
+ : isSet(object.cache_write_tokens)
3752
+ ? globalThis.Number(object.cache_write_tokens)
3753
+ : 0,
3754
+ providerCostUsdNano: isSet(object.providerCostUsdNano)
3755
+ ? globalThis.Number(object.providerCostUsdNano)
3756
+ : isSet(object.provider_cost_usd_nano)
3757
+ ? globalThis.Number(object.provider_cost_usd_nano)
3758
+ : 0,
3759
+ };
3760
+ },
3761
+
3762
+ toJSON(message: AITokenUsage): unknown {
3763
+ const obj: any = {};
3764
+ if (message.inputTokens !== 0) {
3765
+ obj.inputTokens = Math.round(message.inputTokens);
3766
+ }
3767
+ if (message.outputTokens !== 0) {
3768
+ obj.outputTokens = Math.round(message.outputTokens);
3769
+ }
3770
+ if (message.cacheReadTokens !== 0) {
3771
+ obj.cacheReadTokens = Math.round(message.cacheReadTokens);
3772
+ }
3773
+ if (message.cacheWriteTokens !== 0) {
3774
+ obj.cacheWriteTokens = Math.round(message.cacheWriteTokens);
3775
+ }
3776
+ if (message.providerCostUsdNano !== 0) {
3777
+ obj.providerCostUsdNano = Math.round(message.providerCostUsdNano);
3778
+ }
3779
+ return obj;
3780
+ },
3781
+
3782
+ create<I extends Exact<DeepPartial<AITokenUsage>, I>>(base?: I): AITokenUsage {
3783
+ return AITokenUsage.fromPartial(base ?? ({} as any));
3784
+ },
3785
+ fromPartial<I extends Exact<DeepPartial<AITokenUsage>, I>>(object: I): AITokenUsage {
3786
+ const message = createBaseAITokenUsage();
3787
+ message.inputTokens = object.inputTokens ?? 0;
3788
+ message.outputTokens = object.outputTokens ?? 0;
3789
+ message.cacheReadTokens = object.cacheReadTokens ?? 0;
3790
+ message.cacheWriteTokens = object.cacheWriteTokens ?? 0;
3791
+ message.providerCostUsdNano = object.providerCostUsdNano ?? 0;
3792
+ return message;
3793
+ },
3794
+ };
3795
+
3796
+ /**
3797
+ * AIGatewayService is the frontend-facing proxy over telemetry.api.v1.AIService:
3798
+ * the AI session catalog, one session's conversational replay, and the principal
3799
+ * id->name catalog (read + alias write). A thin proxy — it resolves the caller's
3800
+ * identity, stamps the authorized organization/project, and forwards. Messages
3801
+ * duplicate the telemetry-api shape (proto domain isolation); unary responses
3802
+ * carry ResponseStatus, streams do not.
3803
+ */
3804
+ export interface AIGatewayService {
3805
+ ListSessions(request: ListSessionsRequest, metadata?: Metadata): Promise<ListSessionsResponse>;
3806
+ StreamSession(request: StreamSessionRequest, metadata?: Metadata): Observable<AISessionEventEnvelope>;
3807
+ ListPrincipals(request: ListPrincipalsRequest, metadata?: Metadata): Promise<ListPrincipalsResponse>;
3808
+ UpdatePrincipal(request: UpdatePrincipalRequest, metadata?: Metadata): Promise<UpdatePrincipalResponse>;
3809
+ ListGitActivities(request: ListGitActivitiesRequest, metadata?: Metadata): Promise<ListGitActivitiesResponse>;
3810
+ }
3811
+
3812
+ export const AIGatewayServiceServiceName = "gateway.web.v1.AIGatewayService";
3813
+ export class AIGatewayServiceClientImpl implements AIGatewayService {
3814
+ private readonly rpc: Rpc;
3815
+ private readonly service: string;
3816
+ constructor(rpc: Rpc, opts?: { service?: string }) {
3817
+ this.service = opts?.service || AIGatewayServiceServiceName;
3818
+ this.rpc = rpc;
3819
+ this.ListSessions = this.ListSessions.bind(this);
3820
+ this.StreamSession = this.StreamSession.bind(this);
3821
+ this.ListPrincipals = this.ListPrincipals.bind(this);
3822
+ this.UpdatePrincipal = this.UpdatePrincipal.bind(this);
3823
+ this.ListGitActivities = this.ListGitActivities.bind(this);
3824
+ }
3825
+ ListSessions(request: ListSessionsRequest, metadata?: Metadata): Promise<ListSessionsResponse> {
3826
+ const data = ListSessionsRequest.encode(request).finish();
3827
+ const promise = this.rpc.request(this.service, "ListSessions", data, metadata);
3828
+ return promise.then((data) => ListSessionsResponse.decode(new BinaryReader(data)));
3829
+ }
3830
+
3831
+ StreamSession(request: StreamSessionRequest, metadata?: Metadata): Observable<AISessionEventEnvelope> {
3832
+ const data = StreamSessionRequest.encode(request).finish();
3833
+ const result = this.rpc.serverStreamingRequest(this.service, "StreamSession", data, metadata);
3834
+ return result.pipe(map((data) => AISessionEventEnvelope.decode(new BinaryReader(data))));
3835
+ }
3836
+
3837
+ ListPrincipals(request: ListPrincipalsRequest, metadata?: Metadata): Promise<ListPrincipalsResponse> {
3838
+ const data = ListPrincipalsRequest.encode(request).finish();
3839
+ const promise = this.rpc.request(this.service, "ListPrincipals", data, metadata);
3840
+ return promise.then((data) => ListPrincipalsResponse.decode(new BinaryReader(data)));
3841
+ }
3842
+
3843
+ UpdatePrincipal(request: UpdatePrincipalRequest, metadata?: Metadata): Promise<UpdatePrincipalResponse> {
3844
+ const data = UpdatePrincipalRequest.encode(request).finish();
3845
+ const promise = this.rpc.request(this.service, "UpdatePrincipal", data, metadata);
3846
+ return promise.then((data) => UpdatePrincipalResponse.decode(new BinaryReader(data)));
3847
+ }
3848
+
3849
+ ListGitActivities(request: ListGitActivitiesRequest, metadata?: Metadata): Promise<ListGitActivitiesResponse> {
3850
+ const data = ListGitActivitiesRequest.encode(request).finish();
3851
+ const promise = this.rpc.request(this.service, "ListGitActivities", data, metadata);
3852
+ return promise.then((data) => ListGitActivitiesResponse.decode(new BinaryReader(data)));
3853
+ }
3854
+ }
3855
+
3856
+ interface Rpc {
3857
+ request(service: string, method: string, data: Uint8Array, metadata?: Metadata): Promise<Uint8Array>;
3858
+ clientStreamingRequest(
3859
+ service: string,
3860
+ method: string,
3861
+ data: Observable<Uint8Array>,
3862
+ metadata?: Metadata,
3863
+ ): Promise<Uint8Array>;
3864
+ serverStreamingRequest(
3865
+ service: string,
3866
+ method: string,
3867
+ data: Uint8Array,
3868
+ metadata?: Metadata,
3869
+ ): Observable<Uint8Array>;
3870
+ bidirectionalStreamingRequest(
3871
+ service: string,
3872
+ method: string,
3873
+ data: Observable<Uint8Array>,
3874
+ metadata?: Metadata,
3875
+ ): Observable<Uint8Array>;
3876
+ }
3877
+
3878
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
3879
+
3880
+ export type DeepPartial<T> = T extends Builtin ? T
3881
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
3882
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
3883
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
3884
+ : Partial<T>;
3885
+
3886
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
3887
+ export type Exact<P, I extends P> = P extends Builtin ? P
3888
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
3889
+
3890
+ function toTimestamp(date: Date): Timestamp {
3891
+ const seconds = Math.trunc(date.getTime() / 1_000);
3892
+ const nanos = (date.getTime() % 1_000) * 1_000_000;
3893
+ return { seconds, nanos };
3894
+ }
3895
+
3896
+ function fromTimestamp(t: Timestamp): Date {
3897
+ let millis = (t.seconds || 0) * 1_000;
3898
+ millis += (t.nanos || 0) / 1_000_000;
3899
+ return new globalThis.Date(millis);
3900
+ }
3901
+
3902
+ function fromJsonTimestamp(o: any): Date {
3903
+ if (o instanceof globalThis.Date) {
3904
+ return o;
3905
+ } else if (typeof o === "string") {
3906
+ return new globalThis.Date(o);
3907
+ } else {
3908
+ return fromTimestamp(Timestamp.fromJSON(o));
3909
+ }
3910
+ }
3911
+
3912
+ function longToNumber(int64: { toString(): string }): number {
3913
+ const num = globalThis.Number(int64.toString());
3914
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
3915
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
3916
+ }
3917
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
3918
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
3919
+ }
3920
+ return num;
3921
+ }
3922
+
3923
+ function isSet(value: any): boolean {
3924
+ return value !== null && value !== undefined;
3925
+ }
3926
+
3927
+ export interface MessageFns<T> {
3928
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
3929
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
3930
+ fromJSON(object: any): T;
3931
+ toJSON(message: T): unknown;
3932
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
3933
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
3934
+ }