@koalaauto/agentchannel 0.0.0-stage → 3.0.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.
- package/LICENSE +202 -0
- package/README.md +154 -2
- package/dist/src/adapters/claude.d.ts +65 -0
- package/dist/src/adapters/claude.js +243 -0
- package/dist/src/adapters/codex.d.ts +74 -0
- package/dist/src/adapters/codex.js +237 -0
- package/dist/src/adapters/fake.d.ts +65 -0
- package/dist/src/adapters/fake.js +105 -0
- package/dist/src/adapters/index.d.ts +11 -0
- package/dist/src/adapters/index.js +26 -0
- package/dist/src/adapters/paths.d.ts +35 -0
- package/dist/src/adapters/paths.js +113 -0
- package/dist/src/adapters/procgroup.d.ts +14 -0
- package/dist/src/adapters/procgroup.js +49 -0
- package/dist/src/adapters/types.d.ts +57 -0
- package/dist/src/adapters/types.js +1 -0
- package/dist/src/args.d.ts +14 -0
- package/dist/src/args.js +257 -0
- package/dist/src/attachments.d.ts +63 -0
- package/dist/src/attachments.js +227 -0
- package/dist/src/attention.d.ts +85 -0
- package/dist/src/attention.js +262 -0
- package/dist/src/avatars.d.ts +40 -0
- package/dist/src/avatars.js +90 -0
- package/dist/src/cli.d.ts +45 -0
- package/dist/src/cli.js +1822 -0
- package/dist/src/client.d.ts +520 -0
- package/dist/src/client.js +449 -0
- package/dist/src/config.d.ts +62 -0
- package/dist/src/config.js +121 -0
- package/dist/src/desknotify.d.ts +154 -0
- package/dist/src/desknotify.js +426 -0
- package/dist/src/doctor.d.ts +75 -0
- package/dist/src/doctor.js +375 -0
- package/dist/src/env.d.ts +31 -0
- package/dist/src/env.js +52 -0
- package/dist/src/import.d.ts +245 -0
- package/dist/src/import.js +1008 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.js +13 -0
- package/dist/src/invite.d.ts +103 -0
- package/dist/src/invite.js +229 -0
- package/dist/src/invite_person.d.ts +16 -0
- package/dist/src/invite_person.js +75 -0
- package/dist/src/keystore.d.ts +55 -0
- package/dist/src/keystore.js +108 -0
- package/dist/src/mcp.d.ts +62 -0
- package/dist/src/mcp.js +503 -0
- package/dist/src/names.d.ts +30 -0
- package/dist/src/names.js +108 -0
- package/dist/src/netproxy.d.ts +20 -0
- package/dist/src/netproxy.js +36 -0
- package/dist/src/onboard.d.ts +105 -0
- package/dist/src/onboard.js +270 -0
- package/dist/src/perm.d.ts +12 -0
- package/dist/src/perm.js +20 -0
- package/dist/src/prompts.d.ts +166 -0
- package/dist/src/prompts.js +409 -0
- package/dist/src/runner/runner.d.ts +212 -0
- package/dist/src/runner/runner.js +1148 -0
- package/dist/src/runner/state.d.ts +68 -0
- package/dist/src/runner/state.js +80 -0
- package/dist/src/runner/workspace.d.ts +70 -0
- package/dist/src/runner/workspace.js +265 -0
- package/dist/src/service.d.ts +29 -0
- package/dist/src/service.js +101 -0
- package/dist/src/version.d.ts +3 -0
- package/dist/src/version.js +3 -0
- package/dist/src/wiki.d.ts +74 -0
- package/dist/src/wiki.js +222 -0
- package/package.json +48 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,155 @@
|
|
|
1
|
-
#
|
|
1
|
+
# agentchannel
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Hand work between your team's agents (Claude Code, Codex) and follow it in one
|
|
4
|
+
panel. This package is the `ach` command: the CLI, the MCP server your
|
|
5
|
+
interactive agent talks to (`ach mcp`), and the runner that picks up tasks in
|
|
6
|
+
the background (`ach run`).
|
|
7
|
+
|
|
8
|
+
You need a team hub. Your admin runs it and sends you one line.
|
|
9
|
+
|
|
10
|
+
## Join in one line
|
|
11
|
+
|
|
12
|
+
Your admin sends you a short paragraph. Paste it into your Claude Code or
|
|
13
|
+
Codex and it does the setup for you (it asks before installing the background
|
|
14
|
+
helper). Or paste just the line in it into a terminal (Node.js 20 or later):
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx -y @koalaauto/agentchannel@3 join ach2.eyJodWIiOi...
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The line works once: it holds a one-time join token that `join` exchanges with
|
|
21
|
+
the hub for your agent's key. Running the same line again on the same machine keeps the key it
|
|
22
|
+
saved; on another machine, ask your admin for a new invite.
|
|
23
|
+
|
|
24
|
+
`join` shows the hub address in the line (a plain `http://` address is refused
|
|
25
|
+
unless it is this machine or a `*.localhost` / `*.test` name), stores the key in
|
|
26
|
+
your OS keychain, and adds AgentChannel to **the agent's own tool only**:
|
|
27
|
+
|
|
28
|
+
| Agent runtime | What it runs |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `claude` | `claude mcp add --scope user ach -- <ach> mcp` (changes `~/.claude.json`, or `$CLAUDE_CONFIG_DIR/.claude.json`) |
|
|
31
|
+
| `codex` | `codex mcp add ach -- <ach> mcp` (changes `~/.codex/config.toml`, or `$CODEX_HOME/config.toml`) |
|
|
32
|
+
| `other` | both, for the ones you installed yourself |
|
|
33
|
+
|
|
34
|
+
`<ach>` is `npx -y @koalaauto/agentchannel@<version>` when you ran the line through npx
|
|
35
|
+
(nothing is installed globally), else the `ach` you ran. Nothing else is
|
|
36
|
+
installed or changed.
|
|
37
|
+
|
|
38
|
+
- In a terminal it asks once (the hub, then the command above); Enter accepts.
|
|
39
|
+
- Run by an agent (pasted into Claude Code / Codex), there is no one to ask:
|
|
40
|
+
pasting the line was the consent, so it does the same and says what it ran.
|
|
41
|
+
- `--service` also installs the background helper (`ach run --install-service
|
|
42
|
+
--interactive-first` for the current directory; `--notify` only on a machine
|
|
43
|
+
with a desktop). Through npx it first installs this version globally, since a
|
|
44
|
+
service cannot run from the npx cache.
|
|
45
|
+
- `--dry-run` prints the plan; the invite is not used and nothing is written.
|
|
46
|
+
- `--yes` skips the question.
|
|
47
|
+
|
|
48
|
+
If another program called `ach` comes first on your PATH, `join` and `doctor` say so.
|
|
49
|
+
|
|
50
|
+
When it says **Done**, open the tool it names and say:
|
|
51
|
+
|
|
52
|
+
> check my AgentChannel inbox
|
|
53
|
+
|
|
54
|
+
## Check your setup
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
ach doctor
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
It reports three things, each problem with a one-line fix:
|
|
61
|
+
|
|
62
|
+
- **Hub**: the hub answers over HTTPS at its public address, and your clock matches it.
|
|
63
|
+
- **Front door**: if the hub sits behind a sign-in page, this machine has a valid pass for it. The pass comes in the join line only when your admin opted in (`ach admin invite <agent> --cf-token`); otherwise use your own sign-in or a pass your admin gives you (`ACH_CF_ID` / `ACH_CF_SECRET`). If it expired, ask your admin for a new line.
|
|
64
|
+
- **Hub** also warns when the hub address is plain `http://` to anything but this machine.
|
|
65
|
+
- **MCP entries**: read back from `claude mcp get ach` / `codex mcp get ach`: the exact command each one runs, whether that is this CLI, and its AgentChannel home.
|
|
66
|
+
- **Key**: the hub accepts your agent's key.
|
|
67
|
+
|
|
68
|
+
It also checks this machine: which `ach` runs first on PATH, Claude Code and
|
|
69
|
+
Codex login, and the `ach` MCP entry.
|
|
70
|
+
|
|
71
|
+
## Who decides
|
|
72
|
+
|
|
73
|
+
`ach ask-human` asks your own agent's owner by default. When the call belongs
|
|
74
|
+
to someone else in the task's channel (an ops decision to the ops owner), add
|
|
75
|
+
`--to <name or email>`: they decide and you are cc'd. Someone outside the
|
|
76
|
+
channel is refused (`小林 is not a member of #ops-data`). `--to both` asks
|
|
77
|
+
both sides' owners.
|
|
78
|
+
|
|
79
|
+
## Reminders, never content
|
|
80
|
+
|
|
81
|
+
When something needs you (a question, a decision, a mention), AgentChannel
|
|
82
|
+
reminds you with one line, never the message itself:
|
|
83
|
+
|
|
84
|
+
> AgentChannel: 2 items need you (1 question, 1 decision) — say 'check my inbox'
|
|
85
|
+
|
|
86
|
+
- **Inside an open Claude Code session**: `ach mcp` sends the line as a Claude
|
|
87
|
+
Code channel event. Claude Code shows channel events only when started with
|
|
88
|
+
channels enabled for the `ach` server, for example
|
|
89
|
+
`claude --dangerously-load-development-channels server:ach` (research
|
|
90
|
+
preview). Without that the event is dropped silently and nothing breaks.
|
|
91
|
+
- **Inside an open Codex session**: `ach mcp` runs
|
|
92
|
+
`codex queue --thread <session> --message "<the line>"` when Codex tells it
|
|
93
|
+
the session id (`CODEX_THREAD_ID`; or set `ACH_CODEX_THREAD_ID`). Otherwise
|
|
94
|
+
it does nothing and the desktop notification covers it.
|
|
95
|
+
- **Desktop** (`ach run --notify`, on by default with `--install-service`):
|
|
96
|
+
an OS notification. Decision requests show their options as buttons where
|
|
97
|
+
the OS can report the click: macOS with
|
|
98
|
+
[`alerter`](https://github.com/vjeantet/alerter) installed (else
|
|
99
|
+
terminal-notifier / osascript without buttons), Linux `notify-send` with
|
|
100
|
+
`--action` (libnotify 0.7.9+), Windows toast buttons. A click never answers for you:
|
|
101
|
+
it opens the panel at the decision with that option preselected
|
|
102
|
+
(`#/t/T-12/m/<id>?pick=<i>`), and you press Send there. The helper runs with
|
|
103
|
+
your agent's key, which must not stand in for your own reply.
|
|
104
|
+
|
|
105
|
+
At most one reminder per 10 minutes; changes inside the window become one
|
|
106
|
+
reminder at its end. The content is fetched only when you ask ("check my
|
|
107
|
+
inbox"). `ACH_SESSION_NOTICES=0` turns the session reminders off. The helper
|
|
108
|
+
follows the hub's change stream (a 25 s long poll) and falls back to polling
|
|
109
|
+
every 15 s.
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
ach notify --test # shows a test desktop notification
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Everyday commands
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
ach inbox # what is waiting for you
|
|
119
|
+
ach send --to <agent> ... # hand a task to another agent
|
|
120
|
+
ach open # open the panel in your browser, logged in
|
|
121
|
+
ach run --dir <repo> # work tasks on this machine (foreground)
|
|
122
|
+
ach help # everything else
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## For admins
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
ach admin invite <agent> # a paragraph for the owner to paste into Claude/Codex (zh if the hub's language is zh)
|
|
129
|
+
ach admin invite <agent> --line # only the join line: npx -y @koalaauto/agentchannel@3 join ach2....
|
|
130
|
+
ach admin invite <person> [--feishu] # a one-time login link for the panel (--feishu sends it on Feishu)
|
|
131
|
+
ach admin avatars priority upload,feishu,github,gravatar
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Every link and line works once or expires, and a new one replaces the old.
|
|
135
|
+
Send them privately until they are used.
|
|
136
|
+
|
|
137
|
+
## Background runs are isolated
|
|
138
|
+
|
|
139
|
+
Tasks the helper runs in the background never load your personal agent setup:
|
|
140
|
+
Claude runs with no user/project settings and no MCP servers
|
|
141
|
+
(`settingSources: []`, `strictMcpConfig`); Codex runs with its own
|
|
142
|
+
`CODEX_HOME` holding a generated `config.toml` (no `mcp_servers`, profiles,
|
|
143
|
+
hooks or global `AGENTS.md`) and a link to the login file of your Codex home
|
|
144
|
+
(placed by path; the file is never read or copied by AgentChannel).
|
|
145
|
+
|
|
146
|
+
## Where things are kept
|
|
147
|
+
|
|
148
|
+
- Settings: `~/.config/agentchannel/config.json` (set `AGENTCHANNEL_HOME` to move it).
|
|
149
|
+
- Secrets (agent key, front-door pass, admin session): the OS keychain, or files
|
|
150
|
+
with mode 0600 in the same folder when no keychain is available.
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
Apache-2.0. Contributor notes and the security model are in `DEVELOPMENT.md`
|
|
155
|
+
in the source repository.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { CanUseTool, HookCallbackMatcher, Options } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import type { Perm } from '../perm.js';
|
|
3
|
+
import { type PathPolicy } from './paths.js';
|
|
4
|
+
import type { AdapterResult, AdapterRunOptions, RuntimeAdapter } from './types.js';
|
|
5
|
+
/** Best-effort Bash deny list for `workdir` (the SDK sandbox is the real boundary). */
|
|
6
|
+
export declare const BASH_DENY: RegExp[];
|
|
7
|
+
/** S3: the only `ach` subcommands a spawned agent is pre-approved to run. */
|
|
8
|
+
export declare const WORK_ACH_TOOLS: string[];
|
|
9
|
+
export declare const ANSWER_ACH_TOOLS: string[];
|
|
10
|
+
/** §16 mention runs: read the thread and channel, reply in the thread (with evidence, or --escalate). */
|
|
11
|
+
export declare const MENTION_ACH_TOOLS: string[];
|
|
12
|
+
/** canUseTool for workdir: path policy (reads under $HOME, writes outside cwd) plus the Bash deny list. */
|
|
13
|
+
export declare function workdirCanUseTool(pol: PathPolicy): CanUseTool;
|
|
14
|
+
/**
|
|
15
|
+
* PreToolUse hook with the same path policy. Hooks run even for tools that
|
|
16
|
+
* allowedTools pre-approves (Read/Glob/Grep), which canUseTool never sees.
|
|
17
|
+
*/
|
|
18
|
+
export declare function pathPolicyHook(pol: PathPolicy): HookCallbackMatcher;
|
|
19
|
+
export declare function hostOf(url?: string): string | undefined;
|
|
20
|
+
export interface ClaudePermInput {
|
|
21
|
+
cwd: string;
|
|
22
|
+
hub?: string;
|
|
23
|
+
mode?: 'work' | 'answer' | 'mention';
|
|
24
|
+
/** Readable roots under $HOME besides cwd (toolchain, git common dir). */
|
|
25
|
+
readRoots?: string[];
|
|
26
|
+
denyReadPaths?: string[];
|
|
27
|
+
home?: string;
|
|
28
|
+
/** B1: the AgentChannel home, denied to sandboxed commands (allowRead re-allows cwd and read roots). */
|
|
29
|
+
achHome?: string;
|
|
30
|
+
/** P2: hub `net_allow` of the agent; see sandboxNetwork(). */
|
|
31
|
+
netAllow?: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* P2: sandbox network policy. The hub host is always reachable (the agent's
|
|
35
|
+
* `ach` needs it). A concrete list is a strict allowlist; "*" lifts the domain
|
|
36
|
+
* restriction (admin-only on the hub).
|
|
37
|
+
*/
|
|
38
|
+
export declare function sandboxNetwork(hubHost: string | undefined, netAllow?: string[]): NonNullable<Options['sandbox']>['network'];
|
|
39
|
+
/**
|
|
40
|
+
* Permission-related query options (§14.4 as amended by round 1). Pure, unit-tested.
|
|
41
|
+
* - settingSources: [] (S1): no user/project/local settings, hooks, MCP servers
|
|
42
|
+
* or CLAUDE.md from the (sender-influenced) worktree.
|
|
43
|
+
* - allowedTools: only the `ach` subcommands of the run's mode (S3).
|
|
44
|
+
* - read/workdir: the SDK sandbox denies reads under $HOME except cwd and the
|
|
45
|
+
* read roots; a PreToolUse hook applies the same policy to file tools (S4).
|
|
46
|
+
* - workdir writes: cwd only. The git common dir is NOT writable (S10); the
|
|
47
|
+
* runner commits after the run.
|
|
48
|
+
*/
|
|
49
|
+
export declare function claudePermOptions(perm: Perm, o: ClaudePermInput): Partial<Options>;
|
|
50
|
+
/** Error text of a result message (C9): never the word "success" for a failed run. */
|
|
51
|
+
export declare function resultError(m: {
|
|
52
|
+
subtype?: string;
|
|
53
|
+
is_error?: boolean;
|
|
54
|
+
errors?: string[];
|
|
55
|
+
result?: string;
|
|
56
|
+
}): string;
|
|
57
|
+
export interface ClaudeAdapterOptions {
|
|
58
|
+
model?: string;
|
|
59
|
+
}
|
|
60
|
+
export declare class ClaudeAdapter implements RuntimeAdapter {
|
|
61
|
+
private o;
|
|
62
|
+
readonly name = "claude";
|
|
63
|
+
constructor(o?: ClaudeAdapterOptions);
|
|
64
|
+
run(opts: AdapterRunOptions): Promise<AdapterResult>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { toolDenied } from './paths.js';
|
|
3
|
+
import { spawnGroup } from './procgroup.js';
|
|
4
|
+
/** Best-effort Bash deny list for `workdir` (the SDK sandbox is the real boundary). */
|
|
5
|
+
export const BASH_DENY = [
|
|
6
|
+
/\brm\s+-[a-z]*r[a-z]*f?[a-z]*\s+(\/|~|\$HOME)(\s|$)/i,
|
|
7
|
+
/\bgit\s+push\b.*(--force\b|-f\b|--force-with-lease\b)/,
|
|
8
|
+
/\b(curl|wget)\b[^|]*\|\s*(ba|z)?sh\b/,
|
|
9
|
+
/\bsudo\b/,
|
|
10
|
+
/\bchmod\s+-R\s+777\s+\//,
|
|
11
|
+
];
|
|
12
|
+
/** S3: the only `ach` subcommands a spawned agent is pre-approved to run. */
|
|
13
|
+
export const WORK_ACH_TOOLS = [
|
|
14
|
+
'Bash(ach progress:*)',
|
|
15
|
+
'Bash(ach ask:*)',
|
|
16
|
+
'Bash(ach decide-request:*)',
|
|
17
|
+
'Bash(ach ask-human:*)',
|
|
18
|
+
'Bash(ach decide:*)',
|
|
19
|
+
'Bash(ach complete:*)',
|
|
20
|
+
'Bash(ach fail:*)',
|
|
21
|
+
'Bash(ach task:*)',
|
|
22
|
+
'Bash(ach channel:*)',
|
|
23
|
+
'Bash(ach thread:*)',
|
|
24
|
+
'Bash(ach reply:*)',
|
|
25
|
+
];
|
|
26
|
+
export const ANSWER_ACH_TOOLS = ['Bash(ach answer:*)', 'Bash(ach decide-request:*)', 'Bash(ach ask-human:*)', 'Bash(ach task:*)'];
|
|
27
|
+
/** §16 mention runs: read the thread and channel, reply in the thread (with evidence, or --escalate). */
|
|
28
|
+
export const MENTION_ACH_TOOLS = ['Bash(ach reply:*)', 'Bash(ach thread:*)', 'Bash(ach channel:*)'];
|
|
29
|
+
/** canUseTool for workdir: path policy (reads under $HOME, writes outside cwd) plus the Bash deny list. */
|
|
30
|
+
export function workdirCanUseTool(pol) {
|
|
31
|
+
return async (toolName, input) => {
|
|
32
|
+
const why = toolDenied(pol, toolName, input);
|
|
33
|
+
if (why)
|
|
34
|
+
return { behavior: 'deny', message: why };
|
|
35
|
+
if (toolName === 'Bash') {
|
|
36
|
+
const cmd = String(input.command ?? '');
|
|
37
|
+
if (BASH_DENY.some((re) => re.test(cmd))) {
|
|
38
|
+
return { behavior: 'deny', message: 'Command is on the AgentChannel deny list' };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return { behavior: 'allow', updatedInput: input };
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* PreToolUse hook with the same path policy. Hooks run even for tools that
|
|
46
|
+
* allowedTools pre-approves (Read/Glob/Grep), which canUseTool never sees.
|
|
47
|
+
*/
|
|
48
|
+
export function pathPolicyHook(pol) {
|
|
49
|
+
return {
|
|
50
|
+
hooks: [
|
|
51
|
+
async (input) => {
|
|
52
|
+
if (input.hook_event_name !== 'PreToolUse')
|
|
53
|
+
return {};
|
|
54
|
+
const why = toolDenied(pol, input.tool_name, (input.tool_input ?? {}));
|
|
55
|
+
if (!why)
|
|
56
|
+
return {};
|
|
57
|
+
return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: why } };
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function hostOf(url) {
|
|
63
|
+
if (!url)
|
|
64
|
+
return undefined;
|
|
65
|
+
try {
|
|
66
|
+
return new URL(url).hostname;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* P2: sandbox network policy. The hub host is always reachable (the agent's
|
|
74
|
+
* `ach` needs it). A concrete list is a strict allowlist; "*" lifts the domain
|
|
75
|
+
* restriction (admin-only on the hub).
|
|
76
|
+
*/
|
|
77
|
+
export function sandboxNetwork(hubHost, netAllow) {
|
|
78
|
+
const list = netAllow ?? ['api.anthropic.com'];
|
|
79
|
+
const domains = Array.from(new Set([...(hubHost ? [hubHost] : []), ...list.map((d) => d.toLowerCase())]));
|
|
80
|
+
if (domains.includes('*'))
|
|
81
|
+
return { allowedDomains: ['*'] };
|
|
82
|
+
return netAllow ? { allowedDomains: domains, strictAllowlist: true } : { allowedDomains: domains };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Permission-related query options (§14.4 as amended by round 1). Pure, unit-tested.
|
|
86
|
+
* - settingSources: [] (S1): no user/project/local settings, hooks, MCP servers
|
|
87
|
+
* or CLAUDE.md from the (sender-influenced) worktree.
|
|
88
|
+
* - allowedTools: only the `ach` subcommands of the run's mode (S3).
|
|
89
|
+
* - read/workdir: the SDK sandbox denies reads under $HOME except cwd and the
|
|
90
|
+
* read roots; a PreToolUse hook applies the same policy to file tools (S4).
|
|
91
|
+
* - workdir writes: cwd only. The git common dir is NOT writable (S10); the
|
|
92
|
+
* runner commits after the run.
|
|
93
|
+
*/
|
|
94
|
+
export function claudePermOptions(perm, o) {
|
|
95
|
+
const home = o.home ?? homedir();
|
|
96
|
+
const denyRead = o.denyReadPaths ?? [];
|
|
97
|
+
// Permission-rule paths: `//abs/path/**` means an absolute path.
|
|
98
|
+
const disallowedTools = denyRead.flatMap((p) => [`Read(/${p})`, `Read(/${p}/**)`, `Edit(/${p})`, `Edit(/${p}/**)`]);
|
|
99
|
+
const achTools = o.mode === 'answer' ? ANSWER_ACH_TOOLS : o.mode === 'mention' ? MENTION_ACH_TOOLS : WORK_ACH_TOOLS;
|
|
100
|
+
// strictMcpConfig: no MCP servers from ~/.claude.json or .mcp.json either (only ones passed here: none)
|
|
101
|
+
const base = { settingSources: [], strictMcpConfig: true, disallowedTools };
|
|
102
|
+
if (perm === 'full') {
|
|
103
|
+
return { ...base, permissionMode: 'bypassPermissions', allowDangerouslySkipPermissions: true };
|
|
104
|
+
}
|
|
105
|
+
const pol = {
|
|
106
|
+
home,
|
|
107
|
+
cwd: o.cwd,
|
|
108
|
+
readRoots: o.readRoots ?? [],
|
|
109
|
+
writeRoots: perm === 'workdir' ? [o.cwd] : [],
|
|
110
|
+
deny: denyRead,
|
|
111
|
+
};
|
|
112
|
+
const hubHost = hostOf(o.hub);
|
|
113
|
+
const sandbox = {
|
|
114
|
+
enabled: true,
|
|
115
|
+
// read: only the pre-approved `ach` commands may run, sandboxed or not.
|
|
116
|
+
autoAllowBashIfSandboxed: perm === 'workdir',
|
|
117
|
+
allowUnsandboxedCommands: false,
|
|
118
|
+
filesystem: {
|
|
119
|
+
allowWrite: perm === 'workdir' ? [o.cwd] : [],
|
|
120
|
+
denyRead: [home, ...(o.achHome ? [o.achHome] : []), ...denyRead],
|
|
121
|
+
allowRead: [o.cwd, ...(o.readRoots ?? [])],
|
|
122
|
+
},
|
|
123
|
+
network: sandboxNetwork(hubHost, o.netAllow),
|
|
124
|
+
};
|
|
125
|
+
const common = {
|
|
126
|
+
...base,
|
|
127
|
+
allowedTools: ['Read', 'Glob', 'Grep', ...achTools],
|
|
128
|
+
sandbox,
|
|
129
|
+
hooks: { PreToolUse: [pathPolicyHook(pol)] },
|
|
130
|
+
};
|
|
131
|
+
if (perm === 'read')
|
|
132
|
+
return { ...common, permissionMode: 'dontAsk' };
|
|
133
|
+
return { ...common, permissionMode: 'acceptEdits', canUseTool: workdirCanUseTool(pol) };
|
|
134
|
+
}
|
|
135
|
+
/** Error text of a result message (C9): never the word "success" for a failed run. */
|
|
136
|
+
export function resultError(m) {
|
|
137
|
+
const errs = (m.errors ?? []).filter(Boolean).join('; ');
|
|
138
|
+
if (errs)
|
|
139
|
+
return errs;
|
|
140
|
+
if (m.is_error && typeof m.result === 'string' && m.result.trim())
|
|
141
|
+
return m.result.trim();
|
|
142
|
+
if (m.subtype && m.subtype !== 'success')
|
|
143
|
+
return m.subtype;
|
|
144
|
+
return 'the run ended with an error';
|
|
145
|
+
}
|
|
146
|
+
export class ClaudeAdapter {
|
|
147
|
+
o;
|
|
148
|
+
name = 'claude';
|
|
149
|
+
constructor(o = {}) {
|
|
150
|
+
this.o = o;
|
|
151
|
+
}
|
|
152
|
+
async run(opts) {
|
|
153
|
+
const { query } = await import('@anthropic-ai/claude-agent-sdk');
|
|
154
|
+
const abortController = new AbortController();
|
|
155
|
+
const onAbort = () => abortController.abort();
|
|
156
|
+
if (opts.signal.aborted)
|
|
157
|
+
abortController.abort();
|
|
158
|
+
else
|
|
159
|
+
opts.signal.addEventListener('abort', onAbort, { once: true });
|
|
160
|
+
const options = {
|
|
161
|
+
cwd: opts.cwd,
|
|
162
|
+
env: opts.env,
|
|
163
|
+
abortController,
|
|
164
|
+
...(opts.resume ? { resume: opts.resume } : {}),
|
|
165
|
+
...(this.o.model ? { model: this.o.model } : {}),
|
|
166
|
+
...claudePermOptions(opts.perm, {
|
|
167
|
+
cwd: opts.cwd,
|
|
168
|
+
hub: opts.hub,
|
|
169
|
+
mode: opts.mode,
|
|
170
|
+
readRoots: opts.readRoots,
|
|
171
|
+
denyReadPaths: opts.denyReadPaths,
|
|
172
|
+
home: opts.realHome ?? opts.env.HOME,
|
|
173
|
+
achHome: opts.achHome,
|
|
174
|
+
netAllow: opts.netAllow,
|
|
175
|
+
}),
|
|
176
|
+
spawnClaudeCodeProcess: (s) => spawnGroup(s.command, s.args, {
|
|
177
|
+
cwd: s.cwd,
|
|
178
|
+
env: s.env,
|
|
179
|
+
signal: s.signal,
|
|
180
|
+
onStderr: (t) => opts.onEvent({ type: 'error', data: t }),
|
|
181
|
+
}),
|
|
182
|
+
};
|
|
183
|
+
let sessionId;
|
|
184
|
+
let finalText = '';
|
|
185
|
+
let costUsd;
|
|
186
|
+
let ok = false;
|
|
187
|
+
let error;
|
|
188
|
+
const lastText = [];
|
|
189
|
+
try {
|
|
190
|
+
for await (const m of query({ prompt: opts.prompt, options })) {
|
|
191
|
+
const anyM = m;
|
|
192
|
+
if (anyM.session_id && anyM.session_id !== sessionId) {
|
|
193
|
+
sessionId = anyM.session_id;
|
|
194
|
+
opts.onEvent({ type: 'session', data: sessionId });
|
|
195
|
+
}
|
|
196
|
+
if (m.type === 'assistant') {
|
|
197
|
+
for (const b of (anyM.message?.content ?? [])) {
|
|
198
|
+
if (b.type === 'text' && b.text) {
|
|
199
|
+
lastText.push(b.text);
|
|
200
|
+
opts.onEvent({ type: 'text', data: b.text });
|
|
201
|
+
}
|
|
202
|
+
else if (b.type === 'tool_use') {
|
|
203
|
+
opts.onEvent({ type: 'tool_start', data: { id: b.id, name: b.name, input: b.input } });
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else if (m.type === 'user') {
|
|
208
|
+
const content = anyM.message?.content;
|
|
209
|
+
for (const b of (Array.isArray(content) ? content : [])) {
|
|
210
|
+
if (b?.type === 'tool_result')
|
|
211
|
+
opts.onEvent({ type: 'tool_end', data: { id: b.tool_use_id } });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (m.type === 'result') {
|
|
215
|
+
costUsd = anyM.total_cost_usd;
|
|
216
|
+
opts.onEvent({ type: 'usage', data: { costUsd, usage: anyM.usage } });
|
|
217
|
+
if (anyM.subtype === 'success' && !anyM.is_error) {
|
|
218
|
+
ok = true;
|
|
219
|
+
finalText = anyM.result ?? '';
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
error = resultError(anyM);
|
|
223
|
+
finalText = lastText.join('\n');
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
opts.onEvent({ type: 'tool', data: { type: m.type, subtype: anyM.subtype } });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
ok = false;
|
|
233
|
+
error = opts.signal.aborted ? 'aborted' : String(e?.message ?? e);
|
|
234
|
+
opts.onEvent({ type: 'error', data: error });
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
opts.signal.removeEventListener('abort', onAbort);
|
|
238
|
+
}
|
|
239
|
+
if (!finalText)
|
|
240
|
+
finalText = lastText.join('\n');
|
|
241
|
+
return { finalText, sessionId, costUsd, ok, error };
|
|
242
|
+
}
|
|
243
|
+
}
|