iai-personal-memory-engine icon indicating copy to clipboard operation
iai-personal-memory-engine copied to clipboard

[bug] Cowork integration registers the plugin but Cowork never loads it

Open mbusch-regis opened this issue 3 months ago • 3 comments

Summary

iai-mcp cowork install reports ACTIVE, but Cowork never loads the plugin, so none of the four hooks ever execute in a Cowork session.

Environment

  • iai-mcp version: 3.0.8 (from iai-mcp daemon status; see the note at the end about --version)
  • macOS version: 26.6.2, arm64
  • Python version: 3.13.12
  • Node version: v26.7.0
  • MCP host: Claude Desktop, Cowork with local execution enabled. Desktop 1.40609.1.

Installed via the curl bootstrap on 2026-08-28. Daemon healthy, store at the default ~/.iai-mcp, IAI_MCP_STORE unset.

Steps to reproduce

  1. iai-mcp cowork install. It reports the plugin materialized and the Cowork home wired.
  2. Fully quit and relaunch Claude Desktop, per the instructions the command prints.
  3. Start a new Cowork session with local execution enabled, and send it a prompt.
  4. ls ~/.iai-mcp/logs/ ~/.iai-mcp/.deferred-captures/

I also ran cowork uninstall then cowork install and repeated the cycle, several times across an evening. cowork install takes no flags, so there's no option to leave off.

Expected behaviour

SessionStart fires iai-mcp-session-recall.sh, which writes ~/.iai-mcp/logs/recall-<UTC-date>.log. The first prompt fires iai-mcp-turn-capture.sh, which creates ~/.iai-mcp/.deferred-captures/ and ~/.iai-mcp/.capture-state/ and appends to turn-capture-<UTC-date>.log.

Actual behaviour

None of it. No recall-*.log, no capture-*.log, no turn-capture-*.log from any session, and neither .deferred-captures/ nor .capture-state/ exists.

That absence is stronger evidence than it looks, because all four scripts log unconditionally on every path they can take. iai-mcp-session-recall.sh logs cache-hit, cache-miss absent, and skipped: iai-mcp CLI not found. iai-mcp-turn-capture.sh ends with echo "$ts session=$session_id rc=$rc" >> "$log" after its guard clauses. A hook that fires and fails still leaves a line. No log file at all means the script never started.

Meanwhile cowork status reports success:

$ iai-mcp cowork status
plugin marketplace:   /Users/mbusch/.iai-mcp/claude-plugin  PRESENT
Cowork home:          .../876ef341-.../74923e61-...  WIRED
Claude Desktop MCP:   .../claude_desktop_config.json  WIRED

status: ACTIVE — plugin staged and wired into Cowork

It reports ACTIVE because it reads back the file the installer itself wrote. It can't report anything else.

Doctor output

