@blunking/codexlink 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -256,7 +256,13 @@ Allowed Chat ID(s) are no longer typed by hand. To pair a different chat or grou
256
256
  blun-codex telegram-setup
257
257
  ```
258
258
 
259
- If something is missing later, `blun-codex telegram-doctor` tells you exactly what is missing and what to run next.
259
+ If something is missing later, `blun-codex telegram-doctor` tells you exactly what is missing and what to run next.
260
+
261
+ Inbound Telegram messages are mirrored into the visible Codex console by default,
262
+ so the operator can see that the message arrived. Queue summaries and outbound
263
+ reply notices stay out of the console to avoid input-line spam. Set
264
+ `BLUN_TELEGRAM_CONSOLE_UI_NOTICES=off` to disable console mirroring, or `all` to
265
+ also mirror outbound notices for debugging.
260
266
 
261
267
  ## Notes
262
268
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blunking/codexlink",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "BLUN CLI launcher with Telegram channel support for one visible session.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -521,12 +521,17 @@ if ($useRemoteAppServer) {
521
521
  $codexArgs += $telegramAppServerWsUrl
522
522
  } else {
523
523
  $envFilePath = Join-Path $telegramStateDir ".env"
524
- $stateEnv = Read-DotEnvFile -Path $envFilePath
525
- $stateEnv["BLUN_TELEGRAM_AGENT_NAME"] = $profile.agent_name
526
- $stateEnv["BLUN_TELEGRAM_STATE_DIR"] = $telegramStateDir
527
- if ($telegramAllowedChatId) {
528
- $stateEnv["BLUN_TELEGRAM_ALLOWED_CHAT_ID"] = $telegramAllowedChatId
529
- }
524
+ $stateEnv = Read-DotEnvFile -Path $envFilePath
525
+ $stateEnv["BLUN_TELEGRAM_AGENT_NAME"] = $profile.agent_name
526
+ $stateEnv["BLUN_TELEGRAM_STATE_DIR"] = $telegramStateDir
527
+ $stateEnv["BLUN_CODEX_DISPLAY_NAME"] = $profile.display_name
528
+ $stateEnv["BLUN_CODEX_LANE"] = $profile.lane
529
+ $stateEnv["BLUN_CODEX_PERSONALITY"] = $profile.personality
530
+ $stateEnv["BLUN_CODEX_MODEL"] = $profile.model
531
+ $stateEnv["BLUN_CODEX_REASONING_EFFORT"] = $profile.reasoning_effort
532
+ if ($telegramAllowedChatId) {
533
+ $stateEnv["BLUN_TELEGRAM_ALLOWED_CHAT_ID"] = $telegramAllowedChatId
534
+ }
530
535
  $stateEnv["BLUN_TELEGRAM_PLUGIN_MODE"] = $TelegramMode
531
536
  $stateEnv["BLUN_TELEGRAM_APP_SERVER_WS_URL"] = $telegramAppServerWsUrl
532
537
  $stateEnv["BLUN_TELEGRAM_THREAD_ID"] = ""
@@ -1906,7 +1906,7 @@ async function sendOutboundChunks(config, state, options) {
1906
1906
  } else if (chatType === "private" && user) {
1907
1907
  label = `Antwort an ${user}`;
1908
1908
  }
1909
- state.lastUiNotice = {
1909
+ state.lastOutboundUiNotice = {
1910
1910
  ts: nowIso(),
1911
1911
  kind: "outbound",
1912
1912
  text: `${label}: ${preview}`
@@ -120,11 +120,28 @@ export function isAddressOnlyPing(config, text) {
120
120
  return names.includes(normalizedText);
121
121
  }
122
122
 
123
+ function buildAgentRuntimeContext(config) {
124
+ const name = repairMojibake(String(config.displayName || config.agentName || "CodexLink")).trim() || "CodexLink";
125
+ const lane = repairMojibake(String(config.lane || "")).trim();
126
+ const customPrompt = repairMojibake(String(config.agentPrompt || "")).trim();
127
+ const lines = [
128
+ `[CodexLink Agent Context: You are ${name}.`,
129
+ lane ? `Assigned lane: ${lane}. Stay inside this lane unless the user explicitly redirects you.` : "Stay inside your assigned profile scope.",
130
+ "Treat short greetings or name-only pings as reachability checks, not translation/correction tasks.",
131
+ "For a greeting, reply briefly and naturally as this agent. Do not ask whether to translate, correct, or rewrite unless the user asks for that."
132
+ ];
133
+ if (customPrompt) {
134
+ lines.push(customPrompt);
135
+ }
136
+ lines[lines.length - 1] = `${lines[lines.length - 1]}]`;
137
+ return lines.join("\n");
138
+ }
139
+
123
140
  function buildPrompt(config, message) {
124
141
  const compactText = compactInboundText(message);
125
142
  const isBriefSummary = compactText.startsWith("Brief von ") || compactText.startsWith("Mnemo Idle");
126
143
  const label = isBriefSummary ? "" : compactInboundLabel(message);
127
- const header = [];
144
+ const header = [buildAgentRuntimeContext(config), ""];
128
145
 
129
146
  if (label) {
130
147
  header.push(label);
@@ -60,7 +60,9 @@ export function loadConfig() {
60
60
  return {
61
61
  paths,
62
62
  agentName: env.BLUN_TELEGRAM_AGENT_NAME?.trim() || env.TELEGRAM_AGENT_NAME?.trim() || "default",
63
+ displayName: env.BLUN_CODEX_DISPLAY_NAME?.trim() || env.BLUN_TELEGRAM_AGENT_NAME?.trim() || env.TELEGRAM_AGENT_NAME?.trim() || "CodexLink",
63
64
  lane: env.BLUN_CODEX_LANE?.trim() || "",
65
+ agentPrompt: env.BLUN_CODEX_AGENT_PROMPT?.trim() || "",
64
66
  botToken: env.BLUN_TELEGRAM_BOT_TOKEN?.trim() || env.TELEGRAM_BOT_TOKEN?.trim() || "",
65
67
  allowedChatId: allowedChatIds[0] || "",
66
68
  allowedChatIds,
@@ -71,6 +71,9 @@ function ensureSidecar(scriptName, pidFile, stdoutFile, stderrFile, config, opti
71
71
  BLUN_TELEGRAM_OTHER_AGENT_NAMES: Array.isArray(config.otherAgentNames) ? config.otherAgentNames.join(",") : "",
72
72
  BLUN_TELEGRAM_APP_SERVER_WS_URL: config.appServerWsUrl || "",
73
73
  BLUN_TELEGRAM_CODEX_BIN: config.codexBin || "codex",
74
+ BLUN_CODEX_DISPLAY_NAME: config.displayName || "",
75
+ BLUN_CODEX_LANE: config.lane || "",
76
+ BLUN_CODEX_AGENT_PROMPT: config.agentPrompt || "",
74
77
  BLUN_TELEGRAM_RESUME_TIMEOUT_MS: String(config.resumeTimeoutMs || 15000),
75
78
  BLUN_TELEGRAM_IDLE_COOLDOWN_MS: String(config.idleCooldownMs || 15000),
76
79
  BLUN_TELEGRAM_PROGRESS_FALLBACK_MS: String(config.progressFallbackMs || 20000),
@@ -131,11 +131,17 @@ public static class BlunEmbeddedQueueTitleWatcher
131
131
 
132
132
  try
133
133
  {
134
- var enabled = Environment.GetEnvironmentVariable("BLUN_TELEGRAM_CONSOLE_UI_NOTICES");
135
- if (string.Equals(enabled, "1", StringComparison.OrdinalIgnoreCase)
136
- || string.Equals(enabled, "true", StringComparison.OrdinalIgnoreCase)
137
- || string.Equals(enabled, "yes", StringComparison.OrdinalIgnoreCase)
138
- || string.Equals(enabled, "on", StringComparison.OrdinalIgnoreCase))
134
+ var mode = Environment.GetEnvironmentVariable("BLUN_TELEGRAM_CONSOLE_UI_NOTICES") ?? "";
135
+ var disabled = string.Equals(mode, "0", StringComparison.OrdinalIgnoreCase)
136
+ || string.Equals(mode, "false", StringComparison.OrdinalIgnoreCase)
137
+ || string.Equals(mode, "no", StringComparison.OrdinalIgnoreCase)
138
+ || string.Equals(mode, "off", StringComparison.OrdinalIgnoreCase);
139
+ var allowAll = string.Equals(mode, "all", StringComparison.OrdinalIgnoreCase)
140
+ || string.Equals(mode, "1", StringComparison.OrdinalIgnoreCase)
141
+ || string.Equals(mode, "true", StringComparison.OrdinalIgnoreCase)
142
+ || string.Equals(mode, "yes", StringComparison.OrdinalIgnoreCase)
143
+ || string.Equals(mode, "on", StringComparison.OrdinalIgnoreCase);
144
+ if (!disabled && (allowAll || string.Equals(normalizedKind, "inbound", StringComparison.OrdinalIgnoreCase)))
139
145
  {
140
146
  Console.WriteLine("");
141
147
  Console.WriteLine("[Telegram] " + normalized);
@@ -273,10 +273,11 @@ function Write-ConsoleUiNotice {
273
273
  [string]$Kind,
274
274
  [string]$Notice
275
275
  )
276
- if ($env:BLUN_TELEGRAM_CONSOLE_UI_NOTICES -ne "1" -and
277
- $env:BLUN_TELEGRAM_CONSOLE_UI_NOTICES -ine "true" -and
278
- $env:BLUN_TELEGRAM_CONSOLE_UI_NOTICES -ine "yes" -and
279
- $env:BLUN_TELEGRAM_CONSOLE_UI_NOTICES -ine "on") {
276
+ $mode = [string]$env:BLUN_TELEGRAM_CONSOLE_UI_NOTICES
277
+ $disabled = $mode -eq "0" -or $mode -ieq "false" -or $mode -ieq "no" -or $mode -ieq "off"
278
+ $allowAll = $mode -ieq "all" -or $mode -eq "1" -or $mode -ieq "true" -or $mode -ieq "yes" -or $mode -ieq "on"
279
+ $isInbound = [string]::Equals($Kind, "inbound", [System.StringComparison]::OrdinalIgnoreCase)
280
+ if ($disabled -or (-not $allowAll -and -not $isInbound)) {
280
281
  return $false
281
282
  }
282
283
  try {