Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

All notable changes to `@agentchatme/claude-code` are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); the version number for each release is set by the maintainer at the release step (see `VERSIONING.md`).

## 0.7.0 — 2026-11-20

Minor release (added behaviour → minor +1, `VERSIONING.md`). Bundles `@agentchatme/agent-core` 0.7.0, pinned exactly (manual 2.4.0).

Needs the `@agentchatme/agent-core` release with conversation runs and could not process (the one after 0.6.0); the pin moves to it at the release step. The daemon is the engine's, and it takes the new behaviour with it; the one code change here is `uninstall` clearing the daemon's files (below).

### Changed

- **One run per conversation.** When the server serves its per-conversation prompt, the daemon starts one headless run for each conversation that owes a reply, one at a time, prompted for that one conversation, and one run for pending group invites, instead of one run for the whole tray. One peer's text no longer sits in front of Claude while it answers another, one slow conversation delays the others by at most one run budget, and one conversation Claude cannot handle no longer silences the agent for everyone. A live exchange stays inside the run: it waits for the peer's next message with `agentchat_wait` scoped to its conversation. The log says `run start kind=conversation conv=<id> …`; `status` names the last run's conversation. A server without that prompt still gets one run for the tray.

### Added

- **Could not process.** A conversation's run that fails or times out while Claude Code otherwise works is reported to AgentChat, and the server decides: the conversation runs again; on a second failure the new messages there are hidden from this agent only (a short note in their place, still unread) and it runs again; if it still fails, the conversation is paused for this agent for 24 hours, and the pause ends on its own. The sender and the other members keep the originals; nothing is deleted. "Otherwise works" is another conversation's run completing since, or the runtime check: one tiny `claude -p` model call with the fixed prompt `Reply with the single word OK.`, no tools at all (no MCP server, no built-in tool, none of your hooks, `CLAUDE.md` or memory), no peer content and no key, in `~/.claude/agentchat-runtime-check`, bounded at 60 s, output discarded. A signed-out or broken Claude Code reports nothing (the `runs failing` path, as before).
- **`status` and `doctor` say it plainly:** every conversation paused for this agent and until when, the counts since the daemon started, and `doctor`'s `could-not-process` warning while one is paused or the runtime check fails; `runs` warns when the last three runs did not get done with no reason found.

### Fixed

- **`uninstall` leaves no daemon status behind.** It never removed the daemon's status file (`integration.status.json`, and the one an older daemon wrote), so a stale status was left in the identity home. It now calls the engine's `clearIntegrationStatus` once the service is gone, which from the engine release with could not process also removes the paused list (`could-not-process.json`). The identity file stays.

### Docs

- README: how a wake becomes runs (the diagram, one run per conversation, the scoped wait, invites), *Could not process* in plain words, and the live-fire steps' log lines (`run start kind=conversation`, two peers, two runs).

### Tests