$ iai-mcp doctor
iai doctor — daemon health check

  [PASS] (a) daemon process alive                 PID 81999 (iai_mcp.daemon)
  [PASS] (b) socket file fresh                    /Users/mbusch/.iai-mcp/.daemon.sock connected in 0 ms
  [PASS] (c) lock file healthy                    /Users/mbusch/.iai-mcp/hippo/.lock acquirable (store idle)
  [PASS] (d) no orphan iai_mcp.core procs         0 found
  [PASS] (e) daemon state file valid              fsm_state=WAKE
  [PASS] (f) hippo storage readable               Hippo storage readable via the running daemon
  [PASS] (g) no dup binders                       1 binder(s)
  [PASS] (h) crypto key file state                crypto key file present at /Users/mbusch/.iai-mcp/.crypto.key (mode 0o600, valid)
  [PASS] (i) hippo db size                        3.0 MB — healthy
  [PASS] (j) lifecycle current state              WAKE since 1 h (shadow_run=false)
  [PASS] (k) lifecycle history 24h                6 transitions (DROWSY=2, HIBERNATION=1, SLEEP=1, WAKE=2)
  [PASS] (l) sleep cycle quarantine               no quarantine active
  [PASS] (m) heartbeat scanner                    n=2 fresh, 4 stale, 0 orphan
  [PASS] (n) HID idle source                      HIDIdleTime: 0s, pmset: clean, available: HIDIdleTime,pmset
  [PASS] (o) Claude subscription credentials      valid pro subscription with inference scope
  [PASS] (p) anthropic SDK absent                 ImportError as expected (subscription-only path)
  [PASS] (q) iai CLI reachable                    /Users/mbusch/.local/bin/iai -> iai 3.0.8
  [PASS] (r) hippo hnsw index                     0.3 MB
  [PASS] (s) hippo schema version                 schema_version=1
  [PASS] (t) hippo_compacted freshness            last hippo_compacted event 17.3h ago
  [WARN] (u) recall centrality regression         no recall_timing events in last 24h (daemon idle or sampling missed)
  [PASS] (v) configured embedder                  encode ok, backend=rust, 384-dim, model=bge-small-en-v1.5
  [PASS] (dd) exact-index coercions               no non-finite coercions recorded
  [WARN] (ii) store embed identity                store unstamped — protection begins at the first stamp
  [PASS] (w) no permanent-failed captures         No permanent-failed capture files
  [PASS] (x) no collapsed-timestamp groups        no collapsed timestamp groups found
  [PASS] (aa) capture-state hygiene               no stale files (4 live)
  [PASS] (ee) deferred-capture backlog at rest    no undrained capture events at rest
  [PASS] (y) RSS 24h plateau                      +1 MiB over 23.9h (293 -> 293 MiB, median-of-thirds, n=119)
  [FAIL] (bb) nightly insight mint                3 consecutive nights without a minted insight
  [WARN] (cc) background liveness                 possibly-starved input: CLUSTER_REPLAY, COMMUNITY_NAMING, HIPPO_CLEANUP, RECONSOLIDATION, SCHEMA_MINE, identity_audit; unknown effect: CLUSTER_SUMMARY, CRISIS_RECLUSTER, CURIOSITY_MINE, DMN_REFLECTION, DREAM_DECAY, EMBEDDING_INTEGRITY, ENTITY_LINK, ERASURE_AGENT, KNOB_TUNE, OPTIMIZE_HIPPO, RECALL_INDEX_REBUILD, USER_MODEL_UPDATE
  [PASS] (z) AVX2 CPU support                     AVX2 available (or N/A on this architecture)
  [PASS] (+) update available                     source checkout — updates via git, not pip

1/33 FAIL. Run with --apply to attempt recovery. Exit 1.

Everything about the store, daemon, crypto, socket, and embedder passes. The one FAIL and two of the three WARNs look like downstream effects of the capture bug rather than separate problems: (bb) can't mint an insight with no episodes to mint from, (u) sees no recall timing because no recall hook has ever run, and (cc) reports starved background inputs because nothing is feeding the store. (aa) reporting 4 live capture-state files is residue from my manual hook invocation, which is the only thing that ever wrote there.

Daemon status

$ iai-mcp daemon status
ok: True
state: WAKE
uptime_sec: 6241.937477
version: 3.0.8
fsm_state: WAKE
last_tick_at: 2026-09-02T04:53:48.239586+00:00
quiet_window: None
quiet_window_source: None
pending_digest: {'rem_cycles_completed': 4, 'episodes_processed': 0, 'schemas_induced_tier0': 0, 'claude_call_used': False}
daemon_started_at: 2026-09-02T03:09:46.572687+00:00
scheduler_paused: False
ann_pool_health: {'reuse_collisions': 0, 'fence_reopens': 0, 'writer_fallbacks': 0}
wake_spool_sweep: {'at': '2026-09-02T04:20:56.011005+00:00', 'status': 'ok', 'files_drained': 0, 'events_inserted': 0}
embed_identity: {'runtime': 'BAAI/bge-small-en-v1.5@pinned|pool=cls|dim=384', 'stored': None, 'match': True}

episodes_processed: 0 after four completed REM cycles is the same story from the daemon's side: it's running its full schedule against a store nothing has ever written a conversational turn into.

Relevant logs

The two files the template asks for don't exist on my machine, and that's the finding rather than an oversight. ~/.iai-mcp/logs/ contains only launchd-stdout.log, launchd-stderr.log, and lifecycle-events-<date>.jsonl. There's no daemon-<date>.log and no capture-<date>.log.

The only hook log I have came from invoking the script by hand:

$ cat ~/.iai-mcp/logs/turn-capture-2026-09-02.log
2026-09-02T04:20:15Z session=manual-test rc=0

Full listing:

