@koalaauto/agentchannel 3.55.0 → 3.55.1
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/dist/src/adapters/claude.d.ts +13 -7
- package/dist/src/adapters/claude.js +27 -10
- package/dist/src/client.d.ts +2 -0
- package/dist/src/client.js +16 -1
- package/dist/src/prompts.js +2 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
|
@@ -14,15 +14,21 @@ export declare const MENTION_ACH_TOOLS: string[];
|
|
|
14
14
|
/**
|
|
15
15
|
* Mention runs may also read the repository's history: who changed what and when is what people ask in a thread. The sandbox
|
|
16
16
|
* does not make these read-only by itself (the run's directory stays writable to a sandboxed command; live-tested:
|
|
17
|
-
* `git log --output=<file>` wrote the file), so
|
|
17
|
+
* `git log --output=<file>` wrote the file), so mentionCommandDenied() checks every git command of a mention run before it starts.
|
|
18
18
|
*/
|
|
19
19
|
export declare const MENTION_GIT_TOOLS: string[];
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* And read GitHub through `gh`, with the run's read-only token (GH_TOKEN, scoped by the hub): a thread about a pull request needs
|
|
22
|
+
* its diff, and a branch nobody fetched is not in the local history (2026-11-20: four runs answered a thread about PR #12 without
|
|
23
|
+
* ever seeing it, each saying it could not read GitHub). Only the commands below; mentionCommandDenied() checks their options.
|
|
24
24
|
*/
|
|
25
|
-
export declare
|
|
25
|
+
export declare const MENTION_GH_TOOLS: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Why a mention run may not run this git or gh command (undefined: it may). One plain command of the allowed ones: nothing a shell
|
|
28
|
+
* would expand, chain or redirect, no option that writes a file (`--output`, in any abbreviation git accepts) or names a program to
|
|
29
|
+
* run (`--ext-diff`, `-c`, `--exec`), and nothing before `git` or `gh` (an environment variable can name a program too).
|
|
30
|
+
*/
|
|
31
|
+
export declare function mentionCommandDenied(command: string): string | undefined;
|
|
26
32
|
/**
|
|
27
33
|
* Whether a command is one plain `ach <sub> ...` call of an allowed subcommand: literal words only. Claude Code's own rule
|
|
28
34
|
* (`Bash(ach reply:*)`) gives up on a long quoted argument with `;` or a line break in it and asks, which a run that cannot ask
|
|
@@ -37,8 +43,8 @@ export declare function plainAchCommand(command: string, subs: string[]): boolea
|
|
|
37
43
|
export declare const achSubcommands: (tools: string[]) => string[];
|
|
38
44
|
/** PreToolUse for Bash: a plain call of one of the run's `ach` commands is allowed outright (see plainAchCommand). */
|
|
39
45
|
export declare function achCommandHook(tools: string[]): HookCallbackMatcher;
|
|
40
|
-
/** PreToolUse for a mention run's Bash: the git rules above (a hook runs for pre-approved commands too). */
|
|
41
|
-
export declare function
|
|
46
|
+
/** PreToolUse for a mention run's Bash: the git and gh rules above (a hook runs for pre-approved commands too). */
|
|
47
|
+
export declare function mentionReadHook(): HookCallbackMatcher;
|
|
42
48
|
/** canUseTool for workdir: path policy (reads under $HOME, writes outside cwd) plus the Bash deny list. */
|
|
43
49
|
export declare function workdirCanUseTool(pol: PathPolicy): CanUseTool;
|
|
44
50
|
/**
|
|
@@ -44,16 +44,33 @@ export const MENTION_ACH_TOOLS = ['Bash(ach reply:*)', 'Bash(ach thread:*)', 'Ba
|
|
|
44
44
|
/**
|
|
45
45
|
* Mention runs may also read the repository's history: who changed what and when is what people ask in a thread. The sandbox
|
|
46
46
|
* does not make these read-only by itself (the run's directory stays writable to a sandboxed command; live-tested:
|
|
47
|
-
* `git log --output=<file>` wrote the file), so
|
|
47
|
+
* `git log --output=<file>` wrote the file), so mentionCommandDenied() checks every git command of a mention run before it starts.
|
|
48
48
|
*/
|
|
49
49
|
export const MENTION_GIT_TOOLS = ['Bash(git log:*)', 'Bash(git show:*)', 'Bash(git diff:*)', 'Bash(git blame:*)', 'Bash(git status:*)'];
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* And read GitHub through `gh`, with the run's read-only token (GH_TOKEN, scoped by the hub): a thread about a pull request needs
|
|
52
|
+
* its diff, and a branch nobody fetched is not in the local history (2026-11-20: four runs answered a thread about PR #12 without
|
|
53
|
+
* ever seeing it, each saying it could not read GitHub). Only the commands below; mentionCommandDenied() checks their options.
|
|
54
54
|
*/
|
|
55
|
-
export
|
|
55
|
+
export const MENTION_GH_TOOLS = ['Bash(gh pr view:*)', 'Bash(gh pr diff:*)', 'Bash(gh pr checks:*)', 'Bash(gh pr list:*)', 'Bash(gh issue view:*)', 'Bash(gh issue list:*)', 'Bash(gh run view:*)', 'Bash(gh run list:*)'];
|
|
56
|
+
const MENTION_GH = new Set(MENTION_GH_TOOLS.map((t) => /^Bash\(gh ([a-z]+ [a-z]+):\*\)$/.exec(t)[1]));
|
|
57
|
+
/**
|
|
58
|
+
* Why a mention run may not run this git or gh command (undefined: it may). One plain command of the allowed ones: nothing a shell
|
|
59
|
+
* would expand, chain or redirect, no option that writes a file (`--output`, in any abbreviation git accepts) or names a program to
|
|
60
|
+
* run (`--ext-diff`, `-c`, `--exec`), and nothing before `git` or `gh` (an environment variable can name a program too).
|
|
61
|
+
*/
|
|
62
|
+
export function mentionCommandDenied(command) {
|
|
56
63
|
const cmd = command.trim();
|
|
64
|
+
if (/^gh(\s|$)/.test(cmd)) {
|
|
65
|
+
if (/[;&|<>$`\\(){}\n\r]/.test(cmd))
|
|
66
|
+
return 'gh runs here as one plain command: no pipes, redirects, `&&`, `$(...)` or line breaks';
|
|
67
|
+
const args = cmd.replace(/["']/g, '').split(/\s+/).slice(1);
|
|
68
|
+
if (!MENTION_GH.has(args.slice(0, 2).join(' ')))
|
|
69
|
+
return `only ${[...MENTION_GH].map((c) => `gh ${c}`).join(', ')} run here`;
|
|
70
|
+
if (args.some((a) => /^(-w|--web)$/.test(a)))
|
|
71
|
+
return 'this run reads in the terminal: no --web';
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
57
74
|
if (!/^git(\s|$)/.test(cmd))
|
|
58
75
|
return undefined;
|
|
59
76
|
if (/[;&|<>$`\\(){}\n\r]/.test(cmd))
|
|
@@ -136,14 +153,14 @@ export function achCommandHook(tools) {
|
|
|
136
153
|
],
|
|
137
154
|
};
|
|
138
155
|
}
|
|
139
|
-
/** PreToolUse for a mention run's Bash: the git rules above (a hook runs for pre-approved commands too). */
|
|
140
|
-
export function
|
|
156
|
+
/** PreToolUse for a mention run's Bash: the git and gh rules above (a hook runs for pre-approved commands too). */
|
|
157
|
+
export function mentionReadHook() {
|
|
141
158
|
return {
|
|
142
159
|
hooks: [
|
|
143
160
|
async (input) => {
|
|
144
161
|
if (input.hook_event_name !== 'PreToolUse' || input.tool_name !== 'Bash')
|
|
145
162
|
return {};
|
|
146
|
-
const why =
|
|
163
|
+
const why = mentionCommandDenied(String((input.tool_input ?? {}).command ?? ''));
|
|
147
164
|
if (!why)
|
|
148
165
|
return {};
|
|
149
166
|
return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: why } };
|
|
@@ -274,9 +291,9 @@ export function claudePermOptions(perm, o) {
|
|
|
274
291
|
...base,
|
|
275
292
|
// pre-approved at every level: without that, Claude Code does not offer Glob and Grep to the model at workdir (live
|
|
276
293
|
// test). The PreToolUse hook checks them; the SDK's notice that canUseTool is shadowed for them is expected.
|
|
277
|
-
allowedTools: ['Read', 'Glob', 'Grep', ...achTools, ...(o.mode === 'mention' ? MENTION_GIT_TOOLS : [])],
|
|
294
|
+
allowedTools: ['Read', 'Glob', 'Grep', ...achTools, ...(o.mode === 'mention' ? [...MENTION_GIT_TOOLS, ...MENTION_GH_TOOLS] : [])],
|
|
278
295
|
sandbox,
|
|
279
|
-
hooks: { PreToolUse: [pathPolicyHook(pol), achCommandHook(achTools), ...(o.mode === 'mention' ? [
|
|
296
|
+
hooks: { PreToolUse: [pathPolicyHook(pol), achCommandHook(achTools), ...(o.mode === 'mention' ? [mentionReadHook()] : [])] },
|
|
280
297
|
};
|
|
281
298
|
if (perm === 'read')
|
|
282
299
|
return { ...common, permissionMode: 'dontAsk' };
|
package/dist/src/client.d.ts
CHANGED
|
@@ -400,6 +400,8 @@ export declare class NetworkError extends Error {
|
|
|
400
400
|
* (ENOTFOUND, ECONNREFUSED) or a hub that took the request and did not answer in time.
|
|
401
401
|
*/
|
|
402
402
|
export declare function retryable(method: string, e: any): boolean;
|
|
403
|
+
/** The status a proxy answered a CONNECT with, when that is why the fetch failed (undici: "Proxy response (502) !== 200 when HTTP Tunneling", a few causes down). */
|
|
404
|
+
export declare function proxyTunnelStatus(e: any): number | undefined;
|
|
403
405
|
export declare class HubError extends Error {
|
|
404
406
|
status: number;
|
|
405
407
|
code?: string | undefined;
|
package/dist/src/client.js
CHANGED
|
@@ -46,8 +46,22 @@ export function retryable(method, e) {
|
|
|
46
46
|
const code = String(e?.cause?.code ?? e?.code ?? '');
|
|
47
47
|
if (CONNECT_FAULTS.has(code))
|
|
48
48
|
return true;
|
|
49
|
+
// the proxy could not open its tunnel to the hub (a sandbox's proxy answers 502 when its own connect fails): nothing was sent.
|
|
50
|
+
// 2026-11-20: ~20% of connects from one runner machine to the hub's Cloudflare address stalled, and every one surfaced as a
|
|
51
|
+
// failed `ach` call in a run ("cannot reach ... (0)"); a 403 is the proxy refusing the host, which another try does not change.
|
|
52
|
+
if ([502, 503, 504].includes(proxyTunnelStatus(e) ?? 0))
|
|
53
|
+
return true;
|
|
49
54
|
return (method === 'GET' || method === 'HEAD') && SOCKET_FAULTS.has(code);
|
|
50
55
|
}
|
|
56
|
+
/** The status a proxy answered a CONNECT with, when that is why the fetch failed (undici: "Proxy response (502) !== 200 when HTTP Tunneling", a few causes down). */
|
|
57
|
+
export function proxyTunnelStatus(e) {
|
|
58
|
+
for (let c = e, i = 0; c && i < 5; c = c.cause, i++) {
|
|
59
|
+
const m = /Proxy response \((\d{3})\) !== 200/.exec(String(c?.message ?? ''));
|
|
60
|
+
if (m)
|
|
61
|
+
return Number(m[1]);
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
51
65
|
export class HubError extends Error {
|
|
52
66
|
status;
|
|
53
67
|
code;
|
|
@@ -171,7 +185,8 @@ export class Client {
|
|
|
171
185
|
catch {
|
|
172
186
|
return url;
|
|
173
187
|
} })();
|
|
174
|
-
const
|
|
188
|
+
const tunnel = proxyTunnelStatus(e);
|
|
189
|
+
const why = e?.name === 'TimeoutError' ? `no answer within ${REQUEST_TIMEOUT_MS / 1000} s` : tunnel ? `the proxy answered ${tunnel}` : String(e?.cause?.code ?? e?.cause?.message ?? e?.message ?? e);
|
|
175
190
|
const tries = attempt > 0 ? `, ${attempt + 1} tries` : '';
|
|
176
191
|
throw new NetworkError(`cannot reach ${host} (${why}${tries}): check the hub address, your network, and whether a VPN or proxy is in the way. \`ach doctor\` checks each step.`);
|
|
177
192
|
}
|
package/dist/src/prompts.js
CHANGED
|
@@ -547,7 +547,8 @@ export function buildMentionPrompt(c) {
|
|
|
547
547
|
ownerAskedRule(c.ownerName, false),
|
|
548
548
|
"- Flag values go in single quotes, with no backtick or `$` in them; the heredoc's last line is `EOF` alone.",
|
|
549
549
|
'- `ach thread` shows the whole thread; `ach channel` the channel. Reply once, then stop.',
|
|
550
|
-
'- Besides these three `ach` commands only `git log`, `git show`, `git diff`, `git blame` and `git status` run here, each as one plain command (no pipes, no `cd`); any other command is refused (that does not mean `ach reply` is). Read files with Read, Glob and Grep.',
|
|
550
|
+
'- Besides these three `ach` commands only `git log`, `git show`, `git diff`, `git blame` and `git status` run here, and for GitHub `gh pr view|diff|checks|list`, `gh issue view|list` and `gh run view|list` (a pull request\'s branch is usually not in the local history: read it with `gh pr view <n>` and `gh pr diff <n>`), each as one plain command (no pipes, no `cd`); any other command is refused (that does not mean `ach reply` is). Read files with Read, Glob and Grep.',
|
|
551
|
+
'- Say you cannot read something only after the command for it failed, and quote its error in the evidence.',
|
|
551
552
|
'- If `ach reply` itself is refused or fails, end with the reply as your last message, written to the people in the thread: it is posted there as your reply.',
|
|
552
553
|
'- Mention other agents (@name) only when you really need them; every agent-to-agent mention counts against the thread\'s hop limit.',
|
|
553
554
|
];
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalaauto/agentchannel",
|
|
3
|
-
"version": "3.55.
|
|
3
|
+
"version": "3.55.1",
|
|
4
4
|
"description": "Hand work between your team's agents (Claude Code, Codex) and follow it in one panel: the ach CLI, MCP server and runner for AgentChannel v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentchannel",
|