ag-ai 0.1.7 → 0.2.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.
@@ -390,8 +390,7 @@ const generateGoogle = async (request, config = {}) => {
390
390
  // Reactive per-model backoff: a 429 skips the model until its window
391
391
  // elapses while every other model keeps serving.
392
392
  if ((0, quota_1.isModelBackedOff)(selectedModel)) {
393
- (0, log_1.debug)('skipping rate-limited model', {
394
- model: selectedModel,
393
+ (0, log_1.debug)(`[${selectedModel}] skipping rate-limited model`, {
395
394
  remainingMs: (0, quota_1.modelBackoffRemainingMs)(selectedModel),
396
395
  });
397
396
  continue;
@@ -400,7 +399,7 @@ const generateGoogle = async (request, config = {}) => {
400
399
  ...requestConfig,
401
400
  model: selectedModel,
402
401
  };
403
- (0, log_1.info)('generation request', { model: selectedModel, ident: request.ident });
402
+ (0, log_1.info)(`[${selectedModel}] generation request`, { ident: request.ident });
404
403
  try {
405
404
  // oxlint-disable-next-line no-await-in-loop -- model fallback is sequential by design
406
405
  const response = await awaitWithSignal(ai.models.generateContent(selectedRequest), controller.signal);
@@ -411,7 +410,7 @@ const generateGoogle = async (request, config = {}) => {
411
410
  generatedAt: config.dependencies?.now?.() ?? Date.now(),
412
411
  ...(usage === undefined ? {} : { usage }),
413
412
  };
414
- (0, log_1.debug)('generation completed', request.ident);
413
+ (0, log_1.debug)(`[${result.model}] generation completed`, request.ident);
415
414
  return result;
416
415
  }
417
416
  catch (error) {
@@ -424,8 +423,7 @@ const generateGoogle = async (request, config = {}) => {
424
423
  const unavailableModel = failureStatus === 404 && message.includes(selectedModel);
425
424
  // Fallback only; per-model backoff below is keyed by rate limiting.
426
425
  if (rateLimited || overloadedModel || unavailableModel) {
427
- (0, log_1.warn)('generation attempt failed; trying next available combination', {
428
- model: selectedModel,
426
+ (0, log_1.warn)(`[${selectedModel}] generation attempt failed; trying next available combination`, {
429
427
  status: failureStatus,
430
428
  });
431
429
  (0, apikey_1.blockKeyService)(key, `gemini-${selectedModel}`);
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './client';
2
2
  export * from './internal/apikey';
3
+ export * from './internal/log';
package/dist/index.js CHANGED
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./client"), exports);
18
18
  __exportStar(require("./internal/apikey"), exports);
19
+ __exportStar(require("./internal/log"), exports);
@@ -33,7 +33,7 @@ const getAvailableCombinations = (service, resetIfExhausted = true) => {
33
33
  }
34
34
  // If all combinations are blocklisted, clear the blocklist and try again
35
35
  if (combinations.length === 0 && resetIfExhausted) {
36
- (0, log_1.warn)(`All API key + service combinations were blocklisted for ${service}. Clearing blocklist and trying again.`);
36
+ (0, log_1.warn)(`[${service}] all API key + service combinations were blocklisted; clearing blocklist and trying again.`);
37
37
  blocklist.flushAll();
38
38
  for (const key of keys) {
39
39
  combinations.push({ service, key });
@@ -45,7 +45,7 @@ const getAvailableCombinations = (service, resetIfExhausted = true) => {
45
45
  exports.getAvailableCombinations = getAvailableCombinations;
46
46
  // Block a key+service combination
47
47
  const blockKeyService = (apiKey, service) => {
48
- (0, log_1.warn)(`key+service blocklisted for ${service}`);
48
+ (0, log_1.warn)(`[${service}] key+service blocklisted`);
49
49
  addToBlocklist(apiKey, service);
50
50
  };
51
51
  exports.blockKeyService = blockKeyService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-ai",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
4
4
  "description": "Provider-neutral AI client and cluster runtime for the rpi-mega cluster.",
5
5
  "license": "ISC",
6
6
  "author": "admin@gec.dev",