omnius 1.0.66 → 1.0.67

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 CHANGED
@@ -552883,6 +552883,11 @@ var init_sessionMetrics = __esm({
552883
552883
  toolCallsByName = {};
552884
552884
  inputTokens = 0;
552885
552885
  outputTokens = 0;
552886
+ latestEstimatedContextTokens = 0;
552887
+ peakEstimatedContextTokens = 0;
552888
+ measuredOutputTokens = 0;
552889
+ totalGenerationMs = 0;
552890
+ generationSamples = 0;
552886
552891
  filesModified = /* @__PURE__ */ new Set();
552887
552892
  tasks = [];
552888
552893
  currentTask = null;
@@ -552903,8 +552908,24 @@ var init_sessionMetrics = __esm({
552903
552908
  }
552904
552909
  /** Record token usage. */
552905
552910
  recordTokenUsage(inputTokens, outputTokens) {
552906
- this.inputTokens += inputTokens;
552907
- this.outputTokens += outputTokens;
552911
+ this.inputTokens += Math.max(0, Math.trunc(inputTokens || 0));
552912
+ this.outputTokens += Math.max(0, Math.trunc(outputTokens || 0));
552913
+ }
552914
+ /** Record the runner's latest context-token estimate. */
552915
+ recordContextEstimate(tokens) {
552916
+ const normalized = Math.max(0, Math.trunc(tokens || 0));
552917
+ this.latestEstimatedContextTokens = normalized;
552918
+ this.peakEstimatedContextTokens = Math.max(this.peakEstimatedContextTokens, normalized);
552919
+ }
552920
+ /** Record measured generation throughput for one response. */
552921
+ recordGeneration(outputTokens, durationMs) {
552922
+ const tokens = Math.max(0, Math.trunc(outputTokens || 0));
552923
+ const duration = Math.max(0, Math.trunc(durationMs || 0));
552924
+ if (tokens <= 0 || duration <= 0)
552925
+ return;
552926
+ this.measuredOutputTokens += tokens;
552927
+ this.totalGenerationMs += duration;
552928
+ this.generationSamples++;
552908
552929
  }
552909
552930
  /** Record a file modification. */
552910
552931
  recordFileModified(filePath) {
@@ -552912,6 +552933,9 @@ var init_sessionMetrics = __esm({
552912
552933
  }
552913
552934
  /** Start tracking a new task. */
552914
552935
  startTask(description) {
552936
+ if (this.currentTask) {
552937
+ this.endTask();
552938
+ }
552915
552939
  this.currentTask = {
552916
552940
  description,
552917
552941
  startTime: Date.now(),
@@ -552942,6 +552966,13 @@ var init_sessionMetrics = __esm({
552942
552966
  toolCallsByName: { ...this.toolCallsByName },
552943
552967
  totalInputTokens: this.inputTokens,
552944
552968
  totalOutputTokens: this.outputTokens,
552969
+ totalTokens: this.inputTokens + this.outputTokens,
552970
+ latestEstimatedContextTokens: this.latestEstimatedContextTokens,
552971
+ peakEstimatedContextTokens: this.peakEstimatedContextTokens,
552972
+ measuredOutputTokens: this.measuredOutputTokens,
552973
+ totalGenerationMs: this.totalGenerationMs,
552974
+ generationSamples: this.generationSamples,
552975
+ averageOutputTokensPerSecond: this.totalGenerationMs > 0 ? this.measuredOutputTokens / (this.totalGenerationMs / 1e3) : void 0,
552945
552976
  filesModified: [...this.filesModified],
552946
552977
  tasksCompleted: this.tasks.length,
552947
552978
  tasks: [...this.tasks],
@@ -560860,6 +560891,7 @@ function toTelegramBotCommandName(name10) {
560860
560891
  function buildTelegramBotCommands(opts = {}) {
560861
560892
  const maxCommands = Math.max(1, Math.min(100, opts.maxCommands ?? 100));
560862
560893
  const includeAuth = opts.includeAuth !== false;
560894
+ const scope = opts.scope ?? "admin";
560863
560895
  const commands = [];
560864
560896
  const seen = /* @__PURE__ */ new Set();
560865
560897
  const add2 = (command, description, canonical = command) => {
@@ -560872,6 +560904,14 @@ function buildTelegramBotCommands(opts = {}) {
560872
560904
  canonical
560873
560905
  });
560874
560906
  };
560907
+ if (scope === "public") {
560908
+ for (const cmd of TELEGRAM_PUBLIC_BOT_COMMANDS) {
560909
+ if (!includeAuth && cmd.command === "auth") continue;
560910
+ add2(cmd.command, cmd.description, cmd.canonical);
560911
+ if (commands.length >= maxCommands) break;
560912
+ }
560913
+ return commands.slice(0, maxCommands);
560914
+ }
560875
560915
  if (includeAuth) {
560876
560916
  add2("auth", "Authenticate this Telegram user as the bot admin", "auth");
560877
560917
  }
@@ -561071,7 +561111,7 @@ function inferArgsHint(signature) {
561071
561111
  function normalizeCommandName(name10) {
561072
561112
  return name10.replace(/^\//, "").trim().toLowerCase();
561073
561113
  }
561074
- var COMMAND_SIGNATURES, PLANNED_SIGNATURES, CATEGORY_OVERRIDES, ALIASES, USER_ONLY, DESTRUCTIVE, NETWORKED, SECRET_BEARING, PROFILE_GATED, SELF_MODIFY_ALLOWED, REST_BLOCKED, CANONICAL_BY_ALIAS, DYNAMIC_COMMANDS, SLASH_COMMANDS;
561114
+ var COMMAND_SIGNATURES, PLANNED_SIGNATURES, CATEGORY_OVERRIDES, ALIASES, USER_ONLY, DESTRUCTIVE, NETWORKED, SECRET_BEARING, PROFILE_GATED, SELF_MODIFY_ALLOWED, REST_BLOCKED, TELEGRAM_PUBLIC_BOT_COMMANDS, CANONICAL_BY_ALIAS, DYNAMIC_COMMANDS, SLASH_COMMANDS;
561075
561115
  var init_command_registry = __esm({
561076
561116
  "packages/cli/src/tui/command-registry.ts"() {
561077
561117
  "use strict";
@@ -561158,6 +561198,7 @@ var init_command_registry = __esm({
561158
561198
  ["/score", "Show inference capability scorecard (memory, compute, speed, models)"],
561159
561199
  ["/task-type", "Set task type (code, document, analysis, plan, general, auto)"],
561160
561200
  ["/stats", "Show session dashboard (metrics, tool usage, task history)"],
561201
+ ["/metrics", "Show runtime metrics: tokens, context window, throughput, and tool usage"],
561161
561202
  ["/sessions", "Browse saved sessions"],
561162
561203
  ["/pause", "Pause after current turn finishes (gentle halt, /resume to continue)"],
561163
561204
  ["/stop", "Kill current inference immediately and save state (/resume to continue)"],
@@ -561440,7 +561481,9 @@ var init_command_registry = __esm({
561440
561481
  selfmodify: "runtime",
561441
561482
  debug: "runtime",
561442
561483
  selfmod: "runtime",
561443
- "self-modify": "runtime"
561484
+ "self-modify": "runtime",
561485
+ stats: "session",
561486
+ metrics: "session"
561444
561487
  };
561445
561488
  ALIASES = {
561446
561489
  help: ["h", "?"],
@@ -561463,7 +561506,7 @@ var init_command_registry = __esm({
561463
561506
  evaluate: ["eval"],
561464
561507
  score: ["inference"],
561465
561508
  "task-type": ["tasktype", "tt"],
561466
- stats: ["metrics", "dashboard"],
561509
+ stats: ["dashboard"],
561467
561510
  memory: ["mem"],
561468
561511
  files: ["workspace"],
561469
561512
  skills: ["skill"],
@@ -561627,6 +561670,7 @@ var init_command_registry = __esm({
561627
561670
  "selfmodify",
561628
561671
  "debug",
561629
561672
  "stats",
561673
+ "metrics",
561630
561674
  "stream",
561631
561675
  "style",
561632
561676
  "task-type",
@@ -561646,6 +561690,20 @@ var init_command_registry = __esm({
561646
561690
  "bg",
561647
561691
  "paste"
561648
561692
  ]);
561693
+ TELEGRAM_PUBLIC_BOT_COMMANDS = [
561694
+ { command: "start", description: "Show Telegram bridge status", canonical: "start" },
561695
+ { command: "help", description: "Show available Telegram commands", canonical: "help" },
561696
+ { command: "commands", description: "Show available Telegram commands", canonical: "commands" },
561697
+ { command: "auth", description: "Authenticate this Telegram user as bot admin", canonical: "auth" },
561698
+ { command: "call", description: "Get or request the active voice call link", canonical: "call" },
561699
+ { command: "reflect", description: "Run scoped Telegram chat reflection", canonical: "reflect" },
561700
+ { command: "reflection", description: "Alias for scoped Telegram chat reflection", canonical: "reflect" },
561701
+ { command: "daydream", description: "Alias for scoped Telegram chat reflection", canonical: "reflect" },
561702
+ { command: "remind", description: "Set a scoped Telegram reminder", canonical: "remind" },
561703
+ { command: "reminder", description: "List or update scoped Telegram reminders", canonical: "reminder" },
561704
+ { command: "reminders", description: "Alias for scoped Telegram reminders", canonical: "reminder" },
561705
+ { command: "image", description: "Generate a scoped image from a prompt", canonical: "image" }
561706
+ ];
561649
561707
  CANONICAL_BY_ALIAS = /* @__PURE__ */ new Map();
561650
561708
  for (const [canonical, aliases] of Object.entries(ALIASES)) {
561651
561709
  for (const alias of aliases) CANONICAL_BY_ALIAS.set(alias, canonical);
@@ -589812,11 +589870,32 @@ async function handleSlashCommand(input, ctx3) {
589812
589870
  }
589813
589871
  const summary = ctx3.sessionMetrics.getSummary();
589814
589872
  const dur = SessionMetrics.formatDuration(summary.sessionDurationMs);
589873
+ const contextWindowSize = Math.max(0, Math.trunc(ctx3.getContextWindowSize?.() ?? 0));
589874
+ const contextLabel = contextWindowSize > 0 ? formatContextLength(contextWindowSize) : "unknown";
589875
+ const latestContextPct = contextWindowSize > 0 && summary.latestEstimatedContextTokens > 0 ? ` (${Math.round(summary.latestEstimatedContextTokens / contextWindowSize * 100)}%)` : "";
589876
+ const peakContextPct = contextWindowSize > 0 && summary.peakEstimatedContextTokens > 0 ? ` (${Math.round(summary.peakEstimatedContextTokens / contextWindowSize * 100)}%)` : "";
589877
+ const sessionSeconds = Math.max(1, summary.sessionDurationMs / 1e3);
589878
+ const measuredTokPerSec = summary.averageOutputTokensPerSecond;
589879
+ const sessionOutputTokPerSec = summary.totalOutputTokens / sessionSeconds;
589880
+ const avgInputPerTurn = summary.totalTurns > 0 ? summary.totalInputTokens / summary.totalTurns : 0;
589881
+ const avgOutputPerTurn = summary.totalTurns > 0 ? summary.totalOutputTokens / summary.totalTurns : 0;
589882
+ const avgToolsPerTurn = summary.totalTurns > 0 ? summary.totalToolCalls / summary.totalTurns : 0;
589815
589883
  const lines = [];
589816
589884
  lines.push(`
589817
- ${c3.bold("Session Dashboard")}
589885
+ ${c3.bold(cmd === "metrics" ? "Runtime Metrics" : "Session Dashboard")}
589818
589886
  `);
589819
589887
  lines.push(` Duration: ${c3.bold(dur)}`);
589888
+ lines.push(` Context window: ${c3.bold(contextLabel)}`);
589889
+ if (summary.latestEstimatedContextTokens > 0) {
589890
+ lines.push(
589891
+ ` Context now: ${c3.bold(`~${summary.latestEstimatedContextTokens.toLocaleString()}`)} tokens${latestContextPct}`
589892
+ );
589893
+ }
589894
+ if (summary.peakEstimatedContextTokens > 0) {
589895
+ lines.push(
589896
+ ` Context peak: ${c3.bold(`~${summary.peakEstimatedContextTokens.toLocaleString()}`)} tokens${peakContextPct}`
589897
+ );
589898
+ }
589820
589899
  lines.push(
589821
589900
  ` Tasks completed: ${c3.bold(String(summary.tasksCompleted))}`
589822
589901
  );
@@ -589828,6 +589907,18 @@ async function handleSlashCommand(input, ctx3) {
589828
589907
  lines.push(
589829
589908
  ` Output tokens: ${c3.bold(summary.totalOutputTokens.toLocaleString())}`
589830
589909
  );
589910
+ lines.push(
589911
+ ` Total tokens: ${c3.bold(summary.totalTokens.toLocaleString())}`
589912
+ );
589913
+ lines.push(
589914
+ ` Avg / turn: ${c3.bold(`${Math.round(avgInputPerTurn).toLocaleString()} in / ${Math.round(avgOutputPerTurn).toLocaleString()} out`)}`
589915
+ );
589916
+ lines.push(
589917
+ ` Tool / turn: ${c3.bold(avgToolsPerTurn.toFixed(2))}`
589918
+ );
589919
+ lines.push(
589920
+ measuredTokPerSec !== void 0 ? ` Output speed: ${c3.bold(`${measuredTokPerSec.toFixed(1)} tok/s`)} ${c3.dim(`(${summary.generationSamples} measured response${summary.generationSamples === 1 ? "" : "s"})`)}` : ` Output speed: ${c3.bold(`${sessionOutputTokPerSec.toFixed(1)} tok/s`)} ${c3.dim("session average")}`
589921
+ );
589831
589922
  if (ctx3.costTracker?.hasPricing) {
589832
589923
  lines.push(
589833
589924
  ` Estimated cost: ${c3.bold(c3.yellow(ctx3.costTracker.formatCost()))}`
@@ -610096,8 +610187,7 @@ function telegramSyntheticHelpSignatures() {
610096
610187
  function telegramHelpCommandAllowed(cmd, scope) {
610097
610188
  if (cmd.name === "dream") return false;
610098
610189
  if (scope === "admin") return cmd.implementationStatus === "implemented";
610099
- if (TELEGRAM_PUBLIC_HELP_COMMANDS.has(cmd.name)) return true;
610100
- return cmd.surfaces.agentTool && !cmd.safety.secretBearing && !cmd.safety.destructive && !cmd.safety.profileGated;
610190
+ return TELEGRAM_PUBLIC_HELP_COMMANDS.has(cmd.name) || TELEGRAM_PUBLIC_BOT_COMMAND_NAMES.has(cmd.name);
610101
610191
  }
610102
610192
  function buildTelegramHelpHTML(scope, maxPublicCommands = 24) {
610103
610193
  const commands = listCommandRegistry({ includePlanned: false }).filter((cmd) => telegramHelpCommandAllowed(cmd, scope));
@@ -610794,7 +610884,7 @@ function renderTelegramSubAgentError(username, error) {
610794
610884
  process.stdout.write(` ${c3.dim("│")} ${c3.red("✘")} @${username}: ${c3.dim(preview)}
610795
610885
  `);
610796
610886
  }
610797
- var TELEGRAM_TOOL_ACTION_GROUPS, TELEGRAM_TOOL_ACTION_GROUP, TELEGRAM_TOOL_MUTATING_GROUPS, DEFAULT_TELEGRAM_TOOL_GROUP_POLICY, TELEGRAM_TOOL_BUTTON_LABELS, TELEGRAM_SAFETY_PROMPT, ADMIN_DM_PROMPT, ADMIN_GROUP_PROMPT, TELEGRAM_PUBLIC_SOUL_PROFILE, TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT, TELEGRAM_PUBLIC_MEMORY_SCOPE_CONTRACT, TELEGRAM_PUBLIC_VISION_STACK_CONTRACT, GROUP_REPLY_DISCRETION_PROMPT, TELEGRAM_CHAT_MODE_PROMPT, ADMIN_CHAT_PROFILE_PROMPT, TELEGRAM_ACTION_RESPONSE_CONTRACT, TELEGRAM_EXTERNAL_ACQUISITION_CONTRACT, TELEGRAM_STUCK_SELF_TALK_PREFIXES, TELEGRAM_CHAT_HISTORY_LIMIT, TELEGRAM_CONTEXT_RECENT_DEFAULT, TELEGRAM_CONTEXT_LINE_LIMIT, TELEGRAM_CONTEXT_SAMPLE_LIMIT, TELEGRAM_MEMORY_CARD_LIMIT, TELEGRAM_MEMORY_NOTE_LIMIT, TELEGRAM_ASSOCIATIVE_FACT_LIMIT, TELEGRAM_ASSOCIATIVE_USER_FACT_LIMIT, TELEGRAM_ASSOCIATIVE_ACTION_LIMIT, TELEGRAM_ASSOCIATIVE_RELATION_LIMIT, TELEGRAM_MEMORY_STOPWORDS, TELEGRAM_SUB_AGENT_BOUNDED_OPTIONS, TELEGRAM_PUBLIC_HELP_COMMANDS, TELEGRAM_REMINDER_SLASH_COMMANDS, TELEGRAM_REFLECTION_SLASH_COMMANDS, TELEGRAM_IMAGE_EXTENSIONS, MEDIA_CACHE_TTL_MS, TELEGRAM_CHANNEL_DMN_SWEEP_MS, TELEGRAM_CHANNEL_DMN_IDLE_AFTER_MS, TELEGRAM_CHANNEL_DMN_MIN_INTERVAL_MS, TELEGRAM_CHANNEL_DMN_MIN_MESSAGES, TELEGRAM_PUBLIC_TOOL_QUOTAS, TelegramBridge;
610887
+ var TELEGRAM_TOOL_ACTION_GROUPS, TELEGRAM_TOOL_ACTION_GROUP, TELEGRAM_TOOL_MUTATING_GROUPS, DEFAULT_TELEGRAM_TOOL_GROUP_POLICY, TELEGRAM_TOOL_BUTTON_LABELS, TELEGRAM_SAFETY_PROMPT, ADMIN_DM_PROMPT, ADMIN_GROUP_PROMPT, TELEGRAM_PUBLIC_SOUL_PROFILE, TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT, TELEGRAM_PUBLIC_MEMORY_SCOPE_CONTRACT, TELEGRAM_PUBLIC_VISION_STACK_CONTRACT, GROUP_REPLY_DISCRETION_PROMPT, TELEGRAM_CHAT_MODE_PROMPT, ADMIN_CHAT_PROFILE_PROMPT, TELEGRAM_ACTION_RESPONSE_CONTRACT, TELEGRAM_EXTERNAL_ACQUISITION_CONTRACT, TELEGRAM_STUCK_SELF_TALK_PREFIXES, TELEGRAM_CHAT_HISTORY_LIMIT, TELEGRAM_CONTEXT_RECENT_DEFAULT, TELEGRAM_CONTEXT_LINE_LIMIT, TELEGRAM_CONTEXT_SAMPLE_LIMIT, TELEGRAM_MEMORY_CARD_LIMIT, TELEGRAM_MEMORY_NOTE_LIMIT, TELEGRAM_ASSOCIATIVE_FACT_LIMIT, TELEGRAM_ASSOCIATIVE_USER_FACT_LIMIT, TELEGRAM_ASSOCIATIVE_ACTION_LIMIT, TELEGRAM_ASSOCIATIVE_RELATION_LIMIT, TELEGRAM_MEMORY_STOPWORDS, TELEGRAM_SUB_AGENT_BOUNDED_OPTIONS, TELEGRAM_PUBLIC_HELP_COMMANDS, TELEGRAM_REMINDER_SLASH_COMMANDS, TELEGRAM_REFLECTION_SLASH_COMMANDS, TELEGRAM_PUBLIC_BOT_COMMAND_NAMES, TELEGRAM_IMAGE_EXTENSIONS, MEDIA_CACHE_TTL_MS, TELEGRAM_CHANNEL_DMN_SWEEP_MS, TELEGRAM_CHANNEL_DMN_IDLE_AFTER_MS, TELEGRAM_CHANNEL_DMN_MIN_INTERVAL_MS, TELEGRAM_CHANNEL_DMN_MIN_MESSAGES, TELEGRAM_PUBLIC_TOOL_QUOTAS, TelegramBridge;
610798
610888
  var init_telegram_bridge = __esm({
610799
610889
  "packages/cli/src/tui/telegram-bridge.ts"() {
610800
610890
  "use strict";
@@ -611126,6 +611216,9 @@ External acquisition contract:
611126
611216
  TELEGRAM_PUBLIC_HELP_COMMANDS = /* @__PURE__ */ new Set(["help", "start", "auth", "call"]);
611127
611217
  TELEGRAM_REMINDER_SLASH_COMMANDS = /* @__PURE__ */ new Set(["remind", "reminder", "reminders"]);
611128
611218
  TELEGRAM_REFLECTION_SLASH_COMMANDS = /* @__PURE__ */ new Set(["reflect", "reflection", "daydream", "dream"]);
611219
+ TELEGRAM_PUBLIC_BOT_COMMAND_NAMES = new Set(
611220
+ buildTelegramBotCommands({ scope: "public" }).map((cmd) => cmd.command)
611221
+ );
611129
611222
  TELEGRAM_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".gif", ".webp", ".bmp", ".tiff", ".tif", ".svg"]);
611130
611223
  MEDIA_CACHE_TTL_MS = 30 * 60 * 1e3;
611131
611224
  TELEGRAM_CHANNEL_DMN_SWEEP_MS = 2 * 60 * 1e3;
@@ -611153,6 +611246,7 @@ External acquisition contract:
611153
611246
  this.telegramConversationDir = resolve43(repoRoot || ".", ".omnius", "telegram-conversations");
611154
611247
  this.telegramSqlitePath = resolve43(repoRoot || ".", ".omnius", "telegram.sqlite");
611155
611248
  this.telegramToolButtonDir = resolve43(repoRoot || ".", ".omnius", "telegram-tool-buttons");
611249
+ this.hydrateTelegramCommandMap(buildTelegramBotCommands({ scope: "admin" }));
611156
611250
  }
611157
611251
  botToken;
611158
611252
  onMessage;
@@ -611381,6 +611475,9 @@ External acquisition contract:
611381
611475
  const botless = first2.startsWith("/") ? first2.slice(1).split("@")[0]?.toLowerCase() : "";
611382
611476
  return !!botless && this.telegramCommandMap.has(botless);
611383
611477
  }
611478
+ isPublicTelegramSlashName(name10) {
611479
+ return TELEGRAM_PUBLIC_BOT_COMMAND_NAMES.has(name10);
611480
+ }
611384
611481
  async handleTelegramReminderSlash(msg, commandText, context2) {
611385
611482
  if (!this.repoRoot) {
611386
611483
  await this.replyToTelegramMessage(msg, "Reminder storage is not available yet.");
@@ -614551,8 +614648,7 @@ Join: ${newUrl}`);
614551
614648
  return;
614552
614649
  }
614553
614650
  }
614554
- const publicCreativeSlash = telegramSlash === "image";
614555
- if (!isAdmin && msg.text.trim().startsWith("/") && this.isKnownTelegramSlash(normalizedCommandText) && !publicCreativeSlash) {
614651
+ if (!isAdmin && msg.text.trim().startsWith("/") && this.isKnownTelegramSlash(normalizedCommandText) && !this.isPublicTelegramSlashName(telegramSlash)) {
614556
614652
  await this.replyToTelegramMessage(
614557
614653
  msg,
614558
614654
  "That command requires Telegram admin authentication. Run /telegram auth in the TUI, then send /auth <code> here."
@@ -617905,21 +618001,45 @@ Content-Type: ${mimeForPath(pathOrFileId, field === "photo" ? "image" : "video")
617905
618001
  }
617906
618002
  return this.sendMessage(`@${clean5}`, text);
617907
618003
  }
617908
- async setMyCommands(commands) {
618004
+ hydrateTelegramCommandMap(commands) {
618005
+ for (const cmd of commands) {
618006
+ this.telegramCommandMap.set(cmd.command, cmd.canonical);
618007
+ }
618008
+ this.telegramCommandMap.set("auth", "auth");
618009
+ this.telegramCommandMap.set("start", "start");
618010
+ }
618011
+ async setMyCommands(commands, options2 = {}) {
617909
618012
  const apiCommands = commands.map((cmd) => ({
617910
618013
  command: cmd.command,
617911
618014
  description: cmd.description
617912
618015
  }));
617913
- const result = await this.apiCall("setMyCommands", { commands: apiCommands });
618016
+ const payload = { commands: apiCommands };
618017
+ if (options2.scope) payload["scope"] = options2.scope;
618018
+ if (options2.languageCode) payload["language_code"] = options2.languageCode;
618019
+ const result = await this.apiCall("setMyCommands", payload);
617914
618020
  if (result.ok) {
617915
- for (const cmd of commands) {
617916
- this.telegramCommandMap.set(cmd.command, cmd.canonical);
617917
- }
617918
- this.telegramCommandMap.set("auth", "auth");
617919
- this.telegramCommandMap.set("start", "start");
618021
+ this.hydrateTelegramCommandMap(commands);
617920
618022
  }
617921
618023
  return Boolean(result.ok);
617922
618024
  }
618025
+ async registerScopedMyCommands(adminUserId = this.adminUserId) {
618026
+ const publicCommands = buildTelegramBotCommands({ scope: "public" });
618027
+ const adminCommands = buildTelegramBotCommands({ scope: "admin" });
618028
+ this.hydrateTelegramCommandMap([...publicCommands, ...adminCommands]);
618029
+ const publicOk = await this.setMyCommands(publicCommands, { scope: { type: "default" } });
618030
+ const adminId = adminUserId?.trim();
618031
+ if (!adminId || !/^\d+$/.test(adminId)) {
618032
+ return publicOk;
618033
+ }
618034
+ const adminChatId = Number(adminId);
618035
+ if (!Number.isSafeInteger(adminChatId)) {
618036
+ return publicOk;
618037
+ }
618038
+ const adminOk = await this.setMyCommands(adminCommands, {
618039
+ scope: { type: "chat", chat_id: adminChatId }
618040
+ });
618041
+ return publicOk && adminOk;
618042
+ }
617923
618043
  async getMyCommands() {
617924
618044
  const result = await this.apiCall("getMyCommands");
617925
618045
  return Array.isArray(result.result) ? result.result : [];
@@ -644249,7 +644369,7 @@ async function runSelfImprovementCycle(repoRoot) {
644249
644369
  } catch {
644250
644370
  }
644251
644371
  }
644252
- function startTask(task, config, repoRoot, voice, stream, taskStores, bruteForce, statusBar, sudoCallback, costTracker, onComplete, taskType, contextWindowSize, modelCaps, personality, deepContext, onCompaction, emotionEngine, flowEnabled, slashCommandHandler, thinkingEnabled, askUserCallback, selfModifyEnabled) {
644372
+ function startTask(task, config, repoRoot, voice, stream, taskStores, bruteForce, statusBar, sudoCallback, costTracker, onComplete, taskType, contextWindowSize, modelCaps, personality, deepContext, onCompaction, emotionEngine, flowEnabled, slashCommandHandler, thinkingEnabled, askUserCallback, selfModifyEnabled, sessionMetrics) {
644253
644373
  const voiceStyleMap = {
644254
644374
  concise: 1,
644255
644375
  balanced: 3,
@@ -644271,6 +644391,9 @@ function startTask(task, config, repoRoot, voice, stream, taskStores, bruteForce
644271
644391
  }
644272
644392
  const modelTier = getModelTier(config.model);
644273
644393
  const sessionId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
644394
+ const taskMetricDescription = cleanForStorage(task).replace(/\s+/g, " ").slice(0, 160) || "task";
644395
+ costTracker?.startTask(taskMetricDescription);
644396
+ sessionMetrics?.startTask(taskMetricDescription);
644274
644397
  const projectCtx = buildProjectContext(repoRoot, taskStores?.contextStores);
644275
644398
  let dynamicContext = formatContextForPrompt(projectCtx, modelTier);
644276
644399
  try {
@@ -645230,6 +645353,7 @@ ${entry.fullContent}`
645230
645353
  let lastToolCall = null;
645231
645354
  let toolCallStartMs = 0;
645232
645355
  let streamStartMs = 0;
645356
+ let lastStreamDurationMs = 0;
645233
645357
  let streamTextBuffer = "";
645234
645358
  let lastAssistantText = "";
645235
645359
  let lastProvenancePath = null;
@@ -645291,6 +645415,9 @@ ${entry.fullContent}`
645291
645415
  case "tool_call":
645292
645416
  if (_apiCallbacks?.onToolCall)
645293
645417
  _apiCallbacks.onToolCall(event.toolName ?? "unknown", event.toolArgs);
645418
+ if (event.toolName && event.toolName !== "task_complete") {
645419
+ sessionMetrics?.recordToolCall(event.toolName);
645420
+ }
645294
645421
  toolSequence.push({
645295
645422
  tool: event.toolName ?? "unknown",
645296
645423
  argKeys: Object.keys(event.toolArgs ?? {})
@@ -645312,6 +645439,7 @@ ${entry.fullContent}`
645312
645439
  const name10 = event.toolName ?? "";
645313
645440
  if (name10 === "file_write" || name10 === "file_edit" || name10 === "file_patch" || name10 === "batch_edit") {
645314
645441
  filesTouched.add(event.toolArgs.path);
645442
+ sessionMetrics?.recordFileModified(event.toolArgs.path);
645315
645443
  if (isNeovimActive()) {
645316
645444
  notifyNeovimFileChange(event.toolArgs.path).catch(
645317
645445
  () => {
@@ -645540,6 +645668,7 @@ ${entry.fullContent}`
645540
645668
  break;
645541
645669
  case "stream_end": {
645542
645670
  const streamDurationMs = streamStartMs > 0 ? Date.now() - streamStartMs : 0;
645671
+ lastStreamDurationMs = streamDurationMs;
645543
645672
  streamStartMs = 0;
645544
645673
  if (isNeovimActive()) {
645545
645674
  writeToNeovimOutput("\r\n");
@@ -645618,17 +645747,28 @@ ${entry.fullContent}`
645618
645747
  }
645619
645748
  break;
645620
645749
  case "token_usage":
645621
- if (statusBar && event.tokenUsage) {
645750
+ if (event.tokenUsage) {
645751
+ sessionMetrics?.recordTurn();
645622
645752
  const lastPromptTokens = event.tokenUsage.lastPromptTokens ?? event.tokenUsage.promptTokens;
645623
645753
  const lastCompletionTokens = event.tokenUsage.lastCompletionTokens ?? event.tokenUsage.completionTokens;
645754
+ if (lastPromptTokens > 0 || lastCompletionTokens > 0) {
645755
+ sessionMetrics?.recordTokenUsage(lastPromptTokens, lastCompletionTokens);
645756
+ }
645757
+ sessionMetrics?.recordContextEstimate(event.tokenUsage.estimatedContextTokens);
645758
+ if (lastCompletionTokens > 0 && lastStreamDurationMs > 0) {
645759
+ sessionMetrics?.recordGeneration(lastCompletionTokens, lastStreamDurationMs);
645760
+ lastStreamDurationMs = 0;
645761
+ }
645624
645762
  if (costTracker && (lastPromptTokens > 0 || lastCompletionTokens > 0)) {
645625
645763
  costTracker.trackTokens(lastPromptTokens, lastCompletionTokens);
645626
645764
  }
645627
- statusBar.updateMetrics({
645628
- ...event.tokenUsage,
645629
- estimatedCost: costTracker?.currentCost,
645630
- hasPricing: costTracker?.hasPricing
645631
- });
645765
+ if (statusBar) {
645766
+ statusBar.updateMetrics({
645767
+ ...event.tokenUsage,
645768
+ estimatedCost: costTracker?.currentCost,
645769
+ hasPricing: costTracker?.hasPricing
645770
+ });
645771
+ }
645632
645772
  if (config.verbose) {
645633
645773
  const tu = event.tokenUsage;
645634
645774
  const ctxPct = tu.estimatedContextTokens > 0 && statusBar ? ` (ctx: ~${tu.estimatedContextTokens.toLocaleString()} tokens)` : "";
@@ -645741,6 +645881,8 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
645741
645881
  total: result.totalTokens,
645742
645882
  estimated: result.estimatedTokens
645743
645883
  };
645884
+ costTracker?.endTask();
645885
+ sessionMetrics?.endTask();
645744
645886
  if (result.completed) {
645745
645887
  statusBar?.removeRecentContentMatchingText(result.summary);
645746
645888
  }
@@ -648959,7 +649101,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
648959
649101
  });
648960
649102
  await telegramBridge.start();
648961
649103
  statusBar.setTelegramStatus(true, telegramBridge.stats.activeSubAgents);
648962
- telegramBridge.setMyCommands(buildTelegramBotCommands()).catch((err) => {
649104
+ telegramBridge.registerScopedMyCommands(adminId).catch((err) => {
648963
649105
  writeContent(
648964
649106
  () => renderWarning(`Telegram command registration failed: ${err instanceof Error ? err.message : String(err)}`)
648965
649107
  );
@@ -649952,6 +650094,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
649952
650094
  statusBar.setContextWindowSize(size);
649953
650095
  telegramBridge?.setContextWindowSize(size);
649954
650096
  },
650097
+ getContextWindowSize: () => resolvedContextWindowSize,
649955
650098
  setCapabilities: (caps) => {
649956
650099
  resolvedCaps = caps;
649957
650100
  statusBar.setCapabilities(caps);
@@ -650649,7 +650792,8 @@ Execute this skill now. Follow the behavioral guidance above.`;
650649
650792
  buildSlashCommandHandler(),
650650
650793
  thinkingEnabled,
650651
650794
  handleAskUser,
650652
- selfModifyEnabled
650795
+ selfModifyEnabled,
650796
+ sessionMetrics
650653
650797
  );
650654
650798
  activeTask = task;
650655
650799
  setTerminalTitle(input.slice(0, 60), version4);
@@ -651077,7 +651221,8 @@ NEW TASK: ${fullInput}`;
651077
651221
  buildSlashCommandHandler(),
651078
651222
  thinkingEnabled,
651079
651223
  handleAskUser,
651080
- selfModifyEnabled
651224
+ selfModifyEnabled,
651225
+ sessionMetrics
651081
651226
  );
651082
651227
  activeTask = task;
651083
651228
  _recallText = null;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "omnius",
9
- "version": "1.0.66",
9
+ "version": "1.0.67",
10
10
  "bundleDependencies": [
11
11
  "image-to-ascii"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",