omnius 1.0.223 → 1.0.225
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 +504 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -560040,6 +560040,15 @@ var init_agenticRunner = __esm({
|
|
|
560040
560040
|
_fileWritesThisRun = 0;
|
|
560041
560041
|
_backwardPassCyclesUsed = 0;
|
|
560042
560042
|
_lastBackwardPassVerdict = null;
|
|
560043
|
+
// REG-54: completion-gate anti-collapse circuit breaker. The no-progress and
|
|
560044
|
+
// completion-provenance gates can hold task_complete indefinitely. When a
|
|
560045
|
+
// collapsed/weak model resubmits the same (or a similar) completion summary,
|
|
560046
|
+
// the gate rejects it every turn and the model re-emits the identical
|
|
560047
|
+
// task_complete forever — a mode-collapse loop. Unlike the backward-pass
|
|
560048
|
+
// critic (REG-47), these gates had no cycle bound. We track consecutive holds
|
|
560049
|
+
// of the same summary and fail open after a small threshold so the run
|
|
560050
|
+
// terminates instead of spinning. Reset whenever a completion is allowed.
|
|
560051
|
+
_completionHoldState = { count: 0, lastKey: "" };
|
|
560043
560052
|
// ── WO-AM-01/04/10: Associative memory stores ──
|
|
560044
560053
|
// Episode store: every tool call → persistent episode with importance + decay
|
|
560045
560054
|
// Temporal KG: entities + relations with temporal validity (valid_from/valid_until)
|
|
@@ -564982,6 +564991,52 @@ TASK: ${scrubbedTask}` : scrubbedTask;
|
|
|
564982
564991
|
});
|
|
564983
564992
|
return true;
|
|
564984
564993
|
};
|
|
564994
|
+
const completionHoldEscapeMax = (() => {
|
|
564995
|
+
const raw = Number(process.env["OMNIUS_COMPLETION_HOLD_MAX"]);
|
|
564996
|
+
return Number.isFinite(raw) && raw >= 1 ? Math.floor(raw) : 3;
|
|
564997
|
+
})();
|
|
564998
|
+
const holdTaskCompleteGates = (args, turn) => {
|
|
564999
|
+
const held = holdNoProgressTaskComplete(args, turn) || holdProvenanceTaskComplete(args, turn);
|
|
565000
|
+
if (!held) {
|
|
565001
|
+
this._completionHoldState.count = 0;
|
|
565002
|
+
this._completionHoldState.lastKey = "";
|
|
565003
|
+
return false;
|
|
565004
|
+
}
|
|
565005
|
+
const key = (extractTaskCompleteSummary(args) || "").trim().slice(0, 200);
|
|
565006
|
+
if (key && key === this._completionHoldState.lastKey) {
|
|
565007
|
+
this._completionHoldState.count += 1;
|
|
565008
|
+
} else {
|
|
565009
|
+
this._completionHoldState.lastKey = key;
|
|
565010
|
+
this._completionHoldState.count = 1;
|
|
565011
|
+
}
|
|
565012
|
+
if (this._completionHoldState.count >= completionHoldEscapeMax) {
|
|
565013
|
+
messages2.push({
|
|
565014
|
+
role: "system",
|
|
565015
|
+
content: `[COMPLETION GATE ESCAPE] task_complete was held ${this._completionHoldState.count} times for the same summary without new progress. The gate feedback above is not being acted on, so completion is now ALLOWED to avoid a stall/mode-collapse loop. If the summary lacks evidence, that limitation stands in the final result.`
|
|
565016
|
+
});
|
|
565017
|
+
this.emit({
|
|
565018
|
+
type: "status",
|
|
565019
|
+
content: `completion gates yielding after ${this._completionHoldState.count} repeated holds to prevent a mode-collapse loop`,
|
|
565020
|
+
turn,
|
|
565021
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
565022
|
+
});
|
|
565023
|
+
this.emit({
|
|
565024
|
+
type: "adversary_reaction",
|
|
565025
|
+
adversary: {
|
|
565026
|
+
class: "guidance",
|
|
565027
|
+
shortText: "Completion gate escape (anti-loop)",
|
|
565028
|
+
confidence: 0.9,
|
|
565029
|
+
details: `Same task_complete summary held ${this._completionHoldState.count}× — failing open to terminate the run.`
|
|
565030
|
+
},
|
|
565031
|
+
turn,
|
|
565032
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
565033
|
+
});
|
|
565034
|
+
this._completionHoldState.count = 0;
|
|
565035
|
+
this._completionHoldState.lastKey = "";
|
|
565036
|
+
return false;
|
|
565037
|
+
}
|
|
565038
|
+
return true;
|
|
565039
|
+
};
|
|
564985
565040
|
const emitBackwardPassAdvisory = (feedback, turn) => {
|
|
564986
565041
|
messages2.push({
|
|
564987
565042
|
role: "system",
|
|
@@ -568543,7 +568598,7 @@ ${sr.result.output}`;
|
|
|
568543
568598
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
568544
568599
|
});
|
|
568545
568600
|
} else {
|
|
568546
|
-
if (
|
|
568601
|
+
if (holdTaskCompleteGates(matchTc.arguments, turn)) {
|
|
568547
568602
|
continue;
|
|
568548
568603
|
}
|
|
568549
568604
|
const _bp1 = await this._runBackwardPassReview(turn);
|
|
@@ -568598,7 +568653,7 @@ ${sr.result.output}`;
|
|
|
568598
568653
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
568599
568654
|
});
|
|
568600
568655
|
} else {
|
|
568601
|
-
if (
|
|
568656
|
+
if (holdTaskCompleteGates(r2.tc.arguments, turn)) {
|
|
568602
568657
|
continue;
|
|
568603
568658
|
}
|
|
568604
568659
|
const _bp2 = await this._runBackwardPassReview(turn);
|
|
@@ -568690,7 +568745,7 @@ ${sr.result.output}`;
|
|
|
568690
568745
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
568691
568746
|
});
|
|
568692
568747
|
} else {
|
|
568693
|
-
if (
|
|
568748
|
+
if (holdTaskCompleteGates(r2.tc.arguments, turn)) {
|
|
568694
568749
|
continue;
|
|
568695
568750
|
}
|
|
568696
568751
|
const _bp3 = await this._runBackwardPassReview(turn);
|
|
@@ -568911,7 +568966,7 @@ Call task_complete(summary="...") NOW with whatever you have.`
|
|
|
568911
568966
|
const adversaryAddedGuidance = this.pendingUserMessages.length > pendingBeforeAdversary;
|
|
568912
568967
|
if (/task.?complete|all tests pass/i.test(content)) {
|
|
568913
568968
|
const completionArgs = { summary: content };
|
|
568914
|
-
if (
|
|
568969
|
+
if (holdTaskCompleteGates(completionArgs, turn)) {
|
|
568915
568970
|
continue;
|
|
568916
568971
|
}
|
|
568917
568972
|
completed = true;
|
|
@@ -569482,7 +569537,7 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
|
|
|
569482
569537
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
569483
569538
|
});
|
|
569484
569539
|
} else {
|
|
569485
|
-
if (
|
|
569540
|
+
if (holdTaskCompleteGates(tc.arguments, turn)) {
|
|
569486
569541
|
continue;
|
|
569487
569542
|
}
|
|
569488
569543
|
const _bp4 = await this._runBackwardPassReview(turn);
|
|
@@ -569535,7 +569590,7 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
|
|
|
569535
569590
|
});
|
|
569536
569591
|
} else {
|
|
569537
569592
|
const completionArgs = { summary: content };
|
|
569538
|
-
if (
|
|
569593
|
+
if (holdTaskCompleteGates(completionArgs, turn)) {
|
|
569539
569594
|
continue;
|
|
569540
569595
|
}
|
|
569541
569596
|
completed = true;
|
|
@@ -585609,6 +585664,10 @@ var init_command_registry = __esm({
|
|
|
585609
585664
|
["/telegram enable", "Re-enable Telegram long polling"],
|
|
585610
585665
|
["/telegram mode auto|chat|action", "Set Telegram interaction routing: auto, fast chat, or action sub-agent"],
|
|
585611
585666
|
["/telegram subagents <1-5>", "Set global Telegram work-slot limit across all chats/groups"],
|
|
585667
|
+
["/telegram model", "Pick the Telegram-isolated model (model list from the Telegram endpoint)"],
|
|
585668
|
+
["/telegram model <name|reset>", "Set or clear the Telegram-isolated model (separate from main agent)"],
|
|
585669
|
+
["/telegram endpoint", "Pick the Telegram-isolated backend endpoint (same menu as /endpoint, bot-scoped)"],
|
|
585670
|
+
["/telegram endpoint <url|reset> [--auth <t>]", "Set or clear the Telegram-isolated endpoint"],
|
|
585612
585671
|
["/telegram auth", "Show a TUI-only one-time code for Telegram admin authentication"],
|
|
585613
585672
|
["/telegram auth cancel", "Cancel the pending Telegram admin authentication code"],
|
|
585614
585673
|
["/telegram bot <username> <text>", "Send a Bot API bot-to-bot message by @username"],
|
|
@@ -611568,6 +611627,298 @@ var init_sponsor_wizard = __esm({
|
|
|
611568
611627
|
}
|
|
611569
611628
|
});
|
|
611570
611629
|
|
|
611630
|
+
// packages/cli/src/tui/telegram-inference.ts
|
|
611631
|
+
var telegram_inference_exports = {};
|
|
611632
|
+
__export(telegram_inference_exports, {
|
|
611633
|
+
handleTelegramEndpoint: () => handleTelegramEndpoint,
|
|
611634
|
+
showTelegramModelPicker: () => showTelegramModelPicker
|
|
611635
|
+
});
|
|
611636
|
+
function effectiveConfig(ctx3) {
|
|
611637
|
+
return ctx3.telegramGetEffectiveConfig?.();
|
|
611638
|
+
}
|
|
611639
|
+
async function showTelegramModelPicker(arg, ctx3, local = false) {
|
|
611640
|
+
const trimmed = arg.trim();
|
|
611641
|
+
if (/^(reset|main|default|clear|off)$/i.test(trimmed)) {
|
|
611642
|
+
ctx3.telegramApplyInference?.({ model: "" });
|
|
611643
|
+
ctx3.telegramSaveInference?.({ model: null, local });
|
|
611644
|
+
renderInfo("Telegram model override cleared — using the main agent model.");
|
|
611645
|
+
return;
|
|
611646
|
+
}
|
|
611647
|
+
const config = effectiveConfig(ctx3);
|
|
611648
|
+
if (!config) {
|
|
611649
|
+
renderError("Telegram inference context unavailable.");
|
|
611650
|
+
return;
|
|
611651
|
+
}
|
|
611652
|
+
if (trimmed) {
|
|
611653
|
+
await switchTelegramModel(trimmed, config, ctx3, local);
|
|
611654
|
+
return;
|
|
611655
|
+
}
|
|
611656
|
+
renderInfo(`Loading models from Telegram endpoint ${c3.dim(config.backendUrl)}...`);
|
|
611657
|
+
try {
|
|
611658
|
+
const fetchPromise = fetchModels(config.backendUrl, config.apiKey);
|
|
611659
|
+
const timeoutPromise = new Promise(
|
|
611660
|
+
(_, reject) => setTimeout(
|
|
611661
|
+
() => reject(
|
|
611662
|
+
new Error(
|
|
611663
|
+
`Timed out fetching models from ${config.backendUrl} (10s). The Telegram endpoint may be down. Use /telegram endpoint to switch.`
|
|
611664
|
+
)
|
|
611665
|
+
),
|
|
611666
|
+
1e4
|
|
611667
|
+
)
|
|
611668
|
+
);
|
|
611669
|
+
const models = await Promise.race([fetchPromise, timeoutPromise]);
|
|
611670
|
+
if (models.length === 0) {
|
|
611671
|
+
renderWarning("No models found on the Telegram endpoint.");
|
|
611672
|
+
return;
|
|
611673
|
+
}
|
|
611674
|
+
const items = [];
|
|
611675
|
+
const override = ctx3.telegramGetInferenceOverride?.() ?? {};
|
|
611676
|
+
if (!override.model) {
|
|
611677
|
+
items.push({
|
|
611678
|
+
key: "__use_main__",
|
|
611679
|
+
label: `${c3.cyan("↺")} Use main agent model`,
|
|
611680
|
+
detail: `Currently inheriting ${c3.dim(config.model)}`
|
|
611681
|
+
});
|
|
611682
|
+
} else {
|
|
611683
|
+
items.push({
|
|
611684
|
+
key: "__use_main__",
|
|
611685
|
+
label: `${c3.cyan("↺")} Use main agent model`,
|
|
611686
|
+
detail: "Clear the Telegram model override"
|
|
611687
|
+
});
|
|
611688
|
+
}
|
|
611689
|
+
for (const m2 of models) {
|
|
611690
|
+
const ctxLabel = m2.contextLength ? formatContextLength(m2.contextLength) : "";
|
|
611691
|
+
const capStr = m2.caps ? formatCaps(m2.caps) : "";
|
|
611692
|
+
items.push({
|
|
611693
|
+
key: m2.name,
|
|
611694
|
+
label: m2.name,
|
|
611695
|
+
detail: [m2.parameterSize, ctxLabel, capStr, m2.modified].filter(Boolean).join(" ")
|
|
611696
|
+
});
|
|
611697
|
+
}
|
|
611698
|
+
const result = await tuiSelect({
|
|
611699
|
+
items,
|
|
611700
|
+
activeKey: override.model ? stripLatest(override.model) : "__use_main__",
|
|
611701
|
+
title: "Select Telegram Model",
|
|
611702
|
+
rl: ctx3.rl,
|
|
611703
|
+
skipKeys: [],
|
|
611704
|
+
availableRows: ctx3.availableContentRows?.()
|
|
611705
|
+
});
|
|
611706
|
+
if (!result.confirmed || !result.key) {
|
|
611707
|
+
renderInfo("Telegram model selection cancelled.");
|
|
611708
|
+
return;
|
|
611709
|
+
}
|
|
611710
|
+
if (result.key === "__use_main__") {
|
|
611711
|
+
ctx3.telegramApplyInference?.({ model: "" });
|
|
611712
|
+
ctx3.telegramSaveInference?.({ model: null, local });
|
|
611713
|
+
renderInfo("Telegram model override cleared — using the main agent model.");
|
|
611714
|
+
return;
|
|
611715
|
+
}
|
|
611716
|
+
await switchTelegramModel(stripLatest(result.key), config, ctx3, local);
|
|
611717
|
+
} catch (err) {
|
|
611718
|
+
renderError(`Failed to fetch Telegram models: ${err instanceof Error ? err.message : String(err)}`);
|
|
611719
|
+
}
|
|
611720
|
+
}
|
|
611721
|
+
async function switchTelegramModel(query, config, ctx3, local) {
|
|
611722
|
+
let finalModel = query;
|
|
611723
|
+
try {
|
|
611724
|
+
const models = await fetchModels(config.backendUrl, config.apiKey);
|
|
611725
|
+
const match = findModel(models, query);
|
|
611726
|
+
if (match) {
|
|
611727
|
+
finalModel = match.name;
|
|
611728
|
+
} else {
|
|
611729
|
+
renderWarning(`Model "${query}" not found on the Telegram endpoint — setting it anyway.`);
|
|
611730
|
+
renderInfo("It may be pulled/available later, or pull it on that backend first.");
|
|
611731
|
+
}
|
|
611732
|
+
} catch {
|
|
611733
|
+
renderWarning("Could not verify the model against the Telegram endpoint — setting it anyway.");
|
|
611734
|
+
}
|
|
611735
|
+
ctx3.telegramApplyInference?.({ model: finalModel });
|
|
611736
|
+
ctx3.telegramSaveInference?.({ model: finalModel, local });
|
|
611737
|
+
recordUsage("model", finalModel, {
|
|
611738
|
+
repoRoot: local ? ctx3.repoRoot : void 0,
|
|
611739
|
+
local,
|
|
611740
|
+
meta: { endpoint: config.backendUrl }
|
|
611741
|
+
});
|
|
611742
|
+
renderInfo(
|
|
611743
|
+
`Telegram model set to ${c3.bold(finalModel)}${local ? " (project)" : ""} — isolated from the main agent.`
|
|
611744
|
+
);
|
|
611745
|
+
}
|
|
611746
|
+
async function handleTelegramEndpoint(arg, ctx3, local = false) {
|
|
611747
|
+
const trimmed = arg.trim();
|
|
611748
|
+
if (/^(reset|main|default|clear|stop|off)$/i.test(trimmed)) {
|
|
611749
|
+
ctx3.telegramApplyInference?.({ backendUrl: "", backendType: void 0, apiKey: "" });
|
|
611750
|
+
ctx3.telegramSaveInference?.({ backendUrl: null, backendType: null, apiKey: null, local });
|
|
611751
|
+
renderInfo("Telegram endpoint override cleared — using the main agent endpoint.");
|
|
611752
|
+
return;
|
|
611753
|
+
}
|
|
611754
|
+
if (!trimmed) {
|
|
611755
|
+
await showTelegramEndpointMenu(ctx3, local);
|
|
611756
|
+
return;
|
|
611757
|
+
}
|
|
611758
|
+
await setTelegramEndpoint(trimmed, ctx3, local);
|
|
611759
|
+
}
|
|
611760
|
+
async function showTelegramEndpointMenu(ctx3, local) {
|
|
611761
|
+
const config = effectiveConfig(ctx3);
|
|
611762
|
+
if (!config) {
|
|
611763
|
+
renderError("Telegram inference context unavailable.");
|
|
611764
|
+
return;
|
|
611765
|
+
}
|
|
611766
|
+
const override = ctx3.telegramGetInferenceOverride?.() ?? {};
|
|
611767
|
+
const history = loadUsageHistory("endpoint", ctx3.repoRoot);
|
|
611768
|
+
const items = [
|
|
611769
|
+
{
|
|
611770
|
+
key: "__use_main__",
|
|
611771
|
+
label: `${c3.cyan("↺")} Use main agent endpoint`,
|
|
611772
|
+
detail: override.backendUrl ? "Clear the Telegram endpoint override" : "Currently inheriting the main endpoint"
|
|
611773
|
+
}
|
|
611774
|
+
];
|
|
611775
|
+
for (const h of history) {
|
|
611776
|
+
const provider = h.meta?.provider ?? detectProvider(h.value).label;
|
|
611777
|
+
const uses = h.localUses > 0 ? `${h.useCount} uses (${h.localUses} local)` : `${h.useCount} uses`;
|
|
611778
|
+
const auth = h.meta?.authHint ? ` Auth: ${h.meta.authHint}` : "";
|
|
611779
|
+
items.push({ key: h.value, label: h.value, detail: `${provider} ${uses}${auth}` });
|
|
611780
|
+
}
|
|
611781
|
+
items.push({
|
|
611782
|
+
key: "__add__",
|
|
611783
|
+
label: `${c3.green("+")} Add endpoint`,
|
|
611784
|
+
detail: "Type a URL to add a new Telegram endpoint"
|
|
611785
|
+
});
|
|
611786
|
+
let addedEndpoint = null;
|
|
611787
|
+
const result = await tuiSelect({
|
|
611788
|
+
items,
|
|
611789
|
+
activeKey: override.backendUrl ? override.backendUrl : "__use_main__",
|
|
611790
|
+
title: "Select Telegram Endpoint",
|
|
611791
|
+
rl: ctx3.rl,
|
|
611792
|
+
availableRows: ctx3.availableContentRows?.(),
|
|
611793
|
+
onDelete: (item, done) => {
|
|
611794
|
+
if (item.key.startsWith("__")) {
|
|
611795
|
+
done(false);
|
|
611796
|
+
return;
|
|
611797
|
+
}
|
|
611798
|
+
deleteUsageRecord("endpoint", item.key, ctx3.repoRoot);
|
|
611799
|
+
done(true);
|
|
611800
|
+
},
|
|
611801
|
+
onEnter: (item, { getInput, resolve: resolve64 }) => {
|
|
611802
|
+
if (item.key === "__add__") {
|
|
611803
|
+
getInput("URL", "http://").then(async (url) => {
|
|
611804
|
+
if (!url || !url.trim()) return;
|
|
611805
|
+
const authKey = await getInput("Auth key (optional)", "");
|
|
611806
|
+
const authArg = authKey?.trim() ? ` --auth ${authKey.trim()}` : "";
|
|
611807
|
+
addedEndpoint = `${url.trim()}${authArg}`;
|
|
611808
|
+
resolve64({ confirmed: true, key: "__add__", index: -1 });
|
|
611809
|
+
});
|
|
611810
|
+
return true;
|
|
611811
|
+
}
|
|
611812
|
+
return false;
|
|
611813
|
+
}
|
|
611814
|
+
});
|
|
611815
|
+
if (!result.confirmed || !result.key) {
|
|
611816
|
+
renderInfo("Telegram endpoint selection cancelled.");
|
|
611817
|
+
return;
|
|
611818
|
+
}
|
|
611819
|
+
if (result.key === "__use_main__") {
|
|
611820
|
+
ctx3.telegramApplyInference?.({ backendUrl: "", backendType: void 0, apiKey: "" });
|
|
611821
|
+
ctx3.telegramSaveInference?.({ backendUrl: null, backendType: null, apiKey: null, local });
|
|
611822
|
+
renderInfo("Telegram endpoint override cleared — using the main agent endpoint.");
|
|
611823
|
+
return;
|
|
611824
|
+
}
|
|
611825
|
+
if (result.key === "__add__" && addedEndpoint) {
|
|
611826
|
+
await setTelegramEndpoint(addedEndpoint, ctx3, local);
|
|
611827
|
+
return;
|
|
611828
|
+
}
|
|
611829
|
+
const record = history.find((h) => h.value === result.key);
|
|
611830
|
+
const savedAuth = record?.meta?.authKey;
|
|
611831
|
+
await setTelegramEndpoint(savedAuth ? `${result.key} --auth ${savedAuth}` : result.key, ctx3, local);
|
|
611832
|
+
}
|
|
611833
|
+
async function setTelegramEndpoint(arg, ctx3, local) {
|
|
611834
|
+
const normalizedArg = arg.replace(/—/g, "--").replace(/–/g, "--");
|
|
611835
|
+
const parts = normalizedArg.split(/\s+/);
|
|
611836
|
+
const url = parts[0];
|
|
611837
|
+
let apiKey;
|
|
611838
|
+
const authIdx = parts.indexOf("--auth") !== -1 ? parts.indexOf("--auth") : parts.indexOf("-auth");
|
|
611839
|
+
if (authIdx !== -1 && parts[authIdx + 1]) apiKey = parts[authIdx + 1];
|
|
611840
|
+
try {
|
|
611841
|
+
new URL(url);
|
|
611842
|
+
} catch {
|
|
611843
|
+
renderError(`Invalid URL: "${url}"`);
|
|
611844
|
+
return;
|
|
611845
|
+
}
|
|
611846
|
+
const normalizedUrl = normalizeBaseUrl(url);
|
|
611847
|
+
const provider = detectProvider(url);
|
|
611848
|
+
const backendType = provider.id === "ollama" ? "ollama" : "vllm";
|
|
611849
|
+
process.stdout.write(`
|
|
611850
|
+
${c3.dim("Detected:")} ${c3.bold(provider.label)}
|
|
611851
|
+
`);
|
|
611852
|
+
process.stdout.write(` ${c3.dim("Testing connection...")} `);
|
|
611853
|
+
try {
|
|
611854
|
+
const headers = {};
|
|
611855
|
+
if (apiKey) {
|
|
611856
|
+
if (provider.id === "anthropic") {
|
|
611857
|
+
headers["x-api-key"] = apiKey;
|
|
611858
|
+
headers["anthropic-version"] = "2023-06-01";
|
|
611859
|
+
} else {
|
|
611860
|
+
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
611861
|
+
}
|
|
611862
|
+
}
|
|
611863
|
+
const resp = await fetch(`${normalizedUrl}${provider.modelsPath}`, {
|
|
611864
|
+
headers,
|
|
611865
|
+
signal: AbortSignal.timeout(1e4)
|
|
611866
|
+
});
|
|
611867
|
+
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
|
611868
|
+
process.stdout.write(`${c3.green("✔")} Connected
|
|
611869
|
+
`);
|
|
611870
|
+
} catch (err) {
|
|
611871
|
+
process.stdout.write(`${c3.yellow("⚠")} Could not verify
|
|
611872
|
+
`);
|
|
611873
|
+
renderWarning(`Endpoint may not be reachable: ${err instanceof Error ? err.message : String(err)}`);
|
|
611874
|
+
renderInfo("Setting the Telegram endpoint anyway — it may come online later.");
|
|
611875
|
+
}
|
|
611876
|
+
ctx3.telegramApplyInference?.({ backendUrl: normalizedUrl, backendType, apiKey: apiKey ?? "" });
|
|
611877
|
+
ctx3.telegramSaveInference?.({
|
|
611878
|
+
backendUrl: normalizedUrl,
|
|
611879
|
+
backendType,
|
|
611880
|
+
apiKey: apiKey ?? "",
|
|
611881
|
+
local
|
|
611882
|
+
});
|
|
611883
|
+
recordUsage("endpoint", normalizedUrl, {
|
|
611884
|
+
repoRoot: local ? ctx3.repoRoot : void 0,
|
|
611885
|
+
local,
|
|
611886
|
+
meta: {
|
|
611887
|
+
provider: provider.label,
|
|
611888
|
+
backendType,
|
|
611889
|
+
...apiKey ? { authHint: apiKey.slice(0, 4) + "...", authKey: apiKey } : {}
|
|
611890
|
+
}
|
|
611891
|
+
});
|
|
611892
|
+
process.stdout.write(`
|
|
611893
|
+
${c3.green("✔")} Telegram endpoint updated${local ? " (project)" : ""}:
|
|
611894
|
+
`);
|
|
611895
|
+
process.stdout.write(` ${c3.cyan("Provider".padEnd(12))} ${provider.label}
|
|
611896
|
+
`);
|
|
611897
|
+
process.stdout.write(` ${c3.cyan("URL".padEnd(12))} ${normalizedUrl}
|
|
611898
|
+
`);
|
|
611899
|
+
process.stdout.write(` ${c3.cyan("Type".padEnd(12))} ${backendType}
|
|
611900
|
+
`);
|
|
611901
|
+
process.stdout.write(
|
|
611902
|
+
` ${c3.cyan("Auth".padEnd(12))} ${apiKey ? `Bearer ${apiKey.slice(0, 4)}...` : "none"}
|
|
611903
|
+
`
|
|
611904
|
+
);
|
|
611905
|
+
process.stdout.write(
|
|
611906
|
+
` ${c3.dim("Isolated from the main agent. Set the model with /telegram model.")}
|
|
611907
|
+
|
|
611908
|
+
`
|
|
611909
|
+
);
|
|
611910
|
+
}
|
|
611911
|
+
var init_telegram_inference = __esm({
|
|
611912
|
+
"packages/cli/src/tui/telegram-inference.ts"() {
|
|
611913
|
+
"use strict";
|
|
611914
|
+
init_render();
|
|
611915
|
+
init_tui_select();
|
|
611916
|
+
init_model_picker();
|
|
611917
|
+
init_omnius_directory();
|
|
611918
|
+
init_dist();
|
|
611919
|
+
}
|
|
611920
|
+
});
|
|
611921
|
+
|
|
611571
611922
|
// packages/cli/src/tui/image-ascii-preview.ts
|
|
611572
611923
|
var image_ascii_preview_exports = {};
|
|
611573
611924
|
__export(image_ascii_preview_exports, {
|
|
@@ -621652,6 +622003,26 @@ sleep 1
|
|
|
621652
622003
|
);
|
|
621653
622004
|
return "handled";
|
|
621654
622005
|
}
|
|
622006
|
+
if (parts[0] === "model" || parts[0] === "models") {
|
|
622007
|
+
const hasGlobalFlagModel = parts.includes("--global");
|
|
622008
|
+
const projectRootTgModel = ctx3.repoRoot || process.cwd();
|
|
622009
|
+
const projectHasOmniusTgModel = existsSync117(join129(projectRootTgModel, ".omnius"));
|
|
622010
|
+
const wantsLocalTgModel = hasGlobalFlagModel ? false : isLocal || projectHasOmniusTgModel;
|
|
622011
|
+
const modelArg = parts.slice(1).filter((p2) => p2 !== "--global").join(" ");
|
|
622012
|
+
const { showTelegramModelPicker: showTelegramModelPicker2 } = await Promise.resolve().then(() => (init_telegram_inference(), telegram_inference_exports));
|
|
622013
|
+
await showTelegramModelPicker2(modelArg, ctx3, wantsLocalTgModel);
|
|
622014
|
+
return "handled";
|
|
622015
|
+
}
|
|
622016
|
+
if (parts[0] === "endpoint" || parts[0] === "ep") {
|
|
622017
|
+
const hasGlobalFlagEp = parts.includes("--global");
|
|
622018
|
+
const projectRootTgEp = ctx3.repoRoot || process.cwd();
|
|
622019
|
+
const projectHasOmniusTgEp = existsSync117(join129(projectRootTgEp, ".omnius"));
|
|
622020
|
+
const wantsLocalTgEp = hasGlobalFlagEp ? false : isLocal || projectHasOmniusTgEp;
|
|
622021
|
+
const epArg = parts.slice(1).filter((p2) => p2 !== "--global").join(" ");
|
|
622022
|
+
const { handleTelegramEndpoint: handleTelegramEndpoint2 } = await Promise.resolve().then(() => (init_telegram_inference(), telegram_inference_exports));
|
|
622023
|
+
await handleTelegramEndpoint2(epArg, ctx3, wantsLocalTgEp);
|
|
622024
|
+
return "handled";
|
|
622025
|
+
}
|
|
621655
622026
|
if (parts[0] === "auth" || parts[0] === "authenticate") {
|
|
621656
622027
|
if (parts[1] === "cancel") {
|
|
621657
622028
|
const cancelled = ctx3.telegramCancelAdminAuth?.() ?? false;
|
|
@@ -622035,6 +622406,8 @@ sleep 1
|
|
|
622035
622406
|
renderInfo(" /telegram status Show status");
|
|
622036
622407
|
renderInfo(" /telegram mode auto|chat|action Set interaction routing profile");
|
|
622037
622408
|
renderInfo(" /telegram subagents <1-5> Set global Telegram work-slot limit");
|
|
622409
|
+
renderInfo(" /telegram model [name|reset] Pick the Telegram-isolated model (separate from main agent)");
|
|
622410
|
+
renderInfo(" /telegram endpoint [url|reset] [--auth <key>] Pick the Telegram-isolated backend endpoint");
|
|
622038
622411
|
renderInfo(" /telegram auth Show one-time admin auth code");
|
|
622039
622412
|
renderInfo(" /telegram auth cancel Cancel pending admin auth code");
|
|
622040
622413
|
renderInfo(" /telegram bot <username> <text> Send bot-to-bot message");
|
|
@@ -644624,6 +644997,7 @@ Telegram link integrity contract:
|
|
|
644624
644997
|
this.telegramSqlitePath = resolve55(repoRoot || ".", ".omnius", "telegram.sqlite");
|
|
644625
644998
|
this.telegramToolButtonDir = resolve55(repoRoot || ".", ".omnius", "telegram-tool-buttons");
|
|
644626
644999
|
this.state.maxSubAgents = normalizeTelegramSubAgentLimit(resolveSettings(repoRoot || ".").telegramSubAgents);
|
|
645000
|
+
this.telegramBaseInferenceConfig = agentConfig ? { ...agentConfig } : void 0;
|
|
644627
645001
|
this.hydrateTelegramCommandMap(buildTelegramBotCommands({ scope: "admin" }));
|
|
644628
645002
|
}
|
|
644629
645003
|
botToken;
|
|
@@ -644636,6 +645010,15 @@ Telegram link integrity contract:
|
|
|
644636
645010
|
pollFatalNotified = false;
|
|
644637
645011
|
lastUpdateId = 0;
|
|
644638
645012
|
telegramRouterModelCache = null;
|
|
645013
|
+
/**
|
|
645014
|
+
* Snapshot of the main agent inference config captured at construction. The
|
|
645015
|
+
* effective `agentConfig` is this base overlaid with the Telegram-isolated
|
|
645016
|
+
* inference override (see {@link applyInferenceOverride}). Keeping the base
|
|
645017
|
+
* separate lets a later override that clears a field fall back to the main
|
|
645018
|
+
* value rather than to whatever the previous override left behind.
|
|
645019
|
+
*/
|
|
645020
|
+
telegramBaseInferenceConfig;
|
|
645021
|
+
telegramInferenceOverride = {};
|
|
644639
645022
|
state = {
|
|
644640
645023
|
active: false,
|
|
644641
645024
|
botUserId: void 0,
|
|
@@ -644838,6 +645221,45 @@ Telegram link integrity contract:
|
|
|
644838
645221
|
channelReflectionState = /* @__PURE__ */ new Map();
|
|
644839
645222
|
/** Public/group Telegram per-user quota buckets for expensive tools. */
|
|
644840
645223
|
telegramPublicQuotaBuckets = /* @__PURE__ */ new Map();
|
|
645224
|
+
/**
|
|
645225
|
+
* Apply a Telegram-isolated inference override on top of the main agent
|
|
645226
|
+
* config. The router, fast-chat completions, and action sub-agents spawned by
|
|
645227
|
+
* the bridge all read `this.agentConfig`, so overlaying here isolates the
|
|
645228
|
+
* Telegram bot's model/endpoint from the main TUI agent.
|
|
645229
|
+
*
|
|
645230
|
+
* Pass an empty string (or undefined) for a field to clear that override and
|
|
645231
|
+
* fall back to the main agent value. Returns the resulting effective config.
|
|
645232
|
+
*/
|
|
645233
|
+
applyInferenceOverride(override) {
|
|
645234
|
+
const next = { ...this.telegramInferenceOverride };
|
|
645235
|
+
for (const key of ["model", "backendUrl", "backendType", "apiKey"]) {
|
|
645236
|
+
if (key in override) {
|
|
645237
|
+
const value2 = override[key];
|
|
645238
|
+
if (value2 === void 0 || value2 === "") delete next[key];
|
|
645239
|
+
else next[key] = value2;
|
|
645240
|
+
}
|
|
645241
|
+
}
|
|
645242
|
+
this.telegramInferenceOverride = next;
|
|
645243
|
+
const base3 = this.telegramBaseInferenceConfig ?? this.agentConfig;
|
|
645244
|
+
if (!base3) return void 0;
|
|
645245
|
+
const effective = {
|
|
645246
|
+
...base3,
|
|
645247
|
+
...next.model ? { model: next.model } : {},
|
|
645248
|
+
...next.backendUrl ? { backendUrl: next.backendUrl } : {},
|
|
645249
|
+
...next.backendType ? { backendType: next.backendType } : {},
|
|
645250
|
+
// apiKey can legitimately be empty (no-auth endpoint). When the endpoint
|
|
645251
|
+
// is overridden we always take the override's apiKey (possibly "") so we
|
|
645252
|
+
// never leak the main endpoint's key to a different backend.
|
|
645253
|
+
...next.backendUrl !== void 0 ? { apiKey: next.apiKey ?? "" } : {}
|
|
645254
|
+
};
|
|
645255
|
+
this.agentConfig = effective;
|
|
645256
|
+
this.telegramRouterModelCache = null;
|
|
645257
|
+
return effective;
|
|
645258
|
+
}
|
|
645259
|
+
/** The Telegram-isolated inference override currently in effect (if any). */
|
|
645260
|
+
getInferenceOverride() {
|
|
645261
|
+
return { ...this.telegramInferenceOverride };
|
|
645262
|
+
}
|
|
644841
645263
|
/** Set admin user ID filter */
|
|
644842
645264
|
setAdmin(userId) {
|
|
644843
645265
|
this.adminUserId = userId;
|
|
@@ -688380,9 +688802,39 @@ Log: ${nexusLogPath}`)
|
|
|
688380
688802
|
admin: nonEmptyTelegramSetting(source.telegramAdmin),
|
|
688381
688803
|
mode,
|
|
688382
688804
|
subAgents,
|
|
688805
|
+
// Telegram-isolated inference override (falls back to main config when unset).
|
|
688806
|
+
model: nonEmptyTelegramSetting(source.telegramModel),
|
|
688807
|
+
backendUrl: nonEmptyTelegramSetting(source.telegramBackendUrl),
|
|
688808
|
+
backendType: nonEmptyTelegramSetting(source.telegramBackendType),
|
|
688809
|
+
apiKey: typeof source.telegramApiKey === "string" ? source.telegramApiKey : void 0,
|
|
688383
688810
|
keyScope: scope
|
|
688384
688811
|
};
|
|
688385
688812
|
};
|
|
688813
|
+
const telegramInferenceOverrideFromSettings = () => {
|
|
688814
|
+
const project = telegramSettingsForScope("project");
|
|
688815
|
+
const global2 = telegramSettingsForScope("global");
|
|
688816
|
+
const model = project.model ?? global2.model;
|
|
688817
|
+
const backendUrl2 = project.backendUrl ?? global2.backendUrl;
|
|
688818
|
+
const backendTypeRaw = project.backendType ?? global2.backendType;
|
|
688819
|
+
const apiKey = project.backendUrl ? project.apiKey : global2.backendUrl ? global2.apiKey : void 0;
|
|
688820
|
+
const backendType = backendTypeRaw === "ollama" || backendTypeRaw === "vllm" || backendTypeRaw === "fake" || backendTypeRaw === "nexus" ? backendTypeRaw : void 0;
|
|
688821
|
+
return {
|
|
688822
|
+
...model ? { model } : {},
|
|
688823
|
+
...backendUrl2 ? { backendUrl: backendUrl2 } : {},
|
|
688824
|
+
...backendType ? { backendType } : {},
|
|
688825
|
+
...backendUrl2 ? { apiKey: apiKey ?? "" } : {}
|
|
688826
|
+
};
|
|
688827
|
+
};
|
|
688828
|
+
const telegramEffectiveConfig = () => {
|
|
688829
|
+
const override = telegramInferenceOverrideFromSettings();
|
|
688830
|
+
return {
|
|
688831
|
+
...currentConfig,
|
|
688832
|
+
...override.model ? { model: override.model } : {},
|
|
688833
|
+
...override.backendUrl ? { backendUrl: override.backendUrl } : {},
|
|
688834
|
+
...override.backendType ? { backendType: override.backendType } : {},
|
|
688835
|
+
...override.backendUrl !== void 0 ? { apiKey: override.apiKey ?? "" } : {}
|
|
688836
|
+
};
|
|
688837
|
+
};
|
|
688386
688838
|
const commandCtx = {
|
|
688387
688839
|
get config() {
|
|
688388
688840
|
return currentConfig;
|
|
@@ -689018,6 +689470,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
689018
689470
|
telegramBridge.setInteractionMode(savedSettings.telegramMode ?? "auto");
|
|
689019
689471
|
telegramBridge.setSubAgentLimit(telegramSettingsForScope(scope).subAgents ?? 2);
|
|
689020
689472
|
telegramBridge.setTelegramToolPolicy(savedSettings.telegramToolPolicy);
|
|
689473
|
+
telegramBridge.applyInferenceOverride(telegramInferenceOverrideFromSettings());
|
|
689021
689474
|
telegramBridge.setMetricsProvider(() => statusBar?.getMetricsSnapshot());
|
|
689022
689475
|
if (adminId) {
|
|
689023
689476
|
telegramBridge.setAdmin(adminId);
|
|
@@ -689202,12 +689655,28 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
689202
689655
|
if (settings.subAgents !== void 0) {
|
|
689203
689656
|
target.telegramSubAgents = settings.subAgents;
|
|
689204
689657
|
}
|
|
689658
|
+
if (settings.model !== void 0) {
|
|
689659
|
+
target.telegramModel = settings.model === null ? "" : settings.model;
|
|
689660
|
+
}
|
|
689661
|
+
if (settings.backendUrl !== void 0) {
|
|
689662
|
+
target.telegramBackendUrl = settings.backendUrl === null ? "" : settings.backendUrl;
|
|
689663
|
+
}
|
|
689664
|
+
if (settings.backendType !== void 0) {
|
|
689665
|
+
target.telegramBackendType = settings.backendType === null ? "" : settings.backendType;
|
|
689666
|
+
}
|
|
689667
|
+
if (settings.apiKey !== void 0) {
|
|
689668
|
+
target.telegramApiKey = settings.apiKey === null ? "" : settings.apiKey;
|
|
689669
|
+
}
|
|
689205
689670
|
const payload = {
|
|
689206
689671
|
...settings.key !== void 0 ? { telegramKey: settings.key } : {},
|
|
689207
689672
|
...settings.enabled !== void 0 ? { telegramEnabled: settings.enabled } : {},
|
|
689208
689673
|
...settings.admin !== void 0 ? { telegramAdmin: settings.admin === null ? "" : settings.admin } : {},
|
|
689209
689674
|
...settings.mode !== void 0 ? { telegramMode: settings.mode } : {},
|
|
689210
|
-
...settings.subAgents !== void 0 ? { telegramSubAgents: settings.subAgents } : {}
|
|
689675
|
+
...settings.subAgents !== void 0 ? { telegramSubAgents: settings.subAgents } : {},
|
|
689676
|
+
...settings.model !== void 0 ? { telegramModel: settings.model === null ? "" : settings.model } : {},
|
|
689677
|
+
...settings.backendUrl !== void 0 ? { telegramBackendUrl: settings.backendUrl === null ? "" : settings.backendUrl } : {},
|
|
689678
|
+
...settings.backendType !== void 0 ? { telegramBackendType: settings.backendType === null ? "" : settings.backendType } : {},
|
|
689679
|
+
...settings.apiKey !== void 0 ? { telegramApiKey: settings.apiKey === null ? "" : settings.apiKey } : {}
|
|
689211
689680
|
};
|
|
689212
689681
|
if (targetScope === "project") {
|
|
689213
689682
|
saveProjectSettings(repoRoot, payload);
|
|
@@ -689241,6 +689710,18 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
689241
689710
|
savedSettings.telegramSubAgents = limit;
|
|
689242
689711
|
return telegramBridge?.setSubAgentLimit(limit) ?? Math.max(1, Math.min(5, Math.floor(limit)));
|
|
689243
689712
|
},
|
|
689713
|
+
telegramGetEffectiveConfig() {
|
|
689714
|
+
return telegramEffectiveConfig();
|
|
689715
|
+
},
|
|
689716
|
+
telegramGetInferenceOverride() {
|
|
689717
|
+
return telegramInferenceOverrideFromSettings();
|
|
689718
|
+
},
|
|
689719
|
+
telegramApplyInference(override) {
|
|
689720
|
+
telegramBridge?.applyInferenceOverride(override);
|
|
689721
|
+
},
|
|
689722
|
+
telegramSaveInference(override) {
|
|
689723
|
+
commandCtx.saveTelegramSettings?.(override);
|
|
689724
|
+
},
|
|
689244
689725
|
telegramStatus() {
|
|
689245
689726
|
const active = telegramBridge?.isActive ?? false;
|
|
689246
689727
|
const botUser = active ? telegramBridge?.botUsername : void 0;
|
|
@@ -689260,6 +689741,22 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
689260
689741
|
)
|
|
689261
689742
|
);
|
|
689262
689743
|
const effectiveTelegramSettings = telegramSettingsForScope(activeTelegramSettingsScope ?? "project");
|
|
689744
|
+
const tgOverride = telegramInferenceOverrideFromSettings();
|
|
689745
|
+
const tgEffective = telegramEffectiveConfig();
|
|
689746
|
+
if (tgOverride.model || tgOverride.backendUrl) {
|
|
689747
|
+
writeContent(() => {
|
|
689748
|
+
renderInfo(
|
|
689749
|
+
`Telegram model: ${tgOverride.model ?? `${tgEffective.model} (inherited)`}` + (tgOverride.model ? " (isolated)" : "")
|
|
689750
|
+
);
|
|
689751
|
+
renderInfo(
|
|
689752
|
+
`Telegram endpoint: ${tgOverride.backendUrl ?? `${tgEffective.backendUrl} (inherited)`}` + (tgOverride.backendUrl ? " (isolated)" : "")
|
|
689753
|
+
);
|
|
689754
|
+
});
|
|
689755
|
+
} else {
|
|
689756
|
+
writeContent(
|
|
689757
|
+
() => renderInfo("Telegram inference: inheriting main agent model/endpoint (set with /telegram model | /telegram endpoint).")
|
|
689758
|
+
);
|
|
689759
|
+
}
|
|
689263
689760
|
if (effectiveTelegramSettings.enabled === false || process.env["OMNIUS_TELEGRAM_DISABLED"] === "1") {
|
|
689264
689761
|
writeContent(() => renderInfo("Telegram polling is disabled; auto-start and manual start are blocked."));
|
|
689265
689762
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.225",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.225",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED