@chipschat/acp 1.0.14 → 1.0.16
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 +1 -1
- package/dist/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/main.js +457 -326
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ bundles them into `dist/main.js`.
|
|
|
15
15
|
|
|
16
16
|
The card's line is `CHIPS_JOIN_LINK='<link>' chips connect claude-code` or `CHIPS_JOIN_LINK='<link>' chips connect codex` (Chips ADR 0218). It downloads this bridge as the npm package
|
|
17
17
|
`@chipschat/acp`, the newest 1.x, checks it against the registry's checksum, and runs it on the Node
|
|
18
|
-
that Chips carries, so the machine needs no Node or npm of its own. The
|
|
18
|
+
that Chips carries, so the machine needs no Node or npm of its own. The agent itself is the person's to install from its maker and to sign in to. The bridge asks for it first, then fetches Codex's ACP adapter when it isn't on the PATH, with the npm Chips carries, into `~/Chips/.bridges/acp/adapters/codex` (Chips ADR 0288). Claude Code's adapter is still installed by hand until Anthropic has said whether a product like Chips may fetch it. The bridge checks the agent's sign-in,
|
|
19
19
|
joins, and keeps itself running from login. `chips disconnect claude-code` or `chips disconnect codex` stops it. Claude Code and Codex share this one package: their cards hand it `~/Chips/.bridges/acp/claude-code.json` or `codex.json`, and the file's name picks the kind. On another computer,
|
|
20
20
|
`curl -fsSL https://chipschat.ai/install | CHIPS_JOIN_LINK='<link>' sh -s -- connect claude-code` installs Chips there
|
|
21
21
|
first. The steps below run the bridge from this checkout instead, to work on it.
|
package/dist/main.js
CHANGED
|
@@ -8,8 +8,8 @@ var __export = (target, all) => {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// src/main.ts
|
|
11
|
-
import { existsSync as existsSync10, mkdirSync as
|
|
12
|
-
import { basename as basename6, dirname as
|
|
11
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync6, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "node:fs";
|
|
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
|
|
15
15
|
var external_exports = {};
|
|
@@ -2021,8 +2021,8 @@ function emoji() {
|
|
|
2021
2021
|
}
|
|
2022
2022
|
var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
2023
2023
|
var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
2024
|
-
var mac = (
|
|
2025
|
-
const escapedDelim = escapeRegex(
|
|
2024
|
+
var mac = (delimiter4) => {
|
|
2025
|
+
const escapedDelim = escapeRegex(delimiter4 ?? ":");
|
|
2026
2026
|
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
2027
2027
|
};
|
|
2028
2028
|
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
@@ -26079,21 +26079,398 @@ function notOffered(method) {
|
|
|
26079
26079
|
return new AcpError(`${method} is not offered by this client`, -32601);
|
|
26080
26080
|
}
|
|
26081
26081
|
|
|
26082
|
+
// src/adapter.ts
|
|
26083
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
26084
|
+
import { mkdirSync as mkdirSync4, rmSync as rmSync3 } from "node:fs";
|
|
26085
|
+
import { homedir as homedir5 } from "node:os";
|
|
26086
|
+
import { delimiter as delimiter3, dirname as dirname4, join as join7 } from "node:path";
|
|
26087
|
+
|
|
26088
|
+
// src/kinds.ts
|
|
26089
|
+
var SIGN_IN_DOING = "Run this in Terminal, then try again. Your browser opens to sign in.";
|
|
26090
|
+
var KNOWN2 = [
|
|
26091
|
+
{
|
|
26092
|
+
id: "claude-code",
|
|
26093
|
+
name: "Claude Code",
|
|
26094
|
+
program: "claude-agent-acp",
|
|
26095
|
+
adapter: "@agentclientprotocol/claude-agent-acp",
|
|
26096
|
+
adapterMajor: 0,
|
|
26097
|
+
fetches: false,
|
|
26098
|
+
agent: "claude",
|
|
26099
|
+
installLine: "curl -fsSL https://claude.ai/install.sh | bash",
|
|
26100
|
+
mode: "default",
|
|
26101
|
+
signIn: "run `claude auth login`",
|
|
26102
|
+
signInLine: "claude auth login",
|
|
26103
|
+
signInDoing: SIGN_IN_DOING
|
|
26104
|
+
},
|
|
26105
|
+
{
|
|
26106
|
+
id: "codex",
|
|
26107
|
+
name: "Codex",
|
|
26108
|
+
program: "codex-acp",
|
|
26109
|
+
adapter: "@agentclientprotocol/codex-acp",
|
|
26110
|
+
adapterMajor: 2,
|
|
26111
|
+
fetches: true,
|
|
26112
|
+
agent: "codex",
|
|
26113
|
+
installLine: "curl -fsSL https://chatgpt.com/codex/install.sh | sh",
|
|
26114
|
+
mode: "workspace-write",
|
|
26115
|
+
signIn: "run `codex login`",
|
|
26116
|
+
signInLine: "codex login",
|
|
26117
|
+
signInDoing: SIGN_IN_DOING
|
|
26118
|
+
}
|
|
26119
|
+
];
|
|
26120
|
+
function knownConfig(id2) {
|
|
26121
|
+
const known = KNOWN2.find((each) => each.id === id2);
|
|
26122
|
+
return known === void 0 ? void 0 : { name: known.name, command: [known.program], mode: known.mode };
|
|
26123
|
+
}
|
|
26124
|
+
var knownBy = (kind2) => {
|
|
26125
|
+
const program = kind2.command[0]?.split("/").pop();
|
|
26126
|
+
return KNOWN2.find((each) => each.program === program);
|
|
26127
|
+
};
|
|
26128
|
+
var knownOf = (kind2) => knownBy(kind2);
|
|
26129
|
+
function knownIdOf(kind2) {
|
|
26130
|
+
return knownBy(kind2)?.id;
|
|
26131
|
+
}
|
|
26132
|
+
var CODEX_DOC_BYTES = 65536;
|
|
26133
|
+
function codexConfigOf(env2) {
|
|
26134
|
+
const raw = env2["CODEX_CONFIG"];
|
|
26135
|
+
if (raw === void 0 || raw.trim() === "") return void 0;
|
|
26136
|
+
try {
|
|
26137
|
+
const parsed = JSON.parse(raw);
|
|
26138
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
|
|
26139
|
+
} catch {
|
|
26140
|
+
return void 0;
|
|
26141
|
+
}
|
|
26142
|
+
}
|
|
26143
|
+
function adapterEnv(kind2, env2) {
|
|
26144
|
+
if (knownIdOf(kind2) !== "codex") return env2;
|
|
26145
|
+
const raw = env2["CODEX_CONFIG"];
|
|
26146
|
+
const config2 = codexConfigOf(env2);
|
|
26147
|
+
if (raw !== void 0 && raw.trim() !== "" && config2 === void 0) return env2;
|
|
26148
|
+
if (config2?.["project_doc_max_bytes"] !== void 0) return env2;
|
|
26149
|
+
return { ...env2, CODEX_CONFIG: JSON.stringify({ ...config2, project_doc_max_bytes: CODEX_DOC_BYTES }) };
|
|
26150
|
+
}
|
|
26151
|
+
function codexDocBytes(env2) {
|
|
26152
|
+
const said = codexConfigOf(env2)?.["project_doc_max_bytes"];
|
|
26153
|
+
return typeof said === "number" && Number.isFinite(said) && said > 0 ? said : 32768;
|
|
26154
|
+
}
|
|
26155
|
+
function installWords(kind2) {
|
|
26156
|
+
const known = knownBy(kind2);
|
|
26157
|
+
return known === void 0 ? "install the agent's ACP adapter its own way, or name it by its path in the config" : `install it with \`npm install -g ${known.adapter}\``;
|
|
26158
|
+
}
|
|
26159
|
+
function signedOutWords(kind2, info) {
|
|
26160
|
+
const known = knownBy(kind2);
|
|
26161
|
+
if (known !== void 0) return `${kind2.name} isn't signed in on this machine: ${known.signIn} in a terminal.`;
|
|
26162
|
+
const ways = (info?.authMethods ?? []).map((method) => method.name);
|
|
26163
|
+
return `${kind2.name} isn't signed in on this machine: sign it in its own way${ways.length > 0 ? ` (${ways.join(", ")})` : ""}.`;
|
|
26164
|
+
}
|
|
26165
|
+
function notInstalledStop(kind2, program) {
|
|
26166
|
+
const known = knownBy(kind2);
|
|
26167
|
+
if (known === void 0) {
|
|
26168
|
+
return {
|
|
26169
|
+
detail: `${program} isn't on this Mac`,
|
|
26170
|
+
says: `${kind2.name}'s ACP adapter isn't installed.`,
|
|
26171
|
+
doing: "Install the agent's ACP adapter its own way, then try again."
|
|
26172
|
+
};
|
|
26173
|
+
}
|
|
26174
|
+
return {
|
|
26175
|
+
detail: `${kind2.name} can't join Chips yet`,
|
|
26176
|
+
says: `${kind2.name} needs one more piece to join Chips.`,
|
|
26177
|
+
doing: "Run this in Terminal, then try again. It needs npm, which comes with Node.js (nodejs.org).",
|
|
26178
|
+
copy: `npm install -g ${known.adapter}`
|
|
26179
|
+
};
|
|
26180
|
+
}
|
|
26181
|
+
function agentMissingStop(known) {
|
|
26182
|
+
return {
|
|
26183
|
+
detail: `${known.name} isn't on this Mac`,
|
|
26184
|
+
says: `${known.name} isn't installed on this Mac.`,
|
|
26185
|
+
doing: "Run this in Terminal, then try again.",
|
|
26186
|
+
copy: known.installLine
|
|
26187
|
+
};
|
|
26188
|
+
}
|
|
26189
|
+
function adapterFailedStop(name) {
|
|
26190
|
+
return {
|
|
26191
|
+
detail: "The download didn't finish",
|
|
26192
|
+
says: `Chips couldn't get what ${name} needs.`,
|
|
26193
|
+
doing: "Check your connection, then try again."
|
|
26194
|
+
};
|
|
26195
|
+
}
|
|
26196
|
+
function signedOutStop(kind2) {
|
|
26197
|
+
const known = knownBy(kind2);
|
|
26198
|
+
return {
|
|
26199
|
+
detail: "Not signed in",
|
|
26200
|
+
says: `${kind2.name} isn't signed in.`,
|
|
26201
|
+
...known === void 0 ? { doing: "Sign it in its own way, then try again." } : { doing: known.signInDoing, copy: known.signInLine }
|
|
26202
|
+
};
|
|
26203
|
+
}
|
|
26204
|
+
|
|
26205
|
+
// src/places.ts
|
|
26206
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
26207
|
+
import { homedir as homedir4 } from "node:os";
|
|
26208
|
+
import { isAbsolute as isAbsolute2, join as join5, relative, resolve as resolve2, sep as sep2 } from "node:path";
|
|
26209
|
+
function placesOf(home = homedir4()) {
|
|
26210
|
+
return {
|
|
26211
|
+
settings: join5(home, "Chips", ".bridges", "acp"),
|
|
26212
|
+
agents: join5(home, "Chips", "Agents"),
|
|
26213
|
+
oldSettings: join5(home, ".chips-acp"),
|
|
26214
|
+
oldAgents: join5(home, "chips-acp")
|
|
26215
|
+
};
|
|
26216
|
+
}
|
|
26217
|
+
var fromHome = (path, home = homedir4()) => path === "~" ? home : path.startsWith("~/") ? join5(home, path.slice(2)) : path;
|
|
26218
|
+
function inside2(root, path) {
|
|
26219
|
+
const under = relative(root, path);
|
|
26220
|
+
return under === "" || under === ".." || under.startsWith(`..${sep2}`) || isAbsolute2(under) ? void 0 : under;
|
|
26221
|
+
}
|
|
26222
|
+
function nowAt(path, before, after) {
|
|
26223
|
+
const under = inside2(before, path);
|
|
26224
|
+
if (under === void 0) return path;
|
|
26225
|
+
const moved = join5(after, under);
|
|
26226
|
+
return existsSync5(path) && !existsSync5(moved) ? path : moved;
|
|
26227
|
+
}
|
|
26228
|
+
function configTargetOf(word, home = homedir4()) {
|
|
26229
|
+
const places = placesOf(home);
|
|
26230
|
+
const path = resolve2(fromHome(word ?? join5(places.settings, "config.json"), home));
|
|
26231
|
+
const under = inside2(places.oldSettings, path);
|
|
26232
|
+
return under === void 0 ? path : join5(places.settings, under);
|
|
26233
|
+
}
|
|
26234
|
+
function configPathOf(word, home = homedir4()) {
|
|
26235
|
+
const places = placesOf(home);
|
|
26236
|
+
const target = configTargetOf(word, home);
|
|
26237
|
+
const under = inside2(places.settings, target);
|
|
26238
|
+
if (under === void 0) return target;
|
|
26239
|
+
const old = join5(places.oldSettings, under);
|
|
26240
|
+
const kept2 = (path) => existsSync5(path) || existsSync5(path.replace(/\.json$/, ""));
|
|
26241
|
+
return kept2(old) && !kept2(target) ? old : target;
|
|
26242
|
+
}
|
|
26243
|
+
function foldersPathOf(path, home = homedir4()) {
|
|
26244
|
+
const places = placesOf(home);
|
|
26245
|
+
const whole2 = resolve2(fromHome(path, home));
|
|
26246
|
+
const under = inside2(places.agents, whole2);
|
|
26247
|
+
const old = under === void 0 ? void 0 : join5(places.oldAgents, under);
|
|
26248
|
+
if (old !== void 0 && existsSync5(old) && !existsSync5(whole2)) return old;
|
|
26249
|
+
return nowAt(whole2, places.oldAgents, places.agents);
|
|
26250
|
+
}
|
|
26251
|
+
|
|
26252
|
+
// src/setup.ts
|
|
26253
|
+
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
|
|
26254
|
+
import { basename as basename3, delimiter as delimiter2, isAbsolute as isAbsolute3, join as join6, resolve as resolve3 } from "node:path";
|
|
26255
|
+
|
|
26256
|
+
// src/version.ts
|
|
26257
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
26258
|
+
var VERSION = JSON.parse(readFileSync5(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
26259
|
+
|
|
26260
|
+
// src/setup.ts
|
|
26261
|
+
var SetupError = class extends Error {
|
|
26262
|
+
constructor(message, words4 = {}) {
|
|
26263
|
+
super(message);
|
|
26264
|
+
this.words = words4;
|
|
26265
|
+
}
|
|
26266
|
+
words;
|
|
26267
|
+
name = "SetupError";
|
|
26268
|
+
};
|
|
26269
|
+
var STILL_GOOD = "The link is still good: run the same command again once that's done.";
|
|
26270
|
+
var EXAMPLE = '{ "name": "Claude Code", "command": ["claude-agent-acp"], "folders": "~/Chips/Agents/claude-code" }';
|
|
26271
|
+
function readConfig(path) {
|
|
26272
|
+
const known = knownConfig(basename3(path, ".json"));
|
|
26273
|
+
if (!existsSync6(path) && known === void 0) {
|
|
26274
|
+
throw new SetupError(
|
|
26275
|
+
`There is no config at ${path}. Write ${EXAMPLE} there, or name claude-code.json or codex.json, which need none. ${STILL_GOOD}`
|
|
26276
|
+
);
|
|
26277
|
+
}
|
|
26278
|
+
const raw = existsSync6(path) ? JSON.parse(readFileSync6(path, "utf8")) : known;
|
|
26279
|
+
const name = raw["name"];
|
|
26280
|
+
const command = raw["command"];
|
|
26281
|
+
if (typeof name !== "string" || name.trim() === "" || !Array.isArray(command) || command.length === 0) {
|
|
26282
|
+
throw new SetupError(`${path} names a kind of agent and how to run it: ${EXAMPLE}. ${STILL_GOOD}`);
|
|
26283
|
+
}
|
|
26284
|
+
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
26285
|
+
return {
|
|
26286
|
+
name,
|
|
26287
|
+
command: command.map(String),
|
|
26288
|
+
folders: foldersPathOf(typeof raw["folders"] === "string" ? raw["folders"] : `~/Chips/Agents/${slug}`),
|
|
26289
|
+
...typeof raw["folder"] === "string" ? { folder: foldersPathOf(raw["folder"]) } : {},
|
|
26290
|
+
...typeof raw["mode"] === "string" ? { mode: raw["mode"] } : {},
|
|
26291
|
+
...typeof raw["env"] === "object" && raw["env"] !== null ? { env: raw["env"] } : {}
|
|
26292
|
+
};
|
|
26293
|
+
}
|
|
26294
|
+
var runnable = (path) => {
|
|
26295
|
+
try {
|
|
26296
|
+
accessSync2(path, constants2.X_OK);
|
|
26297
|
+
return true;
|
|
26298
|
+
} catch {
|
|
26299
|
+
return false;
|
|
26300
|
+
}
|
|
26301
|
+
};
|
|
26302
|
+
var onPath = (program, path) => path.split(delimiter2).some((dir) => dir !== "" && runnable(join6(dir, program)));
|
|
26303
|
+
function checkCommand(kind2, env2 = process.env) {
|
|
26304
|
+
const [program] = kind2.command;
|
|
26305
|
+
if (program === void 0) throw new SetupError(`${kind2.name} has no command to run. ${STILL_GOOD}`);
|
|
26306
|
+
const path = { ...env2, ...kind2.env }["PATH"] ?? "";
|
|
26307
|
+
const found = program.includes("/") ? runnable(isAbsolute3(program) ? program : resolve3(fromHome(program))) : onPath(program, path);
|
|
26308
|
+
if (!found) {
|
|
26309
|
+
throw new SetupError(
|
|
26310
|
+
`${kind2.name}'s command, ${program}, isn't on this machine's PATH: ${installWords(kind2)}. ${STILL_GOOD}`,
|
|
26311
|
+
notInstalledStop(kind2, program)
|
|
26312
|
+
);
|
|
26313
|
+
}
|
|
26314
|
+
}
|
|
26315
|
+
var MINUTE = 6e4;
|
|
26316
|
+
function within(promise2, ms, what) {
|
|
26317
|
+
let timer;
|
|
26318
|
+
const late = new Promise((_, reject) => {
|
|
26319
|
+
timer = setTimeout(() => reject(new Error(what)), ms);
|
|
26320
|
+
});
|
|
26321
|
+
return Promise.race([promise2, late]).finally(() => clearTimeout(timer));
|
|
26322
|
+
}
|
|
26323
|
+
var wordsOf2 = (error62) => error62 instanceof Error ? error62.message : String(error62);
|
|
26324
|
+
async function checkSignIn(kind2, wire, cwd, options = {}) {
|
|
26325
|
+
let status;
|
|
26326
|
+
let heard = () => {
|
|
26327
|
+
};
|
|
26328
|
+
const said = new Promise((resolve5) => {
|
|
26329
|
+
heard = resolve5;
|
|
26330
|
+
});
|
|
26331
|
+
const client = new AcpClient(wire, {
|
|
26332
|
+
update: () => void 0,
|
|
26333
|
+
request: async (request) => {
|
|
26334
|
+
throw notOffered(request.method);
|
|
26335
|
+
},
|
|
26336
|
+
exit: () => heard(),
|
|
26337
|
+
auth: (now) => {
|
|
26338
|
+
status = now;
|
|
26339
|
+
heard();
|
|
26340
|
+
}
|
|
26341
|
+
});
|
|
26342
|
+
try {
|
|
26343
|
+
let info;
|
|
26344
|
+
try {
|
|
26345
|
+
info = await within(client.initialize({ name: "chips-acp", version: VERSION }), MINUTE, "it didn't answer within a minute");
|
|
26346
|
+
} catch (error62) {
|
|
26347
|
+
const last = options.stderr?.().slice(-3).join(" ") ?? "";
|
|
26348
|
+
throw new SetupError(`${kind2.name} didn't start: ${wordsOf2(error62)}.${last === "" ? "" : ` It said: ${last}`} ${STILL_GOOD}`, {
|
|
26349
|
+
detail: "It didn't start",
|
|
26350
|
+
says: `${kind2.name} didn't start: ${wordsOf2(error62)}.`,
|
|
26351
|
+
...last === "" ? {} : { doing: `It said: ${last}` }
|
|
26352
|
+
});
|
|
26353
|
+
}
|
|
26354
|
+
try {
|
|
26355
|
+
const { sessionId } = await within(client.newSession(cwd), MINUTE, "it didn't answer within a minute");
|
|
26356
|
+
if (info.closeSession) await client.closeSession(sessionId).catch(() => void 0);
|
|
26357
|
+
} catch (error62) {
|
|
26358
|
+
if (isAuthRequired(error62)) throw new SetupError(`${signedOutWords(kind2, info)} ${STILL_GOOD}`, signedOutStop(kind2));
|
|
26359
|
+
throw new SetupError(`${kind2.name} couldn't open a session: ${wordsOf2(error62)}. ${STILL_GOOD}`, {
|
|
26360
|
+
detail: "It couldn't open a session",
|
|
26361
|
+
says: `${kind2.name} couldn't open a session: ${wordsOf2(error62)}.`
|
|
26362
|
+
});
|
|
26363
|
+
}
|
|
26364
|
+
if (info.reportsAuth && status === void 0) await within(said, options.waitMs ?? 6e3, "").catch(() => void 0);
|
|
26365
|
+
if (status?.kind === "none") throw new SetupError(`${signedOutWords(kind2, info)} ${STILL_GOOD}`, signedOutStop(kind2));
|
|
26366
|
+
} finally {
|
|
26367
|
+
client.close();
|
|
26368
|
+
}
|
|
26369
|
+
}
|
|
26370
|
+
|
|
26371
|
+
// src/adapter.ts
|
|
26372
|
+
var PATIENCE_MS = 20 * 6e4;
|
|
26373
|
+
var adapterFolder = (id2, home = homedir5()) => join7(placesOf(home).settings, "adapters", id2);
|
|
26374
|
+
var fetchedAt = (id2, program, home) => join7(adapterFolder(id2, home), "node_modules", ".bin", program);
|
|
26375
|
+
var pathOf2 = (kind2, env2) => ({ ...env2, ...kind2.env })["PATH"] ?? "";
|
|
26376
|
+
function withFetchedAdapter(kind2, env2 = process.env, home = homedir5()) {
|
|
26377
|
+
const known = knownOf(kind2);
|
|
26378
|
+
if (known === void 0 || kind2.command[0] !== known.program || onPath(known.program, pathOf2(kind2, env2))) return kind2;
|
|
26379
|
+
const fetched = fetchedAt(known.id, known.program, home);
|
|
26380
|
+
return runnable(fetched) ? { ...kind2, command: [fetched, ...kind2.command.slice(1)] } : kind2;
|
|
26381
|
+
}
|
|
26382
|
+
function npmInstall(job) {
|
|
26383
|
+
return new Promise((resolve5, reject) => {
|
|
26384
|
+
const registry2 = job.env["CHIPS_NPM_REGISTRY"];
|
|
26385
|
+
const child = spawn2(
|
|
26386
|
+
job.node,
|
|
26387
|
+
[
|
|
26388
|
+
job.npm,
|
|
26389
|
+
"install",
|
|
26390
|
+
job.spec,
|
|
26391
|
+
"--prefix",
|
|
26392
|
+
job.folder,
|
|
26393
|
+
"--omit=dev",
|
|
26394
|
+
"--ignore-scripts",
|
|
26395
|
+
"--no-audit",
|
|
26396
|
+
"--no-fund",
|
|
26397
|
+
"--loglevel=error",
|
|
26398
|
+
...registry2 === void 0 || registry2 === "" ? [] : ["--registry", registry2]
|
|
26399
|
+
],
|
|
26400
|
+
{ env: job.env, stdio: ["ignore", "ignore", "pipe"] }
|
|
26401
|
+
);
|
|
26402
|
+
let said = "";
|
|
26403
|
+
child.stderr.on("data", (chunk) => {
|
|
26404
|
+
said = `${said}${chunk.toString("utf8")}`.slice(-2e3);
|
|
26405
|
+
});
|
|
26406
|
+
const late = setTimeout(() => child.kill("SIGTERM"), PATIENCE_MS);
|
|
26407
|
+
child.on("error", (error62) => {
|
|
26408
|
+
clearTimeout(late);
|
|
26409
|
+
reject(error62);
|
|
26410
|
+
});
|
|
26411
|
+
child.on("exit", (code) => {
|
|
26412
|
+
clearTimeout(late);
|
|
26413
|
+
if (code === 0) resolve5();
|
|
26414
|
+
else reject(new Error(said.trim() || `npm stopped with ${code ?? "a signal"}`));
|
|
26415
|
+
});
|
|
26416
|
+
});
|
|
26417
|
+
}
|
|
26418
|
+
async function readyAdapter(kind2, options = {}) {
|
|
26419
|
+
const env2 = options.env ?? process.env;
|
|
26420
|
+
const home = options.home ?? homedir5();
|
|
26421
|
+
const known = knownOf(kind2);
|
|
26422
|
+
if (known === void 0 || kind2.command[0] !== known.program) return kind2;
|
|
26423
|
+
const path = pathOf2(kind2, env2);
|
|
26424
|
+
if (onPath(known.program, path)) return kind2;
|
|
26425
|
+
if (!onPath(known.agent, path)) {
|
|
26426
|
+
throw new SetupError(`${kind2.name} isn't installed on this machine: run \`${known.installLine}\`. ${STILL_GOOD}`, agentMissingStop(known));
|
|
26427
|
+
}
|
|
26428
|
+
const npm = env2["CHIPS_NPM"];
|
|
26429
|
+
if (!known.fetches || npm === void 0 || npm === "") return kind2;
|
|
26430
|
+
const folder2 = adapterFolder(known.id, home);
|
|
26431
|
+
const { CHIPS_JOIN_LINK: _link, ...rest } = env2;
|
|
26432
|
+
const node2 = process.execPath;
|
|
26433
|
+
options.say?.(`Getting what ${kind2.name} needs from npm, a large download`);
|
|
26434
|
+
try {
|
|
26435
|
+
mkdirSync4(folder2, { recursive: true });
|
|
26436
|
+
await (options.install ?? npmInstall)({
|
|
26437
|
+
node: node2,
|
|
26438
|
+
npm,
|
|
26439
|
+
folder: folder2,
|
|
26440
|
+
spec: `${known.adapter}@${known.adapterMajor}`,
|
|
26441
|
+
env: { ...rest, PATH: `${dirname4(node2)}${delimiter3}${rest["PATH"] ?? ""}` }
|
|
26442
|
+
});
|
|
26443
|
+
} catch (error62) {
|
|
26444
|
+
rmSync3(folder2, { recursive: true, force: true });
|
|
26445
|
+
const why = error62 instanceof Error ? error62.message : String(error62);
|
|
26446
|
+
throw new SetupError(`${kind2.name}'s adapter couldn't be downloaded: ${why}. ${STILL_GOOD}`, adapterFailedStop(kind2.name));
|
|
26447
|
+
}
|
|
26448
|
+
const ready = withFetchedAdapter(kind2, env2, home);
|
|
26449
|
+
if (ready.command[0] === known.program) {
|
|
26450
|
+
rmSync3(folder2, { recursive: true, force: true });
|
|
26451
|
+
throw new SetupError(`${known.adapter} installed, but it has no ${known.program}. ${STILL_GOOD}`, adapterFailedStop(kind2.name));
|
|
26452
|
+
}
|
|
26453
|
+
return ready;
|
|
26454
|
+
}
|
|
26455
|
+
function forgetAdapter(id2, home = homedir5()) {
|
|
26456
|
+
if (knownConfig(id2) !== void 0) rmSync3(adapterFolder(id2, home), { recursive: true, force: true });
|
|
26457
|
+
}
|
|
26458
|
+
|
|
26082
26459
|
// src/bridge.ts
|
|
26083
26460
|
import { randomBytes } from "node:crypto";
|
|
26084
|
-
import { existsSync as
|
|
26461
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
26085
26462
|
import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
|
|
26086
|
-
import { homedir as
|
|
26087
|
-
import { join as
|
|
26463
|
+
import { homedir as homedir6 } from "node:os";
|
|
26464
|
+
import { join as join10 } from "node:path";
|
|
26088
26465
|
|
|
26089
26466
|
// src/claude-settings.ts
|
|
26090
|
-
import { existsSync as
|
|
26091
|
-
import { join as
|
|
26467
|
+
import { existsSync as existsSync7, readFileSync as readFileSync7 } from "node:fs";
|
|
26468
|
+
import { join as join8 } from "node:path";
|
|
26092
26469
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26093
26470
|
function readLayer(path) {
|
|
26094
|
-
if (!
|
|
26471
|
+
if (!existsSync7(path)) return void 0;
|
|
26095
26472
|
try {
|
|
26096
|
-
const read = JSON.parse(
|
|
26473
|
+
const read = JSON.parse(readFileSync7(path, "utf8"));
|
|
26097
26474
|
return isRecord(read) ? read : void 0;
|
|
26098
26475
|
} catch {
|
|
26099
26476
|
return void 0;
|
|
@@ -26101,9 +26478,9 @@ function readLayer(path) {
|
|
|
26101
26478
|
}
|
|
26102
26479
|
function settingsLayers(claudeHome, folder2) {
|
|
26103
26480
|
return [
|
|
26104
|
-
|
|
26105
|
-
|
|
26106
|
-
|
|
26481
|
+
join8(claudeHome, "settings.json"),
|
|
26482
|
+
join8(folder2, ".claude", "settings.json"),
|
|
26483
|
+
join8(folder2, ".claude", "settings.local.json")
|
|
26107
26484
|
].flatMap((path) => {
|
|
26108
26485
|
const layer = readLayer(path);
|
|
26109
26486
|
return layer === void 0 ? [] : [layer];
|
|
@@ -26153,19 +26530,19 @@ function autoCompactWindowFromEnv(env2) {
|
|
|
26153
26530
|
}
|
|
26154
26531
|
function memoryPath(claudeHome, folder2) {
|
|
26155
26532
|
const name = folder2.replace(/[^a-zA-Z0-9]/g, "-");
|
|
26156
|
-
return name.length > 200 ? void 0 :
|
|
26533
|
+
return name.length > 200 ? void 0 : join8(claudeHome, "projects", name, "memory", "MEMORY.md");
|
|
26157
26534
|
}
|
|
26158
26535
|
|
|
26159
26536
|
// src/context.ts
|
|
26160
26537
|
import { createHash as createHash2 } from "node:crypto";
|
|
26161
|
-
import { readdirSync, readFileSync as
|
|
26538
|
+
import { readdirSync, readFileSync as readFileSync8, statSync } from "node:fs";
|
|
26162
26539
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
26163
|
-
import { dirname as
|
|
26164
|
-
function
|
|
26540
|
+
import { dirname as dirname5, join as join9, parse as parse3, relative as relative2, sep as sep3 } from "node:path";
|
|
26541
|
+
function placesOf2(env2, home) {
|
|
26165
26542
|
return {
|
|
26166
26543
|
home,
|
|
26167
|
-
claudeHome: env2["CLAUDE_CONFIG_DIR"] ||
|
|
26168
|
-
codexHome: env2["CODEX_HOME"] ||
|
|
26544
|
+
claudeHome: env2["CLAUDE_CONFIG_DIR"] || join9(home, ".claude"),
|
|
26545
|
+
codexHome: env2["CODEX_HOME"] || join9(home, ".codex")
|
|
26169
26546
|
};
|
|
26170
26547
|
}
|
|
26171
26548
|
function hashOf(text) {
|
|
@@ -26180,13 +26557,13 @@ function isFile(path) {
|
|
|
26180
26557
|
}
|
|
26181
26558
|
function textOf(path) {
|
|
26182
26559
|
try {
|
|
26183
|
-
return
|
|
26560
|
+
return readFileSync8(path, "utf8");
|
|
26184
26561
|
} catch {
|
|
26185
26562
|
return void 0;
|
|
26186
26563
|
}
|
|
26187
26564
|
}
|
|
26188
26565
|
function claudeFilesIn(dir) {
|
|
26189
|
-
const rules =
|
|
26566
|
+
const rules = join9(dir, ".claude", "rules");
|
|
26190
26567
|
let named = [];
|
|
26191
26568
|
try {
|
|
26192
26569
|
named = readdirSync(rules).filter((name) => name.endsWith(".md")).sort();
|
|
@@ -26194,26 +26571,26 @@ function claudeFilesIn(dir) {
|
|
|
26194
26571
|
named = [];
|
|
26195
26572
|
}
|
|
26196
26573
|
return [
|
|
26197
|
-
|
|
26198
|
-
|
|
26199
|
-
|
|
26200
|
-
...named.map((name) =>
|
|
26574
|
+
join9(dir, "CLAUDE.md"),
|
|
26575
|
+
join9(dir, "CLAUDE.local.md"),
|
|
26576
|
+
join9(dir, ".claude", "CLAUDE.md"),
|
|
26577
|
+
...named.map((name) => join9(rules, name))
|
|
26201
26578
|
];
|
|
26202
26579
|
}
|
|
26203
26580
|
function ownTitle(within3) {
|
|
26204
26581
|
if (within3 === "CLAUDE.md") return "How it works";
|
|
26205
26582
|
if (within3 === "CLAUDE.local.md") return "Its local instructions";
|
|
26206
|
-
if (within3 ===
|
|
26583
|
+
if (within3 === join9(".claude", "CLAUDE.md")) return "More of how it works";
|
|
26207
26584
|
return `Rule: ${parse3(within3).name}`.slice(0, 80);
|
|
26208
26585
|
}
|
|
26209
26586
|
function readNote2(name) {
|
|
26210
26587
|
return `${name} reads these when a conversation starts. A change made here applies from the next message.`;
|
|
26211
26588
|
}
|
|
26212
|
-
var
|
|
26589
|
+
var within2 = (path, dir) => path === dir || path.startsWith(`${dir}${sep3}`);
|
|
26213
26590
|
function* upFrom(dir) {
|
|
26214
|
-
for (let at = dir; ; at =
|
|
26591
|
+
for (let at = dir; ; at = dirname5(at)) {
|
|
26215
26592
|
yield at;
|
|
26216
|
-
if (
|
|
26593
|
+
if (dirname5(at) === at) return;
|
|
26217
26594
|
}
|
|
26218
26595
|
}
|
|
26219
26596
|
var ContextFiles = class {
|
|
@@ -26230,19 +26607,19 @@ var ContextFiles = class {
|
|
|
26230
26607
|
/** `~/Chips/Agents/claude-code/CLAUDE.md`, or the whole path where it isn't in the home. */
|
|
26231
26608
|
tilde(path) {
|
|
26232
26609
|
const { home } = this.places;
|
|
26233
|
-
return
|
|
26610
|
+
return within2(path, home) ? `~${path.slice(home.length)}` : path;
|
|
26234
26611
|
}
|
|
26235
26612
|
/** A shared file's name: where it is, a step at a time (`~ › .codex › AGENTS.md`), with no slash. */
|
|
26236
26613
|
crumbs(path) {
|
|
26237
26614
|
const { home } = this.places;
|
|
26238
|
-
const steps =
|
|
26615
|
+
const steps = within2(path, home) ? ["~", ...relative2(home, path).split(sep3)] : ["/", ...path.split(sep3)];
|
|
26239
26616
|
return steps.filter((step) => step !== "").join(" \u203A ").slice(0, 255);
|
|
26240
26617
|
}
|
|
26241
26618
|
/** The harness's own set: what every agent, or every agent below a folder, reads beside its own. */
|
|
26242
26619
|
sharedSpots() {
|
|
26243
26620
|
const { places, kind: kind2 } = this;
|
|
26244
26621
|
if (this.id === "codex") {
|
|
26245
|
-
const yours2 = [
|
|
26622
|
+
const yours2 = [join9(places.codexHome, "AGENTS.override.md"), join9(places.codexHome, "AGENTS.md")].find(isFile);
|
|
26246
26623
|
if (yours2 === void 0) return [];
|
|
26247
26624
|
return [
|
|
26248
26625
|
{
|
|
@@ -26259,7 +26636,7 @@ var ContextFiles = class {
|
|
|
26259
26636
|
}
|
|
26260
26637
|
const spots = [];
|
|
26261
26638
|
if (kind2.folder === void 0) {
|
|
26262
|
-
const path =
|
|
26639
|
+
const path = join9(kind2.folders, "CLAUDE.md");
|
|
26263
26640
|
spots.push({
|
|
26264
26641
|
path,
|
|
26265
26642
|
name: this.crumbs(path),
|
|
@@ -26271,8 +26648,8 @@ var ContextFiles = class {
|
|
|
26271
26648
|
over: kind2.folders
|
|
26272
26649
|
});
|
|
26273
26650
|
}
|
|
26274
|
-
const yours =
|
|
26275
|
-
for (const dir of upFrom(kind2.folder === void 0 ? kind2.folders :
|
|
26651
|
+
const yours = join9(places.claudeHome, "CLAUDE.md");
|
|
26652
|
+
for (const dir of upFrom(kind2.folder === void 0 ? kind2.folders : dirname5(kind2.folder))) {
|
|
26276
26653
|
for (const path of claudeFilesIn(dir)) {
|
|
26277
26654
|
if (path === yours || spots.some((spot) => spot.path === path) || !isFile(path)) continue;
|
|
26278
26655
|
spots.push({
|
|
@@ -26305,13 +26682,13 @@ var ContextFiles = class {
|
|
|
26305
26682
|
/** An agent's own files: its folder's, and for Claude Code its memory, last. */
|
|
26306
26683
|
ownSpots(folder2) {
|
|
26307
26684
|
if (this.id === "codex") {
|
|
26308
|
-
const override =
|
|
26309
|
-
const path = isFile(override) ? override :
|
|
26310
|
-
return [{ path, name:
|
|
26685
|
+
const override = join9(folder2, "AGENTS.override.md");
|
|
26686
|
+
const path = isFile(override) ? override : join9(folder2, "AGENTS.md");
|
|
26687
|
+
return [{ path, name: relative2(folder2, path), title: "How it works", role: "instructions", editable: true }];
|
|
26311
26688
|
}
|
|
26312
26689
|
const spots = claudeFilesIn(folder2).filter((path, at) => at === 0 || isFile(path)).map((path) => {
|
|
26313
|
-
const where =
|
|
26314
|
-
return { path, name: where.split(
|
|
26690
|
+
const where = relative2(folder2, path);
|
|
26691
|
+
return { path, name: where.split(sep3).join(" \u203A "), title: ownTitle(where), role: "instructions", editable: true };
|
|
26315
26692
|
});
|
|
26316
26693
|
const memory = memoryPath(this.places.claudeHome, folder2);
|
|
26317
26694
|
if (memory !== void 0 && memoryOn(settingsLayers(this.places.claudeHome, folder2))) {
|
|
@@ -26328,7 +26705,7 @@ var ContextFiles = class {
|
|
|
26328
26705
|
}
|
|
26329
26706
|
/** The shared files an agent in `folder` reads. */
|
|
26330
26707
|
readBy(folder2) {
|
|
26331
|
-
return this.sharedSpots().filter((spot) => spot.over === void 0 ||
|
|
26708
|
+
return this.sharedSpots().filter((spot) => spot.over === void 0 || within2(folder2, spot.over));
|
|
26332
26709
|
}
|
|
26333
26710
|
/** An agent's copy: its own files and the shared ones it reads, eight at most, and when it reads them. */
|
|
26334
26711
|
agentCopy(folder2) {
|
|
@@ -26402,7 +26779,7 @@ var ContextFiles = class {
|
|
|
26402
26779
|
hash: hashOf(text),
|
|
26403
26780
|
editable: spot.editable,
|
|
26404
26781
|
...spot.whyReadOnly === void 0 ? {} : { why_read_only: spot.whyReadOnly },
|
|
26405
|
-
used_by: over === void 0 ? folders.length : folders.filter((folder2) =>
|
|
26782
|
+
used_by: over === void 0 ? folders.length : folders.filter((folder2) => within2(folder2, over)).length
|
|
26406
26783
|
});
|
|
26407
26784
|
}
|
|
26408
26785
|
return { shared, ...notShown.length === 0 ? {} : { not_shown: notShown } };
|
|
@@ -26445,7 +26822,7 @@ var ContextFiles = class {
|
|
|
26445
26822
|
async write(spot, edit, now) {
|
|
26446
26823
|
if (hashOf(textOf(spot.path) ?? "") !== edit.base_hash) throw new Refuse("", now(), "changed");
|
|
26447
26824
|
try {
|
|
26448
|
-
await mkdir2(
|
|
26825
|
+
await mkdir2(dirname5(spot.path), { recursive: true });
|
|
26449
26826
|
await writeFile2(spot.path, edit.text, "utf8");
|
|
26450
26827
|
} catch (error62) {
|
|
26451
26828
|
throw new Refuse(`It couldn't be saved: ${error62 instanceof Error ? error62.message : String(error62)}`.slice(0, 300), now(), "failed");
|
|
@@ -26453,94 +26830,6 @@ var ContextFiles = class {
|
|
|
26453
26830
|
}
|
|
26454
26831
|
};
|
|
26455
26832
|
|
|
26456
|
-
// src/kinds.ts
|
|
26457
|
-
var KNOWN2 = [
|
|
26458
|
-
{
|
|
26459
|
-
id: "claude-code",
|
|
26460
|
-
name: "Claude Code",
|
|
26461
|
-
program: "claude-agent-acp",
|
|
26462
|
-
adapter: "@agentclientprotocol/claude-agent-acp",
|
|
26463
|
-
mode: "default",
|
|
26464
|
-
signIn: "run `claude`, then /login",
|
|
26465
|
-
signInLine: "claude",
|
|
26466
|
-
signInDoing: "Run this in a terminal, then /login, then try again."
|
|
26467
|
-
},
|
|
26468
|
-
{
|
|
26469
|
-
id: "codex",
|
|
26470
|
-
name: "Codex",
|
|
26471
|
-
program: "codex-acp",
|
|
26472
|
-
adapter: "@agentclientprotocol/codex-acp",
|
|
26473
|
-
mode: "workspace-write",
|
|
26474
|
-
signIn: "run `codex login`",
|
|
26475
|
-
signInLine: "codex login",
|
|
26476
|
-
signInDoing: "Run this in a terminal, then try again."
|
|
26477
|
-
}
|
|
26478
|
-
];
|
|
26479
|
-
function knownConfig(id2) {
|
|
26480
|
-
const known = KNOWN2.find((each) => each.id === id2);
|
|
26481
|
-
return known === void 0 ? void 0 : { name: known.name, command: [known.program], mode: known.mode };
|
|
26482
|
-
}
|
|
26483
|
-
var knownBy = (kind2) => {
|
|
26484
|
-
const program = kind2.command[0]?.split("/").pop();
|
|
26485
|
-
return KNOWN2.find((each) => each.program === program);
|
|
26486
|
-
};
|
|
26487
|
-
function knownIdOf(kind2) {
|
|
26488
|
-
return knownBy(kind2)?.id;
|
|
26489
|
-
}
|
|
26490
|
-
var CODEX_DOC_BYTES = 65536;
|
|
26491
|
-
function codexConfigOf(env2) {
|
|
26492
|
-
const raw = env2["CODEX_CONFIG"];
|
|
26493
|
-
if (raw === void 0 || raw.trim() === "") return void 0;
|
|
26494
|
-
try {
|
|
26495
|
-
const parsed = JSON.parse(raw);
|
|
26496
|
-
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
|
|
26497
|
-
} catch {
|
|
26498
|
-
return void 0;
|
|
26499
|
-
}
|
|
26500
|
-
}
|
|
26501
|
-
function adapterEnv(kind2, env2) {
|
|
26502
|
-
if (knownIdOf(kind2) !== "codex") return env2;
|
|
26503
|
-
const raw = env2["CODEX_CONFIG"];
|
|
26504
|
-
const config2 = codexConfigOf(env2);
|
|
26505
|
-
if (raw !== void 0 && raw.trim() !== "" && config2 === void 0) return env2;
|
|
26506
|
-
if (config2?.["project_doc_max_bytes"] !== void 0) return env2;
|
|
26507
|
-
return { ...env2, CODEX_CONFIG: JSON.stringify({ ...config2, project_doc_max_bytes: CODEX_DOC_BYTES }) };
|
|
26508
|
-
}
|
|
26509
|
-
function codexDocBytes(env2) {
|
|
26510
|
-
const said = codexConfigOf(env2)?.["project_doc_max_bytes"];
|
|
26511
|
-
return typeof said === "number" && Number.isFinite(said) && said > 0 ? said : 32768;
|
|
26512
|
-
}
|
|
26513
|
-
function installWords(kind2) {
|
|
26514
|
-
const known = knownBy(kind2);
|
|
26515
|
-
return known === void 0 ? "install the agent's ACP adapter its own way, or name it by its path in the config" : `install it with \`npm install -g ${known.adapter}\``;
|
|
26516
|
-
}
|
|
26517
|
-
function signedOutWords(kind2, info) {
|
|
26518
|
-
const known = knownBy(kind2);
|
|
26519
|
-
if (known !== void 0) return `${kind2.name} isn't signed in on this machine: ${known.signIn} in a terminal.`;
|
|
26520
|
-
const ways = (info?.authMethods ?? []).map((method) => method.name);
|
|
26521
|
-
return `${kind2.name} isn't signed in on this machine: sign it in its own way${ways.length > 0 ? ` (${ways.join(", ")})` : ""}.`;
|
|
26522
|
-
}
|
|
26523
|
-
function notInstalledStop(kind2, program) {
|
|
26524
|
-
const known = knownBy(kind2);
|
|
26525
|
-
return {
|
|
26526
|
-
detail: `${program} isn't on this Mac`,
|
|
26527
|
-
says: `${kind2.name}'s ACP adapter isn't installed.`,
|
|
26528
|
-
...known === void 0 ? { doing: "Install the agent's ACP adapter its own way, then try again." } : { doing: "Install it with npm, then try again.", copy: `npm install -g ${known.adapter}` }
|
|
26529
|
-
};
|
|
26530
|
-
}
|
|
26531
|
-
function signedOutStop(kind2) {
|
|
26532
|
-
const known = knownBy(kind2);
|
|
26533
|
-
return {
|
|
26534
|
-
detail: "Not signed in",
|
|
26535
|
-
says: `${kind2.name} isn't signed in.`,
|
|
26536
|
-
...known === void 0 ? { doing: "Sign it in its own way, then try again." } : { doing: known.signInDoing, copy: known.signInLine }
|
|
26537
|
-
};
|
|
26538
|
-
}
|
|
26539
|
-
|
|
26540
|
-
// src/version.ts
|
|
26541
|
-
import { readFileSync as readFileSync7 } from "node:fs";
|
|
26542
|
-
var VERSION = JSON.parse(readFileSync7(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
26543
|
-
|
|
26544
26833
|
// src/models.ts
|
|
26545
26834
|
var SETTINGS_LEVEL = "default";
|
|
26546
26835
|
var LEVEL_WORDS = { xhigh: "Extra high" };
|
|
@@ -26736,7 +27025,7 @@ var Bridge = class {
|
|
|
26736
27025
|
this.knew = resolve5;
|
|
26737
27026
|
});
|
|
26738
27027
|
this.env = options.env ?? adapterEnv(options.kind, { ...process.env, ...options.kind.env });
|
|
26739
|
-
this.places =
|
|
27028
|
+
this.places = placesOf2(this.env, options.home ?? homedir6());
|
|
26740
27029
|
this.knownKind = knownIdOf(options.kind);
|
|
26741
27030
|
this.files = this.knownKind === void 0 ? void 0 : new ContextFiles(this.knownKind, options.kind, this.places, codexDocBytes(this.env));
|
|
26742
27031
|
}
|
|
@@ -26899,8 +27188,8 @@ var Bridge = class {
|
|
|
26899
27188
|
const base = slugOf(name).replace(/_/g, "-") || "agent";
|
|
26900
27189
|
const taken = new Set(this.records().map((record2) => record2.folder));
|
|
26901
27190
|
for (let n = 1; ; n += 1) {
|
|
26902
|
-
const folder2 =
|
|
26903
|
-
if (taken.has(folder2) ||
|
|
27191
|
+
const folder2 = join10(kind2.folders, n === 1 ? base : `${base}-${n}`);
|
|
27192
|
+
if (taken.has(folder2) || existsSync8(folder2)) continue;
|
|
26904
27193
|
await mkdir3(folder2, { recursive: true });
|
|
26905
27194
|
return folder2;
|
|
26906
27195
|
}
|
|
@@ -27441,9 +27730,9 @@ ${files.join("\n")}`;
|
|
|
27441
27730
|
const lines2 = [];
|
|
27442
27731
|
for (const file3 of message.attachments ?? []) {
|
|
27443
27732
|
try {
|
|
27444
|
-
const folder2 =
|
|
27733
|
+
const folder2 = join10(record2.folder, "chips-files", message.message_id);
|
|
27445
27734
|
await mkdir3(folder2, { recursive: true });
|
|
27446
|
-
const path =
|
|
27735
|
+
const path = join10(folder2, file3.filename.replace(/[/\\]/g, "_"));
|
|
27447
27736
|
await writeFile3(path, await this.options.chips.download(file3));
|
|
27448
27737
|
lines2.push(`(${file3.filename} is saved at ${path})`);
|
|
27449
27738
|
} catch (error62) {
|
|
@@ -28339,63 +28628,17 @@ function forkName(original) {
|
|
|
28339
28628
|
}
|
|
28340
28629
|
|
|
28341
28630
|
// src/keep.ts
|
|
28342
|
-
import { basename as
|
|
28631
|
+
import { basename as basename4 } from "node:path";
|
|
28343
28632
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
28344
|
-
|
|
28345
|
-
// src/places.ts
|
|
28346
|
-
import { existsSync as existsSync7 } from "node:fs";
|
|
28347
|
-
import { homedir as homedir5 } from "node:os";
|
|
28348
|
-
import { isAbsolute as isAbsolute2, join as join8, relative as relative2, resolve as resolve2, sep as sep3 } from "node:path";
|
|
28349
|
-
function placesOf2(home = homedir5()) {
|
|
28350
|
-
return {
|
|
28351
|
-
settings: join8(home, "Chips", ".bridges", "acp"),
|
|
28352
|
-
agents: join8(home, "Chips", "Agents"),
|
|
28353
|
-
oldSettings: join8(home, ".chips-acp"),
|
|
28354
|
-
oldAgents: join8(home, "chips-acp")
|
|
28355
|
-
};
|
|
28356
|
-
}
|
|
28357
|
-
var fromHome = (path, home = homedir5()) => path === "~" ? home : path.startsWith("~/") ? join8(home, path.slice(2)) : path;
|
|
28358
|
-
function inside2(root, path) {
|
|
28359
|
-
const under = relative2(root, path);
|
|
28360
|
-
return under === "" || under === ".." || under.startsWith(`..${sep3}`) || isAbsolute2(under) ? void 0 : under;
|
|
28361
|
-
}
|
|
28362
|
-
function nowAt(path, before, after) {
|
|
28363
|
-
const under = inside2(before, path);
|
|
28364
|
-
if (under === void 0) return path;
|
|
28365
|
-
const moved = join8(after, under);
|
|
28366
|
-
return existsSync7(path) && !existsSync7(moved) ? path : moved;
|
|
28367
|
-
}
|
|
28368
|
-
function configTargetOf(word, home = homedir5()) {
|
|
28369
|
-
const places = placesOf2(home);
|
|
28370
|
-
const path = resolve2(fromHome(word ?? join8(places.settings, "config.json"), home));
|
|
28371
|
-
const under = inside2(places.oldSettings, path);
|
|
28372
|
-
return under === void 0 ? path : join8(places.settings, under);
|
|
28373
|
-
}
|
|
28374
|
-
function configPathOf(word, home = homedir5()) {
|
|
28375
|
-
const places = placesOf2(home);
|
|
28376
|
-
const target = configTargetOf(word, home);
|
|
28377
|
-
const under = inside2(places.settings, target);
|
|
28378
|
-
const old = under === void 0 ? void 0 : join8(places.oldSettings, under);
|
|
28379
|
-
return old !== void 0 && existsSync7(old) && !existsSync7(target) ? old : target;
|
|
28380
|
-
}
|
|
28381
|
-
function foldersPathOf(path, home = homedir5()) {
|
|
28382
|
-
const places = placesOf2(home);
|
|
28383
|
-
const whole2 = resolve2(fromHome(path, home));
|
|
28384
|
-
const under = inside2(places.agents, whole2);
|
|
28385
|
-
const old = under === void 0 ? void 0 : join8(places.oldAgents, under);
|
|
28386
|
-
if (old !== void 0 && existsSync7(old) && !existsSync7(whole2)) return old;
|
|
28387
|
-
return nowAt(whole2, places.oldAgents, places.agents);
|
|
28388
|
-
}
|
|
28389
|
-
|
|
28390
|
-
// src/keep.ts
|
|
28391
28633
|
var flags = process.argv.slice(2);
|
|
28392
28634
|
var words3 = flags.filter((word) => !word.startsWith("--"));
|
|
28393
28635
|
var handsOver = flags.includes("--keep");
|
|
28636
|
+
var stopping = flags.includes("--stop");
|
|
28394
28637
|
var whole = (word) => configTargetOf(word);
|
|
28395
28638
|
var here = fileURLToPath2(new URL("..", import.meta.url)).replace(/\/$/, "");
|
|
28396
28639
|
var self = fileURLToPath2(import.meta.url);
|
|
28397
28640
|
var run = self.endsWith(".js") ? [self] : ["--import", "tsx", "src/main.ts"];
|
|
28398
|
-
var again = process.env["npm_lifecycle_event"] === "keep" ? "npm run keep --" :
|
|
28641
|
+
var again = process.env["npm_lifecycle_event"] === "keep" ? "npm run keep --" : basename4(process.argv[1] ?? "chips");
|
|
28399
28642
|
var stopLine = process.env["CHIPS_STOP_COMMAND"] || [again, ...words3, "--stop"].join(" ");
|
|
28400
28643
|
var end = (line, code) => {
|
|
28401
28644
|
(code === 0 ? process.stdout : process.stderr).write(`${line}
|
|
@@ -28437,123 +28680,9 @@ function keepIfAsked(label2, url2, names, log2, before = () => void 0) {
|
|
|
28437
28680
|
}
|
|
28438
28681
|
|
|
28439
28682
|
// src/move.ts
|
|
28440
|
-
import { lstatSync, mkdirSync as
|
|
28441
|
-
import { homedir as
|
|
28442
|
-
import { basename as basename5, dirname as
|
|
28443
|
-
|
|
28444
|
-
// src/setup.ts
|
|
28445
|
-
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync8, readFileSync as readFileSync8 } from "node:fs";
|
|
28446
|
-
import { basename as basename4, delimiter as delimiter2, isAbsolute as isAbsolute3, join as join9, resolve as resolve3 } from "node:path";
|
|
28447
|
-
var SetupError = class extends Error {
|
|
28448
|
-
constructor(message, words4 = {}) {
|
|
28449
|
-
super(message);
|
|
28450
|
-
this.words = words4;
|
|
28451
|
-
}
|
|
28452
|
-
words;
|
|
28453
|
-
name = "SetupError";
|
|
28454
|
-
};
|
|
28455
|
-
var STILL_GOOD = "The link is still good: run the same command again once that's done.";
|
|
28456
|
-
var EXAMPLE = '{ "name": "Claude Code", "command": ["claude-agent-acp"], "folders": "~/Chips/Agents/claude-code" }';
|
|
28457
|
-
function readConfig(path) {
|
|
28458
|
-
const known = knownConfig(basename4(path, ".json"));
|
|
28459
|
-
if (!existsSync8(path) && known === void 0) {
|
|
28460
|
-
throw new SetupError(
|
|
28461
|
-
`There is no config at ${path}. Write ${EXAMPLE} there, or name claude-code.json or codex.json, which need none. ${STILL_GOOD}`
|
|
28462
|
-
);
|
|
28463
|
-
}
|
|
28464
|
-
const raw = existsSync8(path) ? JSON.parse(readFileSync8(path, "utf8")) : known;
|
|
28465
|
-
const name = raw["name"];
|
|
28466
|
-
const command = raw["command"];
|
|
28467
|
-
if (typeof name !== "string" || name.trim() === "" || !Array.isArray(command) || command.length === 0) {
|
|
28468
|
-
throw new SetupError(`${path} names a kind of agent and how to run it: ${EXAMPLE}. ${STILL_GOOD}`);
|
|
28469
|
-
}
|
|
28470
|
-
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
28471
|
-
return {
|
|
28472
|
-
name,
|
|
28473
|
-
command: command.map(String),
|
|
28474
|
-
folders: foldersPathOf(typeof raw["folders"] === "string" ? raw["folders"] : `~/Chips/Agents/${slug}`),
|
|
28475
|
-
...typeof raw["folder"] === "string" ? { folder: foldersPathOf(raw["folder"]) } : {},
|
|
28476
|
-
...typeof raw["mode"] === "string" ? { mode: raw["mode"] } : {},
|
|
28477
|
-
...typeof raw["env"] === "object" && raw["env"] !== null ? { env: raw["env"] } : {}
|
|
28478
|
-
};
|
|
28479
|
-
}
|
|
28480
|
-
var runnable = (path) => {
|
|
28481
|
-
try {
|
|
28482
|
-
accessSync2(path, constants2.X_OK);
|
|
28483
|
-
return true;
|
|
28484
|
-
} catch {
|
|
28485
|
-
return false;
|
|
28486
|
-
}
|
|
28487
|
-
};
|
|
28488
|
-
function checkCommand(kind2, env2 = process.env) {
|
|
28489
|
-
const [program] = kind2.command;
|
|
28490
|
-
if (program === void 0) throw new SetupError(`${kind2.name} has no command to run. ${STILL_GOOD}`);
|
|
28491
|
-
const path = { ...env2, ...kind2.env }["PATH"] ?? "";
|
|
28492
|
-
const found = program.includes("/") ? runnable(isAbsolute3(program) ? program : resolve3(fromHome(program))) : path.split(delimiter2).some((dir) => dir !== "" && runnable(join9(dir, program)));
|
|
28493
|
-
if (!found) {
|
|
28494
|
-
throw new SetupError(
|
|
28495
|
-
`${kind2.name}'s command, ${program}, isn't on this machine's PATH: ${installWords(kind2)}. ${STILL_GOOD}`,
|
|
28496
|
-
notInstalledStop(kind2, program)
|
|
28497
|
-
);
|
|
28498
|
-
}
|
|
28499
|
-
}
|
|
28500
|
-
var MINUTE = 6e4;
|
|
28501
|
-
function within2(promise2, ms, what) {
|
|
28502
|
-
let timer;
|
|
28503
|
-
const late = new Promise((_, reject) => {
|
|
28504
|
-
timer = setTimeout(() => reject(new Error(what)), ms);
|
|
28505
|
-
});
|
|
28506
|
-
return Promise.race([promise2, late]).finally(() => clearTimeout(timer));
|
|
28507
|
-
}
|
|
28508
|
-
var wordsOf2 = (error62) => error62 instanceof Error ? error62.message : String(error62);
|
|
28509
|
-
async function checkSignIn(kind2, wire, cwd, options = {}) {
|
|
28510
|
-
let status;
|
|
28511
|
-
let heard = () => {
|
|
28512
|
-
};
|
|
28513
|
-
const said = new Promise((resolve5) => {
|
|
28514
|
-
heard = resolve5;
|
|
28515
|
-
});
|
|
28516
|
-
const client = new AcpClient(wire, {
|
|
28517
|
-
update: () => void 0,
|
|
28518
|
-
request: async (request) => {
|
|
28519
|
-
throw notOffered(request.method);
|
|
28520
|
-
},
|
|
28521
|
-
exit: () => heard(),
|
|
28522
|
-
auth: (now) => {
|
|
28523
|
-
status = now;
|
|
28524
|
-
heard();
|
|
28525
|
-
}
|
|
28526
|
-
});
|
|
28527
|
-
try {
|
|
28528
|
-
let info;
|
|
28529
|
-
try {
|
|
28530
|
-
info = await within2(client.initialize({ name: "chips-acp", version: VERSION }), MINUTE, "it didn't answer within a minute");
|
|
28531
|
-
} catch (error62) {
|
|
28532
|
-
const last = options.stderr?.().slice(-3).join(" ") ?? "";
|
|
28533
|
-
throw new SetupError(`${kind2.name} didn't start: ${wordsOf2(error62)}.${last === "" ? "" : ` It said: ${last}`} ${STILL_GOOD}`, {
|
|
28534
|
-
detail: "Its ACP adapter didn't start",
|
|
28535
|
-
says: `${kind2.name} didn't start: ${wordsOf2(error62)}.`,
|
|
28536
|
-
...last === "" ? {} : { doing: `It said: ${last}` }
|
|
28537
|
-
});
|
|
28538
|
-
}
|
|
28539
|
-
try {
|
|
28540
|
-
const { sessionId } = await within2(client.newSession(cwd), MINUTE, "it didn't answer within a minute");
|
|
28541
|
-
if (info.closeSession) await client.closeSession(sessionId).catch(() => void 0);
|
|
28542
|
-
} catch (error62) {
|
|
28543
|
-
if (isAuthRequired(error62)) throw new SetupError(`${signedOutWords(kind2, info)} ${STILL_GOOD}`, signedOutStop(kind2));
|
|
28544
|
-
throw new SetupError(`${kind2.name} couldn't open a session: ${wordsOf2(error62)}. ${STILL_GOOD}`, {
|
|
28545
|
-
detail: "It couldn't open a session",
|
|
28546
|
-
says: `${kind2.name} couldn't open a session: ${wordsOf2(error62)}.`
|
|
28547
|
-
});
|
|
28548
|
-
}
|
|
28549
|
-
if (info.reportsAuth && status === void 0) await within2(said, options.waitMs ?? 6e3, "").catch(() => void 0);
|
|
28550
|
-
if (status?.kind === "none") throw new SetupError(`${signedOutWords(kind2, info)} ${STILL_GOOD}`, signedOutStop(kind2));
|
|
28551
|
-
} finally {
|
|
28552
|
-
client.close();
|
|
28553
|
-
}
|
|
28554
|
-
}
|
|
28555
|
-
|
|
28556
|
-
// src/move.ts
|
|
28683
|
+
import { lstatSync, mkdirSync as mkdirSync5, readdirSync as readdirSync2, readFileSync as readFileSync9, renameSync as renameSync2, rmdirSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
28684
|
+
import { homedir as homedir7 } from "node:os";
|
|
28685
|
+
import { basename as basename5, dirname as dirname6, join as join11, resolve as resolve4 } from "node:path";
|
|
28557
28686
|
var there = (path) => {
|
|
28558
28687
|
try {
|
|
28559
28688
|
lstatSync(path);
|
|
@@ -28564,11 +28693,11 @@ var there = (path) => {
|
|
|
28564
28693
|
};
|
|
28565
28694
|
var isFolder = (path) => lstatSync(path).isDirectory();
|
|
28566
28695
|
var shown = (path, home) => path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
|
|
28567
|
-
function merge2(from, to, log2, home =
|
|
28696
|
+
function merge2(from, to, log2, home = homedir7(), quiet = false) {
|
|
28568
28697
|
if (!there(from)) return;
|
|
28569
28698
|
try {
|
|
28570
28699
|
if (!there(to)) {
|
|
28571
|
-
|
|
28700
|
+
mkdirSync5(dirname6(to), { recursive: true });
|
|
28572
28701
|
renameSync2(from, to);
|
|
28573
28702
|
if (!quiet) log2(`moved ${shown(from, home)} to ${shown(to, home)}`);
|
|
28574
28703
|
return;
|
|
@@ -28577,7 +28706,7 @@ function merge2(from, to, log2, home = homedir6(), quiet = false) {
|
|
|
28577
28706
|
log2(`${shown(from, home)} was left where it is: ${shown(to, home)} is there already`);
|
|
28578
28707
|
return;
|
|
28579
28708
|
}
|
|
28580
|
-
for (const entry of readdirSync2(from)) merge2(
|
|
28709
|
+
for (const entry of readdirSync2(from)) merge2(join11(from, entry), join11(to, entry), log2, home, true);
|
|
28581
28710
|
if (readdirSync2(from).length === 0) rmdirSync(from);
|
|
28582
28711
|
if (!quiet) log2(`moved what was in ${shown(from, home)} into ${shown(to, home)}`);
|
|
28583
28712
|
} catch (error62) {
|
|
@@ -28590,16 +28719,16 @@ function removeIfEmpty(path) {
|
|
|
28590
28719
|
} catch {
|
|
28591
28720
|
}
|
|
28592
28721
|
}
|
|
28593
|
-
function claudeStoreOf(folder2, env2, home =
|
|
28722
|
+
function claudeStoreOf(folder2, env2, home = homedir7()) {
|
|
28594
28723
|
const name = folder2.replace(/[^a-zA-Z0-9]/g, "-");
|
|
28595
28724
|
if (name.length > 200) return void 0;
|
|
28596
|
-
return
|
|
28725
|
+
return join11(env2["CLAUDE_CONFIG_DIR"] ? resolve4(fromHome(env2["CLAUDE_CONFIG_DIR"], home)) : join11(home, ".claude"), "projects", name);
|
|
28597
28726
|
}
|
|
28598
28727
|
function pairOf(path, places) {
|
|
28599
28728
|
const old = inside2(places.oldAgents, path);
|
|
28600
|
-
if (old !== void 0) return { old: path, now:
|
|
28729
|
+
if (old !== void 0) return { old: path, now: join11(places.agents, old) };
|
|
28601
28730
|
const now = inside2(places.agents, path);
|
|
28602
|
-
return now === void 0 ? void 0 : { old:
|
|
28731
|
+
return now === void 0 ? void 0 : { old: join11(places.oldAgents, now), now: path };
|
|
28603
28732
|
}
|
|
28604
28733
|
function writeJson(path, value) {
|
|
28605
28734
|
const next = `${path}.next`;
|
|
@@ -28615,15 +28744,15 @@ var readJson = (path) => {
|
|
|
28615
28744
|
return void 0;
|
|
28616
28745
|
}
|
|
28617
28746
|
};
|
|
28618
|
-
function moveOld(configPath2, log2, home =
|
|
28619
|
-
const places =
|
|
28620
|
-
const keptIn =
|
|
28747
|
+
function moveOld(configPath2, log2, home = homedir7(), env2 = process.env) {
|
|
28748
|
+
const places = placesOf(home);
|
|
28749
|
+
const keptIn = join11(dirname6(configPath2), basename5(configPath2, ".json"));
|
|
28621
28750
|
const name = inside2(places.settings, configPath2);
|
|
28622
28751
|
if (name !== void 0) {
|
|
28623
|
-
|
|
28624
|
-
|
|
28625
|
-
merge2(
|
|
28626
|
-
merge2(
|
|
28752
|
+
mkdirSync5(dirname6(dirname6(places.settings)), { recursive: true });
|
|
28753
|
+
mkdirSync5(places.settings, { recursive: true, mode: 448 });
|
|
28754
|
+
merge2(join11(places.oldSettings, name), configPath2, log2, home);
|
|
28755
|
+
merge2(join11(places.oldSettings, name.replace(/\.json$/, "")), keptIn, log2, home);
|
|
28627
28756
|
}
|
|
28628
28757
|
let roots;
|
|
28629
28758
|
let kindEnv;
|
|
@@ -28650,7 +28779,7 @@ function moveOld(configPath2, log2, home = homedir6(), env2 = process.env) {
|
|
|
28650
28779
|
}
|
|
28651
28780
|
if (changed) writeJson(configPath2, config2);
|
|
28652
28781
|
}
|
|
28653
|
-
const statePath2 =
|
|
28782
|
+
const statePath2 = join11(keptIn, "state.json");
|
|
28654
28783
|
const state2 = readJson(statePath2);
|
|
28655
28784
|
const agents = state2?.["agents"];
|
|
28656
28785
|
if (state2 !== void 0 && typeof agents === "object" && agents !== null) {
|
|
@@ -28670,7 +28799,7 @@ function moveOld(configPath2, log2, home = homedir6(), env2 = process.env) {
|
|
|
28670
28799
|
if (there(old) || !there(now)) continue;
|
|
28671
28800
|
const folders = [{ old, now }];
|
|
28672
28801
|
for (const entry of readdirSync2(now)) {
|
|
28673
|
-
if (isFolder(
|
|
28802
|
+
if (isFolder(join11(now, entry))) folders.push({ old: join11(old, entry), now: join11(now, entry) });
|
|
28674
28803
|
}
|
|
28675
28804
|
for (const folder2 of folders) {
|
|
28676
28805
|
const from = claudeStoreOf(folder2.old, storeEnv, home);
|
|
@@ -28685,6 +28814,7 @@ function moveOld(configPath2, log2, home = homedir6(), env2 = process.env) {
|
|
|
28685
28814
|
// src/main.ts
|
|
28686
28815
|
var link = process.env["CHIPS_JOIN_LINK"] || void 0;
|
|
28687
28816
|
var LABEL = `chat.chips.acp.${basename6(configTargetOf(words3[0]), ".json")}`;
|
|
28817
|
+
if (stopping) forgetAdapter(basename6(configTargetOf(words3[0]), ".json"));
|
|
28688
28818
|
stopIfAsked(LABEL);
|
|
28689
28819
|
var log = (line) => process.stdout.write(`${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
28690
28820
|
`);
|
|
@@ -28692,10 +28822,11 @@ if (!handsOver) moveOld(configTargetOf(words3[0]), log);
|
|
|
28692
28822
|
var configPath = configPathOf(words3[0]);
|
|
28693
28823
|
var kind;
|
|
28694
28824
|
try {
|
|
28695
|
-
kind = readConfig(configPath);
|
|
28696
|
-
|
|
28825
|
+
kind = withFetchedAdapter(readConfig(configPath));
|
|
28826
|
+
mkdirSync6(kind.folder ?? kind.folders, { recursive: true });
|
|
28697
28827
|
if (link !== void 0) {
|
|
28698
|
-
reportStep("checking", { detail: `
|
|
28828
|
+
reportStep("checking", { detail: `Looking for ${kind.name}` });
|
|
28829
|
+
kind = await readyAdapter(kind, { say: (detail) => reportStep("checking", { detail }) });
|
|
28699
28830
|
checkCommand(kind);
|
|
28700
28831
|
log(`checking that ${kind.name} starts and is signed in`);
|
|
28701
28832
|
const cwd = kind.folder ?? kind.folders;
|
|
@@ -28711,9 +28842,9 @@ try {
|
|
|
28711
28842
|
`);
|
|
28712
28843
|
process.exit(1);
|
|
28713
28844
|
}
|
|
28714
|
-
var folder =
|
|
28715
|
-
var statePath =
|
|
28716
|
-
|
|
28845
|
+
var folder = join12(dirname7(configPath), basename6(configPath, ".json"));
|
|
28846
|
+
var statePath = join12(folder, "state.json");
|
|
28847
|
+
mkdirSync6(folder, { recursive: true, mode: 448 });
|
|
28717
28848
|
var refused2 = (error62) => {
|
|
28718
28849
|
if (!(error62 instanceof JoinError)) throw error62;
|
|
28719
28850
|
process.stderr.write(`${error62.message}
|
|
@@ -28752,7 +28883,7 @@ var chips = await connect({
|
|
|
28752
28883
|
url: joined.url,
|
|
28753
28884
|
token: joined.token,
|
|
28754
28885
|
client: { name: "chips-acp", version: VERSION },
|
|
28755
|
-
store: fileStore(
|
|
28886
|
+
store: fileStore(join12(folder, "chips-state.json")),
|
|
28756
28887
|
onRestart: async () => {
|
|
28757
28888
|
log("a person asked for a restart");
|
|
28758
28889
|
await bridge?.restart();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chipschat/acp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
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": {
|