blun-king-cli 9.1.520 → 9.1.523
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/CHANGELOG.md +19 -0
- package/LIESMICH.txt +1 -1
- package/README.md +1 -1
- package/agent-spine-plugin/blun.plugin.json +1 -1
- package/agent-spine-plugin/hooks/codex.json +1 -1
- package/bin/telegram-approval-relay.cjs +2 -0
- package/blun.mjs +20 -4
- package/package.json +4 -2
- package/scripts/check-approval-observability-regression.js +111 -0
- package/scripts/check-session-start-hook-context-regression.js +54 -4
- package/scripts/check-slash-escape-regression.js +89 -0
- package/telegram-plugin/bin/telegram-approval-relay.cjs +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 9.1.523 - 2026-09-01
|
|
4
|
+
|
|
5
|
+
- Makes `Escape` cancel an open slash-command menu and clear its slash draft in one action instead of leaving the command text behind.
|
|
6
|
+
- Lets `Ctrl+S` pass a slash draft into the existing queue-and-drain path even when the surface currently reports idle, instead of silently returning before the flush.
|
|
7
|
+
- Preserves ordinary drafts when `Escape` only dismisses non-slash autocomplete.
|
|
8
|
+
- Adds red-to-green runtime regressions for both shortcuts against the exact 9.1.522 package behavior.
|
|
9
|
+
|
|
10
|
+
## 9.1.522 - 2026-09-01
|
|
11
|
+
|
|
12
|
+
- Writes `permission.approval_requested` to the session wire as soon as a tool approval opens, so an unattended King no longer looks like a silent model or provider stall while it is waiting for an operator.
|
|
13
|
+
- Reuses the existing Telegram approval buttons automatically when the allowlist contains exactly one private chat plus any number of groups; ambiguous private recipients remain fail-closed unless `BLUN_TELEGRAM_APPROVAL_CHAT_ID` is set.
|
|
14
|
+
- Adds a red-to-green regression for immediate wire visibility, unique-private-chat routing, explicit target precedence, and ambiguous-recipient rejection in both packaged relay copies.
|
|
15
|
+
|
|
16
|
+
## 9.1.521 - 2026-09-01
|
|
17
|
+
|
|
18
|
+
- Runs the AgentSpine `SessionStart` scan outside the interactive startup path, so a cold 123.6-second home-directory scan cannot hold the editor or prevent the first user prompt from reaching the wire.
|
|
19
|
+
- Keeps successful SessionStart output automatic: the completed background hook still persists its scoped briefing into the session context.
|
|
20
|
+
- Extends the cold-scan budget to 180 seconds and adds a red-to-green runtime regression proving that startup returns before a slow hook while the hook can still finish afterward.
|
|
21
|
+
|
|
3
22
|
## 9.1.520 - 2026-08-31
|
|
4
23
|
|
|
5
24
|
- Gives AgentSpine's `SessionStart` hook a 60-second cold-project budget, so startup and `/reload` can persist the automatic briefing even when the measured source scan exceeds the former 15-second limit.
|
package/LIESMICH.txt
CHANGED
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"hooks": [
|
|
18
|
-
{ "event": "SessionStart", "command": "node \"./src/hook.js\"", "timeout":
|
|
18
|
+
{ "event": "SessionStart", "command": "node \"./src/hook.js\"", "timeout": 180 },
|
|
19
19
|
{ "event": "UserPromptSubmit", "command": "node \"./src/hook.js\"", "timeout": 15 },
|
|
20
20
|
{ "event": "PreToolUse", "matcher": "Edit|Write|apply_patch|Bash|exec_command", "command": "node \"./src/hook.js\"", "timeout": 15 },
|
|
21
21
|
{ "event": "PostToolUse", "command": "node \"./src/hook.js\"", "timeout": 15 },
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"SessionStart": [
|
|
5
5
|
{
|
|
6
6
|
"matcher": "startup|resume|clear|compact",
|
|
7
|
-
"hooks": [{ "type": "command", "command": "node \"${PLUGIN_ROOT}/src/hook.js\"", "timeout":
|
|
7
|
+
"hooks": [{ "type": "command", "command": "node \"${PLUGIN_ROOT}/src/hook.js\"", "timeout": 180 }]
|
|
8
8
|
}
|
|
9
9
|
],
|
|
10
10
|
"UserPromptSubmit": [
|
|
@@ -68,6 +68,8 @@ function resolveTelegramApprovalTarget(allowFrom, configuredChatId) {
|
|
|
68
68
|
: [];
|
|
69
69
|
const configured = String(configuredChatId ?? '').trim();
|
|
70
70
|
if (configured.length > 0) return allowed.includes(configured) ? configured : null;
|
|
71
|
+
const privateChats = allowed.filter((value) => /^[1-9]\d*$/u.test(value));
|
|
72
|
+
if (privateChats.length === 1) return privateChats[0];
|
|
71
73
|
return allowed.length === 1 ? allowed[0] : null;
|
|
72
74
|
}
|
|
73
75
|
|
package/blun.mjs
CHANGED
|
@@ -234150,6 +234150,15 @@ var init_permission = __esmMin((() => {
|
|
|
234150
234150
|
let requestedApproval = false;
|
|
234151
234151
|
if (this.agent.rpc?.requestApproval) {
|
|
234152
234152
|
requestedApproval = true;
|
|
234153
|
+
this.agent.records.logRecord({
|
|
234154
|
+
type: "permission.approval_requested",
|
|
234155
|
+
turnId: Number(context.turnId),
|
|
234156
|
+
toolCallId: id,
|
|
234157
|
+
toolName: name,
|
|
234158
|
+
action,
|
|
234159
|
+
display,
|
|
234160
|
+
policyName: policyName ?? null
|
|
234161
|
+
});
|
|
234153
234162
|
this.agent.hooks?.fireAndForgetTrigger?.("PermissionRequest", {
|
|
234154
234163
|
matcherValue: name,
|
|
234155
234164
|
inputData: {
|
|
@@ -297952,7 +297961,7 @@ var init_session$1 = __esmMin((() => {
|
|
|
297952
297961
|
const { agent } = await this.createAgent({ type: "main" }, { profile: DEFAULT_AGENT_PROFILES["agent"] });
|
|
297953
297962
|
const mc = this.options.missionContract;
|
|
297954
297963
|
if (mc && Array.isArray(mc.acceptanceCriteria) && mc.acceptanceCriteria.length > 0) await agent.injection.setMissionContract(mc);
|
|
297955
|
-
|
|
297964
|
+
this.scheduleSessionStart("startup");
|
|
297956
297965
|
return agent;
|
|
297957
297966
|
}
|
|
297958
297967
|
async resume() {
|
|
@@ -297965,7 +297974,7 @@ var init_session$1 = __esmMin((() => {
|
|
|
297965
297974
|
const profile = DEFAULT_AGENT_PROFILES["agent"];
|
|
297966
297975
|
if (main !== void 0 && profile !== void 0 && main.config.systemPrompt === "") await this.bootstrapAgentProfile(main, profile);
|
|
297967
297976
|
if (main !== void 0) this.ensureBaselineSkill(main);
|
|
297968
|
-
|
|
297977
|
+
this.scheduleSessionStart("resume");
|
|
297969
297978
|
return { warning };
|
|
297970
297979
|
}
|
|
297971
297980
|
async close() {
|
|
@@ -298500,6 +298509,11 @@ var init_session$1 = __esmMin((() => {
|
|
|
298500
298509
|
if (agent === void 0) throw new BlunError(ErrorCodes.AGENT_NOT_FOUND, "Main agent was not found");
|
|
298501
298510
|
return agent;
|
|
298502
298511
|
}
|
|
298512
|
+
scheduleSessionStart(source) {
|
|
298513
|
+
void this.triggerSessionStart(source).catch((error) => {
|
|
298514
|
+
this.log.warn("session start hook failed", { source, error });
|
|
298515
|
+
});
|
|
298516
|
+
}
|
|
298503
298517
|
async triggerSessionStart(source) {
|
|
298504
298518
|
const results = await this.hookEngine.trigger("SessionStart", {
|
|
298505
298519
|
matcherValue: source,
|
|
@@ -505909,6 +505923,7 @@ var EditorKeyboardController = class {
|
|
|
505909
505923
|
return;
|
|
505910
505924
|
}
|
|
505911
505925
|
if (autocompleteCancelled) {
|
|
505926
|
+
if (editor.inputMode === "prompt" && editor.getText().trimStart().startsWith("/")) editor.setText("");
|
|
505912
505927
|
this.clearPendingUndoEsc();
|
|
505913
505928
|
return;
|
|
505914
505929
|
}
|
|
@@ -505949,8 +505964,9 @@ var EditorKeyboardController = class {
|
|
|
505949
505964
|
return true;
|
|
505950
505965
|
};
|
|
505951
505966
|
editor.onCtrlS = () => {
|
|
505952
|
-
|
|
505953
|
-
host.
|
|
505967
|
+
const draft = editor.getText().trim();
|
|
505968
|
+
if (!host.streamingUI.hasActiveTurn() && host.state.appState.streamingPhase === "idle" && !draft.trimStart().startsWith("/")) return;
|
|
505969
|
+
host.flushQueuedMessages(draft, editor.inputMode);
|
|
505954
505970
|
host.updateQueueDisplay();
|
|
505955
505971
|
host.state.ui.requestRender();
|
|
505956
505972
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blun-king-cli",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.523",
|
|
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": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "node --test test/*.test.js",
|
|
12
|
-
"prepack": "node scripts/check-release-metadata.js && node scripts/check-todo-loop-regression.js && node scripts/check-todo-recovery-catalog-regression.js && node scripts/check-historical-tool-result-preview-regression.js && node scripts/check-session-start-hook-context-regression.js && node scripts/check-queue-controls-regression.js && node scripts/check-approval-queue-shortcuts-regression.js && node scripts/check-telegram-bridge-watchdog.js && node scripts/check-resume-replay-regression.js && node scripts/check-session-cancel-regression.js && node scripts/check-plugin-startup-regression.js && node scripts/check-active-profile-plugin-startup.js && node scripts/check-mcp-startup-wait-budget.js",
|
|
12
|
+
"prepack": "node scripts/check-release-metadata.js && node scripts/check-todo-loop-regression.js && node scripts/check-todo-recovery-catalog-regression.js && node scripts/check-historical-tool-result-preview-regression.js && node scripts/check-session-start-hook-context-regression.js && node scripts/check-queue-controls-regression.js && node scripts/check-approval-queue-shortcuts-regression.js && node scripts/check-approval-observability-regression.js && node scripts/check-slash-escape-regression.js && node scripts/check-telegram-bridge-watchdog.js && node scripts/check-resume-replay-regression.js && node scripts/check-session-cancel-regression.js && node scripts/check-plugin-startup-regression.js && node scripts/check-active-profile-plugin-startup.js && node scripts/check-mcp-startup-wait-budget.js",
|
|
13
13
|
"release:verify": "node scripts/check-release-metadata.js --external",
|
|
14
14
|
"postinstall": "node scripts/fix-node-pty-perms.js"
|
|
15
15
|
},
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
"scripts/check-package-regression.js",
|
|
39
39
|
"scripts/check-active-profile-plugin-startup.js",
|
|
40
40
|
"scripts/check-approval-queue-shortcuts-regression.js",
|
|
41
|
+
"scripts/check-approval-observability-regression.js",
|
|
42
|
+
"scripts/check-slash-escape-regression.js",
|
|
41
43
|
"scripts/check-mcp-startup-wait-budget.js",
|
|
42
44
|
"scripts/check-plugin-startup-regression.js",
|
|
43
45
|
"scripts/check-queue-controls-regression.js",
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const assert = require('node:assert/strict');
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
|
|
8
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
9
|
+
const bundlePath = process.env.BLUN_BUNDLE_UNDER_TEST
|
|
10
|
+
? path.resolve(process.env.BLUN_BUNDLE_UNDER_TEST)
|
|
11
|
+
: path.join(packageRoot, 'blun.mjs');
|
|
12
|
+
const relayPath = process.env.BLUN_APPROVAL_RELAY_UNDER_TEST
|
|
13
|
+
? path.resolve(process.env.BLUN_APPROVAL_RELAY_UNDER_TEST)
|
|
14
|
+
: path.join(packageRoot, 'bin', 'telegram-approval-relay.cjs');
|
|
15
|
+
const pluginRelayPath = process.env.BLUN_PLUGIN_APPROVAL_RELAY_UNDER_TEST
|
|
16
|
+
? path.resolve(process.env.BLUN_PLUGIN_APPROVAL_RELAY_UNDER_TEST)
|
|
17
|
+
: path.join(packageRoot, 'telegram-plugin', 'bin', 'telegram-approval-relay.cjs');
|
|
18
|
+
|
|
19
|
+
const bundle = fs.readFileSync(bundlePath, 'utf8');
|
|
20
|
+
const requestToolApproval = bundle.match(
|
|
21
|
+
/async requestToolApproval\(context, result, policyName\) \{[\s\S]*?\n\t\t\}/,
|
|
22
|
+
);
|
|
23
|
+
assert(requestToolApproval, 'APPROVAL_OBSERVABILITY_REGRESSION: requestToolApproval is missing');
|
|
24
|
+
assert.match(
|
|
25
|
+
requestToolApproval[0],
|
|
26
|
+
/this\.agent\.records\.logRecord\(\{[\s\S]*?type: "permission\.approval_requested"[\s\S]*?toolCallId: id[\s\S]*?toolName: name/,
|
|
27
|
+
'APPROVAL_OBSERVABILITY_REGRESSION: opening an approval is invisible in the wire',
|
|
28
|
+
);
|
|
29
|
+
assert(
|
|
30
|
+
requestToolApproval[0].indexOf('type: "permission.approval_requested"')
|
|
31
|
+
< requestToolApproval[0].indexOf('await this.agent.rpc.requestApproval'),
|
|
32
|
+
'APPROVAL_OBSERVABILITY_REGRESSION: approval wire event is emitted too late',
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const ApprovalProbe = Function(`return class ApprovalProbe {${requestToolApproval[0]}};`)();
|
|
36
|
+
const wireRecords = [];
|
|
37
|
+
const probe = new ApprovalProbe();
|
|
38
|
+
probe.agent = {
|
|
39
|
+
records: { logRecord(record) { wireRecords.push(record); } },
|
|
40
|
+
rpc: { async requestApproval() { return { decision: 'approved' }; } },
|
|
41
|
+
hooks: { fireAndForgetTrigger() {} },
|
|
42
|
+
telemetry: { track() {} },
|
|
43
|
+
};
|
|
44
|
+
probe.recordApprovalResult = () => {};
|
|
45
|
+
probe.permissionPolicyResolutionToPrepare = () => undefined;
|
|
46
|
+
probe.formatApprovalRejectionMessage = () => '';
|
|
47
|
+
|
|
48
|
+
const approvalRun = probe.requestToolApproval({
|
|
49
|
+
signal: new AbortController().signal,
|
|
50
|
+
turnId: 7,
|
|
51
|
+
toolCall: { id: 'tool-7', name: 'Bash' },
|
|
52
|
+
execution: {
|
|
53
|
+
description: 'Run command',
|
|
54
|
+
display: { kind: 'command', command: 'echo ok' },
|
|
55
|
+
},
|
|
56
|
+
args: { command: 'echo ok' },
|
|
57
|
+
}, {}, 'manual-approval');
|
|
58
|
+
assert.equal(wireRecords.length, 1, 'approval request must be written before awaiting a response');
|
|
59
|
+
assert.deepEqual(
|
|
60
|
+
wireRecords[0],
|
|
61
|
+
{
|
|
62
|
+
type: 'permission.approval_requested',
|
|
63
|
+
turnId: 7,
|
|
64
|
+
toolCallId: 'tool-7',
|
|
65
|
+
toolName: 'Bash',
|
|
66
|
+
action: 'Run command',
|
|
67
|
+
display: { kind: 'command', command: 'echo ok' },
|
|
68
|
+
policyName: 'manual-approval',
|
|
69
|
+
},
|
|
70
|
+
'approval wire record lost identifying fields',
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
function checkRelay(modulePath, label) {
|
|
74
|
+
delete require.cache[require.resolve(modulePath)];
|
|
75
|
+
const { resolveTelegramApprovalTarget } = require(modulePath);
|
|
76
|
+
assert.equal(
|
|
77
|
+
resolveTelegramApprovalTarget(['1605241602', '-1003927574737']),
|
|
78
|
+
'1605241602',
|
|
79
|
+
`${label}: one authorized private chat must be selected even when groups are also allowed`,
|
|
80
|
+
);
|
|
81
|
+
assert.equal(
|
|
82
|
+
resolveTelegramApprovalTarget(['0', '-1003927574737']),
|
|
83
|
+
null,
|
|
84
|
+
`${label}: zero is not a positive private Telegram chat ID`,
|
|
85
|
+
);
|
|
86
|
+
assert.equal(
|
|
87
|
+
resolveTelegramApprovalTarget(['1605241602', '8711923962', '-1003927574737']),
|
|
88
|
+
null,
|
|
89
|
+
`${label}: multiple authorized private chats must remain fail-closed`,
|
|
90
|
+
);
|
|
91
|
+
assert.equal(
|
|
92
|
+
resolveTelegramApprovalTarget(['1605241602', '8711923962'], '8711923962'),
|
|
93
|
+
'8711923962',
|
|
94
|
+
`${label}: an explicitly configured authorized chat must win`,
|
|
95
|
+
);
|
|
96
|
+
assert.equal(
|
|
97
|
+
resolveTelegramApprovalTarget(['1605241602'], '-1003927574737'),
|
|
98
|
+
null,
|
|
99
|
+
`${label}: an unauthorized configured chat must be rejected`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
checkRelay(relayPath, 'package relay');
|
|
104
|
+
checkRelay(pluginRelayPath, 'plugin relay');
|
|
105
|
+
|
|
106
|
+
approvalRun.then(() => {
|
|
107
|
+
process.stdout.write('approval-observability-regression PASS\n');
|
|
108
|
+
}).catch((error) => {
|
|
109
|
+
process.stderr.write(`${error.stack || error.message}\n`);
|
|
110
|
+
process.exitCode = 1;
|
|
111
|
+
});
|
|
@@ -33,6 +33,15 @@ const stringPredicate = bundle.match(
|
|
|
33
33
|
const trigger = bundle.match(
|
|
34
34
|
/async triggerSessionStart\(source\) \{[\s\S]*?\n\t\t\}/,
|
|
35
35
|
);
|
|
36
|
+
const scheduler = bundle.match(
|
|
37
|
+
/scheduleSessionStart\(source\) \{[\s\S]*?\n\t\t\}/,
|
|
38
|
+
);
|
|
39
|
+
const createMain = bundle.match(
|
|
40
|
+
/async createMain\(\) \{[\s\S]*?\n\t\t\}/,
|
|
41
|
+
);
|
|
42
|
+
const resume = bundle.match(
|
|
43
|
+
/async resume\(\) \{[\s\S]*?\n\t\t\}/,
|
|
44
|
+
);
|
|
36
45
|
|
|
37
46
|
assert(renderer, 'SESSION_START_HOOK_CONTEXT_REGRESSION: SessionStart renderer is missing');
|
|
38
47
|
assert(allowRenderer, 'SESSION_START_HOOK_CONTEXT_REGRESSION: shared allow renderer is missing');
|
|
@@ -40,6 +49,9 @@ assert(wrapperRenderer, 'SESSION_START_HOOK_CONTEXT_REGRESSION: hook wrapper ren
|
|
|
40
49
|
assert(messageSelector, 'SESSION_START_HOOK_CONTEXT_REGRESSION: hook message selector is missing');
|
|
41
50
|
assert(stringPredicate, 'SESSION_START_HOOK_CONTEXT_REGRESSION: hook string predicate is missing');
|
|
42
51
|
assert(trigger, 'SESSION_START_HOOK_CONTEXT_REGRESSION: SessionStart trigger is missing');
|
|
52
|
+
assert(scheduler, 'SESSION_START_HOOK_CONTEXT_REGRESSION: non-blocking SessionStart scheduler is missing');
|
|
53
|
+
assert(createMain, 'SESSION_START_HOOK_CONTEXT_REGRESSION: createMain is missing');
|
|
54
|
+
assert(resume, 'SESSION_START_HOOK_CONTEXT_REGRESSION: resume is missing');
|
|
43
55
|
assert(
|
|
44
56
|
/renderAllowHookResult\("SessionStart", results\)/.test(renderer[0]),
|
|
45
57
|
'SESSION_START_HOOK_CONTEXT_REGRESSION: SessionStart output is not rendered',
|
|
@@ -58,7 +70,21 @@ assert(
|
|
|
58
70
|
);
|
|
59
71
|
assert(
|
|
60
72
|
/await mainAgent\.records\.flush\(\)/.test(trigger[0]),
|
|
61
|
-
'SESSION_START_HOOK_CONTEXT_REGRESSION: SessionStart reminder is not flushed
|
|
73
|
+
'SESSION_START_HOOK_CONTEXT_REGRESSION: completed SessionStart reminder is not flushed',
|
|
74
|
+
);
|
|
75
|
+
assert(
|
|
76
|
+
/this\.scheduleSessionStart\("startup"\)/.test(createMain[0])
|
|
77
|
+
&& !/await this\.triggerSessionStart\("startup"\)/.test(createMain[0]),
|
|
78
|
+
'SESSION_START_HOOK_CONTEXT_REGRESSION: fresh-session input is still blocked by SessionStart',
|
|
79
|
+
);
|
|
80
|
+
assert(
|
|
81
|
+
/this\.scheduleSessionStart\("resume"\)/.test(resume[0])
|
|
82
|
+
&& !/await this\.triggerSessionStart\("resume"\)/.test(resume[0]),
|
|
83
|
+
'SESSION_START_HOOK_CONTEXT_REGRESSION: resumed-session input is still blocked by SessionStart',
|
|
84
|
+
);
|
|
85
|
+
assert(
|
|
86
|
+
/void this\.triggerSessionStart\(source\)\.catch\(/.test(scheduler[0]),
|
|
87
|
+
'SESSION_START_HOOK_CONTEXT_REGRESSION: SessionStart is not detached from interactive startup',
|
|
62
88
|
);
|
|
63
89
|
|
|
64
90
|
const packageRoot = path.resolve(__dirname, '..');
|
|
@@ -75,11 +101,11 @@ const blunSessionStart = agentSpineManifest.hooks.find(
|
|
|
75
101
|
const codexSessionStart = agentSpineCodexHooks.hooks.SessionStart?.[0]?.hooks?.[0];
|
|
76
102
|
|
|
77
103
|
assert(
|
|
78
|
-
blunSessionStart?.timeout >=
|
|
79
|
-
'SESSION_START_HOOK_CONTEXT_REGRESSION: BLUN AgentSpine SessionStart timeout must cover
|
|
104
|
+
blunSessionStart?.timeout >= 180,
|
|
105
|
+
'SESSION_START_HOOK_CONTEXT_REGRESSION: BLUN AgentSpine SessionStart timeout must cover the measured 123.6 s cold scan',
|
|
80
106
|
);
|
|
81
107
|
assert(
|
|
82
|
-
codexSessionStart?.timeout >=
|
|
108
|
+
codexSessionStart?.timeout >= 180,
|
|
83
109
|
'SESSION_START_HOOK_CONTEXT_REGRESSION: Codex AgentSpine SessionStart timeout must match the BLUN runtime budget',
|
|
84
110
|
);
|
|
85
111
|
|
|
@@ -126,9 +152,16 @@ const triggerFunction = trigger[0].replace(
|
|
|
126
152
|
/^async triggerSessionStart/,
|
|
127
153
|
'async function triggerSessionStart',
|
|
128
154
|
);
|
|
155
|
+
const schedulerFunction = scheduler[0].replace(
|
|
156
|
+
/^scheduleSessionStart/,
|
|
157
|
+
'function scheduleSessionStart',
|
|
158
|
+
);
|
|
129
159
|
const runTrigger = Function(
|
|
130
160
|
`${wrapperRenderer[0]}\n${messageSelector[0]}\n${stringPredicate[0]}\n${allowRenderer[0]}\n${renderer[0]}\n${triggerFunction}\nreturn triggerSessionStart;`,
|
|
131
161
|
)();
|
|
162
|
+
const scheduleTrigger = Function(
|
|
163
|
+
`${schedulerFunction}\nreturn scheduleSessionStart;`,
|
|
164
|
+
)();
|
|
132
165
|
|
|
133
166
|
(async () => {
|
|
134
167
|
const reminders = [];
|
|
@@ -171,6 +204,23 @@ const runTrigger = Function(
|
|
|
171
204
|
'runtime probe used the wrong reminder origin',
|
|
172
205
|
);
|
|
173
206
|
|
|
207
|
+
let detachedCompleted = false;
|
|
208
|
+
const detachedStartedAt = Date.now();
|
|
209
|
+
scheduleTrigger.call({
|
|
210
|
+
async triggerSessionStart(source) {
|
|
211
|
+
assert(source === 'startup', 'detached runtime probe lost the startup source');
|
|
212
|
+
await new Promise((resolve) => setTimeout(resolve, 75));
|
|
213
|
+
detachedCompleted = true;
|
|
214
|
+
},
|
|
215
|
+
log: { warn() {} },
|
|
216
|
+
}, 'startup');
|
|
217
|
+
assert(
|
|
218
|
+
Date.now() - detachedStartedAt < 50 && detachedCompleted === false,
|
|
219
|
+
'SessionStart scheduler still waits for the hook before returning',
|
|
220
|
+
);
|
|
221
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
222
|
+
assert(detachedCompleted, 'detached SessionStart hook did not finish in the background');
|
|
223
|
+
|
|
174
224
|
process.stdout.write('session-start-hook-context-regression PASS\n');
|
|
175
225
|
})().catch((error) => {
|
|
176
226
|
process.stderr.write(`${error.stack || error.message}\n`);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const assert = require('node:assert/strict');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
|
|
5
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
6
|
+
const bundle = fs.readFileSync(path.join(packageRoot, 'blun.mjs'), 'utf8');
|
|
7
|
+
const match = /editor\.onEscape = \(autocompleteCancelled = false\) => \{([\s\S]*?)\n\t\t\};\n\t\teditor\.onShiftTab =/.exec(bundle);
|
|
8
|
+
assert(match, 'SLASH_ESCAPE_REGRESSION: editor.onEscape handler is missing');
|
|
9
|
+
|
|
10
|
+
const runEscape = Function('host', 'editor', 'autocompleteCancelled', match[1]);
|
|
11
|
+
const ctrlSMatch = /editor\.onCtrlS = \(\) => \{([\s\S]*?)\n\t\t\};\n\t\teditor\.onCtrlB =/.exec(bundle);
|
|
12
|
+
assert(ctrlSMatch, 'SLASH_ESCAPE_REGRESSION: editor.onCtrlS handler is missing');
|
|
13
|
+
const runCtrlS = Function('host', 'editor', ctrlSMatch[1]);
|
|
14
|
+
|
|
15
|
+
function probe(initialText, autocompleteCancelled) {
|
|
16
|
+
let text = initialText;
|
|
17
|
+
const editor = {
|
|
18
|
+
inputMode: 'prompt',
|
|
19
|
+
getText: () => text,
|
|
20
|
+
setText: (value) => { text = value; },
|
|
21
|
+
};
|
|
22
|
+
const host = {
|
|
23
|
+
cancelInFlight: undefined,
|
|
24
|
+
queueSteerInFlight: undefined,
|
|
25
|
+
state: {
|
|
26
|
+
activeDialog: null,
|
|
27
|
+
appState: {
|
|
28
|
+
isCompacting: false,
|
|
29
|
+
streamingPhase: 'idle',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
streamingUI: { hasActiveTurn: () => false },
|
|
33
|
+
btwPanelController: { closeOrCancel: () => false },
|
|
34
|
+
};
|
|
35
|
+
const controller = {
|
|
36
|
+
pendingExit: null,
|
|
37
|
+
pendingUndoEsc: null,
|
|
38
|
+
clearPendingExit() {},
|
|
39
|
+
clearPendingUndoEsc() {},
|
|
40
|
+
armPendingUndoEsc() {},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
runEscape.call(controller, host, editor, autocompleteCancelled);
|
|
44
|
+
return text;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
assert.equal(
|
|
48
|
+
probe('/reload', true),
|
|
49
|
+
'',
|
|
50
|
+
'SLASH_ESCAPE_REGRESSION: Escape must cancel the open slash-command draft together with its menu',
|
|
51
|
+
);
|
|
52
|
+
assert.equal(
|
|
53
|
+
probe('ordinary draft', true),
|
|
54
|
+
'ordinary draft',
|
|
55
|
+
'SLASH_ESCAPE_REGRESSION: cancelling ordinary autocomplete must preserve the draft',
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
let flushed = null;
|
|
59
|
+
const idleHost = {
|
|
60
|
+
streamingUI: { hasActiveTurn: () => false },
|
|
61
|
+
state: {
|
|
62
|
+
appState: { streamingPhase: 'idle' },
|
|
63
|
+
ui: { requestRender() {} },
|
|
64
|
+
},
|
|
65
|
+
flushQueuedMessages: (draft, mode) => { flushed = { draft, mode }; },
|
|
66
|
+
updateQueueDisplay() {},
|
|
67
|
+
};
|
|
68
|
+
const slashEditor = {
|
|
69
|
+
inputMode: 'prompt',
|
|
70
|
+
getText: () => '/reload',
|
|
71
|
+
};
|
|
72
|
+
runCtrlS(idleHost, slashEditor);
|
|
73
|
+
assert.deepEqual(
|
|
74
|
+
flushed,
|
|
75
|
+
{ draft: '/reload', mode: 'prompt' },
|
|
76
|
+
'SLASH_ESCAPE_REGRESSION: Ctrl+S must hand an idle slash draft to the existing queue drain',
|
|
77
|
+
);
|
|
78
|
+
flushed = null;
|
|
79
|
+
runCtrlS(idleHost, {
|
|
80
|
+
inputMode: 'prompt',
|
|
81
|
+
getText: () => 'ordinary draft',
|
|
82
|
+
});
|
|
83
|
+
assert.equal(
|
|
84
|
+
flushed,
|
|
85
|
+
null,
|
|
86
|
+
'SLASH_ESCAPE_REGRESSION: the existing idle behavior for ordinary drafts must stay unchanged',
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
console.log('slash-escape-regression PASS (Escape + Ctrl+S)');
|
|
@@ -68,6 +68,8 @@ function resolveTelegramApprovalTarget(allowFrom, configuredChatId) {
|
|
|
68
68
|
: [];
|
|
69
69
|
const configured = String(configuredChatId ?? '').trim();
|
|
70
70
|
if (configured.length > 0) return allowed.includes(configured) ? configured : null;
|
|
71
|
+
const privateChats = allowed.filter((value) => /^[1-9]\d*$/u.test(value));
|
|
72
|
+
if (privateChats.length === 1) return privateChats[0];
|
|
71
73
|
return allowed.length === 1 ? allowed[0] : null;
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -280,4 +282,3 @@ module.exports = {
|
|
|
280
282
|
wasTelegramApprovalSent,
|
|
281
283
|
writeTelegramApprovalResponse,
|
|
282
284
|
};
|
|
283
|
-
|