blun-king-cli 9.1.467 → 9.1.468

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.
@@ -6,7 +6,12 @@ const { createAgentApiToolBroker } = require('./agent-api-tool-broker.cjs');
6
6
 
7
7
  const CLIENT_TOOL_NAME_PATTERN = /^[A-Za-z0-9_-]{1,64}$/u;
8
8
  const INTERNAL_TOOL_PREFIX = 'client__';
9
- const NO_CLIENT_TOOLS_PREFIX = '__blun_agent_api_no_client_tools__';
9
+ const AGENT_API_INTERNAL_TOOLS = Object.freeze([
10
+ 'Agent',
11
+ 'TaskList',
12
+ 'TaskOutput',
13
+ 'TaskStop',
14
+ ]);
10
15
 
11
16
  class AgentApiRuntimeError extends Error {
12
17
  constructor(code, message) {
@@ -112,10 +117,6 @@ function internalToolName(publicName, index) {
112
117
  return `${prefix}${publicName.slice(0, available)}${suffix}`;
113
118
  }
114
119
 
115
- function noClientToolsSentinel(sessionId, requestId) {
116
- return `${NO_CLIENT_TOOLS_PREFIX}${shortHash(`${sessionId}\0${requestId}`, 16)}`;
117
- }
118
-
119
120
  function validateSession(session) {
120
121
  if (session === null || typeof session !== 'object') {
121
122
  throw runtimeError('AGENT_API_INVALID_SESSION', 'session must be an SDK session');
@@ -188,11 +189,10 @@ function createAgentApiRuntime(options = {}) {
188
189
  registeredNames.push(tool.internalName);
189
190
  }
190
191
 
191
- await input.session.setAllowedTools(
192
- registeredNames.length > 0
193
- ? registeredNames
194
- : [noClientToolsSentinel(sessionId, requestId)],
195
- );
192
+ await input.session.setAllowedTools([
193
+ ...AGENT_API_INTERNAL_TOOLS,
194
+ ...registeredNames,
195
+ ]);
196
196
  } catch (error) {
197
197
  broker.abortRequest({
198
198
  sessionId,
@@ -244,9 +244,9 @@ function createAgentApiRuntime(options = {}) {
244
244
  }
245
245
 
246
246
  export {
247
+ AGENT_API_INTERNAL_TOOLS,
247
248
  AgentApiRuntimeError,
248
249
  CLIENT_TOOL_NAME_PATTERN,
249
- NO_CLIENT_TOOLS_PREFIX,
250
250
  createAgentApiRuntime,
251
251
  normalizeClientToolDefinitions,
252
252
  };
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ const NESTED_AGENT_LIFECYCLE_TOOLS = Object.freeze([
4
+ 'Agent',
5
+ 'TaskList',
6
+ 'TaskOutput',
7
+ 'TaskStop',
8
+ ]);
9
+
10
+ function validateParentAllowedTools(parentTools) {
11
+ if (parentTools === null || typeof parentTools !== 'object') {
12
+ throw new TypeError('parentTools is required');
13
+ }
14
+ const allowed = parentTools.allowedTools;
15
+ if (allowed !== undefined && !Array.isArray(allowed)) {
16
+ throw new TypeError('parentTools.allowedTools must be an array or undefined');
17
+ }
18
+ return allowed;
19
+ }
20
+
21
+ function inheritSubagentLifecycleTools(parentTools, childTools) {
22
+ const allowed = validateParentAllowedTools(parentTools);
23
+ if (allowed === undefined) return [];
24
+ if (childTools === null || typeof childTools !== 'object'
25
+ || typeof childTools.data !== 'function'
26
+ || typeof childTools.setActiveTools !== 'function'
27
+ || typeof childTools.refreshBuiltinTools !== 'function') {
28
+ throw new TypeError('childTools lifecycle controls are required');
29
+ }
30
+
31
+ const toolData = childTools.data();
32
+ if (!Array.isArray(toolData)) throw new TypeError('childTools.data() must return an array');
33
+ const available = new Set(toolData.map((tool) => tool?.name).filter(Boolean));
34
+ const inherited = NESTED_AGENT_LIFECYCLE_TOOLS.filter((name) => (
35
+ allowed.includes(name) && available.has(name)
36
+ ));
37
+ if (inherited.length === 0) return [];
38
+
39
+ const active = toolData.filter((tool) => tool?.active === true).map((tool) => tool.name);
40
+ childTools.setActiveTools([...new Set([...active, ...inherited])]);
41
+ childTools.refreshBuiltinTools();
42
+ return inherited;
43
+ }
44
+
45
+ function inheritSubagentAllowedTools(parentTools, childTools) {
46
+ const allowed = validateParentAllowedTools(parentTools);
47
+ if (childTools === null || typeof childTools !== 'object'
48
+ || typeof childTools.setAllowedTools !== 'function') {
49
+ throw new TypeError('childTools.setAllowedTools is required');
50
+ }
51
+ const inherited = allowed === undefined ? undefined : [...allowed];
52
+ childTools.setAllowedTools(inherited);
53
+ return inherited;
54
+ }
55
+
56
+ module.exports = {
57
+ NESTED_AGENT_LIFECYCLE_TOOLS,
58
+ inheritSubagentAllowedTools,
59
+ inheritSubagentLifecycleTools,
60
+ };
package/blun.mjs CHANGED
@@ -252406,7 +252406,7 @@ function shouldSuppressQueuedAttemptFailureEvent(options, error) {
252406
252406
  if (isProviderRateLimitError(error)) return true;
252407
252407
  return isAbortError$4(error) || options.signal.aborted;
252408
252408
  }
252409
- var DEFAULT_SUBAGENT_TIMEOUT_MS, resolveSubagentTimeoutMs, runAgentWithTimeoutContinuation, buildSubagentUsageDelta, SUBAGENT_MAX_TOKENS_ERROR, SUBAGENT_MAX_TOKENS_HANDOFF_PROMPT, buildSubagentMaxTokensFailure, shouldRequestSubagentHandoff, SUMMARY_MIN_LENGTH, SUMMARY_CONTINUATION_ATTEMPTS, HOOK_TEXT_PREVIEW_LENGTH, TOOL_CALL_DISABLED_MESSAGE, SUBAGENT_PROMPT_ORIGIN, SIDE_QUESTION_SYSTEM_REMINDER, SessionSubagentHost;
252409
+ var DEFAULT_SUBAGENT_TIMEOUT_MS, resolveSubagentTimeoutMs, runAgentWithTimeoutContinuation, buildSubagentUsageDelta, inheritSubagentAllowedTools, inheritSubagentLifecycleTools, SUBAGENT_MAX_TOKENS_ERROR, SUBAGENT_MAX_TOKENS_HANDOFF_PROMPT, buildSubagentMaxTokensFailure, shouldRequestSubagentHandoff, SUMMARY_MIN_LENGTH, SUMMARY_CONTINUATION_ATTEMPTS, HOOK_TEXT_PREVIEW_LENGTH, TOOL_CALL_DISABLED_MESSAGE, SUBAGENT_PROMPT_ORIGIN, SIDE_QUESTION_SYSTEM_REMINDER, SessionSubagentHost;
252410
252410
  var init_subagent_host = __esmMin((() => {
252411
252411
  init_src$4();
252412
252412
  init_errors$8();
@@ -252420,6 +252420,7 @@ var init_subagent_host = __esmMin((() => {
252420
252420
  init_summary_continuation();
252421
252421
  ({ DEFAULT_SUBAGENT_TIMEOUT_MS, resolveSubagentTimeoutMs, runAgentWithTimeoutContinuation } = createRequire(import.meta.url)("./bin/subagent-timeout-policy.cjs"));
252422
252422
  ({ buildSubagentUsageDelta } = createRequire(import.meta.url)("./bin/subagent-usage-rollup-policy.cjs"));
252423
+ ({ inheritSubagentAllowedTools, inheritSubagentLifecycleTools } = createRequire(import.meta.url)("./bin/subagent-tool-policy.cjs"));
252423
252424
  ({
252424
252425
  SUBAGENT_MAX_TOKENS_ERROR,
252425
252426
  SUBAGENT_MAX_TOKENS_HANDOFF_PROMPT,
@@ -252729,6 +252730,8 @@ IMPORTANT:
252729
252730
  const context = await prepareSystemPromptContext(this.session.systemContextKaos(child.kaos.getcwd()), this.session.options.blunHomeDir, { additionalDirs: child.getAdditionalDirs() });
252730
252731
  child.useProfile(profile, context, this.session.options.blunHomeDir);
252731
252732
  child.tools.inheritUserTools(parent.tools);
252733
+ inheritSubagentLifecycleTools(parent.tools, child.tools);
252734
+ inheritSubagentAllowedTools(parent.tools, child.tools);
252732
252735
  }
252733
252736
  async triggerSubagentStart(parent, profileName, prompt, signal) {
252734
252737
  await parent.hooks?.trigger("SubagentStart", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.467",
3
+ "version": "9.1.468",
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": {