babelgate 1.1.0 → 1.1.2

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 CHANGED
@@ -421,9 +421,6 @@ fixtures/tests — see
421
421
  - **`count_tokens` is an estimate** (chars/4), marked by the
422
422
  `x-babelgate-token-estimate: true` header — enough for Claude Code's
423
423
  budgeting, not for billing.
424
- - **Ollama clients get a single JSON reply** when they omit `stream` —
425
- unlike Ollama's own API, which streams NDJSON by default. Send
426
- `"stream": false` explicitly to make that intent clear.
427
424
  - **Non-chat Gemini methods return 501** — `:countTokens`, `:embedContent`
428
425
  and friends aren't translated.
429
426
  - Some provider-specific features (citations, extra usage fields) map to
@@ -9,7 +9,7 @@ exports.resetConfig = resetConfig;
9
9
  const dotenv_1 = __importDefault(require("dotenv"));
10
10
  const model_map_1 = require("../utils/model-map");
11
11
  const errors_1 = require("../utils/errors");
12
- dotenv_1.default.config();
12
+ dotenv_1.default.config({ quiet: true });
13
13
  const VALID_PROVIDERS = ["openai", "gemini", "ollama", "anthropic"];
14
14
  function isValidProvider(value) {
15
15
  return VALID_PROVIDERS.includes(value.toLowerCase());
@@ -73,9 +73,12 @@ function toCanonicalRequest(request) {
73
73
  ...(opts.seed !== undefined && { seed: opts.seed }),
74
74
  };
75
75
  }
76
- // Canonical treats absent and stream:false identically — only an
77
- // explicit true survives, keeping the request round-trip idempotent.
78
- if (request.stream === true) {
76
+ // Ollama's /api/chat streams NDJSON unless the client sends
77
+ // stream:false (api.md: "stream ... if false the response will be
78
+ // returned as a single response object"; default true) — so an
79
+ // omitted flag maps to canonical stream:true and only an explicit
80
+ // false opts out.
81
+ if (request.stream !== false) {
79
82
  result.stream = true;
80
83
  }
81
84
  if (request.tools && request.tools.length > 0) {
@@ -4,18 +4,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.logger = void 0;
7
+ exports.loggerOptions = loggerOptions;
7
8
  const pino_1 = __importDefault(require("pino"));
8
- const isProduction = process.env.NODE_ENV === "production";
9
- exports.logger = (0, pino_1.default)({
10
- level: process.env.LOG_LEVEL || (isProduction ? "info" : "debug"),
11
- transport: isProduction
12
- ? undefined
13
- : {
14
- target: "pino-pretty",
15
- options: {
16
- colorize: true,
17
- translateTime: "SYS:standard",
18
- ignore: "pid,hostname",
19
- },
20
- },
21
- });
9
+ function canResolvePinoPretty() {
10
+ try {
11
+ require.resolve("pino-pretty");
12
+ return true;
13
+ }
14
+ catch {
15
+ return false;
16
+ }
17
+ }
18
+ function loggerOptions(env, canResolve) {
19
+ const isProduction = env.NODE_ENV === "production";
20
+ return {
21
+ level: env.LOG_LEVEL || (isProduction ? "info" : "debug"),
22
+ transport: !isProduction && canResolve()
23
+ ? {
24
+ target: "pino-pretty",
25
+ options: {
26
+ colorize: true,
27
+ translateTime: "SYS:standard",
28
+ ignore: "pid,hostname",
29
+ },
30
+ }
31
+ : undefined,
32
+ };
33
+ }
34
+ exports.logger = (0, pino_1.default)(loggerOptions(process.env, canResolvePinoPretty));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babelgate",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "bin": {
5
5
  "babelgate": "dist/cli.js"
6
6
  },
@@ -18,7 +18,8 @@
18
18
  "test": "vitest run",
19
19
  "record:streams": "ts-node -r dotenv/config scripts/record-streams.ts",
20
20
  "test:live": "vitest run --config vitest.live.config.ts",
21
- "test:watch": "vitest"
21
+ "test:watch": "vitest",
22
+ "prepublishOnly": "./scripts/check.sh"
22
23
  },
23
24
  "keywords": [],
24
25
  "author": "Dorrabb Khan",