@agentchatme/claude-code 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/daemon-main.js +50 -17
- package/dist/daemon-main.js.map +1 -1
- package/dist/index.js +81 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,12 +84,12 @@ The bare command removes what the previous release wired and the doorbell no lon
|
|
|
84
84
|
| Profile | Flags after `-p --output-format text --no-session-persistence` | Effect |
|
|
85
85
|
|---|---|---|
|
|
86
86
|
| `answer` (default) | `--permission-mode default --permission-prompts none --tools Read,Glob,Grep,WebSearch,WebFetch --allowedTools mcp__agentchat__*,Read,Glob,Grep,WebSearch,WebFetch` | read-only file tools, web search and fetch, every AgentChat tool; no edits, no shell (`--tools` removes them from the built-in set) |
|
|
87
|
-
| `work` | `--permission-mode acceptEdits --permission-prompts none --allowedTools mcp__agentchat__*,Read,Glob,Grep,WebSearch,WebFetch,Bash,Edit,Write,MultiEdit,NotebookEdit` | plus edits and shell; the run's working directory is `~/.claude/agentchat
|
|
87
|
+
| `work` | `--permission-mode acceptEdits --permission-prompts none --allowedTools mcp__agentchat__*,Read,Glob,Grep,WebSearch,WebFetch,Bash,Edit,Write,MultiEdit,NotebookEdit` | plus edits and shell; the run's working directory is `~/.claude/agentchat-workdir` — beside the identity home, never inside it (`AGENTCHAT_RUN_CWD` to point it at a workspace) |
|
|
88
88
|
| `full` | `--dangerously-skip-permissions --permission-prompts none --allowedTools mcp__agentchat__*` | Claude Code's bypass mode |
|
|
89
89
|
|
|
90
90
|
Notes. `--tools` restricts built-in tools only; other user-scope MCP servers you have configured are part of the run, as in any session. In `work`, `Bash` is pre-approved as a tool: Claude Code has no shell sandbox flag, so "inside the workspace" means the run's working directory, not a confinement. `AGENTCHAT_RUN_MAX_BUDGET_USD` adds `--max-budget-usd`. The run's environment is the service's: `CLAUDE_CONFIG_DIR` as installed, `DISABLE_AUTOUPDATER=1`, `CLAUDE_CODE_MCP_STARTUP_WAIT_MS=15000` (Claude Code 2.1.274+; bounds how long the first turn waits for the hosted server to connect — Claude Code's own wait is short), and no `CLAUDECODE` sentinel.
|
|
91
91
|
|
|
92
|
-
**The key store is denied to the run's file tools.** Every profile ends with `--disallowedTools Read(//<identity home>),Read(//<identity home>/**),Read(//<.claude.json>),Read(//<.claude.json>/**)` — the identity home (`~/.claude/agentchat`, or under `CLAUDE_CONFIG_DIR`) holds the credential and the daemon's logs, and `~/.claude.json` carries the key in the MCP entry. Deny rules win over allow rules and a `Read(path)` rule covers Read, Grep and Glob, so a run judging a peer's text cannot read the key and send it. In `work` and `full` a shell command still can — there the profile choice and the wake text are the guard. (Not rendered on Windows: the rule syntax for drive paths is undocumented.)
|
|
92
|
+
**The key store is denied to the run's file tools.** Every profile ends with `--disallowedTools Read(//<identity home>),Read(//<identity home>/**),Read(//<.claude.json>),Read(//<.claude.json>/**)` — the identity home (`~/.claude/agentchat`, or under `CLAUDE_CONFIG_DIR`) holds the credential and the daemon's logs, and `~/.claude.json` carries the key in the MCP entry. Deny rules win over allow rules and a `Read(path)` rule covers Read, Grep and Glob, so a run judging a peer's text cannot read the key and send it. In `work` and `full` a shell command still can — there the profile choice and the wake text are the guard. (Not rendered on Windows: the rule syntax for drive paths is undocumented.) The run's working directory is never inside a denied path: the default `~/.claude/agentchat-workdir` (`$CLAUDE_CONFIG_DIR/agentchat-workdir` for a relocated config) sits beside the identity home and is created owner-only on first use; if `AGENTCHAT_RUN_CWD` points inside the identity home, `doctor` and `status` say so and the daemon logs one warning line with the fix.
|
|
93
93
|
|
|
94
94
|
## Switches
|
|
95
95
|
|
|
@@ -98,7 +98,7 @@ Notes. `--tools` restricts built-in tools only; other user-scope MCP servers you
|
|
|
98
98
|
| `AGENTCHAT_RUN_PROFILE` | `answer` | what a headless run may do (table above) |
|
|
99
99
|
| `AGENTCHAT_DOORBELL` | — | `off`: the daemon stays resident but holds no socket and starts no run; tools and manual stay |
|
|
100
100
|
| `AGENTCHAT_RUN_BUDGET_MS` | `600000` | a run is killed past this and counts as failed |
|
|
101
|
-
| `AGENTCHAT_RUN_CWD` | `~/.claude/agentchat
|
|
101
|
+
| `AGENTCHAT_RUN_CWD` | `~/.claude/agentchat-workdir` | the run's working directory (never inside the identity home, which runs may not read) |
|
|
102
102
|
| `AGENTCHAT_RUN_MAX_BUDGET_USD` | — | passed as `--max-budget-usd` |
|
|
103
103
|
| `AGENTCHAT_API_KEY`, `AGENTCHAT_API_BASE` | — | override the stored identity / the server |
|
|
104
104
|
|
package/dist/daemon-main.js
CHANGED
|
@@ -133,12 +133,12 @@ var require_isexe = __commonJS({
|
|
|
133
133
|
if (typeof Promise !== "function") {
|
|
134
134
|
throw new TypeError("callback not provided");
|
|
135
135
|
}
|
|
136
|
-
return new Promise(function(
|
|
136
|
+
return new Promise(function(resolve6, reject) {
|
|
137
137
|
isexe(path10, options || {}, function(er, is) {
|
|
138
138
|
if (er) {
|
|
139
139
|
reject(er);
|
|
140
140
|
} else {
|
|
141
|
-
|
|
141
|
+
resolve6(is);
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
144
|
});
|
|
@@ -205,27 +205,27 @@ var require_which = __commonJS({
|
|
|
205
205
|
opt = {};
|
|
206
206
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
207
207
|
const found = [];
|
|
208
|
-
const step = (i) => new Promise((
|
|
208
|
+
const step = (i) => new Promise((resolve6, reject) => {
|
|
209
209
|
if (i === pathEnv.length)
|
|
210
|
-
return opt.all && found.length ?
|
|
210
|
+
return opt.all && found.length ? resolve6(found) : reject(getNotFoundError(cmd));
|
|
211
211
|
const ppRaw = pathEnv[i];
|
|
212
212
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
213
213
|
const pCmd = path10.join(pathPart, cmd);
|
|
214
214
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
215
|
-
|
|
215
|
+
resolve6(subStep(p, i, 0));
|
|
216
216
|
});
|
|
217
|
-
const subStep = (p, i, ii) => new Promise((
|
|
217
|
+
const subStep = (p, i, ii) => new Promise((resolve6, reject) => {
|
|
218
218
|
if (ii === pathExt.length)
|
|
219
|
-
return
|
|
219
|
+
return resolve6(step(i + 1));
|
|
220
220
|
const ext = pathExt[ii];
|
|
221
221
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
222
222
|
if (!er && is) {
|
|
223
223
|
if (opt.all)
|
|
224
224
|
found.push(p + ext);
|
|
225
225
|
else
|
|
226
|
-
return
|
|
226
|
+
return resolve6(p + ext);
|
|
227
227
|
}
|
|
228
|
-
return
|
|
228
|
+
return resolve6(subStep(p, i, ii + 1));
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
231
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -9788,6 +9788,13 @@ function identityHome() {
|
|
|
9788
9788
|
function identityHomeFor(configDirOverride) {
|
|
9789
9789
|
return path7.join(configDirOverride ?? path7.join(os.homedir(), ".claude"), "agentchat");
|
|
9790
9790
|
}
|
|
9791
|
+
function runWorkdirFor(configDirOverride) {
|
|
9792
|
+
return path7.join(configDirOverride ?? path7.join(os.homedir(), ".claude"), "agentchat-workdir");
|
|
9793
|
+
}
|
|
9794
|
+
function resolveRunWorkdir(configDirOverride, env = process.env) {
|
|
9795
|
+
const cwd = env["AGENTCHAT_RUN_CWD"]?.trim();
|
|
9796
|
+
return cwd !== void 0 && cwd.length > 0 ? path7.resolve(cwd) : runWorkdirFor(configDirOverride);
|
|
9797
|
+
}
|
|
9791
9798
|
function claudeUserStatePathFor(configDirOverride) {
|
|
9792
9799
|
return configDirOverride !== void 0 ? path7.join(configDirOverride, ".claude.json") : path7.join(os.homedir(), ".claude.json");
|
|
9793
9800
|
}
|
|
@@ -9801,6 +9808,11 @@ function skillPath() {
|
|
|
9801
9808
|
return path7.join(skillDir(), MANUAL_FILENAME);
|
|
9802
9809
|
}
|
|
9803
9810
|
var MCP_SERVER_NAME = "agentchat";
|
|
9811
|
+
function invocation() {
|
|
9812
|
+
const override = process.env["AGENTCHAT_CLI_NAME"]?.trim();
|
|
9813
|
+
if (override !== void 0 && override.length > 0) return override;
|
|
9814
|
+
return "npx -y @agentchatme/claude-code";
|
|
9815
|
+
}
|
|
9804
9816
|
|
|
9805
9817
|
// src/runner.ts
|
|
9806
9818
|
import * as fs5 from "fs";
|
|
@@ -9946,6 +9958,17 @@ function inspectClaudeRuntime(configDirOverride, command = "claude") {
|
|
|
9946
9958
|
detail: `${rendered || "unrecognized version"}; AgentChat requires Claude Code >= ${MIN_CLAUDE_CODE_VERSION} (for --permission-prompts none and CLAUDE_CODE_MCP_STARTUP_WAIT_MS)`
|
|
9947
9959
|
};
|
|
9948
9960
|
}
|
|
9961
|
+
function denyReadPathsFor(configDirOverride) {
|
|
9962
|
+
return [identityHomeFor(configDirOverride), claudeUserStatePathFor(configDirOverride)];
|
|
9963
|
+
}
|
|
9964
|
+
function deniedAncestorOf(dir, denied) {
|
|
9965
|
+
const target = path8.resolve(dir);
|
|
9966
|
+
for (const raw of denied) {
|
|
9967
|
+
const root = path8.resolve(raw);
|
|
9968
|
+
if (target === root || target.startsWith(root.endsWith(path8.sep) ? root : root + path8.sep)) return root;
|
|
9969
|
+
}
|
|
9970
|
+
return null;
|
|
9971
|
+
}
|
|
9949
9972
|
var ClaudeRunner = class {
|
|
9950
9973
|
constructor(options) {
|
|
9951
9974
|
this.options = options;
|
|
@@ -9954,23 +9977,33 @@ var ClaudeRunner = class {
|
|
|
9954
9977
|
options;
|
|
9955
9978
|
name = "claude";
|
|
9956
9979
|
command;
|
|
9980
|
+
/** The workdir warning is one line per daemon, not one per preflight (preflight repeats every few minutes). */
|
|
9981
|
+
warnedWorkdir = false;
|
|
9982
|
+
/** The denied path the configured workdir sits in, or null when the run can read its own cwd. */
|
|
9983
|
+
workdirDeniedBy() {
|
|
9984
|
+
return deniedAncestorOf(this.options.workdir, denyReadPathsFor(this.options.configDir));
|
|
9985
|
+
}
|
|
9957
9986
|
async preflight() {
|
|
9958
9987
|
const runtime = inspectClaudeRuntime(this.options.configDir, this.command);
|
|
9959
9988
|
if (!runtime.ok) return { ok: false, detail: runtime.detail };
|
|
9960
9989
|
if (!claudeIsLoggedIn(this.options.configDir, this.command)) {
|
|
9961
9990
|
return { ok: false, detail: "claude is not signed in (run `claude` once and sign in)" };
|
|
9962
9991
|
}
|
|
9963
|
-
|
|
9992
|
+
const denied = this.workdirDeniedBy();
|
|
9993
|
+
if (denied !== null && !this.warnedWorkdir) {
|
|
9994
|
+
this.warnedWorkdir = true;
|
|
9995
|
+
log.warn(
|
|
9996
|
+
`the run workdir ${this.options.workdir} is inside ${denied}, which every run's file tools are denied: runs cannot read their own working directory. Point AGENTCHAT_RUN_CWD outside it, or unset it for the default ${runWorkdirFor(this.options.configDir)}, then re-run \`${invocation()} daemon install\``
|
|
9997
|
+
);
|
|
9998
|
+
}
|
|
9999
|
+
fs5.mkdirSync(this.options.workdir, { recursive: true, mode: 448 });
|
|
9964
10000
|
return { ok: true };
|
|
9965
10001
|
}
|
|
9966
10002
|
/** The exact argv one run uses — exported for tests to pin per profile. */
|
|
9967
10003
|
args() {
|
|
9968
10004
|
return claudeRunArgs(this.options.profile, {
|
|
9969
10005
|
maxBudgetUsd: (this.options.env ?? process.env)["AGENTCHAT_RUN_MAX_BUDGET_USD"],
|
|
9970
|
-
|
|
9971
|
-
// ~/.claude.json, where the user-scope MCP entry carries the key. A run
|
|
9972
|
-
// judging peer text must not be able to read either and send it.
|
|
9973
|
-
denyReadPaths: [identityHomeFor(this.options.configDir), claudeUserStatePathFor(this.options.configDir)]
|
|
10006
|
+
denyReadPaths: denyReadPathsFor(this.options.configDir)
|
|
9974
10007
|
});
|
|
9975
10008
|
}
|
|
9976
10009
|
async start(request) {
|
|
@@ -10006,14 +10039,14 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
10006
10039
|
return 1;
|
|
10007
10040
|
}
|
|
10008
10041
|
const home = values.home !== void 0 ? path9.resolve(values.home) : identityHome();
|
|
10009
|
-
const
|
|
10010
|
-
const workdir = values.workdir !== void 0 ? path9.resolve(values.workdir) :
|
|
10042
|
+
const configDir = claudeConfigOverride();
|
|
10043
|
+
const workdir = values.workdir !== void 0 ? path9.resolve(values.workdir) : resolveRunWorkdir(configDir);
|
|
10011
10044
|
const profile = resolveRunProfile();
|
|
10012
10045
|
return await runDoorbell({
|
|
10013
10046
|
home,
|
|
10014
10047
|
workdir,
|
|
10015
10048
|
profile,
|
|
10016
|
-
runner: new ClaudeRunner({ configDir
|
|
10049
|
+
runner: new ClaudeRunner({ configDir, workdir, profile }),
|
|
10017
10050
|
prompts: buildDoorbellPrompts({
|
|
10018
10051
|
toolName: mcpToolNamer(MCP_SERVER_NAME),
|
|
10019
10052
|
manualPointer: manualPointer(`at ${skillPath()}`)
|