@christang/keel 5.95.1 → 5.95.3
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/assets/bootstrap/AGENTS.md +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/scripts/validate_plugin.py +192 -2
- package/src/core/chat/bridge.js +8 -0
- package/src/core/chat/cli.js +1 -2
- package/src/core/chat/lifecycle.js +62 -9
- package/src/core/chat/notice.js +13 -3
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.95.
|
|
3
|
+
"version": "5.95.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.95.
|
|
9
|
+
"version": "5.95.3",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.95.
|
|
3
|
+
"version": "5.95.3",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.95.
|
|
3
|
+
"version": "5.95.3",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
|
|
|
47
47
|
"scripts/validate_plugin.py",
|
|
48
48
|
]
|
|
49
49
|
|
|
50
|
-
PACKAGE_VERSION = "5.95.
|
|
51
|
-
PROTOCOL_VERSION = "5.95.
|
|
50
|
+
PACKAGE_VERSION = "5.95.3"
|
|
51
|
+
PROTOCOL_VERSION = "5.95.3"
|
|
52
52
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
53
53
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
54
54
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -4095,6 +4095,188 @@ def validate_chat_bridge_lifecycle_scenario() -> int:
|
|
|
4095
4095
|
return 0
|
|
4096
4096
|
|
|
4097
4097
|
|
|
4098
|
+
def validate_chat_bridge_start_race_scenario() -> int:
|
|
4099
|
+
"""Issue #226: start, stop, install, and status follow launchd's state.
|
|
4100
|
+
|
|
4101
|
+
A stateful launchctl double behaves like launchd after a bootout: the
|
|
4102
|
+
unload is still in progress, so the next bootstraps fail with `5:
|
|
4103
|
+
Input/output error`. `start` must retry until the service loads, fail
|
|
4104
|
+
naming launchctl's output when it never does, and `status` must not
|
|
4105
|
+
report a launchd-started bridge running from a stale status file.
|
|
4106
|
+
"""
|
|
4107
|
+
label = "chat-bridge-start-race:"
|
|
4108
|
+
if chat_bridge_node_missing("chat-bridge-start-race"):
|
|
4109
|
+
return 3
|
|
4110
|
+
with tempfile.TemporaryDirectory(prefix="keel-chat-race-") as raw:
|
|
4111
|
+
base = Path(raw)
|
|
4112
|
+
rtl, _verify, env = chat_scratch_group(base)
|
|
4113
|
+
state = base / "launchd"
|
|
4114
|
+
state.mkdir()
|
|
4115
|
+
calls = base / "launchctl.log"
|
|
4116
|
+
launchctl = base / "launchctl"
|
|
4117
|
+
write_text(
|
|
4118
|
+
launchctl,
|
|
4119
|
+
"#!/bin/sh\n"
|
|
4120
|
+
f'S="{state}"\n'
|
|
4121
|
+
f'echo "$@" >> "{calls}"\n'
|
|
4122
|
+
'case "$1" in\n'
|
|
4123
|
+
" bootout)\n"
|
|
4124
|
+
' rm -f "$S/loaded"; echo 2 > "$S/fails"; exit 0 ;;\n'
|
|
4125
|
+
" bootstrap)\n"
|
|
4126
|
+
' if [ -f "$S/forever" ]; then echo "Bootstrap failed: 5: Input/output error" >&2; exit 5; fi\n'
|
|
4127
|
+
' n=$(cat "$S/fails" 2>/dev/null || echo 0)\n'
|
|
4128
|
+
' if [ "$n" -gt 0 ]; then echo $((n - 1)) > "$S/fails"; echo "Bootstrap failed: 5: Input/output error" >&2; exit 5; fi\n'
|
|
4129
|
+
' if [ -f "$S/loaded" ]; then echo "Bootstrap failed: 5: Input/output error" >&2; exit 5; fi\n'
|
|
4130
|
+
' touch "$S/loaded"; exit 0 ;;\n'
|
|
4131
|
+
" print)\n"
|
|
4132
|
+
' if [ -f "$S/loaded" ]; then printf "gui/501/dev.keel.chat-bridge = {\\n\\tstate = running\\n\\tpid = 4242\\n}\\n"; exit 0; fi\n'
|
|
4133
|
+
' echo "Could not find service \\"dev.keel.chat-bridge\\" in domain for user gui: 501" >&2; exit 113 ;;\n'
|
|
4134
|
+
"esac\n"
|
|
4135
|
+
"exit 0\n",
|
|
4136
|
+
)
|
|
4137
|
+
launchctl.chmod(0o755)
|
|
4138
|
+
home = base / "home"
|
|
4139
|
+
lenv = {
|
|
4140
|
+
**env,
|
|
4141
|
+
"KEEL_HOME": str(home),
|
|
4142
|
+
"KEEL_CHAT_LAUNCHCTL": str(launchctl),
|
|
4143
|
+
"KEEL_CHAT_LAUNCH_AGENTS_DIR": str(base / "LaunchAgents"),
|
|
4144
|
+
"KEEL_CHAT_LAUNCHCTL_WAIT_MS": "8000",
|
|
4145
|
+
}
|
|
4146
|
+
|
|
4147
|
+
installed = run_keel(rtl, "chat", "bridge", "install", env=lenv)
|
|
4148
|
+
if installed.returncode != 0:
|
|
4149
|
+
report(f"{label} install failed although the unload finishes: {installed.stderr.strip()}")
|
|
4150
|
+
return 1
|
|
4151
|
+
if not (state / "loaded").exists():
|
|
4152
|
+
report(f"{label} install returned without the agent loaded: {calls.read_text(encoding='utf-8')!r}")
|
|
4153
|
+
return 1
|
|
4154
|
+
stopped = run_keel(rtl, "chat", "bridge", "stop", env=lenv)
|
|
4155
|
+
if stopped.returncode != 0 or (state / "loaded").exists():
|
|
4156
|
+
report(f"{label} stop did not unload the agent: {stopped.stderr.strip()}")
|
|
4157
|
+
return 1
|
|
4158
|
+
write_text(calls, "")
|
|
4159
|
+
started = run_keel(rtl, "chat", "bridge", "start", env=lenv)
|
|
4160
|
+
bootstraps = [line for line in calls.read_text(encoding="utf-8").splitlines() if line.startswith("bootstrap")]
|
|
4161
|
+
if started.returncode != 0:
|
|
4162
|
+
report(f"{label} start after stop failed instead of waiting for the unload: {started.stderr.strip()}")
|
|
4163
|
+
return 1
|
|
4164
|
+
if len(bootstraps) != 3:
|
|
4165
|
+
report(f"{label} start asked launchctl to bootstrap {len(bootstraps)} times, not 3: {bootstraps!r}")
|
|
4166
|
+
return 1
|
|
4167
|
+
if not (state / "loaded").exists():
|
|
4168
|
+
report(f"{label} start reported success with the agent not loaded.")
|
|
4169
|
+
return 1
|
|
4170
|
+
|
|
4171
|
+
run_keel(rtl, "chat", "bridge", "stop", env=lenv)
|
|
4172
|
+
(state / "forever").touch()
|
|
4173
|
+
failed = run_keel(rtl, "chat", "bridge", "start", env={**lenv, "KEEL_CHAT_LAUNCHCTL_WAIT_MS": "1500"})
|
|
4174
|
+
if failed.returncode == 0:
|
|
4175
|
+
report(f"{label} start reported success although every bootstrap failed: {failed.stdout.strip()}")
|
|
4176
|
+
return 1
|
|
4177
|
+
if "5: Input/output error" not in failed.stderr:
|
|
4178
|
+
report(f"{label} the failed start does not name launchctl's output: {failed.stderr.strip()}")
|
|
4179
|
+
return 1
|
|
4180
|
+
(state / "forever").unlink()
|
|
4181
|
+
|
|
4182
|
+
holder = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(60)"])
|
|
4183
|
+
try:
|
|
4184
|
+
status_file = home / "chat" / "bridge" / "status.json"
|
|
4185
|
+
status_file.parent.mkdir(parents=True, exist_ok=True)
|
|
4186
|
+
stale = {"pid": holder.pid, "connected": True, "projects": [], "launchd": True}
|
|
4187
|
+
|
|
4188
|
+
def running(record: dict) -> object:
|
|
4189
|
+
write_text(status_file, json.dumps(record))
|
|
4190
|
+
return chat_json(run_keel(rtl, "chat", "bridge", "status", "--json", env=lenv)).get("running")
|
|
4191
|
+
|
|
4192
|
+
if running(stale) is not False:
|
|
4193
|
+
report(f"{label} status reports a launchd bridge running while launchd has unloaded it.")
|
|
4194
|
+
return 1
|
|
4195
|
+
(state / "loaded").touch()
|
|
4196
|
+
if running(stale) is not False:
|
|
4197
|
+
report(f"{label} status reports running from a status file whose pid launchd does not run.")
|
|
4198
|
+
return 1
|
|
4199
|
+
manual = {key: value for key, value in stale.items() if key != "launchd"}
|
|
4200
|
+
if running(manual) is not True:
|
|
4201
|
+
report(f"{label} status no longer reports a bridge run by hand from its live pid.")
|
|
4202
|
+
return 1
|
|
4203
|
+
finally:
|
|
4204
|
+
holder.kill()
|
|
4205
|
+
holder.wait()
|
|
4206
|
+
|
|
4207
|
+
if "chat-bridge-start-race" not in {name for name, _ in SCENARIOS}:
|
|
4208
|
+
report(f"{label} scenario is not registered.")
|
|
4209
|
+
return 1
|
|
4210
|
+
report("chat-bridge-start-race scenario passed.")
|
|
4211
|
+
return 0
|
|
4212
|
+
|
|
4213
|
+
|
|
4214
|
+
def validate_chat_owner_mention_scenario() -> int:
|
|
4215
|
+
"""Owner's rule of 2026-10-05: a Slack message the owner needs mentions them.
|
|
4216
|
+
|
|
4217
|
+
The session-start notice of a Slack-enabled project that names an owner
|
|
4218
|
+
tells the session to write `@owner` on what the owner needs to see or
|
|
4219
|
+
decide, and says nothing of it when no owner is named; a record with
|
|
4220
|
+
`@owner` is posted as a real mention; both setup guides state the rule.
|
|
4221
|
+
"""
|
|
4222
|
+
label = "chat-owner-mention:"
|
|
4223
|
+
if chat_bridge_node_missing("chat-owner-mention"):
|
|
4224
|
+
return 3
|
|
4225
|
+
FakeSlack = fake_slack_class()
|
|
4226
|
+
with tempfile.TemporaryDirectory(prefix="keel-chat-owner-") as raw, FakeSlack() as slack:
|
|
4227
|
+
base = Path(raw)
|
|
4228
|
+
rtl, _verify, env = chat_scratch_group(base)
|
|
4229
|
+
chat_slack_config(rtl, {"soc": "CSOC"})
|
|
4230
|
+
benv = chat_bridge_environment(env, base / "home", slack)
|
|
4231
|
+
|
|
4232
|
+
def notice() -> str:
|
|
4233
|
+
session = subprocess.run(
|
|
4234
|
+
["node", str(ROOT / PLUGIN_ROOT / "scripts/mail-hook.js"), "session-start"],
|
|
4235
|
+
cwd=rtl, env={**benv, "KEEL_CLI": f'node "{ROOT / "bin" / "keel.js"}"'},
|
|
4236
|
+
text=True, capture_output=True, check=False,
|
|
4237
|
+
input=json.dumps({"hook_event_name": "SessionStart", "cwd": str(rtl)}),
|
|
4238
|
+
)
|
|
4239
|
+
return chat_json(session).get("hookSpecificOutput", {}).get("additionalContext", "")
|
|
4240
|
+
|
|
4241
|
+
told = notice()
|
|
4242
|
+
if "@owner" not in told:
|
|
4243
|
+
report(f"{label} the session-start notice does not tell the session to write @owner: {told!r}")
|
|
4244
|
+
return 1
|
|
4245
|
+
if "decide" not in told:
|
|
4246
|
+
report(f"{label} the notice does not say which messages need @owner: {told!r}")
|
|
4247
|
+
return 1
|
|
4248
|
+
|
|
4249
|
+
run_keel(rtl, "chat", "bridge", "add", env=benv)
|
|
4250
|
+
record_id = chat_json(run_keel(rtl, "chat", "post", "soc", "@owner 需要你决定 CSR 复位值", "--json", env=benv)).get("id", "")
|
|
4251
|
+
once = run_keel(rtl, "chat", "bridge", "run", "--once", env=benv)
|
|
4252
|
+
posted = [c for c in slack.calls_to("chat.postMessage") if slack_payload(c).get("id") == record_id]
|
|
4253
|
+
if not posted:
|
|
4254
|
+
report(f"{label} the @owner record was not posted: {once.stderr.strip()}")
|
|
4255
|
+
return 1
|
|
4256
|
+
if not posted[0]["params"].get("text", "").startswith("<@UOWNER>"):
|
|
4257
|
+
report(f"{label} the @owner record was not posted as a mention: {posted[0]['params'].get('text')!r}")
|
|
4258
|
+
return 1
|
|
4259
|
+
|
|
4260
|
+
config = json.loads((rtl / "keel" / "chat.json").read_text(encoding="utf-8"))
|
|
4261
|
+
del config["slack"]["owner"]
|
|
4262
|
+
write_text(rtl / "keel" / "chat.json", json.dumps(config, indent=2) + "\n")
|
|
4263
|
+
untold = notice()
|
|
4264
|
+
if "@owner" in untold:
|
|
4265
|
+
report(f"{label} the notice asks for @owner although no owner is named: {untold!r}")
|
|
4266
|
+
return 1
|
|
4267
|
+
|
|
4268
|
+
for guide, needle in (("docs/chat-slack-setup.md", "needs to see or decide"), ("docs/chat-slack-setup.zh-CN.md", "需要你知道或决定")):
|
|
4269
|
+
if needle not in (ROOT / guide).read_text(encoding="utf-8"):
|
|
4270
|
+
report(f"{label} {guide} does not state the owner-mention rule ({needle!r}).")
|
|
4271
|
+
return 1
|
|
4272
|
+
|
|
4273
|
+
if "chat-owner-mention" not in {name for name, _ in SCENARIOS}:
|
|
4274
|
+
report(f"{label} scenario is not registered.")
|
|
4275
|
+
return 1
|
|
4276
|
+
report("chat-owner-mention scenario passed.")
|
|
4277
|
+
return 0
|
|
4278
|
+
|
|
4279
|
+
|
|
4098
4280
|
def validate_chat_archive_scenario() -> int:
|
|
4099
4281
|
"""Issue #187: chat history is archived to an orphan branch, never exposed.
|
|
4100
4282
|
|
|
@@ -36249,6 +36431,14 @@ SCENARIOS: tuple = (
|
|
|
36249
36431
|
"chat-bridge-lifecycle",
|
|
36250
36432
|
validate_chat_bridge_lifecycle_scenario,
|
|
36251
36433
|
),
|
|
36434
|
+
(
|
|
36435
|
+
"chat-bridge-start-race",
|
|
36436
|
+
validate_chat_bridge_start_race_scenario,
|
|
36437
|
+
),
|
|
36438
|
+
(
|
|
36439
|
+
"chat-owner-mention",
|
|
36440
|
+
validate_chat_owner_mention_scenario,
|
|
36441
|
+
),
|
|
36252
36442
|
(
|
|
36253
36443
|
"chat-role-apps",
|
|
36254
36444
|
validate_chat_role_apps_scenario,
|
package/src/core/chat/bridge.js
CHANGED
|
@@ -726,6 +726,8 @@ function machineName() {
|
|
|
726
726
|
function writeStatus(ctx) {
|
|
727
727
|
const status = {
|
|
728
728
|
pid: process.pid,
|
|
729
|
+
// launchd names the agent it started in XPC_SERVICE_NAME (D4).
|
|
730
|
+
launchd: process.env.XPC_SERVICE_NAME === lifecycle.LABEL,
|
|
729
731
|
machine: machineName(),
|
|
730
732
|
connected: Boolean(ctx.connected),
|
|
731
733
|
projects: ctx.projects.map((project) => project.where.worktree),
|
|
@@ -813,6 +815,12 @@ function readStatus() {
|
|
|
813
815
|
} catch {
|
|
814
816
|
running = false;
|
|
815
817
|
}
|
|
818
|
+
// A status file a launchd-started bridge wrote is current only while
|
|
819
|
+
// launchd still runs that pid (D4); a bridge run by hand has only its pid.
|
|
820
|
+
if (running && status.launchd && lifecycle.installed()) {
|
|
821
|
+
const state = lifecycle.loadedState();
|
|
822
|
+
if (state && (!state.loaded || (state.pid && state.pid !== status.pid))) running = false;
|
|
823
|
+
}
|
|
816
824
|
return { ...status, running, connected: running && Boolean(status.connected) };
|
|
817
825
|
}
|
|
818
826
|
|
package/src/core/chat/cli.js
CHANGED
|
@@ -444,8 +444,7 @@ function runBridge(where, rest, options) {
|
|
|
444
444
|
out(`Removed ${lifecycle.uninstall()}; the bridge no longer runs on this machine.`);
|
|
445
445
|
return 0;
|
|
446
446
|
case "start":
|
|
447
|
-
lifecycle.start();
|
|
448
|
-
out("Started the bridge.");
|
|
447
|
+
out(lifecycle.start() ? "Started the bridge." : "The bridge is already loaded; launchd keeps it running.");
|
|
449
448
|
return 0;
|
|
450
449
|
case "stop":
|
|
451
450
|
lifecycle.stop();
|
|
@@ -165,6 +165,57 @@ function domain() {
|
|
|
165
165
|
return `gui/${typeof process.getuid === "function" ? process.getuid() : 0}`;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
// launchd's view of the agent (bridge-start-race D1): loaded with its state
|
|
169
|
+
// and pid, unloaded, or null when launchctl gives no answer to read — a
|
|
170
|
+
// system without it, or a test double that prints nothing.
|
|
171
|
+
function loadedState() {
|
|
172
|
+
const result = launchctl(["print", `${domain()}/${LABEL}`]);
|
|
173
|
+
const state = result.output.match(/^\s*state = (\S+)/m);
|
|
174
|
+
if (result.ok && state) {
|
|
175
|
+
const pid = result.output.match(/^\s*pid = (\d+)/m);
|
|
176
|
+
return { loaded: true, state: state[1], pid: pid ? Number(pid[1]) : null };
|
|
177
|
+
}
|
|
178
|
+
if (!result.ok && /could not find service/i.test(result.output)) return { loaded: false };
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function waitLimit() {
|
|
183
|
+
const ms = Number(process.env.KEEL_CHAT_LAUNCHCTL_WAIT_MS);
|
|
184
|
+
return Number.isFinite(ms) && ms >= 0 ? ms : 10000;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function sleep(ms) {
|
|
188
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// `bootout` returns before launchd has removed the service (F1); waits,
|
|
192
|
+
// bounded, until it reports the service gone or gives no answer.
|
|
193
|
+
function bootout() {
|
|
194
|
+
launchctl(["bootout", `${domain()}/${LABEL}`]);
|
|
195
|
+
const deadline = Date.now() + waitLimit();
|
|
196
|
+
for (;;) {
|
|
197
|
+
const state = loadedState();
|
|
198
|
+
if (!state || !state.loaded || Date.now() >= deadline) return;
|
|
199
|
+
sleep(250);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Loads the agent, retrying while a previous unload is still in progress
|
|
204
|
+
// (D2); any other failure, or one that outlasts the wait, is reported with
|
|
205
|
+
// launchctl's own words.
|
|
206
|
+
function bootstrap(what) {
|
|
207
|
+
const deadline = Date.now() + waitLimit();
|
|
208
|
+
for (;;) {
|
|
209
|
+
const loaded = launchctl(["bootstrap", domain(), plistPath()]);
|
|
210
|
+
if (loaded.ok) return;
|
|
211
|
+
const busy = /already|in progress|5:/i.test(loaded.output);
|
|
212
|
+
if (!busy || Date.now() >= deadline) {
|
|
213
|
+
throw new ChatError(`launchctl could not ${what}: ${loaded.output}`);
|
|
214
|
+
}
|
|
215
|
+
sleep(500);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
168
219
|
function install() {
|
|
169
220
|
if (process.platform !== "darwin" && !process.env.KEEL_CHAT_LAUNCHCTL) {
|
|
170
221
|
throw new ChatError("keel chat bridge install sets up a macOS LaunchAgent; on this system run `keel chat bridge run` under your own service manager.");
|
|
@@ -172,14 +223,13 @@ function install() {
|
|
|
172
223
|
fs.mkdirSync(agentsDir(), { recursive: true });
|
|
173
224
|
fs.mkdirSync(bridgeDir(), { recursive: true });
|
|
174
225
|
fs.writeFileSync(plistPath(), plistText());
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (!loaded.ok) throw new ChatError(`launchctl could not load ${plistPath()}: ${loaded.output}`);
|
|
226
|
+
bootout();
|
|
227
|
+
bootstrap(`load ${plistPath()}`);
|
|
178
228
|
return plistPath();
|
|
179
229
|
}
|
|
180
230
|
|
|
181
231
|
function uninstall() {
|
|
182
|
-
|
|
232
|
+
bootout();
|
|
183
233
|
try {
|
|
184
234
|
fs.rmSync(plistPath());
|
|
185
235
|
} catch {
|
|
@@ -188,19 +238,21 @@ function uninstall() {
|
|
|
188
238
|
return plistPath();
|
|
189
239
|
}
|
|
190
240
|
|
|
241
|
+
// Returns false when launchd already has the agent loaded, and so keeps it
|
|
242
|
+
// running, and nothing was done.
|
|
191
243
|
function start() {
|
|
192
244
|
if (!installed()) throw new ChatError("The bridge is not installed: run `keel chat bridge install` first.");
|
|
193
245
|
resume();
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
246
|
+
const state = loadedState();
|
|
247
|
+
if (state && state.loaded) return false;
|
|
248
|
+
bootstrap("start the bridge");
|
|
249
|
+
return true;
|
|
198
250
|
}
|
|
199
251
|
|
|
200
252
|
// Unloads the agent: it stays stopped until `start`, or until the next login
|
|
201
253
|
// loads it again.
|
|
202
254
|
function stop() {
|
|
203
|
-
|
|
255
|
+
bootout();
|
|
204
256
|
}
|
|
205
257
|
|
|
206
258
|
module.exports = {
|
|
@@ -210,6 +262,7 @@ module.exports = {
|
|
|
210
262
|
bridgeDir,
|
|
211
263
|
install,
|
|
212
264
|
installed,
|
|
265
|
+
loadedState,
|
|
213
266
|
missingTokens,
|
|
214
267
|
pause,
|
|
215
268
|
pausedUntil,
|
package/src/core/chat/notice.js
CHANGED
|
@@ -132,14 +132,24 @@ function bridgeLine(where) {
|
|
|
132
132
|
}
|
|
133
133
|
if (!settings.enabled) return null;
|
|
134
134
|
const status = require("./bridge").fullStatus();
|
|
135
|
+
let line;
|
|
135
136
|
if (!status.running) {
|
|
136
|
-
|
|
137
|
+
line = "keel chat bridge: not running on this machine, so Slack messages are not reaching this session "
|
|
137
138
|
+ "(local chat still works). `keel chat bridge start`, or `keel chat bridge install` once, brings it up.";
|
|
139
|
+
} else if (status.paused) {
|
|
140
|
+
line = `keel chat bridge: paused until ${status.paused_until}; messages wait until then.`;
|
|
141
|
+
} else {
|
|
142
|
+
line = `keel chat bridge: running${status.connected ? " and connected" : ", reconnecting"}, serving ${status.projects.length} project${status.projects.length === 1 ? "" : "s"}.`;
|
|
138
143
|
}
|
|
139
|
-
|
|
140
|
-
return `keel chat bridge: running${status.connected ? " and connected" : ", reconnecting"}, serving ${status.projects.length} project${status.projects.length === 1 ? "" : "s"}.`;
|
|
144
|
+
return settings.owner ? `${line}\n${OWNER_RULE}` : line;
|
|
141
145
|
}
|
|
142
146
|
|
|
147
|
+
// The owner's rule of 2026-10-05 (chat-owner-mention D1-D3): Slack notifies
|
|
148
|
+
// the owner only for a mention, and the bridge mentions them only for
|
|
149
|
+
// `@owner`, so whether a message reaches their phone is the session's choice.
|
|
150
|
+
const OWNER_RULE = "Slack notifies the owner only for messages that write `@owner`: write it in any message the owner "
|
|
151
|
+
+ "needs to see or decide on, and leave it out of routine discussion.";
|
|
152
|
+
|
|
143
153
|
const HOST_EVENTS = {
|
|
144
154
|
"session-start": "SessionStart",
|
|
145
155
|
"user-prompt-submit": "UserPromptSubmit",
|