@chipschat/acp 1.0.35 → 1.0.37
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/README.md +55 -4
- package/dist/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/main.js +326 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# chips-acp
|
|
2
2
|
|
|
3
3
|
An agent that speaks the [Agent Client Protocol](https://agentclientprotocol.com) (ACP) — Claude
|
|
4
|
-
Code, Codex, Goose,
|
|
4
|
+
Code, Codex, Cursor, Copilot, Antigravity, Goose, Grok, or any other — as a Chips harness, one kind
|
|
5
|
+
per harness. People make its agents from
|
|
5
6
|
Chips: a room from the +, a new agent from a room's Add page, a copy with Fork. Each agent works in a
|
|
6
7
|
folder of its own; each room it is in is one ACP session of it. There is no Main agent. The bridge
|
|
7
8
|
runs the agent's process, so the bridge is the harness (Chips ADR 0041), built on `@chipschat/harness`.
|
|
@@ -20,6 +21,56 @@ joins, and keeps itself running from login. `chips disconnect claude-code` or `c
|
|
|
20
21
|
`curl -fsSL https://chipschat.ai/install | CHIPS_JOIN_LINK='<link>' sh -s -- connect claude-code` installs Chips there
|
|
21
22
|
first. The steps below run the bridge from this checkout instead, to work on it.
|
|
22
23
|
|
|
24
|
+
## The agents it knows by name
|
|
25
|
+
|
|
26
|
+
Each of these needs no config: its card hands the bridge `~/Chips/.bridges/acp/<id>.json`, and
|
|
27
|
+
the file's name picks the kind. Claude Code and Codex speak ACP through an adapter from npm; the
|
|
28
|
+
others speak it themselves, so there is nothing to fetch (Chips ADR 0301). The person installs the
|
|
29
|
+
agent from its maker and signs it in; the bridge asks for each in turn, with the maker's line, and
|
|
30
|
+
also looks where that line puts the agent, since a terminal opened before doesn't know the folder.
|
|
31
|
+
|
|
32
|
+
| Id | Runs | Install | Sign in | Modes Chips may pick |
|
|
33
|
+
|---|---|---|---|---|
|
|
34
|
+
| `claude-code` | `claude-agent-acp` | `curl -fsSL https://claude.ai/install.sh \| bash`, then the adapter | `claude auth login` | Default, Accept edits, Auto, Bypass permissions |
|
|
35
|
+
| `codex` | `codex-acp` (fetched) | `curl -fsSL https://chatgpt.com/codex/install.sh \| sh` | `codex login` | Read-only, Workspace access, Auto review, Full access |
|
|
36
|
+
| `cursor` | `cursor-agent acp` | `curl https://cursor.com/install -fsS \| bash` | `cursor-agent login` | none |
|
|
37
|
+
| `copilot` | `copilot --acp` | `curl -fsSL https://gh.io/copilot-install \| bash` | `copilot login` | none |
|
|
38
|
+
| `antigravity` | `agy acp` | `curl -fsSL https://antigravity.google/cli/install.sh \| bash` | `agy acp --login` | Default, Accept edits, Auto |
|
|
39
|
+
| `goose` | `goose acp` | Goose's `download_cli.sh` | `goose configure` (a model provider and its key) | Approve, Smart approve, Auto |
|
|
40
|
+
| `grok` | `grok agent stdio` | `curl -fsSL https://x.ai/cli/install.sh \| bash` | `grok login` | none |
|
|
41
|
+
|
|
42
|
+
- **Cursor** and **Copilot** offer modes that are ways of working (Agent, Plan, Ask; Agent, Plan,
|
|
43
|
+
Autopilot), not how much they may do, so Chips puts them in none: each session asks as the agent's
|
|
44
|
+
own settings say (Cursor's `approvalMode`, which never asks about edits in its folder; Copilot's
|
|
45
|
+
Allow all, off unless turned on). Cursor is never asked to sign in over ACP: signed out, that
|
|
46
|
+
opens a browser on the machine each time.
|
|
47
|
+
- **Goose** starts in Auto, which never asks, unless `GOOSE_MODE` says otherwise, so each session
|
|
48
|
+
goes into Approve. With no model provider set up it refuses a session with an internal error
|
|
49
|
+
naming `GOOSE_PROVIDER`, which the bridge says as "Goose has no model provider set up".
|
|
50
|
+
- **Grok** opens no session until it is asked to sign in (`authenticate`), as xAI's own ACP example
|
|
51
|
+
does: by its API key where `XAI_API_KEY` is set, else by what `grok login` saved. Signed out, it
|
|
52
|
+
offers neither, and its session is refused. Its ACP sessions have no mode to be put in. It is left
|
|
53
|
+
to update itself: xAI's API refuses one too old, and a Grok only Chips runs would never be updated
|
|
54
|
+
otherwise.
|
|
55
|
+
- **Antigravity**'s Auto is offered only where Antigravity has it: a personal Google account with
|
|
56
|
+
its terminal sandbox on.
|
|
57
|
+
- None of the five copies a session (`session/fork`), so their cards leave Fork off. Cursor, Copilot,
|
|
58
|
+
Goose and Grok offer their models as a session's `model` option, where they do, and the bridge
|
|
59
|
+
offers them in Chips as it does Claude Code's and Codex's, each once (Copilot on GitHub's free plan
|
|
60
|
+
lists Auto twice). Their files aren't read.
|
|
61
|
+
- The Permissions page shows what each one's own settings let through, read and never written:
|
|
62
|
+
Copilot's Allow all, as its sessions say it (off: it asks before a tool, a path or a URL; on: it
|
|
63
|
+
never asks); Grok's mode and rules from `~/.grok/config.toml` (`[ui] permission_mode`, or the older
|
|
64
|
+
`yolo`; `[permission] rules`) together with the permission rules it takes from Claude Code's
|
|
65
|
+
settings, yours in `~/.claude` and each agent folder's; and for Antigravity and Goose the mode a
|
|
66
|
+
session runs in. Cursor's own settings aren't read yet.
|
|
67
|
+
- An agent's refusal reaches the room in its own words: where JSON-RPC's message is only "Internal
|
|
68
|
+
error", what its details say, as Grok's API answer ("Your Grok CLI version (0.2.99) is outdated …").
|
|
69
|
+
- What signs one in from the environment is carried to the copy kept running: `CURSOR_API_KEY`,
|
|
70
|
+
`COPILOT_GITHUB_TOKEN` (not `GH_TOKEN` or `GITHUB_TOKEN`, which are the gh command's too and
|
|
71
|
+
would beat Copilot's saved sign-in), `GEMINI_API_KEY`, `XAI_API_KEY`, and Goose's
|
|
72
|
+
`GOOSE_PROVIDER`, `GOOSE_MODEL`, `GOOGLE_API_KEY` and `OPENROUTER_API_KEY`.
|
|
73
|
+
|
|
23
74
|
## Run it
|
|
24
75
|
|
|
25
76
|
```bash
|
|
@@ -189,8 +240,8 @@ permissions, and each permission it asks for is an approval card.
|
|
|
189
240
|
|
|
190
241
|
### What Chips shows on an agent's page
|
|
191
242
|
|
|
192
|
-
The bridge says `context`
|
|
193
|
-
in its hello, and sends each agent's copies when it starts and as they change. Chips draws them
|
|
243
|
+
The bridge says `context` (Claude Code and Codex), `models` (every kind it knows by name) and
|
|
244
|
+
`context_windows` (every kind) in its hello, and sends each agent's copies when it starts and as they change. Chips draws them
|
|
194
245
|
where the harness is granted `context_files`, `models` and `context_windows`.
|
|
195
246
|
|
|
196
247
|
| Chips | Claude Code | Codex | Another kind |
|
|
@@ -201,7 +252,7 @@ where the harness is granted `context_files`, `models` and `context_windows`.
|
|
|
201
252
|
| Context window | `usage_update` of the agent's session that said last; the window from the update that ends a turn (it carries the cost), as one before may be a default | `usage_update` | `usage_update` |
|
|
202
253
|
| Compact now | `/compact` said to that session as a turn of its own, after any turn going there; its words go nowhere; from and to from its tool call's `rawOutput` | the same; to from the `usage_update` it sends as it finishes | where it lists `compact` among its commands |
|
|
203
254
|
| Its limit | its own from `autoCompactWindow` in its settings (`modelSettings` per model), about 33,000 tokens short of it; a pick from Chips goes in each session's `_meta.claudeCode.options.settings`, never in a file; `CLAUDE_CODE_AUTO_COMPACT_WINDOW` beats both, and the limit can't be changed then | the bridge's: after a turn that ends at or past it, the bridge compacts that session; off unless picked | as Codex, where it has `compact` |
|
|
204
|
-
| Model | the models its adapter offers for a session (the `model` option), each with its levels (`effort`, without its `default`), by the adapter's own names (its `xhigh` is Extra high); Same as "Claude Code's default" is what a new session starts on: `model` in its settings, or its own `default` | the same, with `reasoning_effort`; the default from Codex's config, which may be a model its list leaves out, with no levels | none |
|
|
255
|
+
| Model | the models its adapter offers for a session (the `model` option), each with its levels (`effort`, without its `default`), by the adapter's own names (its `xhigh` is Extra high); Same as "Claude Code's default" is what a new session starts on: `model` in its settings, or its own `default` | the same, with `reasoning_effort`; the default from Codex's config, which may be a model its list leaves out, with no levels | for a kind it knows by name, the same where its agent offers a `model` option (and a `thought_level` one for its levels); none for any other |
|
|
205
256
|
| Where it learns them | each time the bridge starts the agent, a session opened in the harness's folder and put on each model in turn, then closed, with nothing said to it; a model it won't be put on isn't offered | the same | |
|
|
206
257
|
| A pick | set on each of the agent's sessions with `session/set_config_option`, now and as each opens after, never in a file; kept with the agent, and a copy from Fork starts with its original's. Same as again puts each back on the default, and its level on Claude Code's `default`, which follows its settings | the same; a session Codex won't put back on a model its list leaves out is let go and loaded again before its next turn | |
|
|
207
258
|
|
package/dist/main.js
CHANGED
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// src/main.ts
|
|
11
|
-
import { existsSync as existsSync10, mkdirSync as mkdirSync6, readFileSync as
|
|
11
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync6, readFileSync as readFileSync11, writeFileSync as writeFileSync5 } from "node:fs";
|
|
12
12
|
import { basename as basename6, dirname as dirname7, join as join12 } from "node:path";
|
|
13
13
|
|
|
14
14
|
// node_modules/zod/v4/classic/external.js
|
|
@@ -27737,6 +27737,12 @@ var AcpError = class extends Error {
|
|
|
27737
27737
|
data;
|
|
27738
27738
|
name = "AcpError";
|
|
27739
27739
|
};
|
|
27740
|
+
function agentWords(error62) {
|
|
27741
|
+
const data = error62.data;
|
|
27742
|
+
const said = typeof data === "string" ? data : typeof data === "object" && data !== null && typeof data.message === "string" ? data.message : void 0;
|
|
27743
|
+
if (said === void 0 || said.trim() === "" || !/^internal error$/i.test(error62.message.trim())) return error62.message;
|
|
27744
|
+
return said.trim().slice(0, 600);
|
|
27745
|
+
}
|
|
27740
27746
|
function isAuthRequired(error62) {
|
|
27741
27747
|
return error62 instanceof AcpError && error62.code === -32e3 && /auth/i.test(error62.message);
|
|
27742
27748
|
}
|
|
@@ -27808,6 +27814,13 @@ var AcpClient = class {
|
|
|
27808
27814
|
...typeof info["name"] === "string" ? { name: info["name"] } : {}
|
|
27809
27815
|
};
|
|
27810
27816
|
}
|
|
27817
|
+
/**
|
|
27818
|
+
* Sign in by a way the agent offered at `initialize` that needs nobody at a browser: Grok's saved
|
|
27819
|
+
* sign-in or its API key (Chips ADR 0301). Refused, it says why.
|
|
27820
|
+
*/
|
|
27821
|
+
async authenticate(methodId) {
|
|
27822
|
+
await this.call("authenticate", { methodId, _meta: { headless: true } });
|
|
27823
|
+
}
|
|
27811
27824
|
/**
|
|
27812
27825
|
* A new session in `cwd`. Answers with its id and anything it said it can be set to. `meta` is
|
|
27813
27826
|
* the agent's own `_meta`: Claude Code's takes its settings there (`claudeCode.options.settings`).
|
|
@@ -27979,6 +27992,16 @@ var CODEX_MODES = [
|
|
|
27979
27992
|
everything: true
|
|
27980
27993
|
}
|
|
27981
27994
|
];
|
|
27995
|
+
var ANTIGRAVITY_MODES = [
|
|
27996
|
+
{ id: "default", name: "Default", words: "Asks before edits and commands its settings don't allow." },
|
|
27997
|
+
{ id: "accept-edits", name: "Accept edits", words: "Edits files in its folder without asking. Commands still ask." },
|
|
27998
|
+
{ id: "auto", name: "Auto", words: "Edits files and runs safe commands without asking. Asks before anything it can't undo." }
|
|
27999
|
+
];
|
|
28000
|
+
var GOOSE_MODES = [
|
|
28001
|
+
{ id: "approve", name: "Approve", words: "Asks before every tool call its own permission list doesn't settle." },
|
|
28002
|
+
{ id: "smart_approve", name: "Smart approve", words: "Reads on its own. Goose judges the rest and asks only about ones it finds risky." },
|
|
28003
|
+
{ id: "auto", name: "Auto", words: "Never asks. Whatever it does just happens.", everything: true }
|
|
28004
|
+
];
|
|
27982
28005
|
var KNOWN2 = [
|
|
27983
28006
|
{
|
|
27984
28007
|
id: "claude-code",
|
|
@@ -28013,16 +28036,138 @@ var KNOWN2 = [
|
|
|
28013
28036
|
signInNoScreen: "`codex login --device-auth`",
|
|
28014
28037
|
signInLine: "codex login",
|
|
28015
28038
|
signInDoing: SIGN_IN_DOING
|
|
28039
|
+
},
|
|
28040
|
+
{
|
|
28041
|
+
id: "cursor",
|
|
28042
|
+
name: "Cursor",
|
|
28043
|
+
// The installer links `agent` too, a name other programs use: the legacy one is Cursor's alone.
|
|
28044
|
+
program: "cursor-agent",
|
|
28045
|
+
args: ["acp"],
|
|
28046
|
+
fetches: false,
|
|
28047
|
+
agent: "cursor-agent",
|
|
28048
|
+
installLine: "curl https://cursor.com/install -fsS | bash",
|
|
28049
|
+
installedIn: ".local/bin",
|
|
28050
|
+
// Agent, Plan and Ask are ways of working, not how much it may do: that is its own
|
|
28051
|
+
// `approvalMode` and permission lists, which edits in its folder never ask past.
|
|
28052
|
+
modes: [],
|
|
28053
|
+
signIn: "run `cursor-agent login`",
|
|
28054
|
+
signInNoScreen: "`NO_OPEN_BROWSER=1 cursor-agent login`, then open the address it prints",
|
|
28055
|
+
signInLine: "cursor-agent login",
|
|
28056
|
+
signInDoing: SIGN_IN_DOING,
|
|
28057
|
+
// Never asked to sign in over ACP: signed out, that opens a browser on this machine each time.
|
|
28058
|
+
keys: ["CURSOR_API_KEY"]
|
|
28059
|
+
},
|
|
28060
|
+
{
|
|
28061
|
+
id: "goose",
|
|
28062
|
+
name: "Goose",
|
|
28063
|
+
program: "goose",
|
|
28064
|
+
args: ["acp"],
|
|
28065
|
+
fetches: false,
|
|
28066
|
+
agent: "goose",
|
|
28067
|
+
installLine: "curl -fsSL https://github.com/aaif-goose/goose/releases/download/stable/download_cli.sh | bash",
|
|
28068
|
+
installedIn: ".local/bin",
|
|
28069
|
+
mode: "approve",
|
|
28070
|
+
modes: GOOSE_MODES,
|
|
28071
|
+
// Goose has no account: it runs on a model provider a person picks, with that provider's key.
|
|
28072
|
+
signIn: "run `goose configure` and pick a model provider",
|
|
28073
|
+
signInLine: "goose configure",
|
|
28074
|
+
signInDoing: "Run this in Terminal, then try again. It asks which model provider to use, and for its key.",
|
|
28075
|
+
keys: ["GOOSE_PROVIDER", "GOOSE_MODEL", "GOOGLE_API_KEY", "OPENROUTER_API_KEY"],
|
|
28076
|
+
unready: /GOOSE_PROVIDER|resolve provider and model/,
|
|
28077
|
+
lacks: { detail: "No model provider", says: "has no model provider set up" }
|
|
28078
|
+
},
|
|
28079
|
+
{
|
|
28080
|
+
id: "copilot",
|
|
28081
|
+
name: "Copilot",
|
|
28082
|
+
program: "copilot",
|
|
28083
|
+
args: ["--acp"],
|
|
28084
|
+
fetches: false,
|
|
28085
|
+
agent: "copilot",
|
|
28086
|
+
installLine: "curl -fsSL https://gh.io/copilot-install | bash",
|
|
28087
|
+
installedIn: ".local/bin",
|
|
28088
|
+
// Its session modes are Agent, Plan and Autopilot, ways of working rather than how much it may
|
|
28089
|
+
// do: whether it asks is its Allow all option, off unless the person's settings turn it on.
|
|
28090
|
+
// Chips puts it in neither, so each session asks as Copilot's own settings say.
|
|
28091
|
+
modes: [],
|
|
28092
|
+
signIn: "run `copilot login`",
|
|
28093
|
+
signInNoScreen: "`copilot login --device-code`",
|
|
28094
|
+
signInLine: "copilot login",
|
|
28095
|
+
signInDoing: SIGN_IN_DOING,
|
|
28096
|
+
// Only Copilot's own: GH_TOKEN and GITHUB_TOKEN are the gh command's too, and Copilot lets
|
|
28097
|
+
// either beat the sign-in it saved.
|
|
28098
|
+
keys: ["COPILOT_GITHUB_TOKEN"]
|
|
28099
|
+
},
|
|
28100
|
+
{
|
|
28101
|
+
id: "antigravity",
|
|
28102
|
+
name: "Antigravity",
|
|
28103
|
+
program: "agy",
|
|
28104
|
+
args: ["acp"],
|
|
28105
|
+
fetches: false,
|
|
28106
|
+
agent: "agy",
|
|
28107
|
+
installLine: "curl -fsSL https://antigravity.google/cli/install.sh | bash",
|
|
28108
|
+
installedIn: ".local/bin",
|
|
28109
|
+
mode: "default",
|
|
28110
|
+
modes: ANTIGRAVITY_MODES,
|
|
28111
|
+
// Its sign-in for ACP gives a link to open and takes back the code Google shows, so it works
|
|
28112
|
+
// the same on a machine with no screen.
|
|
28113
|
+
signIn: "run `agy acp --login` and paste back the code it asks for",
|
|
28114
|
+
signInLine: "agy acp --login",
|
|
28115
|
+
signInDoing: "Run this in Terminal, then try again. It gives you a Google sign-in link; paste back the code you get.",
|
|
28116
|
+
keys: ["GEMINI_API_KEY"]
|
|
28117
|
+
},
|
|
28118
|
+
{
|
|
28119
|
+
id: "grok",
|
|
28120
|
+
name: "Grok",
|
|
28121
|
+
program: "grok",
|
|
28122
|
+
// Left to update itself as it does: xAI's API refuses a Grok too old (it refused 0.2.99 with
|
|
28123
|
+
// a 426), and a Grok only Chips runs would never be updated otherwise.
|
|
28124
|
+
args: ["agent", "stdio"],
|
|
28125
|
+
fetches: false,
|
|
28126
|
+
agent: "grok",
|
|
28127
|
+
installLine: "curl -fsSL https://x.ai/cli/install.sh | bash",
|
|
28128
|
+
installedIn: ".grok/bin",
|
|
28129
|
+
// Its Ask, Auto and Always-approve aren't modes its ACP sessions offer to be put in: each
|
|
28130
|
+
// session runs in the one Grok's own config gives it, Ask unless the person changed it.
|
|
28131
|
+
modes: [],
|
|
28132
|
+
signIn: "run `grok login`",
|
|
28133
|
+
signInNoScreen: "`grok login --device-auth`",
|
|
28134
|
+
signInLine: "grok login",
|
|
28135
|
+
signInDoing: SIGN_IN_DOING,
|
|
28136
|
+
keys: ["XAI_API_KEY"],
|
|
28137
|
+
// It opens no session until asked to sign in, as xAI's own ACP example does: by its API key
|
|
28138
|
+
// where one is set, else by what `grok login` saved. Signed out, it offers neither.
|
|
28139
|
+
headless: [{ id: "xai.api_key", env: "XAI_API_KEY" }, { id: "cached_token" }]
|
|
28016
28140
|
}
|
|
28017
28141
|
];
|
|
28018
28142
|
function knownConfig(id2) {
|
|
28019
28143
|
const known = KNOWN2.find((each) => each.id === id2);
|
|
28020
|
-
|
|
28144
|
+
if (known === void 0) return void 0;
|
|
28145
|
+
return {
|
|
28146
|
+
name: known.name,
|
|
28147
|
+
command: [known.program, ...known.args ?? []],
|
|
28148
|
+
...known.mode === void 0 ? {} : { mode: known.mode }
|
|
28149
|
+
};
|
|
28021
28150
|
}
|
|
28022
28151
|
var knownBy = (kind2) => {
|
|
28023
28152
|
const program = kind2.command[0]?.split("/").pop();
|
|
28024
28153
|
return KNOWN2.find((each) => each.program === program);
|
|
28025
28154
|
};
|
|
28155
|
+
var speaksAcp = (known) => known.adapter === void 0;
|
|
28156
|
+
function signedOutBy(kind2, error62) {
|
|
28157
|
+
if (isAuthRequired(error62)) return true;
|
|
28158
|
+
const unready = knownBy(kind2)?.unready;
|
|
28159
|
+
if (unready === void 0 || !(error62 instanceof AcpError)) return false;
|
|
28160
|
+
const data = typeof error62.data === "string" ? error62.data : JSON.stringify(error62.data ?? "");
|
|
28161
|
+
return unready.test(`${error62.message} ${data}`);
|
|
28162
|
+
}
|
|
28163
|
+
function headlessAuthOf(kind2, offered, env3) {
|
|
28164
|
+
return knownBy(kind2)?.headless?.find(
|
|
28165
|
+
(way) => offered.some((method) => method.id === way.id) && (way.env === void 0 || (env3[way.env] ?? "") !== "")
|
|
28166
|
+
)?.id;
|
|
28167
|
+
}
|
|
28168
|
+
function keptEnvOf(kind2) {
|
|
28169
|
+
return ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "CODEX_HOME", "CLAUDE_CONFIG_DIR", ...knownBy(kind2)?.keys ?? []];
|
|
28170
|
+
}
|
|
28026
28171
|
function modesOf(kind2) {
|
|
28027
28172
|
const known = knownBy(kind2);
|
|
28028
28173
|
if (known === void 0 || kind2.mode !== known.mode) return [];
|
|
@@ -28030,7 +28175,8 @@ function modesOf(kind2) {
|
|
|
28030
28175
|
}
|
|
28031
28176
|
var knownOf = (kind2) => knownBy(kind2);
|
|
28032
28177
|
function knownIdOf(kind2) {
|
|
28033
|
-
|
|
28178
|
+
const id2 = knownBy(kind2)?.id;
|
|
28179
|
+
return id2 === "claude-code" || id2 === "codex" ? id2 : void 0;
|
|
28034
28180
|
}
|
|
28035
28181
|
var CODEX_DOC_BYTES = 65536;
|
|
28036
28182
|
function codexConfigOf(env3) {
|
|
@@ -28057,13 +28203,14 @@ function codexDocBytes(env3) {
|
|
|
28057
28203
|
}
|
|
28058
28204
|
function installWords(kind2) {
|
|
28059
28205
|
const known = knownBy(kind2);
|
|
28060
|
-
|
|
28206
|
+
if (known === void 0) return "install the agent's ACP adapter its own way, or name it by its path in the config";
|
|
28207
|
+
return speaksAcp(known) ? `install it with \`${known.installLine}\`` : `install it with \`npm install -g ${known.adapter}\``;
|
|
28061
28208
|
}
|
|
28062
28209
|
function signedOutWords(kind2, info) {
|
|
28063
28210
|
const known = knownBy(kind2);
|
|
28064
28211
|
if (known !== void 0) {
|
|
28065
28212
|
const noScreen = known.signInNoScreen === void 0 ? "" : `, or ${known.signInNoScreen} on a machine with no screen`;
|
|
28066
|
-
return `${kind2.name} isn't signed in on this machine: ${known.signIn} in a new terminal${noScreen}.`;
|
|
28213
|
+
return `${kind2.name} ${known.lacks?.says ?? "isn't signed in"} on this machine: ${known.signIn} in a new terminal${noScreen}.`;
|
|
28067
28214
|
}
|
|
28068
28215
|
const ways = (info?.authMethods ?? []).map((method) => method.name);
|
|
28069
28216
|
return `${kind2.name} isn't signed in on this machine: sign it in its own way${ways.length > 0 ? ` (${ways.join(", ")})` : ""}.`;
|
|
@@ -28077,6 +28224,7 @@ function notInstalledStop(kind2, program) {
|
|
|
28077
28224
|
doing: "Install the agent's ACP adapter its own way, then try again."
|
|
28078
28225
|
};
|
|
28079
28226
|
}
|
|
28227
|
+
if (speaksAcp(known)) return agentMissingStop(known);
|
|
28080
28228
|
return {
|
|
28081
28229
|
detail: `${kind2.name} can't join Chips yet`,
|
|
28082
28230
|
says: `${kind2.name} needs one more piece to join Chips.`,
|
|
@@ -28102,8 +28250,8 @@ function adapterFailedStop(name) {
|
|
|
28102
28250
|
function signedOutStop(kind2) {
|
|
28103
28251
|
const known = knownBy(kind2);
|
|
28104
28252
|
return {
|
|
28105
|
-
detail: "Not signed in",
|
|
28106
|
-
says: `${kind2.name} isn't signed in.`,
|
|
28253
|
+
detail: known?.lacks?.detail ?? "Not signed in",
|
|
28254
|
+
says: `${kind2.name} ${known?.lacks?.says ?? "isn't signed in"}.`,
|
|
28107
28255
|
...known === void 0 ? { doing: "Sign it in its own way, then try again." } : { doing: known.signInDoing, copy: known.signInLine }
|
|
28108
28256
|
};
|
|
28109
28257
|
}
|
|
@@ -28257,11 +28405,19 @@ async function checkSignIn(kind2, wire, cwd, options = {}) {
|
|
|
28257
28405
|
...last === "" ? {} : { doing: `It said: ${last}` }
|
|
28258
28406
|
});
|
|
28259
28407
|
}
|
|
28408
|
+
const method = headlessAuthOf(kind2, info.authMethods, { ...process.env, ...kind2.env, ...options.env });
|
|
28409
|
+
if (method !== void 0) {
|
|
28410
|
+
try {
|
|
28411
|
+
await within(client.authenticate(method), MINUTE, "it didn't answer within a minute");
|
|
28412
|
+
} catch (error62) {
|
|
28413
|
+
throw new SetupError(`${signedOutWords(kind2, info)} It said: ${wordsOf2(error62)}. ${STILL_GOOD}`, signedOutStop(kind2));
|
|
28414
|
+
}
|
|
28415
|
+
}
|
|
28260
28416
|
try {
|
|
28261
28417
|
const { sessionId } = await within(client.newSession(cwd), MINUTE, "it didn't answer within a minute");
|
|
28262
28418
|
if (info.closeSession) await client.closeSession(sessionId).catch(() => void 0);
|
|
28263
28419
|
} catch (error62) {
|
|
28264
|
-
if (
|
|
28420
|
+
if (signedOutBy(kind2, error62)) throw new SetupError(`${signedOutWords(kind2, info)} ${STILL_GOOD}`, signedOutStop(kind2));
|
|
28265
28421
|
throw new SetupError(`${kind2.name} couldn't open a session: ${wordsOf2(error62)}. ${STILL_GOOD}`, {
|
|
28266
28422
|
detail: "It couldn't open a session",
|
|
28267
28423
|
says: `${kind2.name} couldn't open a session: ${wordsOf2(error62)}.`
|
|
@@ -28289,7 +28445,9 @@ function makersFolder(kind2, env3 = process.env, home = homedir5()) {
|
|
|
28289
28445
|
var pathWithLast = (path, folder2) => [...(path ?? "").split(delimiter3).filter((each) => each !== ""), folder2].join(delimiter3);
|
|
28290
28446
|
function withFetchedAdapter(kind2, env3 = process.env, home = homedir5()) {
|
|
28291
28447
|
const known = knownOf(kind2);
|
|
28292
|
-
if (known === void 0 || kind2.command[0] !== known.program || onPath(known.program, pathOf2(kind2, env3)))
|
|
28448
|
+
if (known === void 0 || known.adapter === void 0 || kind2.command[0] !== known.program || onPath(known.program, pathOf2(kind2, env3))) {
|
|
28449
|
+
return kind2;
|
|
28450
|
+
}
|
|
28293
28451
|
const fetched = fetchedAt(known.id, known.program, home);
|
|
28294
28452
|
return runnable(fetched) ? { ...kind2, command: [fetched, ...kind2.command.slice(1)] } : kind2;
|
|
28295
28453
|
}
|
|
@@ -28343,7 +28501,8 @@ async function readyAdapter(kind2, options = {}) {
|
|
|
28343
28501
|
);
|
|
28344
28502
|
}
|
|
28345
28503
|
const npm = env3["CHIPS_NPM"];
|
|
28346
|
-
if (!known.fetches || npm === void 0 || npm === "") return kind2;
|
|
28504
|
+
if (!known.fetches || known.adapter === void 0 || npm === void 0 || npm === "") return kind2;
|
|
28505
|
+
const adapter = known.adapter;
|
|
28347
28506
|
const folder2 = adapterFolder(known.id, home);
|
|
28348
28507
|
const { CHIPS_JOIN_LINK: _link, ...rest } = env3;
|
|
28349
28508
|
const node2 = process.execPath;
|
|
@@ -28354,7 +28513,7 @@ async function readyAdapter(kind2, options = {}) {
|
|
|
28354
28513
|
node: node2,
|
|
28355
28514
|
npm,
|
|
28356
28515
|
folder: folder2,
|
|
28357
|
-
spec: `${
|
|
28516
|
+
spec: `${adapter}@${known.adapterMajor ?? 0}`,
|
|
28358
28517
|
env: { ...rest, PATH: `${dirname4(node2)}${delimiter3}${rest["PATH"] ?? ""}` }
|
|
28359
28518
|
});
|
|
28360
28519
|
} catch (error62) {
|
|
@@ -28365,7 +28524,7 @@ async function readyAdapter(kind2, options = {}) {
|
|
|
28365
28524
|
const ready = withFetchedAdapter(kind2, env3, home);
|
|
28366
28525
|
if (ready.command[0] === known.program) {
|
|
28367
28526
|
rmSync3(folder2, { recursive: true, force: true });
|
|
28368
|
-
throw new SetupError(`${
|
|
28527
|
+
throw new SetupError(`${adapter} installed, but it has no ${known.program}. ${STILL_GOOD}`, adapterFailedStop(kind2.name));
|
|
28369
28528
|
}
|
|
28370
28529
|
return ready;
|
|
28371
28530
|
}
|
|
@@ -28375,7 +28534,7 @@ function forgetAdapter(id2, home = homedir5()) {
|
|
|
28375
28534
|
|
|
28376
28535
|
// src/bridge.ts
|
|
28377
28536
|
import { randomBytes } from "node:crypto";
|
|
28378
|
-
import { existsSync as existsSync8 } from "node:fs";
|
|
28537
|
+
import { existsSync as existsSync8, readFileSync as readFileSync9 } from "node:fs";
|
|
28379
28538
|
import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
|
|
28380
28539
|
import { homedir as homedir7 } from "node:os";
|
|
28381
28540
|
import { join as join10 } from "node:path";
|
|
@@ -28783,6 +28942,10 @@ function currentIn(options) {
|
|
|
28783
28942
|
const value = modeOption(options)?.currentValue;
|
|
28784
28943
|
return value === void 0 || value === "" ? void 0 : value;
|
|
28785
28944
|
}
|
|
28945
|
+
function permissionsIn(options) {
|
|
28946
|
+
const value = options?.find((option) => option.category === "permissions")?.currentValue;
|
|
28947
|
+
return value === void 0 || value === "" ? void 0 : value;
|
|
28948
|
+
}
|
|
28786
28949
|
function withCurrent(options, mode) {
|
|
28787
28950
|
const option = modeOption(options);
|
|
28788
28951
|
return option === void 0 ? options : options.map((each) => each === option ? { ...each, currentValue: mode } : each);
|
|
@@ -28942,6 +29105,87 @@ function codexOwnRules(mode) {
|
|
|
28942
29105
|
runs: []
|
|
28943
29106
|
};
|
|
28944
29107
|
}
|
|
29108
|
+
function modeOwnRules(name, running, mode) {
|
|
29109
|
+
const read_from = [`the mode Chips starts each ${name} session in`];
|
|
29110
|
+
if (mode === void 0) return { read_from, mode: running, runs: [] };
|
|
29111
|
+
return { read_from, mode: mode.name, ...mode.everything === true ? { everything: true } : {}, note: mode.words, runs: [] };
|
|
29112
|
+
}
|
|
29113
|
+
function copilotOwnRules(allowAll) {
|
|
29114
|
+
const read_from = ["Copilot's Allow all, as its sessions say it"];
|
|
29115
|
+
if (allowAll === "on") {
|
|
29116
|
+
return { read_from, mode: "Allow all", everything: true, note: "Copilot approves every tool, path and URL request without asking.", runs: [] };
|
|
29117
|
+
}
|
|
29118
|
+
return { read_from, mode: "Asks first", note: "Copilot asks before it uses a tool, reaches a path or fetches a URL.", runs: [] };
|
|
29119
|
+
}
|
|
29120
|
+
function tomlSection(toml, name) {
|
|
29121
|
+
let inside3 = false;
|
|
29122
|
+
const lines2 = [];
|
|
29123
|
+
for (const line of toml.split("\n")) {
|
|
29124
|
+
const header = /^\s*\[([^\]]+)\]\s*(?:#.*)?$/.exec(line);
|
|
29125
|
+
if (header !== null) {
|
|
29126
|
+
inside3 = header[1]?.trim() === name;
|
|
29127
|
+
continue;
|
|
29128
|
+
}
|
|
29129
|
+
if (inside3) lines2.push(line);
|
|
29130
|
+
}
|
|
29131
|
+
return lines2.join("\n");
|
|
29132
|
+
}
|
|
29133
|
+
var tomlString = (section, key) => new RegExp(`^\\s*${key}\\s*=\\s*"([^"]*)"`, "m").exec(section)?.[1];
|
|
29134
|
+
var tomlTrue = (section, key) => new RegExp(`^\\s*${key}\\s*=\\s*true\\b`, "m").test(section);
|
|
29135
|
+
function grokModeOf(toml) {
|
|
29136
|
+
const ui = tomlSection(toml ?? "", "ui");
|
|
29137
|
+
const said = tomlString(ui, "permission_mode") ?? tomlString(ui, "approval_mode");
|
|
29138
|
+
if (said === "auto" || said === "always-approve" || said === "ask") return said;
|
|
29139
|
+
return tomlTrue(ui, "yolo") ? "always-approve" : "ask";
|
|
29140
|
+
}
|
|
29141
|
+
var GROK_MODES = {
|
|
29142
|
+
ask: { name: "Ask", note: "Grok asks before anything its rules don't allow." },
|
|
29143
|
+
auto: { name: "Auto", note: "Grok's own check lets safe steps through and asks about risky ones." },
|
|
29144
|
+
"always-approve": { name: "Always-approve", note: "Grok approves every step without asking: only deny rules and hooks stop one." }
|
|
29145
|
+
};
|
|
29146
|
+
function grokEntry(tool, pattern, raw) {
|
|
29147
|
+
const name = clip(tool, LONGEST_NAME);
|
|
29148
|
+
const lower = tool.toLowerCase();
|
|
29149
|
+
if (lower === "bash") {
|
|
29150
|
+
const words4 = bashWords(pattern);
|
|
29151
|
+
return { kind: "command", name, ...words4 === void 0 ? {} : { words: words4 }, raw: clip(raw, LONGEST_RAW) };
|
|
29152
|
+
}
|
|
29153
|
+
const kind2 = lower === "read" || lower === "grep" ? "read" : lower === "edit" ? "write" : lower.startsWith("web") ? "web" : "tool";
|
|
29154
|
+
return { kind: kind2, name, raw: clip(raw, LONGEST_RAW) };
|
|
29155
|
+
}
|
|
29156
|
+
function grokRulesOf(toml) {
|
|
29157
|
+
const rules = { allow: [], ask: [], deny: [] };
|
|
29158
|
+
const section = tomlSection(toml ?? "", "permission");
|
|
29159
|
+
for (const table of section.matchAll(/\{([^{}]*)\}/g)) {
|
|
29160
|
+
const body = table[1] ?? "";
|
|
29161
|
+
const field = (key) => new RegExp(`\\b${key}\\s*=\\s*"([^"]*)"`).exec(body)?.[1];
|
|
29162
|
+
const action2 = field("action");
|
|
29163
|
+
const tool = field("tool");
|
|
29164
|
+
if ((action2 === "allow" || action2 === "ask" || action2 === "deny") && tool !== void 0) {
|
|
29165
|
+
rules[action2].push(grokEntry(tool, field("pattern"), `{${body.trim()}}`));
|
|
29166
|
+
}
|
|
29167
|
+
}
|
|
29168
|
+
return { allow: rules.allow.slice(0, MOST), ask: rules.ask.slice(0, MOST), deny: rules.deny.slice(0, MOST) };
|
|
29169
|
+
}
|
|
29170
|
+
function grokOwnRules(options) {
|
|
29171
|
+
const home = options.home ?? homedir6();
|
|
29172
|
+
const mode = grokModeOf(options.config);
|
|
29173
|
+
const own2 = grokRulesOf(options.config);
|
|
29174
|
+
const layers = options.claude.map((each) => each.layer);
|
|
29175
|
+
const borrowed = { allow: joined(layers, "allow"), ask: joined(layers, "ask"), deny: joined(layers, "deny") };
|
|
29176
|
+
const withClaude = borrowed.allow.length + borrowed.ask.length + borrowed.deny.length > 0;
|
|
29177
|
+
const read_from = [tilde(options.configPath, home), ...withClaude ? options.claude.map((each) => tilde(each.path, home)) : []].slice(0, MOST_PLACES);
|
|
29178
|
+
const note = [GROK_MODES[mode].note, withClaude ? "It follows your Claude Code permission rules too, as listed here." : void 0].filter((line) => line !== void 0).join(" ");
|
|
29179
|
+
if (mode === "always-approve") return { read_from, mode: GROK_MODES[mode].name, everything: true, note, runs: [] };
|
|
29180
|
+
return {
|
|
29181
|
+
read_from,
|
|
29182
|
+
mode: GROK_MODES[mode].name,
|
|
29183
|
+
note,
|
|
29184
|
+
runs: [...own2.allow, ...borrowed.allow].slice(0, MOST),
|
|
29185
|
+
asks: [...own2.ask, ...borrowed.ask].slice(0, MOST),
|
|
29186
|
+
refuses: [...own2.deny, ...borrowed.deny].slice(0, MOST)
|
|
29187
|
+
};
|
|
29188
|
+
}
|
|
28945
29189
|
async function sendOwnRules(settings, copy) {
|
|
28946
29190
|
const send = settings?.ownRules;
|
|
28947
29191
|
if (typeof send !== "function") return false;
|
|
@@ -28986,7 +29230,8 @@ async function lookAt(options, set2) {
|
|
|
28986
29230
|
const model = modelOption(options);
|
|
28987
29231
|
const fallback = pickOf(options);
|
|
28988
29232
|
if (model === void 0 || fallback === void 0) return { refused: [] };
|
|
28989
|
-
const
|
|
29233
|
+
const named = model.options.some((each) => each.value === fallback.model) ? model.options : [{ value: fallback.model, name: fallback.model }, ...model.options];
|
|
29234
|
+
const listed = named.filter((each, at) => named.findIndex((other) => other.value === each.value) === at);
|
|
28990
29235
|
let others = MODEL_CHOICES_MAX - 1;
|
|
28991
29236
|
const offered = listed.filter((each) => each.value === fallback.model || others-- > 0);
|
|
28992
29237
|
const choices = [];
|
|
@@ -29217,6 +29462,8 @@ var Bridge = class {
|
|
|
29217
29462
|
modeSaid = /* @__PURE__ */ new Map();
|
|
29218
29463
|
/** What it runs on its own, to send again in a moment: a mode change moves every session at once. */
|
|
29219
29464
|
ownRulesTimer;
|
|
29465
|
+
/** Its sessions' permission option, as the last to say it said: Copilot's Allow all. */
|
|
29466
|
+
permissionsNow;
|
|
29220
29467
|
/** Hear what Chips asks, learn the agents Chips has, run the agent, and close idle sessions. */
|
|
29221
29468
|
async start() {
|
|
29222
29469
|
const { chips: chips2 } = this.options;
|
|
@@ -29424,6 +29671,7 @@ var Bridge = class {
|
|
|
29424
29671
|
copied = { client, sessionId: forked.sessionId };
|
|
29425
29672
|
this.process.live.add(forked.sessionId);
|
|
29426
29673
|
this.sessionOptions.set(forked.sessionId, forked.configOptions);
|
|
29674
|
+
this.permissionsHeard(forked.configOptions);
|
|
29427
29675
|
await this.moded(client, forked.sessionId);
|
|
29428
29676
|
}
|
|
29429
29677
|
record2 = await this.made(forkName(original.name), {
|
|
@@ -29573,6 +29821,10 @@ var Bridge = class {
|
|
|
29573
29821
|
proc.info = await client.initialize({ name: "chips-acp", version: VERSION });
|
|
29574
29822
|
proc.failures = 0;
|
|
29575
29823
|
this.log(`${name} is running${proc.info.name === void 0 ? "" : ` (${proc.info.name})`}`);
|
|
29824
|
+
const method = headlessAuthOf(this.options.kind, proc.info.authMethods, this.env);
|
|
29825
|
+
if (method !== void 0) {
|
|
29826
|
+
await client.authenticate(method).catch((error62) => this.log(`${signedOutWords(this.options.kind, proc.info)} It said: ${messageOf(error62)}`));
|
|
29827
|
+
}
|
|
29576
29828
|
if (this.options.models === true) void this.look(client);
|
|
29577
29829
|
} catch (error62) {
|
|
29578
29830
|
this.log(`${name} didn't say hello: ${String(error62)}`);
|
|
@@ -29591,7 +29843,7 @@ var Bridge = class {
|
|
|
29591
29843
|
}
|
|
29592
29844
|
/** What a turn's failure says: how to sign in when that's why, else the agent's own words. */
|
|
29593
29845
|
failure(record2, error62, what = "") {
|
|
29594
|
-
if (
|
|
29846
|
+
if (signedOutBy(this.options.kind, error62)) return `${signedOutWords(this.options.kind, this.process.info)} Then send this again.`;
|
|
29595
29847
|
return `${record2.name}${what}: ${messageOf(error62)}`;
|
|
29596
29848
|
}
|
|
29597
29849
|
async stopped(client, why) {
|
|
@@ -29861,7 +30113,7 @@ var Bridge = class {
|
|
|
29861
30113
|
try {
|
|
29862
30114
|
turn.sessionId = await this.sessionFor(record2, client, spaceId);
|
|
29863
30115
|
} catch (error62) {
|
|
29864
|
-
if (!run2.over) await run2.fail({ error: this.failure(record2, error62, " couldn't open a session"), retryable:
|
|
30116
|
+
if (!run2.over) await run2.fail({ error: this.failure(record2, error62, " couldn't open a session"), retryable: signedOutBy(this.options.kind, error62) });
|
|
29865
30117
|
return;
|
|
29866
30118
|
}
|
|
29867
30119
|
const { sessionId } = turn;
|
|
@@ -29992,6 +30244,7 @@ ${files.join("\n")}`;
|
|
|
29992
30244
|
const loaded = await client.loadSession(kept2, record2.folder, [], this.sessionMeta(record2));
|
|
29993
30245
|
live.add(kept2);
|
|
29994
30246
|
this.sessionOptions.set(kept2, loaded.configOptions);
|
|
30247
|
+
this.permissionsHeard(loaded.configOptions);
|
|
29995
30248
|
await this.moded(client, kept2);
|
|
29996
30249
|
await this.modelled(client, record2, kept2);
|
|
29997
30250
|
return kept2;
|
|
@@ -30002,6 +30255,7 @@ ${files.join("\n")}`;
|
|
|
30002
30255
|
const made = await client.newSession(record2.folder, [], this.sessionMeta(record2));
|
|
30003
30256
|
live.add(made.sessionId);
|
|
30004
30257
|
this.sessionOptions.set(made.sessionId, made.configOptions);
|
|
30258
|
+
this.permissionsHeard(made.configOptions);
|
|
30005
30259
|
await this.moded(client, made.sessionId);
|
|
30006
30260
|
await this.modelled(client, record2, made.sessionId);
|
|
30007
30261
|
state2.sessions[key] = made.sessionId;
|
|
@@ -30091,6 +30345,13 @@ ${files.join("\n")}`;
|
|
|
30091
30345
|
this.modeNow = mode;
|
|
30092
30346
|
this.ownRulesSoon();
|
|
30093
30347
|
}
|
|
30348
|
+
/** A session's permission option, heard: what it runs on its own is sent again when it moved. */
|
|
30349
|
+
permissionsHeard(options) {
|
|
30350
|
+
const now = permissionsIn(options);
|
|
30351
|
+
if (now === void 0 || now === this.permissionsNow) return;
|
|
30352
|
+
this.permissionsNow = now;
|
|
30353
|
+
this.ownRulesSoon();
|
|
30354
|
+
}
|
|
30094
30355
|
/** What it runs on its own, sent again in a moment. */
|
|
30095
30356
|
ownRulesSoon() {
|
|
30096
30357
|
clearTimeout(this.ownRulesTimer);
|
|
@@ -30363,6 +30624,15 @@ ${files.join("\n")}`;
|
|
|
30363
30624
|
}
|
|
30364
30625
|
ownRulesNow() {
|
|
30365
30626
|
if (this.knownKind === "codex") return codexOwnRules(this.runningMode() ?? "workspace-write");
|
|
30627
|
+
if (this.knownKind === void 0) {
|
|
30628
|
+
const { kind: kind2 } = this.options;
|
|
30629
|
+
const id2 = knownOf(kind2)?.id;
|
|
30630
|
+
if (id2 === "copilot") return copilotOwnRules(this.permissionsNow);
|
|
30631
|
+
if (id2 === "grok") return this.grokOwnRules();
|
|
30632
|
+
const running = this.runningMode();
|
|
30633
|
+
if (id2 === void 0 || running === void 0 || modesOf(kind2).length === 0) return void 0;
|
|
30634
|
+
return modeOwnRules(kind2.name, running, modesOf(kind2).find((mode) => mode.id === running));
|
|
30635
|
+
}
|
|
30366
30636
|
if (this.knownKind !== "claude-code") return void 0;
|
|
30367
30637
|
const userPath = join10(this.places.claudeHome, "settings.json");
|
|
30368
30638
|
const folders = [...new Set(this.records().map((record2) => record2.folder))].flatMap(
|
|
@@ -30379,6 +30649,31 @@ ${files.join("\n")}`;
|
|
|
30379
30649
|
home: this.places.home
|
|
30380
30650
|
});
|
|
30381
30651
|
}
|
|
30652
|
+
/**
|
|
30653
|
+
* Grok's: its own config, and the Claude Code settings it takes permission rules from: yours, in
|
|
30654
|
+
* `~/.claude`, and each agent folder's `.claude`.
|
|
30655
|
+
*/
|
|
30656
|
+
grokOwnRules() {
|
|
30657
|
+
const { home, claudeHome } = this.places;
|
|
30658
|
+
const configPath2 = join10(home, ".grok", "config.toml");
|
|
30659
|
+
let config2;
|
|
30660
|
+
try {
|
|
30661
|
+
config2 = readFileSync9(configPath2, "utf8");
|
|
30662
|
+
} catch {
|
|
30663
|
+
config2 = void 0;
|
|
30664
|
+
}
|
|
30665
|
+
const folders = [...new Set(this.records().map((record2) => record2.folder))];
|
|
30666
|
+
const paths = [
|
|
30667
|
+
join10(claudeHome, "settings.json"),
|
|
30668
|
+
join10(claudeHome, "settings.local.json"),
|
|
30669
|
+
...folders.flatMap((folder2) => [join10(folder2, ".claude", "settings.json"), join10(folder2, ".claude", "settings.local.json")])
|
|
30670
|
+
];
|
|
30671
|
+
const claude = paths.flatMap((path) => {
|
|
30672
|
+
const layer = readLayer(path);
|
|
30673
|
+
return layer === void 0 ? [] : [{ path, layer }];
|
|
30674
|
+
});
|
|
30675
|
+
return grokOwnRules({ configPath: configPath2, config: config2, claude, home });
|
|
30676
|
+
}
|
|
30382
30677
|
/** The harness's own set and each agent's files, as they are on disk now. */
|
|
30383
30678
|
async sendContexts() {
|
|
30384
30679
|
const files = this.files;
|
|
@@ -30500,6 +30795,7 @@ ${files.join("\n")}`;
|
|
|
30500
30795
|
const options = configOptionsOf(update);
|
|
30501
30796
|
if (this.sessionOptions.has(sessionId) && options.length > 0) {
|
|
30502
30797
|
this.sessionOptions.set(sessionId, options);
|
|
30798
|
+
this.permissionsHeard(options);
|
|
30503
30799
|
const now = currentIn(options);
|
|
30504
30800
|
if (now !== void 0) {
|
|
30505
30801
|
this.modeSaid.set(sessionId, now);
|
|
@@ -30777,6 +31073,7 @@ ${files.join("\n")}`;
|
|
|
30777
31073
|
try {
|
|
30778
31074
|
const made = await client.newSession(kind2.folder ?? kind2.folders);
|
|
30779
31075
|
sessionId = made.sessionId;
|
|
31076
|
+
this.permissionsHeard(made.configOptions);
|
|
30780
31077
|
const offered = offeredIn(made.configOptions);
|
|
30781
31078
|
if (offered !== void 0 && offered.join() !== this.offered?.join()) {
|
|
30782
31079
|
this.offered = offered;
|
|
@@ -30992,10 +31289,8 @@ function settingsFor(kind2, bridge2) {
|
|
|
30992
31289
|
return running;
|
|
30993
31290
|
};
|
|
30994
31291
|
return {
|
|
30995
|
-
...knownIdOf(kind2) === void 0 ? {} : {
|
|
30996
|
-
|
|
30997
|
-
models: (change) => active().modelChange(change)
|
|
30998
|
-
},
|
|
31292
|
+
...knownIdOf(kind2) === void 0 ? {} : { context: (edit) => active().contextEdited(edit) },
|
|
31293
|
+
...knownOf(kind2) === void 0 ? {} : { models: (change) => active().modelChange(change) },
|
|
30999
31294
|
contextWindows: {
|
|
31000
31295
|
compact: (ask2) => active().windowCompact(ask2),
|
|
31001
31296
|
change: (ask2) => active().windowChange(ask2)
|
|
@@ -31003,7 +31298,7 @@ function settingsFor(kind2, bridge2) {
|
|
|
31003
31298
|
};
|
|
31004
31299
|
}
|
|
31005
31300
|
function messageOf(error62) {
|
|
31006
|
-
if (error62 instanceof AcpError) return error62
|
|
31301
|
+
if (error62 instanceof AcpError) return agentWords(error62);
|
|
31007
31302
|
return error62 instanceof Error ? error62.message : String(error62);
|
|
31008
31303
|
}
|
|
31009
31304
|
function goalOf(message, name) {
|
|
@@ -31188,7 +31483,7 @@ function keepIfAsked(label2, url2, names, log2, before = () => void 0) {
|
|
|
31188
31483
|
}
|
|
31189
31484
|
|
|
31190
31485
|
// src/move.ts
|
|
31191
|
-
import { lstatSync, mkdirSync as mkdirSync5, readdirSync as readdirSync2, readFileSync as
|
|
31486
|
+
import { lstatSync, mkdirSync as mkdirSync5, readdirSync as readdirSync2, readFileSync as readFileSync10, renameSync as renameSync2, rmdirSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
31192
31487
|
import { homedir as homedir8 } from "node:os";
|
|
31193
31488
|
import { basename as basename5, dirname as dirname6, join as join11, resolve as resolve5 } from "node:path";
|
|
31194
31489
|
var there = (path) => {
|
|
@@ -31246,7 +31541,7 @@ function writeJson(path, value) {
|
|
|
31246
31541
|
}
|
|
31247
31542
|
var readJson = (path) => {
|
|
31248
31543
|
try {
|
|
31249
|
-
const read = JSON.parse(
|
|
31544
|
+
const read = JSON.parse(readFileSync10(path, "utf8"));
|
|
31250
31545
|
return typeof read === "object" && read !== null ? read : void 0;
|
|
31251
31546
|
} catch {
|
|
31252
31547
|
return void 0;
|
|
@@ -31383,15 +31678,16 @@ var joined2 = await join3({
|
|
|
31383
31678
|
"new_agents",
|
|
31384
31679
|
"forks",
|
|
31385
31680
|
"restarts",
|
|
31386
|
-
// Each agent's files
|
|
31387
|
-
// every agent's context window.
|
|
31388
|
-
...knownIdOf(kind) === void 0 ? [] : ["context_files"
|
|
31681
|
+
// Each agent's files, for the kinds whose files the bridge reads; its model, for every kind it
|
|
31682
|
+
// knows by name, of those its agent offers (Chips ADR 0301); and every agent's context window.
|
|
31683
|
+
...knownIdOf(kind) === void 0 ? [] : ["context_files"],
|
|
31684
|
+
...knownOf(kind) === void 0 ? [] : ["models"],
|
|
31389
31685
|
"context_windows"
|
|
31390
31686
|
],
|
|
31391
31687
|
onCode: (code) => log(`Allow this harness in Chips: ${code}`)
|
|
31392
31688
|
}).catch(refused2);
|
|
31393
|
-
keepIfAsked(LABEL, joined2.url,
|
|
31394
|
-
var kept = existsSync10(statePath) ? JSON.parse(
|
|
31689
|
+
keepIfAsked(LABEL, joined2.url, keptEnvOf(kind), log);
|
|
31690
|
+
var kept = existsSync10(statePath) ? JSON.parse(readFileSync11(statePath, "utf8")) : {};
|
|
31395
31691
|
var state = {
|
|
31396
31692
|
sessions: kept.sessions ?? {},
|
|
31397
31693
|
agents: kept.agents ?? {},
|
|
@@ -31429,8 +31725,8 @@ bridge = new Bridge({
|
|
|
31429
31725
|
chips,
|
|
31430
31726
|
kind,
|
|
31431
31727
|
projects: git2.ok,
|
|
31432
|
-
//
|
|
31433
|
-
models:
|
|
31728
|
+
// The kinds it knows by name offer their models as session options, where they offer any (Chips ADRs 0241, 0301).
|
|
31729
|
+
models: knownOf(kind) !== void 0,
|
|
31434
31730
|
state,
|
|
31435
31731
|
saveState: (next) => writeFileSync5(statePath, `${JSON.stringify(next, null, 2)}
|
|
31436
31732
|
`, { mode: 384 }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chipschat/acp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.37",
|
|
4
4
|
"description": "An agent that speaks the Agent Client Protocol, as a Chips harness of its kind: agents made from Chips, each in a folder of its own, each room a session.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|