macrocosmos 1.2.2 → 1.2.4

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.
@@ -1,100 +1,425 @@
1
1
  "use strict";
2
- // Generated from sn13/v1/sn13_validator.proto
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.7.0
5
+ // protoc v3.20.3
6
+ // source: sn13/v1/sn13_validator.proto
3
7
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.sn13_validator = void 0;
5
- // Original protobuf JSON schema
6
- exports.sn13_validator = {
7
- options: {
8
- syntax: "proto3",
9
- },
10
- nested: {
11
- sn13: {
12
- nested: {
13
- v1: {
14
- options: {
15
- go_package: "macrocosm-os/rift/constellation_api/gen/sn13/v1",
16
- },
17
- nested: {
18
- Sn13Service: {
19
- methods: {
20
- ListTopics: {
21
- requestType: "ListTopicsRequest",
22
- responseType: "ListTopicsResponse",
23
- },
24
- ValidateRedditTopic: {
25
- requestType: "ValidateRedditTopicRequest",
26
- responseType: "ValidateRedditTopicResponse",
27
- },
28
- },
29
- },
30
- ListTopicsRequest: {
31
- fields: {
32
- source: {
33
- type: "string",
34
- id: 1,
35
- },
36
- },
37
- },
38
- ListTopicsResponseDetail: {
39
- fields: {
40
- labelValue: {
41
- type: "string",
42
- id: 1,
43
- },
44
- contentSizeBytes: {
45
- type: "uint64",
46
- id: 2,
47
- },
48
- adjContentSizeBytes: {
49
- type: "uint64",
50
- id: 3,
51
- },
52
- },
53
- },
54
- ListTopicsResponse: {
55
- fields: {
56
- details: {
57
- rule: "repeated",
58
- type: "ListTopicsResponseDetail",
59
- id: 1,
60
- },
61
- },
62
- },
63
- ValidateRedditTopicRequest: {
64
- fields: {
65
- topic: {
66
- type: "string",
67
- id: 1,
68
- },
69
- },
70
- },
71
- ValidateRedditTopicResponse: {
72
- fields: {
73
- platform: {
74
- type: "string",
75
- id: 1,
76
- },
77
- topic: {
78
- type: "string",
79
- id: 2,
80
- },
81
- exists: {
82
- type: "bool",
83
- id: 3,
84
- },
85
- over18: {
86
- type: "bool",
87
- id: 4,
88
- },
89
- quarantine: {
90
- type: "bool",
91
- id: 5,
92
- },
93
- },
94
- },
95
- },
96
- },
97
- },
98
- },
8
+ exports.Sn13ServiceClient = exports.Sn13ServiceService = exports.ValidateRedditTopicResponse = exports.ValidateRedditTopicRequest = exports.ListTopicsResponse = exports.ListTopicsResponseDetail = exports.ListTopicsRequest = exports.protobufPackage = void 0;
9
+ /* eslint-disable */
10
+ const wire_1 = require("@bufbuild/protobuf/wire");
11
+ const grpc_js_1 = require("@grpc/grpc-js");
12
+ exports.protobufPackage = "sn13.v1";
13
+ function createBaseListTopicsRequest() {
14
+ return { source: "" };
15
+ }
16
+ exports.ListTopicsRequest = {
17
+ encode(message, writer = new wire_1.BinaryWriter()) {
18
+ if (message.source !== "") {
19
+ writer.uint32(10).string(message.source);
20
+ }
21
+ return writer;
22
+ },
23
+ decode(input, length) {
24
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
25
+ let end = length === undefined ? reader.len : reader.pos + length;
26
+ const message = createBaseListTopicsRequest();
27
+ while (reader.pos < end) {
28
+ const tag = reader.uint32();
29
+ switch (tag >>> 3) {
30
+ case 1: {
31
+ if (tag !== 10) {
32
+ break;
33
+ }
34
+ message.source = reader.string();
35
+ continue;
36
+ }
37
+ }
38
+ if ((tag & 7) === 4 || tag === 0) {
39
+ break;
40
+ }
41
+ reader.skip(tag & 7);
42
+ }
43
+ return message;
44
+ },
45
+ fromJSON(object) {
46
+ return {
47
+ source: isSet(object.source) ? globalThis.String(object.source) : "",
48
+ };
49
+ },
50
+ toJSON(message) {
51
+ const obj = {};
52
+ if (message.source !== "") {
53
+ obj.source = message.source;
54
+ }
55
+ return obj;
56
+ },
57
+ create(base) {
58
+ return exports.ListTopicsRequest.fromPartial(base ?? {});
59
+ },
60
+ fromPartial(object) {
61
+ const message = createBaseListTopicsRequest();
62
+ message.source = object.source ?? "";
63
+ return message;
64
+ },
65
+ };
66
+ function createBaseListTopicsResponseDetail() {
67
+ return { labelValue: "", contentSizeBytes: 0, adjContentSizeBytes: 0 };
68
+ }
69
+ exports.ListTopicsResponseDetail = {
70
+ encode(message, writer = new wire_1.BinaryWriter()) {
71
+ if (message.labelValue !== "") {
72
+ writer.uint32(10).string(message.labelValue);
73
+ }
74
+ if (message.contentSizeBytes !== 0) {
75
+ writer.uint32(16).uint64(message.contentSizeBytes);
76
+ }
77
+ if (message.adjContentSizeBytes !== 0) {
78
+ writer.uint32(24).uint64(message.adjContentSizeBytes);
79
+ }
80
+ return writer;
81
+ },
82
+ decode(input, length) {
83
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
84
+ let end = length === undefined ? reader.len : reader.pos + length;
85
+ const message = createBaseListTopicsResponseDetail();
86
+ while (reader.pos < end) {
87
+ const tag = reader.uint32();
88
+ switch (tag >>> 3) {
89
+ case 1: {
90
+ if (tag !== 10) {
91
+ break;
92
+ }
93
+ message.labelValue = reader.string();
94
+ continue;
95
+ }
96
+ case 2: {
97
+ if (tag !== 16) {
98
+ break;
99
+ }
100
+ message.contentSizeBytes = longToNumber(reader.uint64());
101
+ continue;
102
+ }
103
+ case 3: {
104
+ if (tag !== 24) {
105
+ break;
106
+ }
107
+ message.adjContentSizeBytes = longToNumber(reader.uint64());
108
+ continue;
109
+ }
110
+ }
111
+ if ((tag & 7) === 4 || tag === 0) {
112
+ break;
113
+ }
114
+ reader.skip(tag & 7);
115
+ }
116
+ return message;
117
+ },
118
+ fromJSON(object) {
119
+ return {
120
+ labelValue: isSet(object.labelValue)
121
+ ? globalThis.String(object.labelValue)
122
+ : "",
123
+ contentSizeBytes: isSet(object.contentSizeBytes)
124
+ ? globalThis.Number(object.contentSizeBytes)
125
+ : 0,
126
+ adjContentSizeBytes: isSet(object.adjContentSizeBytes)
127
+ ? globalThis.Number(object.adjContentSizeBytes)
128
+ : 0,
129
+ };
130
+ },
131
+ toJSON(message) {
132
+ const obj = {};
133
+ if (message.labelValue !== "") {
134
+ obj.labelValue = message.labelValue;
135
+ }
136
+ if (message.contentSizeBytes !== 0) {
137
+ obj.contentSizeBytes = Math.round(message.contentSizeBytes);
138
+ }
139
+ if (message.adjContentSizeBytes !== 0) {
140
+ obj.adjContentSizeBytes = Math.round(message.adjContentSizeBytes);
141
+ }
142
+ return obj;
143
+ },
144
+ create(base) {
145
+ return exports.ListTopicsResponseDetail.fromPartial(base ?? {});
146
+ },
147
+ fromPartial(object) {
148
+ const message = createBaseListTopicsResponseDetail();
149
+ message.labelValue = object.labelValue ?? "";
150
+ message.contentSizeBytes = object.contentSizeBytes ?? 0;
151
+ message.adjContentSizeBytes = object.adjContentSizeBytes ?? 0;
152
+ return message;
153
+ },
154
+ };
155
+ function createBaseListTopicsResponse() {
156
+ return { details: [] };
157
+ }
158
+ exports.ListTopicsResponse = {
159
+ encode(message, writer = new wire_1.BinaryWriter()) {
160
+ for (const v of message.details) {
161
+ exports.ListTopicsResponseDetail.encode(v, writer.uint32(10).fork()).join();
162
+ }
163
+ return writer;
164
+ },
165
+ decode(input, length) {
166
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
167
+ let end = length === undefined ? reader.len : reader.pos + length;
168
+ const message = createBaseListTopicsResponse();
169
+ while (reader.pos < end) {
170
+ const tag = reader.uint32();
171
+ switch (tag >>> 3) {
172
+ case 1: {
173
+ if (tag !== 10) {
174
+ break;
175
+ }
176
+ message.details.push(exports.ListTopicsResponseDetail.decode(reader, reader.uint32()));
177
+ continue;
178
+ }
179
+ }
180
+ if ((tag & 7) === 4 || tag === 0) {
181
+ break;
182
+ }
183
+ reader.skip(tag & 7);
184
+ }
185
+ return message;
186
+ },
187
+ fromJSON(object) {
188
+ return {
189
+ details: globalThis.Array.isArray(object?.details)
190
+ ? object.details.map((e) => exports.ListTopicsResponseDetail.fromJSON(e))
191
+ : [],
192
+ };
193
+ },
194
+ toJSON(message) {
195
+ const obj = {};
196
+ if (message.details?.length) {
197
+ obj.details = message.details.map(e => exports.ListTopicsResponseDetail.toJSON(e));
198
+ }
199
+ return obj;
200
+ },
201
+ create(base) {
202
+ return exports.ListTopicsResponse.fromPartial(base ?? {});
203
+ },
204
+ fromPartial(object) {
205
+ const message = createBaseListTopicsResponse();
206
+ message.details =
207
+ object.details?.map(e => exports.ListTopicsResponseDetail.fromPartial(e)) || [];
208
+ return message;
209
+ },
210
+ };
211
+ function createBaseValidateRedditTopicRequest() {
212
+ return { topic: "" };
213
+ }
214
+ exports.ValidateRedditTopicRequest = {
215
+ encode(message, writer = new wire_1.BinaryWriter()) {
216
+ if (message.topic !== "") {
217
+ writer.uint32(10).string(message.topic);
218
+ }
219
+ return writer;
220
+ },
221
+ decode(input, length) {
222
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
223
+ let end = length === undefined ? reader.len : reader.pos + length;
224
+ const message = createBaseValidateRedditTopicRequest();
225
+ while (reader.pos < end) {
226
+ const tag = reader.uint32();
227
+ switch (tag >>> 3) {
228
+ case 1: {
229
+ if (tag !== 10) {
230
+ break;
231
+ }
232
+ message.topic = reader.string();
233
+ continue;
234
+ }
235
+ }
236
+ if ((tag & 7) === 4 || tag === 0) {
237
+ break;
238
+ }
239
+ reader.skip(tag & 7);
240
+ }
241
+ return message;
242
+ },
243
+ fromJSON(object) {
244
+ return {
245
+ topic: isSet(object.topic) ? globalThis.String(object.topic) : "",
246
+ };
247
+ },
248
+ toJSON(message) {
249
+ const obj = {};
250
+ if (message.topic !== "") {
251
+ obj.topic = message.topic;
252
+ }
253
+ return obj;
254
+ },
255
+ create(base) {
256
+ return exports.ValidateRedditTopicRequest.fromPartial(base ?? {});
257
+ },
258
+ fromPartial(object) {
259
+ const message = createBaseValidateRedditTopicRequest();
260
+ message.topic = object.topic ?? "";
261
+ return message;
262
+ },
263
+ };
264
+ function createBaseValidateRedditTopicResponse() {
265
+ return {
266
+ platform: "",
267
+ topic: "",
268
+ exists: false,
269
+ over18: false,
270
+ quarantine: false,
271
+ };
272
+ }
273
+ exports.ValidateRedditTopicResponse = {
274
+ encode(message, writer = new wire_1.BinaryWriter()) {
275
+ if (message.platform !== "") {
276
+ writer.uint32(10).string(message.platform);
277
+ }
278
+ if (message.topic !== "") {
279
+ writer.uint32(18).string(message.topic);
280
+ }
281
+ if (message.exists !== false) {
282
+ writer.uint32(24).bool(message.exists);
283
+ }
284
+ if (message.over18 !== false) {
285
+ writer.uint32(32).bool(message.over18);
286
+ }
287
+ if (message.quarantine !== false) {
288
+ writer.uint32(40).bool(message.quarantine);
289
+ }
290
+ return writer;
291
+ },
292
+ decode(input, length) {
293
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
294
+ let end = length === undefined ? reader.len : reader.pos + length;
295
+ const message = createBaseValidateRedditTopicResponse();
296
+ while (reader.pos < end) {
297
+ const tag = reader.uint32();
298
+ switch (tag >>> 3) {
299
+ case 1: {
300
+ if (tag !== 10) {
301
+ break;
302
+ }
303
+ message.platform = reader.string();
304
+ continue;
305
+ }
306
+ case 2: {
307
+ if (tag !== 18) {
308
+ break;
309
+ }
310
+ message.topic = reader.string();
311
+ continue;
312
+ }
313
+ case 3: {
314
+ if (tag !== 24) {
315
+ break;
316
+ }
317
+ message.exists = reader.bool();
318
+ continue;
319
+ }
320
+ case 4: {
321
+ if (tag !== 32) {
322
+ break;
323
+ }
324
+ message.over18 = reader.bool();
325
+ continue;
326
+ }
327
+ case 5: {
328
+ if (tag !== 40) {
329
+ break;
330
+ }
331
+ message.quarantine = reader.bool();
332
+ continue;
333
+ }
334
+ }
335
+ if ((tag & 7) === 4 || tag === 0) {
336
+ break;
337
+ }
338
+ reader.skip(tag & 7);
339
+ }
340
+ return message;
341
+ },
342
+ fromJSON(object) {
343
+ return {
344
+ platform: isSet(object.platform)
345
+ ? globalThis.String(object.platform)
346
+ : "",
347
+ topic: isSet(object.topic) ? globalThis.String(object.topic) : "",
348
+ exists: isSet(object.exists)
349
+ ? globalThis.Boolean(object.exists)
350
+ : false,
351
+ over18: isSet(object.over18)
352
+ ? globalThis.Boolean(object.over18)
353
+ : false,
354
+ quarantine: isSet(object.quarantine)
355
+ ? globalThis.Boolean(object.quarantine)
356
+ : false,
357
+ };
358
+ },
359
+ toJSON(message) {
360
+ const obj = {};
361
+ if (message.platform !== "") {
362
+ obj.platform = message.platform;
363
+ }
364
+ if (message.topic !== "") {
365
+ obj.topic = message.topic;
366
+ }
367
+ if (message.exists !== false) {
368
+ obj.exists = message.exists;
369
+ }
370
+ if (message.over18 !== false) {
371
+ obj.over18 = message.over18;
372
+ }
373
+ if (message.quarantine !== false) {
374
+ obj.quarantine = message.quarantine;
375
+ }
376
+ return obj;
377
+ },
378
+ create(base) {
379
+ return exports.ValidateRedditTopicResponse.fromPartial(base ?? {});
380
+ },
381
+ fromPartial(object) {
382
+ const message = createBaseValidateRedditTopicResponse();
383
+ message.platform = object.platform ?? "";
384
+ message.topic = object.topic ?? "";
385
+ message.exists = object.exists ?? false;
386
+ message.over18 = object.over18 ?? false;
387
+ message.quarantine = object.quarantine ?? false;
388
+ return message;
389
+ },
390
+ };
391
+ exports.Sn13ServiceService = {
392
+ /** ListTopics is the RPC method for getting the top topics */
393
+ listTopics: {
394
+ path: "/sn13.v1.Sn13Service/ListTopics",
395
+ requestStream: false,
396
+ responseStream: false,
397
+ requestSerialize: (value) => Buffer.from(exports.ListTopicsRequest.encode(value).finish()),
398
+ requestDeserialize: (value) => exports.ListTopicsRequest.decode(value),
399
+ responseSerialize: (value) => Buffer.from(exports.ListTopicsResponse.encode(value).finish()),
400
+ responseDeserialize: (value) => exports.ListTopicsResponse.decode(value),
401
+ },
402
+ validateRedditTopic: {
403
+ path: "/sn13.v1.Sn13Service/ValidateRedditTopic",
404
+ requestStream: false,
405
+ responseStream: false,
406
+ requestSerialize: (value) => Buffer.from(exports.ValidateRedditTopicRequest.encode(value).finish()),
407
+ requestDeserialize: (value) => exports.ValidateRedditTopicRequest.decode(value),
408
+ responseSerialize: (value) => Buffer.from(exports.ValidateRedditTopicResponse.encode(value).finish()),
409
+ responseDeserialize: (value) => exports.ValidateRedditTopicResponse.decode(value),
99
410
  },
100
411
  };
412
+ exports.Sn13ServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.Sn13ServiceService, "sn13.v1.Sn13Service");
413
+ function longToNumber(int64) {
414
+ const num = globalThis.Number(int64.toString());
415
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
416
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
417
+ }
418
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
419
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
420
+ }
421
+ return num;
422
+ }
423
+ function isSet(value) {
424
+ return value !== null && value !== undefined;
425
+ }
@@ -7,14 +7,14 @@ const constants_1 = require("../constants");
7
7
  */
