baychat 0.29.9 → 0.30.0

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.
@@ -37,6 +37,8 @@ exports.TERMINAL_SETTINGS_FILE = exports.UNATTENDED_SETTINGS = exports.JOIN_ALLO
37
37
  exports.approvalPathFor = approvalPathFor;
38
38
  exports.launchDir = launchDir;
39
39
  exports.approvalSettingsPath = approvalSettingsPath;
40
+ exports.deniedCardHooks = deniedCardHooks;
41
+ exports.withDeniedCard = withDeniedCard;
40
42
  exports.approvalSettings = approvalSettings;
41
43
  exports.terminalApprovalSettings = terminalApprovalSettings;
42
44
  exports.approvalsDir = approvalsDir;
@@ -48,6 +50,7 @@ const fs = __importStar(require("fs"));
48
50
  const path = __importStar(require("path"));
49
51
  const approve_hook_1 = require("../../approve-hook");
50
52
  const config_1 = require("../../config");
53
+ const opt_in_1 = require("../../denied/opt-in");
51
54
  /** Always `"hook"` for now: Claude Code's channel permission relay is behind a flag that is off. */
52
55
  function approvalPathFor(_sessionName) {
53
56
  return "hook";
@@ -94,6 +97,57 @@ function permissionHook(cli, flags) {
94
97
  ],
95
98
  };
96
99
  }
100
+ /** The tools the after-hook watches: the ones a once-rule can be written for (permission-rule.ts). */
101
+ const DENIED_AFTER_MATCHER = "Bash|WebFetch|mcp__.*";
102
+ /** The after-hook is async and returns in milliseconds; this bounds only a wedged one. */
103
+ const DENIED_AFTER_TIMEOUT_SECONDS = 30;
104
+ /**
105
+ * The denied-command card's hooks (docs/features/DENIED_COMMAND_CARD.md). `flags` are the same
106
+ * session flags approve-hook gets in that file.
107
+ */
108
+ function deniedCardHooks(cli, flags) {
109
+ const after = {
110
+ matcher: DENIED_AFTER_MATCHER,
111
+ hooks: [
112
+ {
113
+ type: "command",
114
+ command: cli.node,
115
+ args: [cli.entry, "denied-after"],
116
+ // Never in a tool call's way: Claude Code starts it and carries on.
117
+ async: true,
118
+ timeout: DENIED_AFTER_TIMEOUT_SECONDS,
119
+ },
120
+ ],
121
+ };
122
+ return {
123
+ PermissionDenied: [
124
+ {
125
+ matcher: "*",
126
+ hooks: [
127
+ {
128
+ type: "command",
129
+ command: cli.node,
130
+ args: [cli.entry, "denied-hook", ...flags, "--timeout", String(approve_hook_1.DEFAULT_WAIT_SECONDS)],
131
+ // Our own deadline (which withdraws the card) lands first; being killed would only
132
+ // leave the denial standing, but also the card looking answerable.
133
+ timeout: approve_hook_1.RECOMMENDED_HANDLER_TIMEOUT_SECONDS,
134
+ statusMessage: "Blocked by auto mode — asking in BayChat…",
135
+ },
136
+ ],
137
+ },
138
+ ],
139
+ PostToolUse: [after],
140
+ PostToolUseFailure: [after],
141
+ };
142
+ }
143
+ /** `settings` with the denied-command card's hooks added beside its own. Pure. */
144
+ function withDeniedCard(settings, cli, flags) {
145
+ return { ...settings, hooks: { ...(settings.hooks ?? {}), ...deniedCardHooks(cli, flags) } };
146
+ }
147
+ /** The file's settings, with the card's hooks when the owner turned it on. */
148
+ function withOptIn(settings, cli, flags) {
149
+ return (0, opt_in_1.deniedCardEnabled)() ? withDeniedCard(settings, cli, flags) : settings;
150
+ }
97
151
  /**
98
152
  * Claude Code nudges that stop a session with a menu nobody can answer, switched off for
99
153
  * launched sessions only. "Teach auto mode about your environment?" (1 Yes / 2 Not now / 3 Don't
@@ -130,7 +184,7 @@ exports.TERMINAL_SETTINGS_FILE = "claude-terminal.settings.json";
130
184
  */
131
185
  function writeTerminalApprovalSettings(cli, dir = approvalsDir()) {
132
186
  const file = path.join(dir, exports.TERMINAL_SETTINGS_FILE);
133
- writePrivateJson(dir, file, terminalApprovalSettings(cli));
187
+ writePrivateJson(dir, file, withOptIn(terminalApprovalSettings(cli), cli, ["--session-from-claude"]));
134
188
  return file;
135
189
  }
136
190
  function writePrivateJson(dir, file, value) {
@@ -145,7 +199,7 @@ function currentCliLaunch() {
145
199
  /** Write the session's settings file (0600) and return its path. `sessionName` must already be validated. */
146
200
  function writeApprovalSettings(sessionName, cli, dir = launchDir(), bayEntry) {
147
201
  const file = approvalSettingsPath(sessionName, dir);
148
- writePrivateJson(dir, file, approvalSettings(sessionName, cli, bayEntry));
202
+ writePrivateJson(dir, file, withOptIn(approvalSettings(sessionName, cli, bayEntry), cli, ["--session", sessionName]));
149
203
  return file;
150
204
  }
151
205
  /** Delete the session's settings file. Idempotent: an absent file is already deleted. */
package/dist/runtimes.js CHANGED
@@ -181,13 +181,13 @@ ${ctx.invocation}
181
181
  \`\`\`
182
182
 
183
183
  - The supplied name becomes both your BayChat agent name and session name automatically.
184
- - With a name only: the shared Sessions group in your Bay, plus your private owner chat.
184
+ - With a name only: the shared Sessions group in your Bay. No private chat is created.
185
185
  - With \`--sessions\` and no name: automatically name this verified session and join Sessions.
186
186
  - With \`<name> --private\`: join only your private owner chat.
187
187
  - With a name and a group title: join that exact group, or create it if missing.
188
188
  - With a name and a group id (\`--group "<id>"\`, as a session started from the
189
189
  BayChat app gets): join that group; never create one.
190
- Joining an existing group requires membership and admin rights. Your private chat stays available under the same name.
190
+ Joining an existing group requires membership and admin rights. A group join creates no private chat; one you already have stays available under the same name.
191
191
  \`list_groups\` prints the exact titles.
192
192
  - With \`--group "<title>"\` and no name: automatic naming is explicitly requested.
193
193
  The join command chooses a name from this verified native session. It stays
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baychat",
3
- "version": "0.29.9",
3
+ "version": "0.30.0",
4
4
  "description": "BayChat connector CLI — pair an agent session (Claude Code, Codex, Cursor) with BayChat, or have the relay run DeepSeek or the Cursor CLI for you",
5
5
  "bin": {
6
6
  "baychat": "dist/index.js"