Repository navigation
feat(agents): add Prime Agent as a supported TUI agent with session history - #12935
Conversation
…istory Wire Prime Intellect's prime-agent CLI (a Pi fork) into the desktop and mobile agent catalogs following the Trae registration pattern, and into the Agent Session History browser following the OMP pattern: - types.ts, tui-agent-config.ts: register 'prime-agent' with argv prompt injection behind a `--` separator (its own help documents `--` as "treat all following arguments as messages"; without it, prompts starting with `help`/`agents`/`-…` dispatch as subcommands or flags), plus csi-u Shift+Enter encoding matching the Pi TUI it embeds. - agent-kind.ts, telemetry-events.ts, agent-status-types.ts, agent-type-label.ts, tui-agent-display-names.ts, tui-agent-selection.ts, skills-cli-agent-keys.ts: standard per-agent registrations. - agent-headless-command.ts: `-p/--print` one-shot runs share the print-mode matcher with Claude/Trae so they are not mistaken for live interactive panes. - agent-process-recognition: the npm shim launches a generic bundled cli.js, so only the exact package path is an authoritative identity (same as Pi and cursor-agent). The three per-agent regex branches are now one table in agent-node-entrypoint-identities.ts — the module was at its max-lines budget and a table makes the next agent one entry. - AI Vault: sessions are Pi's message-graph JSONL under ~/.prime/agent/sessions (override PRIME_AGENT_CODING_AGENT_DIR — Prime Agent brands Pi's env contract instead of sharing PI_CODING_AGENT_DIR); parsed by the shared message-graph parser with incremental append-resume; discovered locally, in WSL homes, and over remote SSH; resumes by absolute transcript path (`prime-agent --resume <path>`) like OMP, with session-id fallback. - skill-discovery-sources.ts: ~/.prime/agent/skills home source. - Catalog, i18n (en/es/ja/ko/zh), mobile registries, and a bundled 64x64 favicon (required by mobile's offline-icon invariant). Scanner-test fixtures for OMP and Prime Agent move into session-scanner-test-fixtures.ts and the incremental fixture into its own module, keeping every touched file inside its max-lines budget without ratchet bumps.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdded Prime Agent as a supported agent across shared types, telemetry, process recognition, launch configuration, automatic selection, and UI catalogs. Added Prime Agent icons, favicon assets, localized labels, and mobile mappings. Added local, WSL, and remote session discovery for 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 08d27e8c-bab7-457b-896f-6d6eb002c313
⛔ Files ignored due to path filters (2)
mobile/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlsrc/shared/agent-icons/prime-agent.pngis excluded by!**/*.png
📒 Files selected for processing (42)
mobile/src/components/mobile-agent-icon-assets.tsmobile/src/tasks/mobile-tui-agents.tssrc/main/ai-vault/remote-session-scanner-sources.tssrc/main/ai-vault/session-scanner-agent-parser.tssrc/main/ai-vault/session-scanner-codex-workers.test.tssrc/main/ai-vault/session-scanner-graph-parsers.tssrc/main/ai-vault/session-scanner-incremental-fixtures.tssrc/main/ai-vault/session-scanner-opencode-sqlite-coexistence.test.tssrc/main/ai-vault/session-scanner-parse-cache.tssrc/main/ai-vault/session-scanner-prime-agent-fixtures.tssrc/main/ai-vault/session-scanner-source-discovery.tssrc/main/ai-vault/session-scanner-test-fixtures.tssrc/main/ai-vault/session-scanner-types.tssrc/main/ai-vault/session-scanner-values.tssrc/main/ai-vault/session-scanner.test.tssrc/main/skills/skill-discovery-sources.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/agent-catalog.tsxsrc/renderer/src/lib/agent-favicon-assets.tssrc/renderer/src/lib/agent-status.test.tssrc/renderer/src/lib/agent-status.tssrc/renderer/src/lib/tui-agent-startup.test.tssrc/shared/agent-headless-command.tssrc/shared/agent-kind.tssrc/shared/agent-node-entrypoint-identities.tssrc/shared/agent-process-recognition.test.tssrc/shared/agent-process-recognition.tssrc/shared/agent-status-types.tssrc/shared/agent-type-label.tssrc/shared/ai-vault-resume-command.test.tssrc/shared/ai-vault-resume-command.tssrc/shared/ai-vault-types.tssrc/shared/skills-cli-agent-keys.tssrc/shared/telemetry-events.tssrc/shared/tui-agent-config.tssrc/shared/tui-agent-display-names.tssrc/shared/tui-agent-selection.tssrc/shared/types.ts
PRIME_AGENT_CODING_AGENT_DIR is consumed verbatim by the CLI as its agent config dir, with transcripts always in <agentDir>/sessions — unlike PI_CODING_AGENT_DIR's <home>/agent/sessions shape the shared normalizer models. A custom root with a non-special basename (or a `.prime` leaf) was therefore scanned as-is instead of its sessions child. Dedicated normalizePrimeAgentSessionsDir appends `sessions` to every configured root, taking only an explicit `.../sessions` path as-is; the shared Pi/OMP normalizer drops the `.prime` widening it no longer needs. Raised in review on stablyai#12935.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 969ec4b2-6cf4-465e-8ddf-d23762120a09
📒 Files selected for processing (4)
src/main/ai-vault/remote-session-scanner-sources.tssrc/main/ai-vault/session-scanner-source-discovery.tssrc/main/ai-vault/session-scanner-values.test.tssrc/main/ai-vault/session-scanner-values.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/ai-vault/remote-session-scanner-sources.ts
- src/main/ai-vault/session-scanner-source-discovery.ts
…e source
normalizePrimeAgentSessionsDir stripped a filesystem-root value ('/' or '//')
to '', which then joined into the relative root 'sessions' and would walk the
main-process cwd. session-scanner-roots.ts already carries this guard for the
OMP variant; apply the same fallback here.
The remote SSH source had no test: deleting jsonlSource('prime-agent', ...)
left the suite green, unlike the local path which is pinned by the
AI_VAULT_AGENTS exhaustiveness assertion in session-scanner.test.ts. Add a
case that fixes the .prime/agent/sessions root segments, the .jsonl
extension, and parser routing.
Raised in review on stablyai#12935.
Electron QA — PR #12935 (Prime Agent + Agent Session History)Environment: Dev app from worktree head Verdicts
D — Observed resume command(Resume path form matches absolute transcript resume for this agent.) E — ComparisonBaseline installed set (before Prime detection): Claude, Claude Agent Teams, Codex, Grok, OMP, Gemini, Antigravity. After: same seven rows still present with the same labels/commands; Prime Agent added (Installed went 7 → 8). Picker shows the same existing agents plus Prime Agent. No renames, drops, or command-string changes observed on existing rows. ScreenshotsA — New-tab picker (Prime Agent + icon) B — Agents settings (Prime Agent installed) C — Session History seeded session D — Resume action (terminal shows prime-agent --resume …) D (menu) — Copy Resume Command available E — Picker negative control (existing agents retained) E — Settings negative control (existing agents retained) Gaps / notes
|
Review pass — 2 fixes pushed (95499b6), 1 doc correction requestedReviewed with adversarial subagent lanes plus live Electron QA. Nice work — the registration is genuinely complete, and I could not break the recognition refactor. Two real issues found and fixed; one claim in the PR body needs correcting. Fixed in 95499b61. Degenerate The codebase already guards this exact hazard for the OMP variant at 2. The remote SSH source had no test coverage. Please correct in the PR bodyThe Security Audit section states that
This is not a blocker for this PR — the same property holds for every previously added agent, and making the reader tolerant of unknown enum values is a shared-validation change that deserves its own PR. But the body should not claim additive degradation. Worth a follow-up issue. Verified, no action needed
Gates on the pushed head: Electron QA screenshots posted separately. |
|
Thanks for the thorough pass — the QA matrix, the mutation-testing of the new suites, and both fixes in 95499b6 (the PR body corrected as requested: the Security Audit no longer claims additive degradation and now states the actual mixed-version behavior (per-row drops with the codex-misattributed notice, and the all-rows-unknown throw with the SSH SFTP-crawl fallback). Filed the shared-validation follow-up as #12958. |
…ive modes Verified against upstream PrimeIntellect-ai/prime-agent source rather than inferred from the CLI's help text. config.ts getSessionsDir() reads PRIME_AGENT_SESSION_DIR (and its legacy PRIME_AGENT_CODING_AGENT_SESSION_DIR alias) ahead of the agent dir and uses it verbatim; setting either left the vault silently empty. It also appends `sessions` to the agent dir unconditionally, with no basename escape hatch, so PRIME_AGENT_CODING_AGENT_DIR=/data/sessions writes to /data/sessions/sessions while Orca scanned /data/sessions. getAgentDir() and the session-dir override both run through expandTildePath, so a `~` value set outside a shell resolves. cli/args.ts also spells the non-interactive runs `--mode json|rpc|acp|daemon`, which the shared print-mode matcher does not know, so those panes were counted as live interactive agents and the paste-submit path would write user text into a JSON-RPC/ACP stream. Match upstream exactly: only the space-separated form, since `--mode=json` is not parsed by the CLI and does start the TUI. Raised in review on stablyai#12935.
Round 2 — 3 more fixes pushed (906fdac)Two further review lanes reported after my last comment, and both landed real findings. I verified every claim against upstream Fixed in 906fdac1. export function getSessionsDir(agentDir = getAgentDir()): string {
const envDir = getSessionDirEnvOverride(); // PRIME_AGENT_SESSION_DIR ?? PRIME_AGENT_CODING_AGENT_SESSION_DIR
if (envDir) return envDir;
return join(agentDir, "sessions");
}Both variables outrank the agent dir and point straight at the transcripts root. Orca read only 2. The 3. One detail worth flagging, because the obvious fix over-matches: upstream parses Also: a Not changed, deliberately
VerificationFull Each fix is mutation-proven, not just covered: gutting the |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5824e9dc-e4b2-4d44-846d-652b2edaf2b6
📒 Files selected for processing (7)
src/main/ai-vault/remote-session-scanner-sources.tssrc/main/ai-vault/session-scanner-source-discovery.tssrc/main/ai-vault/session-scanner-values.test.tssrc/main/ai-vault/session-scanner-values.tssrc/shared/agent-headless-command.tssrc/shared/agent-process-recognition.test.tssrc/shared/prime-agent-headless-command.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/ai-vault/remote-session-scanner-sources.ts
- src/main/ai-vault/session-scanner-source-discovery.ts
Two holes in the previous commit.
The degenerate-root guard only rejected pure-separator values, so a relative
env value still resolved against the main-process cwd:
PRIME_AGENT_CODING_AGENT_DIR='.' scanned '<cwd>/sessions' and, worse,
PRIME_AGENT_SESSION_DIR='.' scanned the cwd itself. Require an absolute path in
both branches and fall back to the default otherwise.
remotePrimeAgentSessionsSegments() built its segments with the local-platform
join, so on a Windows client scanning a posix SSH host it produced
'\.prime\agent\sessions' and split('/') collapsed it to one bogus segment —
remote discovery would have found nothing. Remote roots are posix regardless of
client platform, so keep them literal. Pi and OMP are unaffected: their
normalizer returns a '.../sessions' input unchanged and never joins.
Raised in review on stablyai#12935.
Round 3 — self-inflicted regression caught and fixed (f7d29c1)Two holes, both in my own previous commit rather than in the original PR. 1. Windows-client remote discovery was broken by my last change. In 906fdac I changed so remote Prime Agent discovery from a Windows client would have found nothing. The pre-existing code survived only by accident: the old escape hatch returned a Worth noting this class does not show up in CI or in the test I added, because the suite runs on posix and the bug is in the local platform's 2. The degenerate-root guard was incomplete. It rejected pure-separator values but not relative ones, so the exact class it was added to close was still open:
Both branches now require an absolute path and fall back to the default otherwise. Verification
Independent verification of the earlier roundsA separate adversarial pass confirmed, with execution rather than reasoning:
The |
…llback 'C:\' and 'C:/' strip to the drive-relative 'C:', which isAbsolute rejects on every platform — assert they land in the default fallback so a looser truthiness check can't reintroduce a 'C:sessions' scan root. Raised in review on stablyai#12935.
Final verdict — CLEAN at a094036Adversarial verification is done. No correctness defects survive. One non-blocking coverage gap, called out below as a conscious decision rather than an oversight. Thanks for What was checked, and howPath resolution — 48-value matrix run under both
Resume quoting — 128 executed POSIX runs (16 hostile payloads × 2 branches × 4 shells) against an argv recorder: 0 injections, 0 argv mismatches, no marker file created by any breakout string. PowerShell and cmd were string-level only, since neither exists on the verification host — stated plainly as the weaker evidence it is. Regression sweep — Mutation checks — three of the four review fixes are pinned: removing the Accepted gap (conscious call, not an oversight)The fourth fix — I am accepting that rather than papering over it. The code is now platform-independent by construction — there is no Still with you, not blocking
Correction to my own round-3 commentI understated one thing. The relative-root issue was not just untidy — it was demonstrated live. With |
Small follow-up on a094036 — right behavior, wrong stated reasonVerdict unchanged: CLEAN, and this commit is not a blocker. The behavior it pins is correct. But two details in it are worth fixing before merge, because as written the comment will mislead the next reader. The stated hazard is unreachableThe message says the pin stops a looser truthiness check from reintroducing a path.win32.join('C:', 'sessions') // => 'C:\\sessions' (not 'C:sessions')The code only ever uses The two new cases add no coverage
Proven by mutation, three ways:
That third one is decisive: the change the test says it prevents passes the test. The shape that is actually dangerous on WindowsNot the drive root — the drive-relative form, which is absent from both loops: path.win32.isAbsolute('C:foo') // false
path.win32.resolve('C:foo', 'sessions') // => '<cwd-on-C:>\\foo\\sessions'Your Suggested (all optional, none blocking)
On the divergence questionFalling back rather than matching the CLI's One thing for a separate PRThe pre-existing pi/OMP normalizer still has the Windows drive-relative leak that prime-agent now blocks: Out of scope here — flagging it so it isn't lost. Standing caveatThis PR now has two Windows-only behaviors that no posix CI run can observe: the drive-root env handling above, and the remote posix-segments fix at Regression sweep at |
…osix runner can assert
|
Both suggestions applied in 7b74ad7:
On the two standing items from the final verdict: the Security Audit section was already reworded after your first pass — the “Mixed versions (corrected after review)” bullet states the all-rows-unknown throw and the codex misattribution outright, with the shared-reader tolerance tracked in #12958. The Verification: full |
|
Thanks for this — really nice work, and you turned around every review point precisely. I'm going to hold off merging for now, and it's not the code. Prime Agent is moving fast at the moment (~3 releases a week), and our integration leans on its launch, resume, and transcript contracts staying put. Supporting an agent is an ongoing commitment on our side, so I'd rather pick this up once the CLI surface settles. We also tend to wait for a bit more adoption before taking one on, and that's a factor here too. Happy to revisit on both counts — the branch is in good shape. Thanks again for the effort here. |
|
Completely fair on both counts, and thanks for the thorough rounds — the branch will stay ready either way. On contract stability: that concern is exactly why PrimeIntellect-ai/prime-agent#808 exists — it asks upstream directly whether the session-file format and the launch/env/CLI contracts this integration leans on are stable across releases, and which surface they intend for host-IDE integrations long-term. I'll relay their answer here when it lands. On the ongoing-commitment side: I run an automation that checks every prime-agent release against precisely the contracts this PR consumes (the npm entrypoint path, On adoption, for what it's worth: #12892 requested this agent before this PR existed. What signal would make this worth picking back up for you — some number of prime-agent releases without a breaking change to those contracts, a stability statement from upstream in #808, an adoption bar, or something else? Happy to track whichever and ping only when it's met. |
|
thanks for reporting. looking into it |
Resolves the conflict with stablyai#10249's table refactor: per-agent discovery moved from session-scanner-source-discovery.ts into the AI_VAULT_AGENT_SOURCES table, so the Prime Agent source becomes a table entry following the Pi shape (env resolution via primeAgentSessionsDirFromEnv unchanged). Prime Agent stays out of AI_VAULT_DELETABLE_AGENTS. Also picks up stablyai#12999 (unknown-agent tolerance in session-list validation) with no overlap.
|
Update: taking this off hold — we're moving to merge. Two things changed the calculus:
One known cosmetic quirk to be aware of: prime-agent's daemon mode currently leaves zero-message draft session files on shutdown (upstream PrimeIntellect-ai/prime-agent#1078, fix pending in PrimeIntellect-ai/prime-agent#1079), which will show as empty rows in Session History until that lands. Since it's an upstream bug with an active fix, we're deliberately not adding a scanner-side workaround. Follow-up tracked separately: register prime-agent as a third Pi-family kind so the managed extension installer can deliver live agent status — deliberately kept out of this PR, since the extension API is the one genuinely churn-exposed surface. @smwbev — thanks for the quality of this contribution and for keeping the branch current through the hold. |
Prime Agent (stablyai#12935) landed in main and added its own cases to session-scanner-values.test.ts at the same insertion point; both suites are kept side by side. The pi/OMP normalizer guard this PR adds is untouched by the merge.
|
Thank you — and for the audit itself, which answered the contract question far more rigorously than the guarantee I went looking for upstream. On the two follow-ups you named:
Also, unrelated to this PR but in the same area: #13020 (the pi/OMP normalizer leak this review surfaced) is green and waiting, and #13118 implements the #13082 sweep across the other six agents using it as the template. I checked they don't conflict with each other, in case that helps sequencing. |
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…istory (stablyai#12935) * feat(agents): add Prime Agent as a supported TUI agent with session history Wire Prime Intellect's prime-agent CLI (a Pi fork) into the desktop and mobile agent catalogs following the Trae registration pattern, and into the Agent Session History browser following the OMP pattern: - types.ts, tui-agent-config.ts: register 'prime-agent' with argv prompt injection behind a `--` separator (its own help documents `--` as "treat all following arguments as messages"; without it, prompts starting with `help`/`agents`/`-…` dispatch as subcommands or flags), plus csi-u Shift+Enter encoding matching the Pi TUI it embeds. - agent-kind.ts, telemetry-events.ts, agent-status-types.ts, agent-type-label.ts, tui-agent-display-names.ts, tui-agent-selection.ts, skills-cli-agent-keys.ts: standard per-agent registrations. - agent-headless-command.ts: `-p/--print` one-shot runs share the print-mode matcher with Claude/Trae so they are not mistaken for live interactive panes. - agent-process-recognition: the npm shim launches a generic bundled cli.js, so only the exact package path is an authoritative identity (same as Pi and cursor-agent). The three per-agent regex branches are now one table in agent-node-entrypoint-identities.ts — the module was at its max-lines budget and a table makes the next agent one entry. - AI Vault: sessions are Pi's message-graph JSONL under ~/.prime/agent/sessions (override PRIME_AGENT_CODING_AGENT_DIR — Prime Agent brands Pi's env contract instead of sharing PI_CODING_AGENT_DIR); parsed by the shared message-graph parser with incremental append-resume; discovered locally, in WSL homes, and over remote SSH; resumes by absolute transcript path (`prime-agent --resume <path>`) like OMP, with session-id fallback. - skill-discovery-sources.ts: ~/.prime/agent/skills home source. - Catalog, i18n (en/es/ja/ko/zh), mobile registries, and a bundled 64x64 favicon (required by mobile's offline-icon invariant). Scanner-test fixtures for OMP and Prime Agent move into session-scanner-test-fixtures.ts and the incremental fixture into its own module, keeping every touched file inside its max-lines budget without ratchet bumps. * fix(ai-vault): map custom Prime Agent roots to their sessions child PRIME_AGENT_CODING_AGENT_DIR is consumed verbatim by the CLI as its agent config dir, with transcripts always in <agentDir>/sessions — unlike PI_CODING_AGENT_DIR's <home>/agent/sessions shape the shared normalizer models. A custom root with a non-special basename (or a `.prime` leaf) was therefore scanned as-is instead of its sessions child. Dedicated normalizePrimeAgentSessionsDir appends `sessions` to every configured root, taking only an explicit `.../sessions` path as-is; the shared Pi/OMP normalizer drops the `.prime` widening it no longer needs. Raised in review on stablyai#12935. * fix(ai-vault): guard degenerate Prime Agent roots and cover the remote source normalizePrimeAgentSessionsDir stripped a filesystem-root value ('/' or '//') to '', which then joined into the relative root 'sessions' and would walk the main-process cwd. session-scanner-roots.ts already carries this guard for the OMP variant; apply the same fallback here. The remote SSH source had no test: deleting jsonlSource('prime-agent', ...) left the suite green, unlike the local path which is pinned by the AI_VAULT_AGENTS exhaustiveness assertion in session-scanner.test.ts. Add a case that fixes the .prime/agent/sessions root segments, the .jsonl extension, and parser routing. Raised in review on stablyai#12935. * fix(ai-vault): honor Prime Agent's sessions-root env and non-interactive modes Verified against upstream PrimeIntellect-ai/prime-agent source rather than inferred from the CLI's help text. config.ts getSessionsDir() reads PRIME_AGENT_SESSION_DIR (and its legacy PRIME_AGENT_CODING_AGENT_SESSION_DIR alias) ahead of the agent dir and uses it verbatim; setting either left the vault silently empty. It also appends `sessions` to the agent dir unconditionally, with no basename escape hatch, so PRIME_AGENT_CODING_AGENT_DIR=/data/sessions writes to /data/sessions/sessions while Orca scanned /data/sessions. getAgentDir() and the session-dir override both run through expandTildePath, so a `~` value set outside a shell resolves. cli/args.ts also spells the non-interactive runs `--mode json|rpc|acp|daemon`, which the shared print-mode matcher does not know, so those panes were counted as live interactive agents and the paste-submit path would write user text into a JSON-RPC/ACP stream. Match upstream exactly: only the space-separated form, since `--mode=json` is not parsed by the CLI and does start the TUI. Raised in review on stablyai#12935. * fix(ai-vault): keep Prime Agent roots absolute and remote segments posix Two holes in the previous commit. The degenerate-root guard only rejected pure-separator values, so a relative env value still resolved against the main-process cwd: PRIME_AGENT_CODING_AGENT_DIR='.' scanned '<cwd>/sessions' and, worse, PRIME_AGENT_SESSION_DIR='.' scanned the cwd itself. Require an absolute path in both branches and fall back to the default otherwise. remotePrimeAgentSessionsSegments() built its segments with the local-platform join, so on a Windows client scanning a posix SSH host it produced '\.prime\agent\sessions' and split('/') collapsed it to one bogus segment — remote discovery would have found nothing. Remote roots are posix regardless of client platform, so keep them literal. Pi and OMP are unaffected: their normalizer returns a '.../sessions' input unchanged and never joins. Raised in review on stablyai#12935. * test(ai-vault): pin Windows drive roots to the Prime Agent default fallback 'C:\' and 'C:/' strip to the drive-relative 'C:', which isAbsolute rejects on every platform — assert they land in the default fallback so a looser truthiness check can't reintroduce a 'C:sessions' scan root. Raised in review on stablyai#12935. * test(ai-vault): pin the drive-relative root form and state what the posix runner can assert --------- Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted 1102 commits since the original merge base. Agent behavior is unchanged from the original PR; only the landing sites moved. Relocations forced by two refactors on main: - stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated moves to src/shared/global-settings-types.ts. - src/main/persistence.ts is now an 8-line barrel; the three opt-in migration hunks move to persistence/loading-store/store.ts. - stablyai#14728 split the oversized test files, so the Bob detection test moves to preflight-agent-detection.test.ts and the disabledTuiAgents tests move to persistence-settings-update.test.ts. - i18n locales and agent-headless-command.ts took both sides of the collision with Prime Agent (stablyai#12935). Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>







Summary
Adds Prime Agent — Prime Intellect's coding/research CLI, an open-source fork of Pi — as a supported TUI agent, and indexes its transcripts in Agent Session History. After this change
prime-agentappears in the agent pickers and Agents settings on desktop and mobile, launches with a startup prompt, is recognized in the process table and tab titles, and its saved sessions list and resume from the history sidebar, locally and over SSH.The integration follows the two established patterns end to end: registration mirrors Trae (#10763), session history mirrors OMP (#7618). Both fit because Prime Agent is Pi under the hood (
@earendil-works/pi-coding-agentis its direct dependency), with three deliberate differences, each verified against the real CLI v0.7.0 rather than assumed:PI_CODING_AGENT_DIRPI_CODING_AGENT_DIRPRIME_AGENT_CODING_AGENT_DIR~/.pi/agent/sessions~/.omp/agent/sessions(+ artifact dirs)~/.prime/agent/sessions(flat)--session <path>--resume <path>--resume <path|id>What changed
types.ts,tui-agent-config.ts+ the standard satellite tables): prompt injection is positional argv behind a--separator — Prime Agent's help documents--as "treat all following arguments as messages", and without it a prompt starting withhelp/agents/-…dispatches as one of its 16 subcommands or a flag (same rationale as Trae and Grok).windowsShiftEnterEncoding: 'csi-u'matches the Pi TUI it embeds. No YOLO entry: the CLI has no permissions-bypass flag, so it stays out of the permission-mode summary by design.node …/node_modules/prime-agent/dist/bundle/cli.js, a generic script name, so recognition needs the exact package path — the same situation as Pi and cursor-agent. The three per-agent regex branches became one table (agent-node-entrypoint-identities.ts); the module sat at its max-lines budget, and a table makes the next agent one entry instead of a fourth branch.-p/--printone-shots reuse the shared print-mode headless matcher so they are not mistaken for live panes.model_change.modelIdkey), so the existing parser and incremental append-resume are reused as-is — the diff adds discovery (local, WSL homes, remote SSH), routing, and resume. Resume uses the absolute transcript path like OMP, so it resolves regardless of which session-dir root the file was discovered under, with session-id fallback.~/.prime/agent/skillsjoins the home skill-discovery sources (global skills root per Prime Agent's docs, same shape as Pi/OMP).primeAgentSessionsDirso a real~/.primeon a dev machine cannot pollute assertions; the OMP and Prime Agent scanner fixtures moved intosession-scanner-test-fixtures.tsand the incremental fixture into its own module, keeping each touched file inside its max-lines budget without ratchet bumps.Deliberately out of scope for this PR (planned follow-up): the Pi-family managed extensions (status/titlebar/prefill),
/hook/*wiring, and theompResumeFilePathRPC generalization. Those require widening the two-elementPiAgentKindmachinery and a capability-negotiated relay field, and none of them block launch, recognition, or history.Screenshots
New rows only, no existing UI changes:
Prime Agentappears in the new-tab agent picker, the Agents settings pane, and the Agent Session History agent filter/groups, rendering the bundled 64×64 favicon (fetched from primeintellect.ai, required by mobile's offline-icon invariant). All labels come from the localized catalog entry added to all five locales.Testing
pnpm lintpnpm typecheckpnpm testpnpm buildNew tests: process recognition (binary path, npm entrypoint on posix and Windows, headless
-p/--printexclusion,--guard), startup plan (argv + separator, subcommand-shaped prompts), status label/icon mapping, resume command (path form, id fallback), the all-agents scanner test (which fails if anyAI_VAULT_AGENTSmember goes undiscovered — it now asserts Prime Agent's title, pre-replymodelId, and path-based resume command), and an incremental parse-parity fixture exercising the'prime-agent'registry branch with the v3 tree-session header.Beyond fixtures, the parser was verified against a real
~/.prime/agent/sessionstranscript written by prime-agent v0.7.0 (22 messages, 241k tokens): title, cwd, model, message/token counts, and the generatedprime-agent --resume '<path>'command all resolve correctly.prime-agent --helpoutput was used as ground truth for the launch contract ([@files...] [message...],--,-p/--print,-r/--resume <path|id>).Full suite on this branch: 47,061 passed, 7 failures across 4 files. Every deterministic failure (
agent-exec-handler.test.ts,ssh-posix-command-wrapper.test.ts) fails identically on a cleanupstream/maincheckout (f71373953) on this machine — verified by stashing the diff and re-running; the remaining two (project-view-wrapper-source-context-boundary,worktree-base-directory-poller) are timeouts that pass in isolation. None touch agent registries. Mobile:tsc --noEmitclean, 3,371 tests passed; the parity tests that diff the mobile catalog against the desktop source accept the new agent.AI Review Report
An automated multi-dimension review ran over the staged diff (registry-convention completeness against the Trae and MiMo integration commits, session-history correctness, cross-platform behavior, test adequacy), with each finding adversarially re-verified against the code. No finding survived verification; three test-coverage suggestions were assessed as pre-existing patterns rather than regressions (remote sources for pi/droid/kimi are equally fixture-untested; the scope test's roots omission predates this PR for
ompSessionsDir), and one — the missing skills home source — was accepted and folded into the diff.Cross-platform was checked explicitly: all new paths go through
path.join/joinRemotePath; resume commands reuse the existing per-shell quoting (posix/pwsh/cmd) and are covered by the OMP-shaped tests; WSL homes get.prime/agent/sessionsroots the same way.pi/.ompdo; Windows recognition of thenode.exe …\node_modules\prime-agent\…command line has a dedicated test; no shortcuts, labels, or Electron platform surfaces are touched.Security Audit
PRIME_AGENT_CODING_AGENT_DIRis user-owned env, normalized through the samenormalizeAgentSessionsDirpath-shape guard Pi and OMP use; transcript contents are parsed line-by-line as JSON with the existing tolerant parser and never executed or interpolated unquoted.quoteStartupArg/quoteWindowsCmdArg); startup prompts go through the established argv quoting with the--separator preventing flag/subcommand injection via prompt text.z.enum(AI_VAULT_AGENTS)result validation drops unknown-agent rows per-row, but not additively: dropped rows surface a "Skipped N invalid Agent Session History result entries." notice hardcoded toagent: 'codex', and when every row is unknown the parser throws — zero sessions locally, and over SSH the throw falls through to the full SFTP crawl. The same property holds for every previously added agent; making the shared reader tolerant of unknown agents is tracked in AI Vault: session-list validation should tolerate agents unknown to the client #12958.Notes
'.prime'widening ofnormalizeAgentSessionsDirkeeps the same prefix-acceptance semantics;OMP_CODING_AGENT_DIR-style scanner-only overrides get their Prime Agent counterpart through the standardprimeAgentSessionsDirscan option.rlm(...)child agents save ordinary session files in the same flat directory (only anrlmDepthheader field distinguishes them), so they list as regular sessions — the OMP artifact-dir pruning does not apply and no subagent partitioning is needed.ORCA_*_PREFILLenv contract needs the managed prefill extension, which is part of the deferred extensions follow-up.