$ ls -la ~/.iai-mcp/logs/
total 192
drwxr-xr-x  11 mbusch  staff    352 Sep  1 22:20 .
drwxr-xr-x  30 mbusch  staff    960 Sep  1 22:53 ..
-rw-r--r--   1 mbusch  staff   1911 Sep  1 21:14 launchd-stderr.log
-rw-r--r--   1 mbusch  staff      0 Aug 27 20:43 launchd-stdout.log
-rw-------   1 mbusch  staff  18775 Aug 28 17:15 lifecycle-events-2026-08-28.jsonl
-rw-------   1 mbusch  staff  17750 Aug 29 17:57 lifecycle-events-2026-08-29.jsonl
-rw-------   1 mbusch  staff  16817 Aug 30 17:41 lifecycle-events-2026-08-30.jsonl
-rw-------   1 mbusch  staff   2028 Aug 31 13:12 lifecycle-events-2026-08-31.jsonl
-rw-------   1 mbusch  staff  16753 Sep  1 17:55 lifecycle-events-2026-09-01.jsonl
-rw-------   1 mbusch  staff    947 Sep  1 22:09 lifecycle-events-2026-09-02.jsonl
-rw-------   1 mbusch  staff     46 Sep  1 22:20 turn-capture-2026-09-02.log

That 46-byte file is the manual invocation and nothing else. 2026-09-02T04:20:15Z session=manual-test rc=0 plus a newline is exactly 46 bytes, so no session ever appended to it.

Additional context

The scripts work when something calls them

$ echo '{"session_id":"manual-test","transcript_path":"/tmp/nonexistent.jsonl","prompt_id":"p1","prompt":"manual hook invocation test with enough characters"}' \
  | bash ~/.iai-mcp/claude-plugin/iai-mcp/hooks/iai-mcp-turn-capture.sh

$ ls ~/.iai-mcp/.deferred-captures/
manual-test.live.jsonl

rc=0, spool created, and the line came out AES-encrypted rather than falling back to plaintext, so the key file resolves and the whole write path is healthy. Feed the script the stdin shape Claude Code sends and it does its job. Nothing is calling it.

Suspected cause: Cowork keeps two registries and the installer writes one

_patch_cowork_settings() adds the marketplace to extraKnownMarketplaces and sets the enabledPlugins flag in cowork_settings.json. Mine looks correct:

{
  "extraKnownMarketplaces": {
    "knowledge-work-plugins": {
      "source": { "source": "github", "repo": "anthropics/knowledge-work-plugins" }
    },
    "iai-mcp-local": {
      "source": { "source": "directory", "path": "/Users/mbusch/.iai-mcp/claude-plugin" }
    }
  },
  "enabledPlugins": { "iai-mcp@iai-mcp-local": true }
}

But the Cowork home also has cowork_plugins/known_marketplaces.json, carrying two fields the installer never writes:

{
  "knowledge-work-plugins": {
    "source": { "source": "github", "repo": "anthropics/knowledge-work-plugins" },
    "installLocation": ".../cowork_plugins/marketplaces/knowledge-work-plugins",
    "lastUpdated": "2026-03-05T22:22:03.202Z"
  }
}

installLocation points into cowork_plugins/marketplaces/, where the GitHub-sourced marketplace sits as a real checkout. Mine was declared in settings and never installed anywhere. The registration says "this marketplace exists," not "this plugin is here, load it."

I closed that gap by hand and it still didn't work

Copied ~/.iai-mcp/claude-plugin/. into cowork_plugins/marketplaces/iai-mcp-local/, producing the same layout as the working marketplace: .claude-plugin/marketplace.json at the root, iai-mcp/.claude-plugin/plugin.json, and iai-mcp/hooks/ with the four scripts and hooks.json. Added an iai-mcp-local entry to known_marketplaces.json with a directory source, an installLocation pointing at the copy, and a lastUpdated stamp.

Quit Claude, relaunched, confirmed the entry survived, started a new local session, and verified it ran locally by the new local_<uuid> directory appearing under local-agent-mode-sessions/.

No hook execution.

One note on machine state, since cowork uninstall doesn't undo either edit. It unwires cowork_settings.json and deletes ~/.iai-mcp/claude-plugin, leaving cowork_plugins/marketplaces/ and known_marketplaces.json untouched. So my final uninstall, reinstall, restart, new-session cycle ran with the plugin staged by the installer, wired in settings, and materialized in Cowork's own marketplace directory and listed in its own registry. A superset of a clean install, and it produced no hook logs either.