8
8
  class BaseClient {
9
9
  constructor(options) {
10
- this.apiKey = options.apiKey || "";
11
- this.baseURL = options.baseURL || constants_1.BASE_URL;
12
- this.appName = options.appName || "unknown";
13
- this.userId = options.userId || "";
10
+ this.apiKey = options.apiKey ?? "";
11
+ this.baseURL = options.baseURL ?? constants_1.BASE_URL;
12
+ this.appName = options.appName ?? "unknown";
13
+ this.userId = options.userId ?? "";
14
14
  // Check environment variable for HTTPS setting
15
15
  const useHttps = process.env.MACROCOSMOS_USE_HTTPS !== "false";
16
16
  // Use secure if explicitly set in options or if HTTPS is enabled via env var
17
- this.secure = options.secure !== undefined ? options.secure : useHttps;
17
+ this.secure = options.secure ?? useHttps;
18
18
  // Check if the API key is valid
19
19
  if (!this.apiKey) {
20
20
  throw new Error("API key is required");
@@ -1,18 +1,15 @@
1
+ import { ApexServiceClient, ChatCompletionRequest as GeneratedChatCompletionRequest, ChatCompletionResponse, ChatCompletionChunkResponse, WebRetrievalRequest as GeneratedWebRetrievalRequest, WebRetrievalResponse, ChatMessage } from "../../generated/apex/v1/apex";
1
2
  import * as grpc from "@grpc/grpc-js";
2
- import { IChatCompletionRequest, IChatMessage, ISamplingParameters, IChatCompletionResponse, IChatCompletionChunkResponse, IWebRetrievalRequest, IWebRetrievalResponse, IApexServiceClient } from "../../generated/apex/v1/apex";
3
3
  import { BaseClient, BaseClientOptions } from "../BaseClient";
4
4
  import { ApexStream } from "./Stream";
5
+ import { MarkFieldsOptional } from "../util.types";
6
+ type ChatCompletionRequest = MarkFieldsOptional<GeneratedChatCompletionRequest, "uids">;
7
+ type WebRetrievalRequest = MarkFieldsOptional<GeneratedWebRetrievalRequest, "uids">;
8
+ export { ApexStream, WebRetrievalRequest, WebRetrievalResponse, ChatCompletionRequest, ChatMessage, };
5
9
  interface ApexClientOptions extends BaseClientOptions {
6
10
  timeout?: number;
7
11
  }
8
- export type ChatMessage = IChatMessage;
9
- export type SamplingParameters = ISamplingParameters;
10
- export type ChatCompletionRequest = IChatCompletionRequest;
11
- export type ChatCompletionResponse = IChatCompletionResponse;
12
- export type ChatCompletionChunkResponse = IChatCompletionChunkResponse;
13
- export type WebRetrievalRequest = IWebRetrievalRequest;
14
- export type WebRetrievalResponse = IWebRetrievalResponse;
15
- interface ApexService extends grpc.ServiceClientConstructor, IApexServiceClient {
12
+ interface ApexService extends grpc.ServiceClientConstructor, ApexServiceClient {
16
13
  }
17
14
  export interface ApexProtoClient {
18
15
  ApexService: {
@@ -24,10 +21,9 @@ export interface ApexProtoClient {
24
21
  * Provides OpenAI-compatible interface over gRPC
25
22
  */
26
23
  export declare class ApexClient extends BaseClient {
27
- private protoClient;
24
+ private _grpcClient?;
28
25
  private defaultTimeout;
29
- constructor(options: ApexClientOptions);
30
- private initializeGrpcClient;
26
+ constructor(options: ApexClientOptions, grpcClient?: ApexServiceClient);
31
27
  private createGrpcClient;
32
28
  /**
33
29
  * Get the default timeout for chat completions
@@ -46,4 +42,3 @@ export declare class ApexClient extends BaseClient {
46
42
  */
47
43
  webRetrieval: (params: WebRetrievalRequest) => Promise<WebRetrievalResponse>;
48
44
  }
49
- export {};
@@ -33,18 +33,20 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ApexClient = void 0;
36
+ exports.ApexClient = exports.ChatMessage = exports.WebRetrievalResponse = exports.ApexStream = void 0;
37
+ const apex_1 = require("../../generated/apex/v1/apex");
38
+ Object.defineProperty(exports, "WebRetrievalResponse", { enumerable: true, get: function () { return apex_1.WebRetrievalResponse; } });
39
+ Object.defineProperty(exports, "ChatMessage", { enumerable: true, get: function () { return apex_1.ChatMessage; } });
37
40
  const grpc = __importStar(require("@grpc/grpc-js"));
38
- const protoLoader = __importStar(require("@grpc/proto-loader"));
39
- const path = __importStar(require("path"));
40
41
  const BaseClient_1 = require("../BaseClient");
41
42
  const Stream_1 = require("./Stream");
43
+ Object.defineProperty(exports, "ApexStream", { enumerable: true, get: function () { return Stream_1.ApexStream; } });
42
44
  /**
43
45
  * Client for interacting with the Apex API
44
46
  * Provides OpenAI-compatible interface over gRPC
45
47
  */
46
48
  class ApexClient extends BaseClient_1.BaseClient {
47
- constructor(options) {
49
+ constructor(options, grpcClient) {
48
50
  super(options);
49
51
  /**
50
52
  * OpenAI-compatible chat completions API
@@ -56,12 +58,13 @@ class ApexClient extends BaseClient_1.BaseClient {
56
58
  // Apply default timeout if not specified in params
57
59
  const requestParams = {
58
60
  ...params,
61
+ uids: params.uids ?? [],
59
62
  timeout: params.timeout || this.getDefaultTimeout(),
60
63
  };
61
64
  // Handle streaming vs non-streaming
62
65
  if (requestParams.stream) {
63
66
  // Create a streaming call
64
- const stream = (await client.ChatCompletionStream(requestParams));
67
+ const stream = client.chatCompletionStream(requestParams);
65
68
  // Create controller for abort capability
66
69
  const controller = new AbortController();
67
70
  // Return a Stream object that wraps the gRPC stream
@@ -70,7 +73,7 @@ class ApexClient extends BaseClient_1.BaseClient {
70
73
  else {
71
74
  // For non-streaming, return a promise that resolves with the completion
72
75
  return new Promise((resolve, reject) => {
73
- void client.ChatCompletion(requestParams, (error, response) => {
76
+ client.chatCompletion(requestParams, (error, response) => {
74
77
  if (error) {
75
78
  reject(error);
76
79
  return;
@@ -88,7 +91,7 @@ class ApexClient extends BaseClient_1.BaseClient {
88
91
  this.webRetrieval = async (params) => {
89
92
  const client = this.createGrpcClient();
90
93
  return new Promise((resolve, reject) => {
91
- void client.WebRetrieval(params, (error, response) => {
94
+ client.webRetrieval({ ...params, uids: params.uids ?? [] }, (error, response) => {
92
95
  if (error) {
93
96
  reject(error);
94
97
  return;
@@ -98,24 +101,11 @@ class ApexClient extends BaseClient_1.BaseClient {
98
101
  });
99
102
  };
100
103
  this.defaultTimeout = options.timeout || 60;
101
- this.protoClient = this.initializeGrpcClient();
102
- }
103
- initializeGrpcClient() {
104
- // Load proto file directly
105
- const PROTO_PATH = path.resolve(__dirname, "../../../protos/apex/v1/apex.proto");
106
- // Load protos using standard protobuf loader
107
- const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
108
- keepCase: false,
109
- longs: String,
110
- enums: String,
111
- defaults: true,
112
- oneofs: true,
113
- });
114
- // Get the ApexService definition
115
- const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
116
- return protoDescriptor.apex.v1;
104
+ this._grpcClient = grpcClient;
117
105
  }
118
106
  createGrpcClient() {
107
+ if (this._grpcClient)
108
+ return this._grpcClient;
119
109
  // Create gRPC credentials with API key
120
110
  const callCreds = grpc.credentials.createFromMetadataGenerator((_params, callback) => {
121
111
  const meta = new grpc.Metadata();
@@ -138,7 +128,7 @@ class ApexClient extends BaseClient_1.BaseClient {
138
128
  credentials = grpc.credentials.createInsecure();
139
129
  }
140
130
  // Create gRPC client
141
- return new this.protoClient.ApexService(this.getBaseURL(), credentials);
131
+ return new apex_1.ApexServiceClient(this.getBaseURL(), credentials);
142
132
  }
143
133
  /**
144
134
  * Get the default timeout for chat completions