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/codex` 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 the model while it answers another, one slow conversation delays the others by at most one run budget, and one conversation the model 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 Codex 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 `codex exec` model call with the fixed prompt `Reply with the single word OK.`, no peer content, no AgentChat tools (the `agentchat` server switched off for it) and no key, read-only and ephemeral, in `$CODEX_HOME/agentchat-runtime-check`, bounded at 60 s, output discarded. A signed-out or broken Codex 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/codex",
"version": "0.6.0",
"version": "0.7.0",
"description": "The AgentChat integration for Codex — a persistent @handle other agents can DM, the hosted AgentChat tools as [mcp_servers.agentchat], the identity line in AGENTS.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 build && 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.

8 changes: 5 additions & 3 deletions src/daemon-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import { CodexRunner, runPointer } from './runner.js'
//
// The host is a compile-time fact here exactly as it is in the CLI: this file
// imports Codex's runner and Codex's home, and cannot name another coding
// agent. The run prompt is the server's wake instruction, fetched for the
// `codex` runtime (`GET /v1/texts?runtime=codex`, tool names already spelled
// `mcp__agentchat__agentchat_inbox` for `[mcp_servers.agentchat]`;
// 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 `codex` runtime (`GET /v1/texts?runtime=codex`, tool names
// already spelled `mcp__agentchat__agentchat_inbox` for `[mcp_servers.agentchat]`;
// codex-rs/core/src/tools/handlers/mcp.rs: `mcp__` prefix, `__` delimiter),
// then one pointer to the skill — the one line only this package knows — in
// the profiles whose runs can open it (`runPointer`: an answer run has no file
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,
INTEGRATION_ENV,
INTEGRATION_ENV_LEGACY,
INTEGRATION_ENV_LEGACY_REMOVAL,
Expand Down Expand Up @@ -236,6 +237,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'
39 changes: 39 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 { manualPointer, PEER_RUN_WARNING, RUN_PROFILES, type RunProfile } from '@agentchatme/agent-core'
import * as presets from '@agentchatme/agent-core/presets'
import { codexRunArgs } from '@agentchatme/agent-core/presets'
import { CodexRunner, OWN_PROFILE_LINE, OWN_PROFILE_WARNING, guardsHomeWorkdir, profileNote, profileSummary, runPointer } from '../src/runner.js'
import { headersHelperCommand, headersHelperPathFor } from '../src/headers-helper.js'
Expand Down Expand Up @@ -423,3 +424,41 @@ describe.skipIf(!ENGINE_HAS_OWN)('own: the agent itself, under the user’s own
expect(runner(OWN as 'answer', {}, fakeHome).workdir()).toBe(path.join(codexHome, 'agentchat-answer-workdir'))
})
})

/**
* The runtime check (could not process) comes from the engine's Codex preset:
* the runner here inherits it, with this integration's environment. 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 (CodexRunner.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 `codex exec` with the fixed prompt: read-only, ephemeral, the AgentChat server switched off, no headers helper and no key, in an empty folder of its own; ok when the model answers, not ok when it fails', async () => {
const url = 'https://api.agentchat.test/mcp'
const r = new CodexRunner({ codexHome, identityHome, workdir, profile: OWN, pinMcpUrl: url, env: env({ AGENTCHAT_API_KEY: OTHER_KEY }) })
const check = (r as unknown as { checkRuntime: RuntimeCheck }).checkRuntime.bind(r)
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.')
const dir = path.join(codexHome, 'agentchat-runtime-check')
// The engine's argv for it, exactly: read-only, ephemeral, the AgentChat server pinned and switched off.
expect(run.argv).toEqual((presets as unknown as { codexRuntimeCheckArgs: (dir: string, url?: string) => string[] }).codexRuntimeCheckArgs(dir, url))
expect(run.argv.slice(0, 8)).toEqual(['exec', '--json', '--skip-git-repo-check', '--ephemeral', '-C', dir, '--sandbox', 'read-only'])
expect(run.argv.slice(-5)).toEqual(['-c', `mcp_servers.agentchat.url=${JSON.stringify(url)}`, '-c', 'mcp_servers.agentchat.enabled=false', '-'])
// The run's headers helper is not pinned for it: the AgentChat server is off, and the check needs no key.
expect(run.argv.join(' ')).not.toContain('http_headers_helper')
expect(fs.realpathSync(run.cwd)).toBe(fs.realpathSync(dir))
expect(run.env.AGENTCHAT_API_KEY).toBeUndefined()
expect(run.env.CODEX_HOME).toBe(codexHome)
expect(JSON.stringify(run)).not.toContain(KEY)
expect(JSON.stringify(run)).not.toContain(OTHER_KEY)

// A provider error (some output, exit 1) is not ok.
const failing = new CodexRunner({ codexHome, identityHome, workdir, profile: OWN, pinMcpUrl: url, env: env({ FAKE_CODEX_RUN: 'fail' }) })
expect(await (failing as unknown as { checkRuntime: RuntimeCheck }).checkRuntime()).toMatchObject({ ok: false, detail: expect.stringContaining('codex 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 @@ -11,6 +11,7 @@ import { DEFAULT_RUN_PROFILE, INTEGRATION_ENV, INTEGRATION_ENV_LEGACY, INTEGRATI

/** Whether the engine this build runs on has the `own` profile (the pin moves to it at the release step). */
const ENGINE_HAS_OWN = (RUN_PROFILES as readonly string[]).includes('own')
import * as engine from '@agentchatme/agent-core'
import { VERSION } from '../src/version.js'
import { headersHelperCommand } from '../src/headers-helper.js'
import { installFakeCodex, type FakeCodex } from './helpers/fake-codex.js'
Expand Down Expand Up @@ -422,6 +423,22 @@ describe('there is no way to address another agent', () => {
expect(fs.existsSync(skill())).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 () => {
giveCodexAnIdentity()
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 () => {
giveCodexAnIdentity()
fs.writeFileSync(configToml(), '[model]\nname = "o4"\n')
Expand Down
Loading