The question

With the plugin sitting where a working marketplace sits, registered in both files with matching shape, in a confirmed-local session, the hooks still don't run. So either directory-source marketplaces aren't loaded by this Cowork build, or plugin hooks aren't run in Cowork sessions at all.

If it's the first, cowork install needs to materialize into cowork_plugins/marketplaces/ and write known_marketplaces.json, and it'd want to survive whatever the app does to those files on launch. If it's the second, the integration can't work from this side and the README shouldn't promise it.

Either way, cowork status should verify something Cowork controls rather than reading back its own edit. Checking for a materialized plugin directory, or for a hook log written this session, would have saved me the evening.

Minor, unrelated

The issue template asks for iai-mcp --version, but that flag doesn't exist. iai-mcp -h shows only [-h], and running it prints a usage error. iai --version works on the user-facing CLI. The version above came from daemon status instead.

mbusch-regis avatar Sep 02 '26 04:09 mbusch-regis

Following up with a root cause. I was wrong about where the problem is, and it isn't cowork_settings.json at all.

The Cowork home has a third plugin location I missed: rpm/. It holds a manifest.json plus one directory per installed plugin, and those are exactly the plugins active in my sessions.

json { "lastUpdated": 1788397561370, "plugins": [ { "id": "plugin_0155zZVATbJU3jHUmPP9NvMC", "name": "cowork-plugin-management", "updatedAt": "2026-09-01T14:07:01.634450Z", "updatedAtVerified": true, "displayName": "Plugin Management", "marketplaceId": "marketplace_01QRn9XAjzzeAokB5nPWVMxP", "marketplaceName": "knowledge-work-plugins", "installedBy": "user", "installationPreference": "available" }, ... ] }

The giveaway is that the same marketplace exists twice on my disk. cowork_plugins/marketplaces/knowledge-work-plugins/ is dated 2026-03-05 and nothing has written to it since. The live copy is under rpm/, refreshed 2026-09-01. The app moved its plugin store and cowork_plugins/ is what got left behind.

So cowork install is writing to a location this Desktop build no longer reads. That also explains why my manual staging into cowork_plugins/marketplaces/iai-mcp-local/ changed nothing. I put the plugin in the abandoned directory.

The part I can't see a way around is the manifest schema. Every entry is keyed by a server-issued id and marketplaceId, carries updatedAtVerified: true, and has no path or source field. There's nowhere to say "this marketplace is a directory on my disk," and I can't mint a marketplace_01... ID. If plugins only enter rpm/ through an app-side install against a server-registered marketplace, then a locally staged plugin has no path in at all and this isn't fixable by writing files.

Which turns my report into a question: is there a supported way to get a local plugin into rpm/ on current builds? If yes, cowork install wants to target that and write manifest.json instead. If no, the integration is blocked upstream at Anthropic rather than here, and the README shouldn't promise ambient capture in every Cowork session.

I think this is also the same root cause as #119. There the home-discovery heuristic fails outright on Windows because it looks for marker files the current layout doesn't guarantee. Here discovery succeeds, the home gets wired, and the plugin still never loads. Same relocation, two symptoms, two platforms.

Separately, and smaller: cowork status currently reads back the file the installer wrote, so it reports ACTIVE no matter what the app does. Checking for the plugin in rpm/manifest.json, or for a hook log written during the current session, would turn it into a real check. Same class of thing as #114.

mbusch-regis avatar Sep 03 '26 01:09 mbusch-regis

Update, and it changes the conclusion. My suspected cause in the original report was wrong, and I think the hook-based approach can't work on current Desktop builds at all. But there's a way to get the same result without hooks, and I have it running.

cowork_plugins/ isn't where plugins live anymore

The Cowork home has a third location I missed: rpm/. It holds a manifest.json plus one directory per installed plugin, and those are the plugins actually active in my sessions.

{
  "lastUpdated": 1788397561370,
  "plugins": [
    {
      "id": "plugin_0155zZVATbJU3jHUmPP9NvMC",
      "name": "cowork-plugin-management",
      "updatedAt": "2026-09-01T14:07:01.634450Z",
      "updatedAtVerified": true,
      "displayName": "Plugin Management",
      "marketplaceId": "marketplace_01QRn9XAjzzeAokB5nPWVMxP",
      "marketplaceName": "knowledge-work-plugins",
      "installedBy": "user",
      "installationPreference": "available"
    }
  ]
}

