blun-king-cli 9.1.113 → 9.1.115

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.
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ const SYSTEM_PROMPT_DIRECTORY_MAX_CHARS = 4_000;
4
+ const SYSTEM_PROMPT_DIRECTORY_TRUNCATED_MARKER =
5
+ '... [directory overview shortened; use Glob, Grep, or Read for complete contents]';
6
+
7
+ function boundSystemPromptDirectoryListing(value) {
8
+ const listing = String(value ?? '');
9
+ if (listing.length <= SYSTEM_PROMPT_DIRECTORY_MAX_CHARS) return listing;
10
+
11
+ const contentBudget = Math.max(
12
+ 0,
13
+ SYSTEM_PROMPT_DIRECTORY_MAX_CHARS
14
+ - SYSTEM_PROMPT_DIRECTORY_TRUNCATED_MARKER.length
15
+ - 1,
16
+ );
17
+ const lines = listing.split(/\r?\n/u);
18
+ const kept = [];
19
+ let used = 0;
20
+ for (const line of lines) {
21
+ const added = line.length + (kept.length > 0 ? 1 : 0);
22
+ if (used + added > contentBudget) break;
23
+ kept.push(line);
24
+ used += added;
25
+ }
26
+
27
+ return `${kept.join('\n')}\n${SYSTEM_PROMPT_DIRECTORY_TRUNCATED_MARKER}`;
28
+ }
29
+
30
+ module.exports = {
31
+ SYSTEM_PROMPT_DIRECTORY_MAX_CHARS,
32
+ SYSTEM_PROMPT_DIRECTORY_TRUNCATED_MARKER,
33
+ boundSystemPromptDirectoryListing,
34
+ };
@@ -93,6 +93,18 @@ function createDeferredToolLoader(selectedTools, deferredTools, loadedToolNames
93
93
  execute: async () => {
94
94
  const matches = searchDeferredTools([...available.values()], query);
95
95
  if (matches.length === 0) {
96
+ const alreadyLoaded = query.toLowerCase().startsWith('select:')
97
+ ? searchDeferredTools(
98
+ selectedTools.filter((tool) => tool?.name !== DEFERRED_TOOL_LOADER_NAME),
99
+ query,
100
+ )
101
+ : [];
102
+ if (alreadyLoaded.length === 1) {
103
+ return {
104
+ isError: false,
105
+ output: `Tool schema already loaded: ${alreadyLoaded[0].name}. Invoke it now.`,
106
+ };
107
+ }
96
108
  return {
97
109
  isError: true,
98
110
  output: `No deferred tools matched: ${query || '[empty query]'}`,
package/blun.mjs CHANGED
@@ -21437,10 +21437,11 @@ var init_list_directory = __esmMin((() => {
21437
21437
  }));
21438
21438
  //#endregion
21439
21439
  //#region ../../packages/agent-core/src/profile/context.ts
21440
+ var { boundSystemPromptDirectoryListing } = createRequire(import.meta.url)("./bin/system-prompt-context-policy.cjs");
21440
21441
  async function prepareSystemPromptContext(kaos, brandHome, options) {
21441
21442
  const additionalDirs = normalizeAdditionalDirs(options?.additionalDirs ?? []);
21442
21443
  const [cwdListing, agentsMdResult, additionalDirsInfo] = await Promise.all([
21443
- listDirectory(kaos, void 0, { collapseHiddenDirs: true }),
21444
+ listDirectory(kaos, void 0, { collapseHiddenDirs: true }).then(boundSystemPromptDirectoryListing),
21444
21445
  loadAgentsMdForRoots(kaos, brandHome, [kaos.getcwd()]),
21445
21446
  loadAdditionalDirsInfo(kaos, additionalDirs)
21446
21447
  ]);
@@ -264501,10 +264502,12 @@ var init_agent = __esmMin((() => {
264501
264502
  agentsMd: context?.agentsMd,
264502
264503
  additionalDirsInfo: context?.additionalDirsInfo
264503
264504
  });
264505
+ if (systemPrompt === this.config.systemPrompt) return false;
264504
264506
  this.config.update({
264505
264507
  profileName: profile.name,
264506
264508
  systemPrompt
264507
264509
  });
264510
+ return true;
264508
264511
  }
264509
264512
  async resume(options) {
264510
264513
  const result = await this.records.replay(options);
@@ -296910,11 +296913,8 @@ var init_session$1 = __esmMin((() => {
296910
296913
  if (agent.config.systemPrompt === "") return;
296911
296914
  const profile = this.resolvePersistedProfile(agent, meta, parentAgent);
296912
296915
  if (profile === void 0) return;
296913
- if (hasLegacyLocalMemorySystemBlock(agent.config.systemPrompt)) {
296914
- await this.bootstrapAgentProfile(agent, profile);
296915
- return;
296916
- }
296917
296916
  agent.setActiveProfile(profile, this.options.blunHomeDir);
296917
+ await agent.refreshSystemPrompt();
296918
296918
  }
296919
296919
  ensureBaselineSkill(agent) {
296920
296920
  if (agent.skills?.ensureBaseline(BASELINE_SKILL_NAME) !== true) this.log.warn("baseline skill is unavailable", { skill: BASELINE_SKILL_NAME });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.113",
3
+ "version": "9.1.115",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -52,5 +52,10 @@
52
52
  "directories": {
53
53
  "test": "test"
54
54
  },
55
- "type": "commonjs"
55
+ "type": "commonjs",
56
+ "dependencies": {
57
+ "blun-king-cli": "^9.1.62",
58
+ "node-addon-api": "^7.1.1"
59
+ },
60
+ "devDependencies": {}
56
61
  }
@@ -4390,11 +4390,10 @@ function claimPollerPid() {
4390
4390
  ownerPid = parseInt(readFileSync(pidFile(), "utf8"), 10);
4391
4391
  } catch {}
4392
4392
  if (ownerPid === process.pid) return true;
4393
- if (ownerPid !== void 0 && ownerPid > 1) try {
4394
- process.kill(ownerPid, 0);
4393
+ if (pidAlive(ownerPid)) {
4395
4394
  process.stderr.write(`telegram channel: live poller pid=${ownerPid} already owns the bot token\n`);
4396
4395
  return false;
4397
- } catch {}
4396
+ }
4398
4397
  try {
4399
4398
  rmSync(pidFile());
4400
4399
  } catch {
@@ -4498,8 +4497,8 @@ function pidAlive(pid) {
4498
4497
  try {
4499
4498
  process.kill(pid, 0);
4500
4499
  return true;
4501
- } catch {
4502
- return false;
4500
+ } catch (error) {
4501
+ return error?.code === "EPERM";
4503
4502
  }
4504
4503
  }
4505
4504
  function isTuiLeaseFresh(maxAgeMs = TUI_LEASE_MAX_AGE_MS, now = Date.now()) {