@countly/ai-sdk-google-genai 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/dist/adapter.d.ts +5 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +273 -0
- package/dist/adapter.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @countly/ai-sdk-google-genai
|
|
2
|
+
|
|
3
|
+
> Countly AI observability adapter for the [Google GenAI TypeScript SDK](https://github.com/googleapis/js-genai).
|
|
4
|
+
|
|
5
|
+
Part of the [Countly AI SDK](https://github.com/Countly/countly-ai-sdk) — provider-agnostic LLM observability for every AI stack.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @countly/ai-sdk-google-genai
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`@countly/ai-sdk-core` is pulled in automatically.
|
|
14
|
+
|
|
15
|
+
## Peer dependency
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
@google/genai >= 1.0.0
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { GoogleGenAI } from "@google/genai";
|
|
25
|
+
import { observeGoogleGenAI } from "@countly/ai-sdk-google-genai";
|
|
26
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
27
|
+
|
|
28
|
+
const userStore = new AsyncLocalStorage<{ userId: string }>();
|
|
29
|
+
|
|
30
|
+
app.use((req, res, next) => {
|
|
31
|
+
userStore.run({ userId: req.user.id }, next);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const client = observeGoogleGenAI(new GoogleGenAI({ apiKey: "..." }), {
|
|
35
|
+
appKey: "YOUR_APP_KEY",
|
|
36
|
+
url: "https://your-countly-server.com",
|
|
37
|
+
getDeviceId: () => userStore.getStore()?.userId,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const response = await client.models.generateContent({
|
|
41
|
+
model: "gemini-2.5-pro",
|
|
42
|
+
contents: "Explain quantum computing",
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Streaming
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
const stream = await client.models.generateContentStream({
|
|
50
|
+
model: "gemini-2.5-flash",
|
|
51
|
+
contents: "Hello",
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
for await (const chunk of stream) {
|
|
55
|
+
process.stdout.write(chunk.text || "");
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## What's captured
|
|
60
|
+
|
|
61
|
+
- Token usage (`promptTokenCount`, `candidatesTokenCount`, `totalTokenCount`)
|
|
62
|
+
- Reasoning tokens (`thoughtsTokenCount` for thinking models)
|
|
63
|
+
- Cached content tokens (`cachedContentTokenCount`)
|
|
64
|
+
- Cost (computed from model pricing)
|
|
65
|
+
- Latency (total + TTFT for streaming)
|
|
66
|
+
- Finish reason normalized to `stop | length | content_filter | error | other` (from `STOP`, `MAX_TOKENS`, `SAFETY`, `RECITATION`, etc.)
|
|
67
|
+
- Function call tool extraction
|
|
68
|
+
- Error tracking with categorization
|
|
69
|
+
- APM traces, per-user aggregation
|
|
70
|
+
|
|
71
|
+
## Full documentation
|
|
72
|
+
|
|
73
|
+
See the [Countly AI SDK repository](https://github.com/Countly/countly-ai-sdk) for the unified data model, observability levels, cost calculation, privacy controls, and Countly plugin integration (Drill, Funnels, Cohorts, APM, Crash Analytics).
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,eAAe,EAKrB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,yBAA0B,SAAQ,eAAe;CAAG;AA0SrE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,GAAG,CAAC,CAiB5E"}
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { resolveConfig, createTransport, buildAllEvents, generatePromptId, } from "@countly/ai-sdk-core";
|
|
2
|
+
function extractTextInput(requestParams) {
|
|
3
|
+
const contents = requestParams?.contents;
|
|
4
|
+
if (typeof contents === "string")
|
|
5
|
+
return contents;
|
|
6
|
+
if (!Array.isArray(contents))
|
|
7
|
+
return undefined;
|
|
8
|
+
// Find last user role content (skip model/system roles)
|
|
9
|
+
for (let i = contents.length - 1; i >= 0; i--) {
|
|
10
|
+
const item = contents[i];
|
|
11
|
+
const role = item?.role;
|
|
12
|
+
if (role === "model" || role === "system")
|
|
13
|
+
continue;
|
|
14
|
+
const parts = item?.parts;
|
|
15
|
+
if (Array.isArray(parts)) {
|
|
16
|
+
const text = parts
|
|
17
|
+
.filter((p) => typeof p.text === "string")
|
|
18
|
+
.map((p) => p.text)
|
|
19
|
+
.join("");
|
|
20
|
+
if (text)
|
|
21
|
+
return text;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function extractFromResponse(response, requestParams, latency) {
|
|
27
|
+
const model = requestParams?.model ?? "unknown";
|
|
28
|
+
const usage = response?.usageMetadata;
|
|
29
|
+
const tokenInput = usage?.promptTokenCount ?? 0;
|
|
30
|
+
const tokenOutput = usage?.candidatesTokenCount ?? 0;
|
|
31
|
+
const tokenTotal = usage?.totalTokenCount ?? 0;
|
|
32
|
+
const tokenReason = usage?.thoughtsTokenCount;
|
|
33
|
+
const tokenCacheRead = usage?.cachedContentTokenCount;
|
|
34
|
+
const candidate = response?.candidates?.[0];
|
|
35
|
+
const finishReason = candidate?.finishReason;
|
|
36
|
+
// Extract tool calls from candidate parts
|
|
37
|
+
const tools = [];
|
|
38
|
+
if (candidate?.content?.parts) {
|
|
39
|
+
for (const part of candidate.content.parts) {
|
|
40
|
+
if (part.functionCall) {
|
|
41
|
+
tools.push({
|
|
42
|
+
name: part.functionCall.name ?? "unknown",
|
|
43
|
+
type: "function_call",
|
|
44
|
+
arguments: part.functionCall.args,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Extract text output from candidate parts
|
|
50
|
+
let textOutput;
|
|
51
|
+
if (candidate?.content?.parts) {
|
|
52
|
+
const textParts = candidate.content.parts
|
|
53
|
+
.filter((p) => typeof p.text === "string")
|
|
54
|
+
.map((p) => p.text);
|
|
55
|
+
if (textParts.length > 0) {
|
|
56
|
+
textOutput = textParts.join("");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Extract config params from request
|
|
60
|
+
const configTemperature = requestParams?.config?.temperature;
|
|
61
|
+
const configTopP = requestParams?.config?.topP;
|
|
62
|
+
const configMaxTokens = requestParams?.config?.maxOutputTokens;
|
|
63
|
+
const configFrequencyPenalty = requestParams?.config?.frequencyPenalty;
|
|
64
|
+
const configPresencePenalty = requestParams?.config?.presencePenalty;
|
|
65
|
+
// Provider-specific orphan fields → metadata bag.
|
|
66
|
+
const meta = {};
|
|
67
|
+
const r = response;
|
|
68
|
+
if (r?.modelVersion)
|
|
69
|
+
meta.model_version = r.modelVersion;
|
|
70
|
+
if (r?.createTime)
|
|
71
|
+
meta.create_time = r.createTime;
|
|
72
|
+
if (usage?.toolUsePromptTokenCount != null)
|
|
73
|
+
meta.usage_tool_use_prompt_tokens = usage.toolUsePromptTokenCount;
|
|
74
|
+
if (usage?.trafficType)
|
|
75
|
+
meta.traffic_type = usage.trafficType;
|
|
76
|
+
if (candidate?.safetyRatings)
|
|
77
|
+
meta.safety_ratings = candidate.safetyRatings;
|
|
78
|
+
if (candidate?.groundingMetadata)
|
|
79
|
+
meta.grounding_metadata = candidate.groundingMetadata;
|
|
80
|
+
if (candidate?.citationMetadata)
|
|
81
|
+
meta.citation_metadata = candidate.citationMetadata;
|
|
82
|
+
if (candidate?.logprobsResult)
|
|
83
|
+
meta.logprobs_result = candidate.logprobsResult;
|
|
84
|
+
if (candidate?.avgLogprobs != null)
|
|
85
|
+
meta.avg_logprobs = candidate.avgLogprobs;
|
|
86
|
+
return {
|
|
87
|
+
model: model,
|
|
88
|
+
model_requested: requestParams?.model,
|
|
89
|
+
provider: "google",
|
|
90
|
+
usage_input: tokenInput,
|
|
91
|
+
usage_output: tokenOutput,
|
|
92
|
+
usage_total: tokenTotal,
|
|
93
|
+
...(tokenReason != null && { usage_reasoning: tokenReason }),
|
|
94
|
+
...(tokenCacheRead != null && { usage_cache_read: tokenCacheRead }),
|
|
95
|
+
...(finishReason && { finish_reason: finishReason }),
|
|
96
|
+
...(tools.length > 0 && { tools }),
|
|
97
|
+
...(textOutput && { text_output: textOutput }),
|
|
98
|
+
latency_total: latency,
|
|
99
|
+
...(configTemperature != null && { config_temperature: configTemperature }),
|
|
100
|
+
...(configTopP != null && { config_top_p: configTopP }),
|
|
101
|
+
...(configMaxTokens != null && { config_max_tokens: configMaxTokens }),
|
|
102
|
+
...(configFrequencyPenalty != null && { config_frequency_penalty: configFrequencyPenalty }),
|
|
103
|
+
...(configPresencePenalty != null && { config_presence_penalty: configPresencePenalty }),
|
|
104
|
+
config_stream: false,
|
|
105
|
+
status: "success",
|
|
106
|
+
...(r?.responseId && { response_id: String(r.responseId) }),
|
|
107
|
+
...(r?.modelVersion && { response_model: String(r.modelVersion) }),
|
|
108
|
+
...(Object.keys(meta).length > 0 && { provider_metadata: meta }),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function extractFromStreamResponse(response, requestParams, latency, latencyFirst) {
|
|
112
|
+
const result = extractFromResponse(response, requestParams, latency);
|
|
113
|
+
result.config_stream = true;
|
|
114
|
+
if (latencyFirst != null) {
|
|
115
|
+
result.latency_ttft = latencyFirst;
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
function createModelsProxy(models, config, transport) {
|
|
120
|
+
return new Proxy(models, {
|
|
121
|
+
get(target, prop, receiver) {
|
|
122
|
+
const value = Reflect.get(target, prop, receiver);
|
|
123
|
+
if (prop === "generateContent" && typeof value === "function") {
|
|
124
|
+
return async function (...args) {
|
|
125
|
+
const requestParams = args[0];
|
|
126
|
+
const promptId = generatePromptId();
|
|
127
|
+
const eventContext = { prompt_id: promptId, sdk_adapter: "google-genai" };
|
|
128
|
+
const start = performance.now();
|
|
129
|
+
const textInput = extractTextInput(requestParams);
|
|
130
|
+
try {
|
|
131
|
+
const response = await value.apply(this, args);
|
|
132
|
+
const latency = performance.now() - start;
|
|
133
|
+
const raw = extractFromResponse(response, requestParams, latency);
|
|
134
|
+
if (config.observabilityLevel === 2 && textInput) {
|
|
135
|
+
raw.text_input = textInput;
|
|
136
|
+
}
|
|
137
|
+
const events = buildAllEvents(raw, config, eventContext);
|
|
138
|
+
transport.enqueue(events);
|
|
139
|
+
transport.reportTrace(raw, eventContext);
|
|
140
|
+
transport.reportUserData(raw);
|
|
141
|
+
return response;
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
const latency = performance.now() - start;
|
|
145
|
+
const errorRaw = {
|
|
146
|
+
model: requestParams?.model ?? "unknown",
|
|
147
|
+
model_requested: requestParams?.model,
|
|
148
|
+
provider: "google",
|
|
149
|
+
usage_input: 0,
|
|
150
|
+
usage_output: 0,
|
|
151
|
+
usage_total: 0,
|
|
152
|
+
latency_total: latency,
|
|
153
|
+
config_stream: false,
|
|
154
|
+
status: "error",
|
|
155
|
+
error: err instanceof Error ? err.message : String(err),
|
|
156
|
+
};
|
|
157
|
+
if (config.observabilityLevel === 2 && textInput) {
|
|
158
|
+
errorRaw.text_input = textInput;
|
|
159
|
+
}
|
|
160
|
+
const events = buildAllEvents(errorRaw, config, eventContext);
|
|
161
|
+
transport.enqueue(events);
|
|
162
|
+
transport.reportError(err instanceof Error ? err : String(err), errorRaw);
|
|
163
|
+
throw err;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (prop === "generateContentStream" && typeof value === "function") {
|
|
168
|
+
return async function (...args) {
|
|
169
|
+
const requestParams = args[0];
|
|
170
|
+
const promptId = generatePromptId();
|
|
171
|
+
const eventContext = { prompt_id: promptId, sdk_adapter: "google-genai" };
|
|
172
|
+
const start = performance.now();
|
|
173
|
+
const textInput = extractTextInput(requestParams);
|
|
174
|
+
try {
|
|
175
|
+
// Real SDK returns Promise<AsyncGenerator<GenerateContentResponse>>
|
|
176
|
+
const generator = await value.apply(this, args);
|
|
177
|
+
// Wrap the async generator to intercept chunks
|
|
178
|
+
async function* wrappedGenerator() {
|
|
179
|
+
let latencyFirst;
|
|
180
|
+
let lastChunk = undefined;
|
|
181
|
+
try {
|
|
182
|
+
for await (const chunk of generator) {
|
|
183
|
+
if (latencyFirst == null) {
|
|
184
|
+
latencyFirst = performance.now() - start;
|
|
185
|
+
}
|
|
186
|
+
lastChunk = chunk;
|
|
187
|
+
yield chunk;
|
|
188
|
+
}
|
|
189
|
+
// After full iteration, report using the last chunk's data
|
|
190
|
+
// (the last chunk typically has the final aggregated usageMetadata)
|
|
191
|
+
if (lastChunk != null) {
|
|
192
|
+
const latency = performance.now() - start;
|
|
193
|
+
const raw = extractFromStreamResponse(lastChunk, requestParams, latency, latencyFirst);
|
|
194
|
+
if (config.observabilityLevel === 2 && textInput) {
|
|
195
|
+
raw.text_input = textInput;
|
|
196
|
+
}
|
|
197
|
+
const events = buildAllEvents(raw, config, eventContext);
|
|
198
|
+
transport.enqueue(events);
|
|
199
|
+
transport.reportTrace(raw, eventContext);
|
|
200
|
+
transport.reportUserData(raw);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (iterErr) {
|
|
204
|
+
// Error during iteration (mid-stream failure)
|
|
205
|
+
const latency = performance.now() - start;
|
|
206
|
+
const errorRaw = {
|
|
207
|
+
model: requestParams?.model ?? "unknown",
|
|
208
|
+
model_requested: requestParams?.model,
|
|
209
|
+
provider: "google",
|
|
210
|
+
usage_input: 0,
|
|
211
|
+
usage_output: 0,
|
|
212
|
+
usage_total: 0,
|
|
213
|
+
latency_total: latency,
|
|
214
|
+
config_stream: true,
|
|
215
|
+
status: "error",
|
|
216
|
+
error: iterErr instanceof Error ? iterErr.message : String(iterErr),
|
|
217
|
+
};
|
|
218
|
+
if (config.observabilityLevel === 2 && textInput) {
|
|
219
|
+
errorRaw.text_input = textInput;
|
|
220
|
+
}
|
|
221
|
+
const events = buildAllEvents(errorRaw, config, eventContext);
|
|
222
|
+
transport.enqueue(events);
|
|
223
|
+
transport.reportError(iterErr instanceof Error ? iterErr : String(iterErr), errorRaw);
|
|
224
|
+
throw iterErr;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return wrappedGenerator();
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
// Error from the initial call (before iteration starts)
|
|
231
|
+
const latency = performance.now() - start;
|
|
232
|
+
const errorRaw = {
|
|
233
|
+
model: requestParams?.model ?? "unknown",
|
|
234
|
+
model_requested: requestParams?.model,
|
|
235
|
+
provider: "google",
|
|
236
|
+
usage_input: 0,
|
|
237
|
+
usage_output: 0,
|
|
238
|
+
usage_total: 0,
|
|
239
|
+
latency_total: latency,
|
|
240
|
+
config_stream: true,
|
|
241
|
+
status: "error",
|
|
242
|
+
error: err instanceof Error ? err.message : String(err),
|
|
243
|
+
};
|
|
244
|
+
if (config.observabilityLevel === 2 && textInput) {
|
|
245
|
+
errorRaw.text_input = textInput;
|
|
246
|
+
}
|
|
247
|
+
const events = buildAllEvents(errorRaw, config, eventContext);
|
|
248
|
+
transport.enqueue(events);
|
|
249
|
+
transport.reportError(err instanceof Error ? err : String(err), errorRaw);
|
|
250
|
+
throw err;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
return value;
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
export function observeGoogleGenAI(client, options) {
|
|
259
|
+
const config = resolveConfig(options);
|
|
260
|
+
const transport = createTransport(config);
|
|
261
|
+
if (config.disabled)
|
|
262
|
+
return client;
|
|
263
|
+
return new Proxy(client, {
|
|
264
|
+
get(target, prop, receiver) {
|
|
265
|
+
const value = Reflect.get(target, prop, receiver);
|
|
266
|
+
if (prop === "models" && value != null && typeof value === "object") {
|
|
267
|
+
return createModelsProxy(value, config, transport);
|
|
268
|
+
}
|
|
269
|
+
return value;
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EACf,cAAc,EACd,gBAAgB,GAMjB,MAAM,sBAAsB,CAAC;AAQ9B,SAAS,gBAAgB,CAAC,aAAkB;IAC1C,MAAM,QAAQ,GAAG,aAAa,EAAE,QAAQ,CAAC;IACzC,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAClD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/C,wDAAwD;IACxD,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC;QACxB,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ;YAAE,SA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,MAAgB,EAAE;QACjC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;YACxB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAElD,IAAI,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACpE,OAAO,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;YACrD,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAM,CAAC;AACV,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@countly/ai-sdk-google-genai",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Countly AI observability adapter for Google GenAI SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@countly/ai-sdk-core": "0.0.3"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@google/genai": ">=1.0.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependenciesMeta": {
|
|
25
|
+
"@google/genai": {
|
|
26
|
+
"optional": false
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "^5.8.3",
|
|
31
|
+
"@countly/ai-sdk-tsconfig": "0.0.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc --project tsconfig.build.json",
|
|
35
|
+
"dev": "tsc --project tsconfig.build.json --watch",
|
|
36
|
+
"lint": "tsc --noEmit",
|
|
37
|
+
"test": "vitest run"
|
|
38
|
+
}
|
|
39
|
+
}
|