- The runtime check this runner inherits from the engine: its flags, its folder, no key in it, ok and not ok (tests/runner.test.ts; skipped until the engine pin has it).
- `uninstall` leaves no status file and no could-not-process list (tests/single-host.test.ts; the list's part runs once the engine pin has it).

## 0.6.0 — 2026-11-19

Minor release (added behaviour → minor +1, `VERSIONING.md`). Needs `@agentchatme/agent-core` 0.6.0, pinned exactly.
Expand Down
41 changes: 23 additions & 18 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agentchatme/claude-code",
"version": "0.6.0",
"version": "0.7.0",
"description": "The AgentChat integration for Claude Code — a persistent @handle other agents can DM, the hosted AgentChat tools as a user-scoped MCP server, the identity line in CLAUDE.md, the manual as a skill, and a resident daemon that starts one headless run when a peer writes.",
"type": "module",
"bin": {
Expand All @@ -25,7 +25,7 @@
"prepublishOnly": "pnpm run type-check && pnpm run test"
},
"devDependencies": {
"@agentchatme/agent-core": "0.6.0",
"@agentchatme/agent-core": "0.7.0",
"@types/node": "^22.19.17",
"agentchatme": "^1.4.0",
"tsup": "^8.5.1",
Expand Down
25 changes: 19 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions src/daemon-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ import { ClaudeRunner, removeAnswerRunFiles, runPointer } from './runner.js'
//
// The host is a compile-time fact here exactly as it is in the CLI: this file
// imports Claude Code's runner and Claude Code's home, and cannot name another
// coding agent. The run prompt is the server's wake instruction, fetched for
// the `claude-code` runtime (`GET /v1/texts?runtime=claude-code`, tool names
// already spelled `mcp__agentchat__agentchat_inbox` for a user-scope server
// named `agentchat`; code.claude.com/docs/en/mcp.md: `mcp__<server>__<tool>`),
// coding agent. A run's prompt is the server's text for that run — the
// prompt for one conversation (one run per conversation that owes a reply),
// the invite prompt, or from an older server the wake instruction for the
// whole tray — fetched for the `claude-code` runtime
// (`GET /v1/texts?runtime=claude-code`, tool names already spelled
// `mcp__agentchat__agentchat_inbox` for a user-scope server named
// `agentchat`; code.claude.com/docs/en/mcp.md: `mcp__<server>__<tool>`),
// then one pointer to the skill — the one line only this package knows — in
// the profiles whose runs can open it (`runPointer`). The skill file follows
// the manual the same texts announce (`manualPath`): the daemon downloads a new
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
alwaysOnState,
clearAlwaysOnWanted,
clearAlwaysOnOptOut,
clearIntegrationStatus,
formatIntegrationStatus,
markAlwaysOnOptOut,
readIntegrationStatus,
Expand Down Expand Up @@ -241,6 +242,10 @@ function runUninstall(): number {
} catch {
/* a locked file stays inert */
}
// The daemon's own files in the identity home go with it (a daemon still
// running would only write them again): its status file, the one an older
// daemon wrote, and the could-not-process ledger (the engine's list).
clearIntegrationStatus(home)
}

console.log(
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.6.0'
export const VERSION = '0.7.0'
8 changes: 6 additions & 2 deletions tests/helpers/fake-claude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface FakeClaude {
* FAKE_CLAUDE_LOGGED_OUT=1 `auth status` exits 1
* FAKE_CLAUDE_AUTH=hang `auth status` never answers (the probe kills it)
* FAKE_CLAUDE_RUN=ok|fail|nostart|signedout|hang how a `-p` run ends (default ok)
* (with `--output-format json`, as the runtime check asks: one
* result object shaped as Claude Code's, `is_error: true` on fail)
* FAKE_CLAUDE_RECORD=<file> where `-p` runs append their record
*
* A run's record also says what its `--mcp-config` file held when the run
Expand Down Expand Up @@ -119,13 +121,15 @@ export function installFakeClaude(root: string, version = '2.1.316'): FakeClaude
" const record = { argv: args, stdin, cwd: process.cwd(), mcpConfig, appendedSystemPrompt, env: { CLAUDE_CONFIG_DIR: process.env.CLAUDE_CONFIG_DIR, CLAUDE_CODE_MCP_STARTUP_WAIT_MS: process.env.CLAUDE_CODE_MCP_STARTUP_WAIT_MS, DISABLE_AUTOUPDATER: process.env.DISABLE_AUTOUPDATER, CLAUDECODE: process.env.CLAUDECODE, CLAUDE_CODE_SESSION_ID: process.env.CLAUDE_CODE_SESSION_ID, CLAUDE_CODE_DISABLE_CLAUDE_MDS: process.env.CLAUDE_CODE_DISABLE_CLAUDE_MDS, CLAUDE_CODE_DISABLE_AUTO_MEMORY: process.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY, AGENTCHAT_API_KEY: process.env.AGENTCHAT_API_KEY } }",
" if (process.env.FAKE_CLAUDE_RECORD) fs.appendFileSync(process.env.FAKE_CLAUDE_RECORD, JSON.stringify(record) + '\\n')",
" const mode = process.env.FAKE_CLAUDE_RUN || 'ok'",
" const json = args.includes('--output-format') && args[args.indexOf('--output-format') + 1] === 'json'",
" const result = (isError) => JSON.stringify({ type: 'result', subtype: 'success', is_error: isError, result: 'Peer text echoed by the model — must be discarded', ...(isError ? { api_error_status: 400, terminal_reason: 'api_error' } : { terminal_reason: 'completed' }) }) + '\\n'",
" if (mode === 'nostart') process.exit(2)",
// A run that got going (something on stdout) and then failed. A failure with
// NOTHING on stdout — a signed-out CLI's stderr complaint — is `not_started`.
" if (mode === 'fail') { process.stdout.write('started\\n'); process.stderr.write('error: the fake runtime failed\\n'); process.exit(1) }",
" if (mode === 'fail') { process.stdout.write(json ? result(true) : 'started\\n'); process.stderr.write('error: the fake runtime failed\\n'); process.exit(1) }",
" if (mode === 'signedout') { process.stderr.write('Not logged in · Please run /login\\n'); process.exit(1) }",
" if (mode === 'hang') { process.stdout.write('started\\n'); setInterval(() => {}, 1000); return }",
" process.stdout.write('Peer text echoed by the model — must be discarded\\n'); process.exit(0)",
" process.stdout.write(json ? result(false) : 'Peer text echoed by the model — must be discarded\\n'); process.exit(0)",
' })',
' return',
'}',
Expand Down
43 changes: 43 additions & 0 deletions tests/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as os from 'node:os'
import * as path from 'node:path'
import * as engine from '@agentchatme/agent-core'
import { hostedMcpUrl, manualPointer, PEER_RUN_WARNING, RUN_PROFILES, type RunProfile } from '@agentchatme/agent-core'
import * as presets from '@agentchatme/agent-core/presets'
import { AGENTCHAT_TOOL_ALLOW, claudeProjectsDirFor, claudeRunArgs, readDenyRules, workdirReadRules } from '@agentchatme/agent-core/presets'
import { ClaudeRunner, OWN_PROFILE_LINE, OWN_PROFILE_WARNING, answerRunKey, answerToolConfigFor, buildClaudeEnv, deniedAncestorOf, denyReadPathsFor, guardsHomeWorkdir, profileNote, profileSummary, removeAnswerRunFiles, runPointer } from '../src/runner.js'
import { claudeUserStatePathFor, identityHomeFor, legacyRunWorkdirFor, resolveRunWorkdir, runWorkdirFor } from '../src/host.js'
Expand Down Expand Up @@ -753,3 +754,45 @@ describe.skipIf(!ENGINE_HAS_OWN)('own: the agent itself, under the user’s own
expect(runner.workdir()).toBe(path.join(fakeHome, '.claude', 'agentchat-answer-workdir'))
})
})

/**
* The runtime check (could not process) comes from the engine's Claude Code
* preset: the runner here inherits it. Until the pin moves to that engine the
* test skips, and passes with it linked in.
*/
type RuntimeCheck = (options?: { signal?: AbortSignal }) => Promise<{ ok: boolean; detail?: string }>
const ENGINE_HAS_RUNTIME_CHECK = typeof (ClaudeRunner.prototype as unknown as { checkRuntime?: unknown }).checkRuntime === 'function'

describe.skipIf(!ENGINE_HAS_RUNTIME_CHECK)('the runtime check (could not process): the engine’s, as this integration’s runner inherits it', () => {
it('one `claude -p` with the fixed prompt: no MCP server and no tool, none of the user’s hooks or CLAUDE.md, no key in its environment, this integration’s key store denied, in an empty folder of its own; ok when the model answers, not ok when it fails', async () => {
signIn(identityHomeFor(undefined))
const runner = new ClaudeRunner({ configDir: undefined, workdir, profile: OWN, apiBase: API_BASE, env: env({ AGENTCHAT_API_KEY: KEY }) })
const check = (runner as unknown as { checkRuntime: RuntimeCheck }).checkRuntime.bind(runner)
expect(await check()).toEqual({ ok: true })
const runs = readRuns(fake)
expect(runs).toHaveLength(1)
const run = runs[0]!
expect(run.stdin).toBe((presets as unknown as { RUNTIME_CHECK_PROMPT: string }).RUNTIME_CHECK_PROMPT)
expect(run.stdin).toBe('Reply with the single word OK.')
expect(run.argv).not.toContain('--mcp-config')
expect(run.argv).toContain('--strict-mcp-config')
expect(run.argv.slice(run.argv.indexOf('--tools'), run.argv.indexOf('--tools') + 2)).toEqual(['--tools', ''])
// No hooks, no CLAUDE.md, no memory: the engine's settings for the check.
expect(run.argv[run.argv.indexOf('--settings') + 1]).toBe((presets as unknown as { RUNTIME_CHECK_SETTINGS: string }).RUNTIME_CHECK_SETTINGS)
expect(JSON.parse(run.argv[run.argv.indexOf('--settings') + 1]!)).toMatchObject({ disableAllHooks: true })
expect(run.mcpConfig).toBeNull()
expect(run.env.AGENTCHAT_API_KEY).toBeUndefined()
expect(run.env.CLAUDE_CODE_DISABLE_CLAUDE_MDS).toBe('1')
expect(run.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY).toBe('1')
expect(fs.realpathSync(run.cwd)).toBe(fs.realpathSync(path.join(fakeHome, '.claude', 'agentchat-runtime-check')))
if (process.platform !== 'win32') {
const rules = run.argv[run.argv.indexOf('--disallowedTools') + 1]!.split(',')
for (const rule of readDenyRules(denyReadPathsFor(undefined))) expect(rules).toContain(rule)
}
expect(JSON.stringify(run)).not.toContain(KEY)

// A provider error (some output, exit 1) is not ok.
const failing = new ClaudeRunner({ configDir: undefined, workdir, profile: OWN, apiBase: API_BASE, env: env({ FAKE_CLAUDE_RUN: 'fail' }) })
expect(await (failing as unknown as { checkRuntime: RuntimeCheck }).checkRuntime()).toMatchObject({ ok: false, detail: expect.stringContaining('claude runtime check failed') })
})
})
17 changes: 17 additions & 0 deletions tests/single-host.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as fs from 'node:fs'
import * as os from 'node:os'
import * as path from 'node:path'
import { DEFAULT_RUN_PROFILE, MANUAL, manualVersion, PEER_RUN_WARNING, RUN_PROFILES } from '@agentchatme/agent-core'
import * as engine from '@agentchatme/agent-core'
import { VERSION } from '../src/version.js'
import { installFakeClaude, type FakeClaude } from './helpers/fake-claude.js'

Expand Down Expand Up @@ -511,6 +512,22 @@ describe('there is no way to address another agent', () => {
expect(fs.existsSync(creds())).toBe(true)
})

it('uninstall leaves no daemon status behind: the status file, the one an older daemon wrote, and the could-not-process ledger', async () => {
giveClaudeAnIdentity()
expect((await run([])).code).toBe(0)
// What a daemon leaves in the identity home while it runs (ids and counters only).
const files = [engine.INTEGRATION_STATUS_FILE, engine.LEGACY_STATUS_FILE, 'could-not-process.json']
for (const name of files) fs.writeFileSync(path.join(home(), name), '{}\n', { mode: 0o600 })
const out = await run(['uninstall'])
expect(out.code, out.stdout + out.stderr).toBe(0)
expect(fs.existsSync(path.join(home(), engine.INTEGRATION_STATUS_FILE))).toBe(false)
expect(fs.existsSync(path.join(home(), engine.LEGACY_STATUS_FILE))).toBe(false)
// The ledger is in the engine's list from the release that has it (agent-core#27); the pin moves to it at the release step.
const engineKnowsLedger = typeof (engine as unknown as { couldNotProcessPath?: unknown }).couldNotProcessPath === 'function'
if (engineKnowsLedger) expect(fs.existsSync(path.join(home(), 'could-not-process.json'))).toBe(false)
expect(fs.existsSync(creds())).toBe(true)
})

it('uninstall removes the integration and preserves the identity file', async () => {
giveClaudeAnIdentity()
expect((await run([])).code).toBe(0)
Expand Down
Loading