open-agents-ai 0.187.393 → 0.187.395
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/index.js +263 -51
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -532397,12 +532397,25 @@ var init_status_bar = __esm({
|
|
|
532397
532397
|
this.refreshHeaderPanels();
|
|
532398
532398
|
if (this.active) this.renderFooterPreserveCursor();
|
|
532399
532399
|
}
|
|
532400
|
-
|
|
532401
|
-
const raw =
|
|
532400
|
+
normalizeDisplayModelName(rawName) {
|
|
532401
|
+
const raw = rawName.trim();
|
|
532402
532402
|
if (!raw) return "";
|
|
532403
532403
|
const leaf = raw.split("/").pop() ?? raw;
|
|
532404
|
-
const
|
|
532405
|
-
|
|
532404
|
+
const withoutLatest = leaf.replace(/:latest$/i, "");
|
|
532405
|
+
if (!/^open-agents-/i.test(withoutLatest)) return withoutLatest;
|
|
532406
|
+
const derived = withoutLatest.replace(/^open-agents-/i, "");
|
|
532407
|
+
const sizeMatch = derived.match(/-(\d+(?:\.\d+)?[bBmMkK])$/);
|
|
532408
|
+
const size = sizeMatch?.[1]?.toLowerCase() ?? "";
|
|
532409
|
+
let family = sizeMatch ? derived.slice(0, -sizeMatch[0].length) : derived;
|
|
532410
|
+
family = family.replace(/-latest$/i, "");
|
|
532411
|
+
family = family.replace(/^qwen(\d)(\d)(?=$|-)/i, "qwen$1.$2").replace(/^llama(\d)(\d)(?=$|-)/i, "llama$1.$2").replace(/^phi(\d)(\d)(?=$|-)/i, "phi$1.$2").replace(/^deepseekr(\d)(?=$|-)/i, "deepseek-r$1").replace(/^commandr(?=$|-)/i, "command-r").replace(/^commanda(?=$|-)/i, "command-a");
|
|
532412
|
+
return size ? `${family}:${size}` : family;
|
|
532413
|
+
}
|
|
532414
|
+
summarizeHeaderModelName() {
|
|
532415
|
+
const displayName = this.normalizeDisplayModelName(this._modelName);
|
|
532416
|
+
if (!displayName) return "";
|
|
532417
|
+
const familySource = displayName.split(":")[0]?.trim() || displayName;
|
|
532418
|
+
const paramMatch = displayName.match(/(\d+(?:\.\d+)?\s*[bBmMkK])/);
|
|
532406
532419
|
const param = paramMatch ? paramMatch[1].replace(/\s+/g, "").toLowerCase() : "";
|
|
532407
532420
|
let summary = param && !familySource.toLowerCase().includes(param) ? `${familySource} ${param}` : familySource;
|
|
532408
532421
|
if (summary.length > 18) {
|
|
@@ -532452,14 +532465,15 @@ var init_status_bar = __esm({
|
|
|
532452
532465
|
_headerPanels = [];
|
|
532453
532466
|
/** Index of the currently visible panel (0 = main) */
|
|
532454
532467
|
_headerPanelIndex = 0;
|
|
532468
|
+
_headerCommandZones = [];
|
|
532455
532469
|
/** Register a header panel. Returns its index. */
|
|
532456
|
-
registerHeaderPanel(id, render2) {
|
|
532470
|
+
registerHeaderPanel(id, render2, meta) {
|
|
532457
532471
|
const existing = this._headerPanels.findIndex((p2) => p2.id === id);
|
|
532458
532472
|
if (existing >= 0) {
|
|
532459
|
-
this._headerPanels[existing] = { id, render: render2 };
|
|
532473
|
+
this._headerPanels[existing] = { id, render: render2, meta };
|
|
532460
532474
|
return existing;
|
|
532461
532475
|
}
|
|
532462
|
-
this._headerPanels.push({ id, render: render2 });
|
|
532476
|
+
this._headerPanels.push({ id, render: render2, meta });
|
|
532463
532477
|
return this._headerPanels.length - 1;
|
|
532464
532478
|
}
|
|
532465
532479
|
/** Rebuild all header panels. Two categories are kept separate:
|
|
@@ -532509,10 +532523,6 @@ var init_status_bar = __esm({
|
|
|
532509
532523
|
let out = "";
|
|
532510
532524
|
let usedW = 0;
|
|
532511
532525
|
if (isFirstPage) {
|
|
532512
|
-
try {
|
|
532513
|
-
this._verClickZone = this._updateLatest ? { start: 4, end: 4 + verW - 1 } : null;
|
|
532514
|
-
} catch {
|
|
532515
|
-
}
|
|
532516
532526
|
out += `\x1B[1;38;5;${TEXT_PRIMARY}m${verText}\x1B[0m`;
|
|
532517
532527
|
usedW += verW;
|
|
532518
532528
|
}
|
|
@@ -532524,6 +532534,11 @@ var init_status_bar = __esm({
|
|
|
532524
532534
|
out += renderBtn(btn.cmd, btn.label) + " ";
|
|
532525
532535
|
}
|
|
532526
532536
|
return out;
|
|
532537
|
+
}, {
|
|
532538
|
+
kind: "main",
|
|
532539
|
+
buttons: btns,
|
|
532540
|
+
isFirstPage,
|
|
532541
|
+
versionWidth: verW
|
|
532527
532542
|
});
|
|
532528
532543
|
}
|
|
532529
532544
|
const sysItems = [];
|
|
@@ -532572,7 +532587,7 @@ var init_status_bar = __esm({
|
|
|
532572
532587
|
let out = "";
|
|
532573
532588
|
for (const item of items) out += item.render();
|
|
532574
532589
|
return out;
|
|
532575
|
-
});
|
|
532590
|
+
}, { kind: "system" });
|
|
532576
532591
|
}
|
|
532577
532592
|
this._headerPanelIndex = Math.min(savedIdx, Math.max(0, this._headerPanels.length - 1));
|
|
532578
532593
|
}
|
|
@@ -532592,15 +532607,65 @@ var init_status_bar = __esm({
|
|
|
532592
532607
|
get currentHeaderPanel() {
|
|
532593
532608
|
return this._headerPanels[this._headerPanelIndex]?.id ?? "main";
|
|
532594
532609
|
}
|
|
532610
|
+
getHeaderChromeLayout(termWidth) {
|
|
532611
|
+
const hasMultiple = this._headerPanels.length > 1;
|
|
532612
|
+
const showPrev = hasMultiple && this._headerPanelIndex > 0;
|
|
532613
|
+
const showNext = hasMultiple && this._headerPanelIndex < this._headerPanels.length - 1;
|
|
532614
|
+
const leftPadWidth = showPrev ? 2 : 0;
|
|
532615
|
+
const rightPadWidth = showNext ? 1 : 0;
|
|
532616
|
+
return {
|
|
532617
|
+
showPrev,
|
|
532618
|
+
showNext,
|
|
532619
|
+
contentStartCol: 2 + leftPadWidth,
|
|
532620
|
+
innerWidth: Math.max(1, termWidth - 2 - leftPadWidth - rightPadWidth)
|
|
532621
|
+
};
|
|
532622
|
+
}
|
|
532623
|
+
hitTestCurrentHeaderAction(row, col, termWidth) {
|
|
532624
|
+
const hdrRow = layout().headerContent;
|
|
532625
|
+
if (row !== hdrRow) return null;
|
|
532626
|
+
const chrome = this.getHeaderChromeLayout(termWidth);
|
|
532627
|
+
if (chrome.showPrev && col === 2) return "header-prev";
|
|
532628
|
+
if (chrome.showNext && col === termWidth - 1) return "header-next";
|
|
532629
|
+
const hit = this._headerCommandZones.find((zone) => col >= zone.start && col <= zone.end);
|
|
532630
|
+
return hit?.cmd ?? null;
|
|
532631
|
+
}
|
|
532595
532632
|
/** Render the current header panel content onto terminal row 2 (inside box) */
|
|
532596
532633
|
refreshHeaderContent() {
|
|
532597
532634
|
if (!this.active) return;
|
|
532598
532635
|
const w = termCols();
|
|
532599
|
-
const
|
|
532636
|
+
const chrome = this.getHeaderChromeLayout(w);
|
|
532637
|
+
const innerW = chrome.innerWidth;
|
|
532600
532638
|
const panel = this._headerPanels[this._headerPanelIndex];
|
|
532601
532639
|
if (!panel) return;
|
|
532640
|
+
this._headerCommandZones = [];
|
|
532641
|
+
try {
|
|
532642
|
+
this._verClickZone = null;
|
|
532643
|
+
} catch {
|
|
532644
|
+
}
|
|
532602
532645
|
let content = panel.render(innerW);
|
|
532603
532646
|
this._sysClickZones = [];
|
|
532647
|
+
if (panel.meta?.kind === "main") {
|
|
532648
|
+
const buttons = panel.meta.buttons ?? [];
|
|
532649
|
+
const versionWidth = panel.meta.versionWidth ?? 0;
|
|
532650
|
+
const usedW = panel.meta.isFirstPage ? versionWidth : 0;
|
|
532651
|
+
const btnTotalW = buttons.reduce((sum, btn) => sum + btn.w + 1, 0);
|
|
532652
|
+
const gap = Math.max(1, innerW - usedW - btnTotalW);
|
|
532653
|
+
let col = chrome.contentStartCol + usedW + gap;
|
|
532654
|
+
if (panel.meta.isFirstPage && this._updateLatest) {
|
|
532655
|
+
try {
|
|
532656
|
+
this._verClickZone = {
|
|
532657
|
+
start: chrome.contentStartCol,
|
|
532658
|
+
end: chrome.contentStartCol + versionWidth - 1
|
|
532659
|
+
};
|
|
532660
|
+
} catch {
|
|
532661
|
+
}
|
|
532662
|
+
}
|
|
532663
|
+
this._headerCommandZones = buttons.map((btn) => {
|
|
532664
|
+
const zone = { start: col, end: col + btn.w - 1, cmd: `/${btn.cmd}` };
|
|
532665
|
+
col += btn.w + 1;
|
|
532666
|
+
return zone;
|
|
532667
|
+
});
|
|
532668
|
+
}
|
|
532604
532669
|
if (String(this.currentHeaderPanel).startsWith("sys-")) {
|
|
532605
532670
|
const zones = [];
|
|
532606
532671
|
const trunc3 = (s2) => s2.trim().split(/\s+/).slice(0, 3).join(" ");
|
|
@@ -532637,7 +532702,7 @@ var init_status_bar = __esm({
|
|
|
532637
532702
|
if (cur.length > 0) pages.push(cur);
|
|
532638
532703
|
const idx = parseInt(String(this.currentHeaderPanel).split("-")[1] || "0", 10) || 0;
|
|
532639
532704
|
const page2 = pages[Math.max(0, Math.min(idx, pages.length - 1))] ?? [];
|
|
532640
|
-
let col =
|
|
532705
|
+
let col = chrome.contentStartCol;
|
|
532641
532706
|
const clickZones = [];
|
|
532642
532707
|
for (const z16 of page2) {
|
|
532643
532708
|
if (z16.id) clickZones.push({ start: col, end: col + z16.w - 2, id: z16.id });
|
|
@@ -532645,19 +532710,22 @@ var init_status_bar = __esm({
|
|
|
532645
532710
|
}
|
|
532646
532711
|
this._sysClickZones = clickZones;
|
|
532647
532712
|
}
|
|
532648
|
-
const
|
|
532649
|
-
const
|
|
532650
|
-
const rightArrow = hasMultiple ? `\x1B]8;;oa-cmd:header-next\x07\x1B[38;5;${TEXT_DIM}m${this._headerPanelIndex < this._headerPanels.length - 1 ? "▶" : " "}\x1B]8;;\x07` : " ";
|
|
532713
|
+
const leftArrow = chrome.showPrev ? `\x1B]8;;oa-cmd:header-prev\x07\x1B[38;5;${TEXT_DIM}m◀\x1B]8;;\x07` : "";
|
|
532714
|
+
const rightArrow = chrome.showNext ? `\x1B]8;;oa-cmd:header-next\x07\x1B[38;5;${TEXT_DIM}m▶\x1B]8;;\x07` : "";
|
|
532651
532715
|
const hdrRow = layout().headerContent;
|
|
532652
532716
|
let buf = "\x1B7";
|
|
532653
532717
|
buf += `\x1B[${hdrRow};1H${PANEL_BG_SEQ}\x1B[2K`;
|
|
532654
532718
|
buf += `${BOX_FG}│${RESET2}${PANEL_BG_SEQ}`;
|
|
532655
|
-
|
|
532656
|
-
|
|
532719
|
+
if (chrome.showPrev) {
|
|
532720
|
+
buf += leftArrow;
|
|
532721
|
+
buf += ` `;
|
|
532722
|
+
}
|
|
532657
532723
|
buf += `\x1B[38;5;${TEXT_PRIMARY}m${PANEL_BG_SEQ}`;
|
|
532658
532724
|
buf += content;
|
|
532659
|
-
|
|
532660
|
-
|
|
532725
|
+
if (chrome.showNext) {
|
|
532726
|
+
buf += `\x1B[${hdrRow};${w - 1}H`;
|
|
532727
|
+
buf += rightArrow;
|
|
532728
|
+
}
|
|
532661
532729
|
buf += `\x1B[${hdrRow};${w}H${BOX_FG}│${RESET2}`;
|
|
532662
532730
|
buf += "\x1B8";
|
|
532663
532731
|
this.termWrite(buf);
|
|
@@ -533503,7 +533571,7 @@ var init_status_bar = __esm({
|
|
|
533503
533571
|
return;
|
|
533504
533572
|
}
|
|
533505
533573
|
}
|
|
533506
|
-
const cmd =
|
|
533574
|
+
const cmd = this.hitTestCurrentHeaderAction(row, col, w);
|
|
533507
533575
|
if (type === "press" && cmd) {
|
|
533508
533576
|
if (cmd === "header-prev") {
|
|
533509
533577
|
this.prevHeaderPanel();
|
|
@@ -536712,6 +536780,7 @@ __export(setup_exports, {
|
|
|
536712
536780
|
pullModelWithAutoUpdate: () => pullModelWithAutoUpdate,
|
|
536713
536781
|
recommendModel: () => recommendModel,
|
|
536714
536782
|
renderScoreBar: () => renderScoreBar,
|
|
536783
|
+
repairAllExpandedVariants: () => repairAllExpandedVariants,
|
|
536715
536784
|
runElevatedCommand: () => runElevatedCommand,
|
|
536716
536785
|
runSetupWizard: () => runSetupWizard,
|
|
536717
536786
|
updateOllama: () => updateOllama
|
|
@@ -536880,6 +536949,16 @@ function calculateContextWindow(specs, modelSizeGB2, kvBytesPerToken, archMax) {
|
|
|
536880
536949
|
const label = numCtx >= 1024 ? `${Math.floor(numCtx / 1024)}K` : String(numCtx);
|
|
536881
536950
|
return { numCtx, label };
|
|
536882
536951
|
}
|
|
536952
|
+
function formatContextLabel(numCtx) {
|
|
536953
|
+
return numCtx >= 1024 ? `${Math.floor(numCtx / 1024)}K` : String(numCtx);
|
|
536954
|
+
}
|
|
536955
|
+
function calculateExpandedVariantContextWindow(specs, modelSizeGB2, kvBytesPerToken, archMax) {
|
|
536956
|
+
if (archMax && archMax > 0) {
|
|
536957
|
+
const numCtx = Math.max(2048, Math.floor(archMax / 1024) * 1024);
|
|
536958
|
+
return { numCtx, label: formatContextLabel(numCtx) };
|
|
536959
|
+
}
|
|
536960
|
+
return calculateContextWindow(specs, modelSizeGB2, kvBytesPerToken, archMax);
|
|
536961
|
+
}
|
|
536883
536962
|
function ask(rl, question) {
|
|
536884
536963
|
return new Promise((resolve41) => {
|
|
536885
536964
|
rl.question(question, (answer) => resolve41(answer.trim()));
|
|
@@ -538636,16 +538715,48 @@ async function queryModelKVInfo(backendUrl, modelName) {
|
|
|
538636
538715
|
const keyDim = info[`${arch2}.attention.key_length`];
|
|
538637
538716
|
const valDim = info[`${arch2}.attention.value_length`] ?? keyDim;
|
|
538638
538717
|
const archMax = info[`${arch2}.context_length`];
|
|
538639
|
-
if (!
|
|
538718
|
+
if (!archMax) return null;
|
|
538719
|
+
if (!nLayers || !nKVHeads || !keyDim || !valDim) return { archMax };
|
|
538640
538720
|
const kvBytesPerToken = nLayers * nKVHeads * (keyDim + valDim) * 2;
|
|
538641
538721
|
return { kvBytesPerToken, archMax };
|
|
538642
538722
|
} catch {
|
|
538643
538723
|
return null;
|
|
538644
538724
|
}
|
|
538645
538725
|
}
|
|
538726
|
+
async function readExpandedVariantState(backendUrl, modelName) {
|
|
538727
|
+
try {
|
|
538728
|
+
const normalized = backendUrl.replace(/\/+$/, "");
|
|
538729
|
+
const showRes = await fetch(`${normalized}/api/show`, {
|
|
538730
|
+
method: "POST",
|
|
538731
|
+
headers: { "Content-Type": "application/json" },
|
|
538732
|
+
body: JSON.stringify({ name: modelName }),
|
|
538733
|
+
signal: AbortSignal.timeout(5e3)
|
|
538734
|
+
});
|
|
538735
|
+
if (!showRes.ok) return null;
|
|
538736
|
+
const showData = await showRes.json();
|
|
538737
|
+
const numCtxMatch = showData.parameters?.match(/num_ctx\s+(\d+)/);
|
|
538738
|
+
const currentNumCtx = numCtxMatch ? parseInt(numCtxMatch[1], 10) : 0;
|
|
538739
|
+
const fromMatch = showData.modelfile?.match(/^FROM\s+(.+)$/m);
|
|
538740
|
+
const baseModel = fromMatch?.[1]?.trim() ?? null;
|
|
538741
|
+
return { currentNumCtx, baseModel };
|
|
538742
|
+
} catch {
|
|
538743
|
+
return null;
|
|
538744
|
+
}
|
|
538745
|
+
}
|
|
538746
|
+
async function repairExpandedVariantIfStale(variantModel, fallbackBaseModel, backendUrl, specs, sizeGB, targetNumCtx, kvBytesPerToken, archMax) {
|
|
538747
|
+
const state = await readExpandedVariantState(backendUrl, variantModel);
|
|
538748
|
+
if (!state) return { repaired: false, currentNumCtx: 0, baseModel: null };
|
|
538749
|
+
if (state.currentNumCtx > 0 && state.currentNumCtx >= targetNumCtx) {
|
|
538750
|
+
return { repaired: false, currentNumCtx: state.currentNumCtx, baseModel: state.baseModel };
|
|
538751
|
+
}
|
|
538752
|
+
const baseModel = state.baseModel && !state.baseModel.startsWith("open-agents-") ? state.baseModel : fallbackBaseModel;
|
|
538753
|
+
if (!baseModel) return { repaired: false, currentNumCtx: state.currentNumCtx, baseModel: null };
|
|
538754
|
+
const created = await createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerToken, archMax);
|
|
538755
|
+
return { repaired: !!created, currentNumCtx: state.currentNumCtx, baseModel };
|
|
538756
|
+
}
|
|
538646
538757
|
function createExpandedVariant(baseModel, specs, sizeGB, kvBytesPerToken, archMax) {
|
|
538647
538758
|
const customName = expandedModelName(baseModel);
|
|
538648
|
-
const ctx3 =
|
|
538759
|
+
const ctx3 = calculateExpandedVariantContextWindow(specs, sizeGB, kvBytesPerToken, archMax);
|
|
538649
538760
|
try {
|
|
538650
538761
|
const numPredict = Math.min(16384, Math.max(2048, Math.floor(ctx3.numCtx * 0.25)));
|
|
538651
538762
|
const modelfileContent = [
|
|
@@ -538670,7 +538781,7 @@ function createExpandedVariant(baseModel, specs, sizeGB, kvBytesPerToken, archMa
|
|
|
538670
538781
|
}
|
|
538671
538782
|
async function createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerToken, archMax) {
|
|
538672
538783
|
const customName = expandedModelName(baseModel);
|
|
538673
|
-
const ctx3 =
|
|
538784
|
+
const ctx3 = calculateExpandedVariantContextWindow(specs, sizeGB, kvBytesPerToken, archMax);
|
|
538674
538785
|
try {
|
|
538675
538786
|
const numPredict = Math.min(16384, Math.max(2048, Math.floor(ctx3.numCtx * 0.25)));
|
|
538676
538787
|
const modelfileContent = [
|
|
@@ -538704,30 +538815,19 @@ async function ensureExpandedContext(modelName, backendUrl) {
|
|
|
538704
538815
|
sizeGB = modelSizeGB(models, modelName);
|
|
538705
538816
|
} catch {
|
|
538706
538817
|
}
|
|
538707
|
-
const ctx3 =
|
|
538818
|
+
const ctx3 = calculateExpandedVariantContextWindow(specs, sizeGB, kvInfo?.kvBytesPerToken, kvInfo?.archMax);
|
|
538708
538819
|
if (modelName.startsWith("open-agents-")) {
|
|
538709
|
-
|
|
538710
|
-
|
|
538711
|
-
|
|
538712
|
-
|
|
538713
|
-
|
|
538714
|
-
|
|
538715
|
-
|
|
538716
|
-
|
|
538717
|
-
|
|
538718
|
-
|
|
538719
|
-
|
|
538720
|
-
const currentNumCtx = numCtxMatch ? parseInt(numCtxMatch[1], 10) : 0;
|
|
538721
|
-
if (currentNumCtx !== ctx3.numCtx) {
|
|
538722
|
-
const fromMatch = showData.modelfile?.match(/^FROM\s+(.+)$/m);
|
|
538723
|
-
const baseModel = fromMatch?.[1]?.trim();
|
|
538724
|
-
if (baseModel && !baseModel.startsWith("open-agents-")) {
|
|
538725
|
-
await createExpandedVariantAsync(baseModel, specs, sizeGB, kvInfo?.kvBytesPerToken, kvInfo?.archMax);
|
|
538726
|
-
}
|
|
538727
|
-
}
|
|
538728
|
-
}
|
|
538729
|
-
} catch {
|
|
538730
|
-
}
|
|
538820
|
+
await repairExpandedVariantIfStale(
|
|
538821
|
+
modelName,
|
|
538822
|
+
null,
|
|
538823
|
+
backendUrl,
|
|
538824
|
+
specs,
|
|
538825
|
+
sizeGB,
|
|
538826
|
+
ctx3.numCtx,
|
|
538827
|
+
kvInfo?.kvBytesPerToken,
|
|
538828
|
+
kvInfo?.archMax
|
|
538829
|
+
).catch(() => {
|
|
538830
|
+
});
|
|
538731
538831
|
return { model: modelName, created: false, contextLabel: ctx3.label, numCtx: ctx3.numCtx };
|
|
538732
538832
|
}
|
|
538733
538833
|
const existing = await checkExpandedVariant(modelName, backendUrl);
|
|
@@ -538735,6 +538835,17 @@ async function ensureExpandedContext(modelName, backendUrl) {
|
|
|
538735
538835
|
return { model: modelName, created: false, contextLabel: "", numCtx: 0 };
|
|
538736
538836
|
}
|
|
538737
538837
|
if (typeof existing === "string") {
|
|
538838
|
+
await repairExpandedVariantIfStale(
|
|
538839
|
+
existing,
|
|
538840
|
+
modelName,
|
|
538841
|
+
backendUrl,
|
|
538842
|
+
specs,
|
|
538843
|
+
sizeGB,
|
|
538844
|
+
ctx3.numCtx,
|
|
538845
|
+
kvInfo?.kvBytesPerToken,
|
|
538846
|
+
kvInfo?.archMax
|
|
538847
|
+
).catch(() => {
|
|
538848
|
+
});
|
|
538738
538849
|
return { model: existing, created: false, contextLabel: ctx3.label, numCtx: ctx3.numCtx };
|
|
538739
538850
|
}
|
|
538740
538851
|
const created = await createExpandedVariantAsync(modelName, specs, sizeGB, kvInfo?.kvBytesPerToken, kvInfo?.archMax);
|
|
@@ -538743,6 +538854,59 @@ async function ensureExpandedContext(modelName, backendUrl) {
|
|
|
538743
538854
|
}
|
|
538744
538855
|
return { model: modelName, created: false, contextLabel: ctx3.label, numCtx: ctx3.numCtx };
|
|
538745
538856
|
}
|
|
538857
|
+
async function repairAllExpandedVariants(backendUrl) {
|
|
538858
|
+
const specs = await detectSystemSpecsAsync();
|
|
538859
|
+
const models = await fetchOllamaModels(backendUrl);
|
|
538860
|
+
const variants = models.filter((model) => /^open-agents-/i.test(model.name));
|
|
538861
|
+
const summary = {
|
|
538862
|
+
scanned: 0,
|
|
538863
|
+
unchanged: 0,
|
|
538864
|
+
repaired: [],
|
|
538865
|
+
failed: []
|
|
538866
|
+
};
|
|
538867
|
+
for (const variant of variants) {
|
|
538868
|
+
summary.scanned += 1;
|
|
538869
|
+
const state = await readExpandedVariantState(backendUrl, variant.name);
|
|
538870
|
+
if (!state) {
|
|
538871
|
+
summary.failed.push({ model: variant.name, reason: "missing-state" });
|
|
538872
|
+
continue;
|
|
538873
|
+
}
|
|
538874
|
+
const baseModel = state.baseModel && !state.baseModel.startsWith("open-agents-") ? state.baseModel : null;
|
|
538875
|
+
if (!baseModel) {
|
|
538876
|
+
summary.failed.push({ model: variant.name, reason: "missing-base-model" });
|
|
538877
|
+
continue;
|
|
538878
|
+
}
|
|
538879
|
+
const sizeGB = modelSizeGB(models, baseModel || variant.name);
|
|
538880
|
+
const kvInfo = await queryModelKVInfo(backendUrl, baseModel);
|
|
538881
|
+
const target = calculateExpandedVariantContextWindow(specs, sizeGB, kvInfo?.kvBytesPerToken, kvInfo?.archMax);
|
|
538882
|
+
try {
|
|
538883
|
+
const result = await repairExpandedVariantIfStale(
|
|
538884
|
+
variant.name,
|
|
538885
|
+
baseModel,
|
|
538886
|
+
backendUrl,
|
|
538887
|
+
specs,
|
|
538888
|
+
sizeGB,
|
|
538889
|
+
target.numCtx,
|
|
538890
|
+
kvInfo?.kvBytesPerToken,
|
|
538891
|
+
kvInfo?.archMax
|
|
538892
|
+
);
|
|
538893
|
+
if (result.repaired) {
|
|
538894
|
+
summary.repaired.push({
|
|
538895
|
+
model: variant.name,
|
|
538896
|
+
baseModel,
|
|
538897
|
+
previousNumCtx: result.currentNumCtx,
|
|
538898
|
+
targetNumCtx: target.numCtx
|
|
538899
|
+
});
|
|
538900
|
+
} else {
|
|
538901
|
+
summary.unchanged += 1;
|
|
538902
|
+
}
|
|
538903
|
+
} catch (err) {
|
|
538904
|
+
const message2 = err instanceof Error ? err.message : String(err);
|
|
538905
|
+
summary.failed.push({ model: variant.name, reason: message2 || "repair-failed" });
|
|
538906
|
+
}
|
|
538907
|
+
}
|
|
538908
|
+
return summary;
|
|
538909
|
+
}
|
|
538746
538910
|
async function ensureNeovim() {
|
|
538747
538911
|
try {
|
|
538748
538912
|
const nvimPath = execSync47("which nvim 2>/dev/null || where nvim 2>nul", {
|
|
@@ -581745,9 +581909,7 @@ ${opts.systemPromptAddition}` : `Working directory: ${repoRoot}`;
|
|
|
581745
581909
|
if (ctxSize) {
|
|
581746
581910
|
resolvedContextWindowSize = ctxSize;
|
|
581747
581911
|
statusBar.setContextWindowSize(ctxSize);
|
|
581748
|
-
|
|
581749
|
-
activeTask.runner.setContextWindowSize(ctxSize);
|
|
581750
|
-
}
|
|
581912
|
+
setActiveTaskContextWindowSize(ctxSize);
|
|
581751
581913
|
}
|
|
581752
581914
|
}).catch(() => {
|
|
581753
581915
|
});
|
|
@@ -581762,6 +581924,37 @@ ${opts.systemPromptAddition}` : `Working directory: ${repoRoot}`;
|
|
|
581762
581924
|
}).catch(() => {
|
|
581763
581925
|
});
|
|
581764
581926
|
statusBar.setHeaderIdentity(config.model, config.backendType, config.backendUrl);
|
|
581927
|
+
const formatCtxLabel = (tokens) => tokens >= 1024 ? `${Math.floor(tokens / 1024)}K` : String(tokens);
|
|
581928
|
+
let expandedVariantSweepPromise = null;
|
|
581929
|
+
const startExpandedVariantRepairSweep = (backendType, backendUrl) => {
|
|
581930
|
+
const normalizedUrl = normalizeBaseUrl(backendUrl);
|
|
581931
|
+
const isLocalOllama = backendType === "ollama" && (normalizedUrl.includes("127.0.0.1") || normalizedUrl.includes("localhost") || normalizedUrl.includes("0.0.0.0"));
|
|
581932
|
+
if (!isLocalOllama || expandedVariantSweepPromise) return;
|
|
581933
|
+
expandedVariantSweepPromise = repairAllExpandedVariants(normalizedUrl).then(async (summary) => {
|
|
581934
|
+
if (summary.repaired.length > 0) {
|
|
581935
|
+
const preview = summary.repaired.slice(0, 3).map((entry) => `${entry.model} ${formatCtxLabel(entry.previousNumCtx)}->${formatCtxLabel(entry.targetNumCtx)}`).join(", ");
|
|
581936
|
+
writeContent(() => {
|
|
581937
|
+
renderInfo2(`Repaired ${summary.repaired.length} open-agents model variant${summary.repaired.length === 1 ? "" : "s"} to max context.`);
|
|
581938
|
+
renderInfo2(preview + (summary.repaired.length > 3 ? `, +${summary.repaired.length - 3} more` : ""));
|
|
581939
|
+
});
|
|
581940
|
+
if (currentConfig.backendType === "ollama" && currentConfig.model.startsWith("open-agents-")) {
|
|
581941
|
+
const repairedCtxSize = await queryContextSize(currentConfig.backendUrl, currentConfig.model, currentConfig.apiKey);
|
|
581942
|
+
if (repairedCtxSize) {
|
|
581943
|
+
resolvedContextWindowSize = repairedCtxSize;
|
|
581944
|
+
statusBar.setContextWindowSize(repairedCtxSize);
|
|
581945
|
+
setActiveTaskContextWindowSize(repairedCtxSize);
|
|
581946
|
+
}
|
|
581947
|
+
}
|
|
581948
|
+
} else if (summary.failed.length > 0) {
|
|
581949
|
+
writeContent(() => {
|
|
581950
|
+
renderWarning2(`Expanded-model repair sweep skipped ${summary.failed.length} variant${summary.failed.length === 1 ? "" : "s"} with unreadable metadata.`);
|
|
581951
|
+
});
|
|
581952
|
+
}
|
|
581953
|
+
}).catch(() => {
|
|
581954
|
+
}).finally(() => {
|
|
581955
|
+
expandedVariantSweepPromise = null;
|
|
581956
|
+
});
|
|
581957
|
+
};
|
|
581765
581958
|
const provider = detectProvider(config.backendUrl);
|
|
581766
581959
|
const costTracker = new CostTracker(provider.id);
|
|
581767
581960
|
const sessionMetrics = new SessionMetrics();
|
|
@@ -582007,6 +582200,10 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
582007
582200
|
}, delayMs);
|
|
582008
582201
|
}
|
|
582009
582202
|
let activeTask = null;
|
|
582203
|
+
const setActiveTaskContextWindowSize = (size) => {
|
|
582204
|
+
const runner = activeTask?.runner;
|
|
582205
|
+
if (runner) runner.setContextWindowSize(size);
|
|
582206
|
+
};
|
|
582010
582207
|
let messageQueue = [];
|
|
582011
582208
|
let carouselRetired = isResumed;
|
|
582012
582209
|
let lastSubmittedPrompt = "";
|
|
@@ -582408,6 +582605,17 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
582408
582605
|
} catch {
|
|
582409
582606
|
}
|
|
582410
582607
|
}
|
|
582608
|
+
if (currentConfig.backendType === "ollama" && currentConfig.model.startsWith("open-agents-")) {
|
|
582609
|
+
try {
|
|
582610
|
+
const expandedCtxSize = await queryContextSize(currentConfig.backendUrl, currentConfig.model, currentConfig.apiKey);
|
|
582611
|
+
if (expandedCtxSize) {
|
|
582612
|
+
resolvedContextWindowSize = expandedCtxSize;
|
|
582613
|
+
statusBar.setContextWindowSize(expandedCtxSize);
|
|
582614
|
+
setActiveTaskContextWindowSize(expandedCtxSize);
|
|
582615
|
+
}
|
|
582616
|
+
} catch {
|
|
582617
|
+
}
|
|
582618
|
+
}
|
|
582411
582619
|
if (!isResumed) {
|
|
582412
582620
|
try {
|
|
582413
582621
|
const baseUrl = normalizeBaseUrl(currentConfig.backendUrl);
|
|
@@ -582678,6 +582886,9 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
582678
582886
|
});
|
|
582679
582887
|
setupTasks.push(startupChecksPromise.catch(() => {
|
|
582680
582888
|
}));
|
|
582889
|
+
startupChecksPromise.finally(() => {
|
|
582890
|
+
startExpandedVariantRepairSweep(currentConfig.backendType, currentConfig.backendUrl);
|
|
582891
|
+
});
|
|
582681
582892
|
Promise.resolve().then(() => (init_daemon(), daemon_exports)).then(async ({ ensureDaemon: ensureDaemon2, isDaemonRunning: isDaemonRunning2 }) => {
|
|
582682
582893
|
const apiPort = parseInt(process.env["OA_PORT"] || "11435", 10);
|
|
582683
582894
|
if (await isDaemonRunning2(apiPort)) {
|
|
@@ -582871,6 +583082,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
582871
583082
|
} else {
|
|
582872
583083
|
statusBar.stopRemoteMetricsPolling();
|
|
582873
583084
|
}
|
|
583085
|
+
startExpandedVariantRepairSweep(backendType, url);
|
|
582874
583086
|
},
|
|
582875
583087
|
setKeyPool(keys) {
|
|
582876
583088
|
if (activeTask) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-agents-ai",
|
|
3
|
-
"version": "0.187.
|
|
3
|
+
"version": "0.187.395",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "open-agents-ai",
|
|
9
|
-
"version": "0.187.
|
|
9
|
+
"version": "0.187.395",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "CC-BY-NC-4.0",
|
|
12
12
|
"dependencies": {
|
package/package.json
CHANGED