The giveaway is that the same marketplace exists twice on my disk. cowork_plugins/marketplaces/knowledge-work-plugins/ is dated 2026-03-05 and nothing has written to it since. The live copy under rpm/ was refreshed 2026-09-01. The app moved, and cowork_plugins/ is what it left behind. That's also why my manual staging in the original report did nothing: I put the plugin in the abandoned directory.

rpm/ is a managed cache, not a place you can write

I tested it. Quit the app, copied the plugin into rpm/plugin_01IaiMcpLocalTest0000001/, and added a matching manifest.json entry with IDs in the observed format (marketplace_01IaiMcpLocalMkt00000001), mirroring a working entry field for field.

After relaunch, both the manifest entry and the plugin directory were gone. The app didn't ignore my entry, it deleted it and removed the directory. My three real plugins were untouched.

So the app reconciles rpm/ against a server-side registry and removes anything it didn't install. Every entry carries a server-issued id and marketplaceId plus updatedAtVerified: true, and the schema has no path or source field, so there's no way to express "this marketplace is a directory on my disk" even in principle.

That means cowork install isn't writing to the wrong directory. Every directory is the wrong directory, because the app owns that tree.

One more data point worth having: none of the three installed plugins ships a hooks/ directory at all. find rpm/ -type d -name hooks and find rpm/ -name hooks.json both come back empty. So there's no positive evidence anywhere on my machine that Cowork's plugin loader honors hooks.json even for plugins it installed itself. It might. Nothing here demonstrates it.

I suspect this is the same root cause as #119. There the discovery heuristic fails outright on Windows; here discovery succeeds, the home gets wired, and the plugin still never loads. One relocation, two symptoms.

What does work: watch the transcripts

Hooks were only ever a means to an end, and the end is getting transcripts into the store. Cowork already writes those itself:

local-agent-mode-sessions/<account>/<device>/local_<uuid>/.claude/projects/<slug>/<cliSessionId>.jsonl

Native Claude Code JSONL, the exact format capture-transcript reads. No plugin surface required.

I put a launchd agent on it. Every two minutes it globs that tree, skips subagents/ traces, skips anything written in the last 90 seconds so an active session isn't re-dumped each cycle, and runs iai-mcp capture-transcript --no-spawn on transcripts that have gone quiet and changed since last seen. State is tracked by path, mtime and size.

--no-spawn matters. It stages into the deferred spool exactly like the Stop hook, so it never contends with the daemon for the store's single-writer lock. The daemon drains on its normal schedule. Re-walking a growing transcript is safe because capture keys user turns on promptId and assistant turns on uuid, so replays collapse onto the same idempotency tags.

First run: 14 transcripts, 0 failures. The store went from 168 nodes to 207, topology regime moved from insufficient_data to healthy, sigma became computable, and episodes_recent now returns real dialogue with both roles and the tool trailers attached. Before this, five days of running had produced zero conversational records.

Happy to clean this up and open a PR if you want it in the repo, as cowork watch install or similar. It's about 130 lines of stdlib Python plus a plist. Two caveats: it only covers local sessions, since cloud Cowork sessions write nothing to the user's disk, and capture lands seconds-to-minutes late rather than per-turn, which for a system that consolidates during sleep cycles doesn't seem to matter.

Worth considering as the primary mechanism rather than a fallback. The transcript files are stable and already in your format. The plugin surface is owned by the app and just demonstrated it will delete what you put there.

Smaller

cowork status reads back the file the installer wrote, so it reports ACTIVE regardless of what the app does. Checking for the plugin in rpm/manifest.json, or for a hook log written during the current session, would make it a real check. Same class of thing as #114.


No Cluades were harmed, although they were used, in the formulation of this workaround.

mbusch-regis avatar Sep 03 '26 02:09 mbusch-regis

Fixed in v3.1.0 — the bundled plugin marketplace and its Cowork registration load correctly now. Update with pip install -U iai-pme (3.1.0) and reinstall the plugin. Thanks for the report @mbusch-regis.

CodeAbra avatar Sep 06 '26 03:09 CodeAbra