zam-core 0.4.2 → 0.4.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/dist/cli/index.js CHANGED
@@ -4955,12 +4955,15 @@ async function getLlmConfig(db) {
4955
4955
  }
4956
4956
  async function getVisionConfig(db) {
4957
4957
  const base = await getLlmConfig(db);
4958
+ const maxFramesStr = await getSetting(db, "llm.vision.max_frames");
4959
+ const maxFrames = maxFramesStr ? parseInt(maxFramesStr, 10) : 100;
4958
4960
  return {
4959
4961
  enabled: await getSetting(db, "llm.vision.enabled") === "true",
4960
4962
  url: await getSetting(db, "llm.vision.url") || base.url,
4961
4963
  model: await getSetting(db, "llm.vision.model") || base.model,
4962
4964
  apiKey: await getSetting(db, "llm.vision.api_key") || base.apiKey,
4963
- locale: base.locale
4965
+ locale: base.locale,
4966
+ maxFrames: Number.isNaN(maxFrames) ? 100 : maxFrames
4964
4967
  };
4965
4968
  }
4966
4969
  var LANGUAGE_NAMES = {
@@ -5497,8 +5500,8 @@ async function ensureHighQualityQuestion(db, token) {
5497
5500
  }
5498
5501
 
5499
5502
  // src/cli/llm/vision.ts
5500
- import { readFileSync as readFileSync9 } from "fs";
5501
5503
  import { randomBytes } from "crypto";
5504
+ import { readFileSync as readFileSync9 } from "fs";
5502
5505
  import { tmpdir } from "os";
5503
5506
  import { basename as basename2, join as join12 } from "path";
5504
5507
  var LANGUAGE_NAMES2 = {
@@ -5538,7 +5541,10 @@ async function observeUiSnapshotViaLLM(db, input8) {
5538
5541
  if (isVideo) {
5539
5542
  const { mkdirSync: mkdirSync12, readdirSync: readdirSync3, rmSync: rmSync3 } = await import("fs");
5540
5543
  const { execSync: execSync7 } = await import("child_process");
5541
- const tempDir = join12(tmpdir(), `zam-frames-${randomBytes(4).toString("hex")}`);
5544
+ const tempDir = join12(
5545
+ tmpdir(),
5546
+ `zam-frames-${randomBytes(4).toString("hex")}`
5547
+ );
5542
5548
  mkdirSync12(tempDir, { recursive: true });
5543
5549
  try {
5544
5550
  execSync7(
@@ -5553,13 +5559,18 @@ async function observeUiSnapshotViaLLM(db, input8) {
5553
5559
  );
5554
5560
  files = readdirSync3(tempDir).filter((f) => f.endsWith(".png")).sort();
5555
5561
  }
5562
+ const maxFrames = cfg.maxFrames ?? 100;
5556
5563
  let sampledFiles = files;
5557
- if (files.length > 12) {
5558
- const step = (files.length - 1) / 11;
5559
- sampledFiles = [];
5560
- for (let i = 0; i < 12; i++) {
5561
- const index = Math.round(i * step);
5562
- sampledFiles.push(files[index]);
5564
+ if (files.length > maxFrames) {
5565
+ if (maxFrames <= 1) {
5566
+ sampledFiles = [files[0]];
5567
+ } else {
5568
+ const step = (files.length - 1) / (maxFrames - 1);
5569
+ sampledFiles = [];
5570
+ for (let i = 0; i < maxFrames; i++) {
5571
+ const index = Math.round(i * step);
5572
+ sampledFiles.push(files[index]);
5573
+ }
5563
5574
  }
5564
5575
  }
5565
5576
  for (const file of sampledFiles) {
@@ -5657,7 +5668,8 @@ ${schema}`
5657
5668
  }
5658
5669
  ],
5659
5670
  temperature: 0,
5660
- max_tokens: args.input.maxTokens ?? 450
5671
+ max_tokens: args.input.maxTokens ?? 450,
5672
+ ...args.url.includes("11434") || args.url.includes("localhost") || args.url.includes("127.0.0.1") ? { options: { num_ctx: 32768 } } : {}
5661
5673
  }),
5662
5674
  locale: args.locale,
5663
5675
  hardTimeoutMs: args.input.hardTimeoutMs ?? 18e4
@@ -6961,13 +6973,13 @@ bridgeCommand.command("stop-recording").description(
6961
6973
  const { pid, outputPath } = state;
6962
6974
  try {
6963
6975
  process.kill(pid, "SIGINT");
6964
- } catch (e) {
6976
+ } catch (_e) {
6965
6977
  }
6966
6978
  const isProcessRunning = (pId) => {
6967
6979
  try {
6968
6980
  process.kill(pId, 0);
6969
6981
  return true;
6970
- } catch (e) {
6982
+ } catch (_e) {
6971
6983
  return false;
6972
6984
  }
6973
6985
  };
@@ -6979,7 +6991,7 @@ bridgeCommand.command("stop-recording").description(
6979
6991
  if (isProcessRunning(pid)) {
6980
6992
  try {
6981
6993
  process.kill(pid, "SIGKILL");
6982
- } catch (e) {
6994
+ } catch (_e) {
6983
6995
  }
6984
6996
  }
6985
6997
  try {