feat(devin): managed hooks, sleeping resume, AI Vault (#5380)
* Revert "fix(terminal): add proportional scroll fallback for sidebar resize" (#937) * fix(sidebar): smoothly animate off-screen worktree reveal on click (#1302) Clicking a worktree card whose row lies outside the sidebar viewport caused an instant jump when scrolling it into view. Switching `scrollToIndex` to `behavior: 'smooth'` turns that minimum-distance scroll into an animated slide while keeping `align: 'auto'` so visible cards still no-op (no re-centering). Co-authored-by: Orca <help@stably.ai> * Avoid local scrollback serialization on shutdown (#1821) * Fix PR refresh coordinator test arguments (#2545) * release: v1.4.31 * release: v1.4.31 * release: v1.4.31 * release: v1.4.31 * release: v1.4.31 * release: v1.4.31 * release: v1.4.31 * release: v1.4.36-rc.6 * release: v1.4.36-rc.6 * release: v1.4.36-rc.6 * ci: gate release-cut to the canonical repo so it skips forks (#4815) The cut job checks out main, bumps package.json's version, and fast-forwards main. On a fork with Actions enabled, the scheduled RC cut runs against the fork's main and diverges it on the version line every slot, so that contributor's PRs back to upstream conflict on package.json even when their change never touches it. Gate the job to github.repository == 'stablyai/orca' so it (and the jobs that depend on it) no-op on forks. Canonical scheduled and manual cuts are unaffected. * feat(hooks): install Devin managed status hooks * feat(devin): address hook review, resume, and UI polish - Parse Devin config.json as JSONC; warn on read_config_from overlap - Windows hook command uses forward slashes; APPDATA fallback - Add devin to sleeping-agent resume and UI registries (plan 003/004) - Add hook-service and hook-config-json tests Closes follow-up for plans 002–004 on feat/add-devin-agent. * feat(devin): scan ATIF transcripts for AI Vault Register devin in AI_VAULT_AGENTS, discover ~/.local/share/devin/cli/transcripts (or DEVIN_HOME), parse ATIF JSON sessions, and build devin --resume commands. * docs(devin): clarify stdin-after-start vs bracketed paste * fix(devin): use JSONC for remote install, add partial+APPDATA tests - installRemote: replace readHooksJsonRemote (JSON.parse) with readTextFileRemote + parseJsonc for JSONC compatibility on SSH - Add partial status test (some hooks missing → state:'partial') - Add Windows APPDATA config path test with fallback * fix(devin): address CodeRabbit review — sessionId fallback, parseJsonc errors, comment, i18n * Fix Devin integration edge cases Co-authored-by: Orca <help@stably.ai> * Package Devin JSONC parser dependency Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com> Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Co-authored-by: Orca <help@stably.ai> Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Trevin Chow <trevin@trevinchow.com> Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
This commit is contained in:
co-authored by
Orca
Neil
Brennan Benson
Jinjing
github-actions[bot]
Trevin Chow
Jinwoo-H
parent
53fe9b4ff1
commit
08ba730d8e
@@ -160,13 +160,9 @@ function containsBrailleSpinner(title: string): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
function containsLegacyAgentName(title: string): boolean {
|
||||
return titleHasAnyLegacyAgentName(title)
|
||||
}
|
||||
|
||||
function containsAgentName(title: string): boolean {
|
||||
return (
|
||||
containsLegacyAgentName(title) ||
|
||||
titleHasAnyLegacyAgentName(title) ||
|
||||
AGY_AGENT_NAME_RE.test(title) ||
|
||||
DROID_AGENT_NAME_RE.test(title) ||
|
||||
HERMES_AGENT_NAME_RE.test(title)
|
||||
@@ -381,6 +377,9 @@ export function getAgentLabel(title: string): string | null {
|
||||
if (titleHasAgentName(title, 'grok')) {
|
||||
return 'Grok'
|
||||
}
|
||||
if (titleHasAgentName(title, 'devin')) {
|
||||
return 'Devin'
|
||||
}
|
||||
if (titleHasAgentName(title, 'antigravity') || AGY_AGENT_NAME_RE.test(title)) {
|
||||
return 'Antigravity'
|
||||
}
|
||||
@@ -468,7 +467,7 @@ export function detectAgentStatusFromTitle(title: string): AgentStatus | null {
|
||||
const hasDroidAgentName = DROID_AGENT_NAME_RE.test(title)
|
||||
const hasHermesAgentName = HERMES_AGENT_NAME_RE.test(title)
|
||||
const hasAgyAgentName = AGY_AGENT_NAME_RE.test(title)
|
||||
const hasLegacyAgentName = containsLegacyAgentName(title)
|
||||
const hasLegacyAgentName = titleHasAnyLegacyAgentName(title)
|
||||
if (hasLegacyAgentName || hasDroidAgentName || hasHermesAgentName || hasAgyAgentName) {
|
||||
if (containsAny(title, ['action required', 'permission', 'waiting'])) {
|
||||
return 'permission'
|
||||
|
||||
@@ -383,6 +383,40 @@ describe('shared agent-hook-listener', () => {
|
||||
expect(event?.payload.lastAssistantMessage).toBeUndefined()
|
||||
})
|
||||
|
||||
it('normalizes Devin documented lifecycle events', () => {
|
||||
const started = normalizeHookPayload(
|
||||
state,
|
||||
'devin',
|
||||
{
|
||||
paneKey: PANE_KEY,
|
||||
payload: { hook_event_name: 'SessionStart', source: 'resume' }
|
||||
},
|
||||
'production'
|
||||
)
|
||||
const compacted = normalizeHookPayload(
|
||||
state,
|
||||
'devin',
|
||||
{
|
||||
paneKey: PANE_KEY,
|
||||
payload: { hook_event_name: 'PostCompaction', summary: 'trimmed' }
|
||||
},
|
||||
'production'
|
||||
)
|
||||
const ended = normalizeHookPayload(
|
||||
state,
|
||||
'devin',
|
||||
{
|
||||
paneKey: PANE_KEY,
|
||||
payload: { hook_event_name: 'SessionEnd', reason: 'complete' }
|
||||
},
|
||||
'production'
|
||||
)
|
||||
|
||||
expect(started?.payload).toMatchObject({ agentType: 'devin', state: 'working' })
|
||||
expect(compacted?.payload).toMatchObject({ agentType: 'devin', state: 'working' })
|
||||
expect(ended?.payload).toMatchObject({ agentType: 'devin', state: 'done' })
|
||||
})
|
||||
|
||||
it('rejects oversized paneKey', () => {
|
||||
const event = normalizeHookPayload(
|
||||
state,
|
||||
|
||||
@@ -1832,6 +1832,8 @@ function isNewTurnEvent(source: AgentHookSource, eventName: unknown): boolean {
|
||||
}
|
||||
case 'hermes':
|
||||
return eventName === 'pre_llm_call' || eventName === 'on_session_start'
|
||||
case 'devin':
|
||||
return eventName === 'SessionStart' || eventName === 'UserPromptSubmit'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1916,6 +1918,8 @@ function extractToolFields(
|
||||
return extractCopilotToolFields(normalizeCopilotEventName(eventName), hookPayload)
|
||||
case 'hermes':
|
||||
return extractHermesToolFields(eventName, hookPayload)
|
||||
case 'devin':
|
||||
return extractClaudeToolFields(eventName, hookPayload)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1967,6 +1971,58 @@ function normalizeClaudeEvent(
|
||||
)
|
||||
}
|
||||
|
||||
// Why: Devin uses Claude-compatible hook payload shapes but has its own
|
||||
// documented lifecycle event set. Keep attribution as Devin while normalizing
|
||||
// those event names into Orca's shared status states.
|
||||
function normalizeDevinEvent(
|
||||
state: HookListenerState,
|
||||
eventName: unknown,
|
||||
promptText: string,
|
||||
paneKey: string,
|
||||
hookPayload: Record<string, unknown>
|
||||
): ParsedAgentStatusPayload | null {
|
||||
const stateName =
|
||||
eventName === 'SessionStart' ||
|
||||
eventName === 'UserPromptSubmit' ||
|
||||
eventName === 'PreToolUse' ||
|
||||
eventName === 'PostToolUse' ||
|
||||
eventName === 'PostCompaction'
|
||||
? 'working'
|
||||
: eventName === 'PermissionRequest'
|
||||
? 'waiting'
|
||||
: eventName === 'Stop' || eventName === 'SessionEnd'
|
||||
? 'done'
|
||||
: null
|
||||
|
||||
if (!stateName) {
|
||||
return null
|
||||
}
|
||||
|
||||
const snapshot = resolveToolState(
|
||||
state,
|
||||
paneKey,
|
||||
extractToolFields('devin', eventName, hookPayload),
|
||||
{ resetOnNewTurn: isNewTurnEvent('devin', eventName) }
|
||||
)
|
||||
|
||||
const interrupted =
|
||||
eventName === 'Stop' && hookPayload['is_interrupt'] === true ? true : undefined
|
||||
|
||||
return parseAgentStatusPayload(
|
||||
JSON.stringify({
|
||||
state: stateName,
|
||||
prompt: resolvePrompt(state, paneKey, promptText, {
|
||||
resetOnNewTurn: isNewTurnEvent('devin', eventName)
|
||||
}),
|
||||
agentType: 'devin',
|
||||
toolName: snapshot.toolName,
|
||||
toolInput: snapshot.toolInput,
|
||||
lastAssistantMessage: snapshot.lastAssistantMessage,
|
||||
interrupted
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
function normalizeGeminiEvent(
|
||||
state: HookListenerState,
|
||||
eventName: unknown,
|
||||
@@ -2904,6 +2960,9 @@ export function normalizeHookPayload(
|
||||
case 'hermes':
|
||||
payload = normalizeHermesEvent(state, eventName, promptText, paneKey, hookPayloadRecord)
|
||||
break
|
||||
case 'devin':
|
||||
payload = normalizeDevinEvent(state, eventName, promptText, paneKey, hookPayloadRecord)
|
||||
break
|
||||
}
|
||||
|
||||
// Why: connectionId stays null at the listener layer. The local server keeps
|
||||
@@ -2956,7 +3015,8 @@ export const HOOK_SOURCE_BY_PATHNAME: Readonly<Record<string, AgentHookSource>>
|
||||
'/hook/command-code': 'command-code',
|
||||
'/hook/grok': 'grok',
|
||||
'/hook/copilot': 'copilot',
|
||||
'/hook/hermes': 'hermes'
|
||||
'/hook/hermes': 'hermes',
|
||||
'/hook/devin': 'devin'
|
||||
})
|
||||
|
||||
export function resolveHookSource(pathname: string): AgentHookSource | null {
|
||||
|
||||
@@ -46,6 +46,7 @@ export type AgentHookSource =
|
||||
| 'grok'
|
||||
| 'copilot'
|
||||
| 'hermes'
|
||||
| 'devin'
|
||||
|
||||
/** Env marker used by the remote relay. It is a transport/location marker, not
|
||||
* a dev-vs-prod build tag, so main-process env mismatch diagnostics ignore it. */
|
||||
|
||||
@@ -15,7 +15,8 @@ export const AGENT_HOOK_TARGETS = [
|
||||
'command-code',
|
||||
'grok',
|
||||
'copilot',
|
||||
'hermes'
|
||||
'hermes',
|
||||
'devin'
|
||||
] as const
|
||||
export type AgentHookTarget = (typeof AGENT_HOOK_TARGETS)[number]
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ export const AGENT_NAMES = [
|
||||
'opencode',
|
||||
'openclaw',
|
||||
'aider',
|
||||
'grok'
|
||||
'grok',
|
||||
'devin'
|
||||
]
|
||||
|
||||
// Why: Windows agent titles can surface launcher process names such as
|
||||
|
||||
@@ -2,10 +2,15 @@ import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
extractAgentProviderSession,
|
||||
getAgentResumeArgv,
|
||||
isResumableTuiAgent,
|
||||
normalizeAgentProviderSession
|
||||
} from './agent-session-resume'
|
||||
|
||||
describe('agent session resume metadata', () => {
|
||||
it('treats devin as a resumable TUI agent', () => {
|
||||
expect(isResumableTuiAgent('devin')).toBe(true)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['claude', { session_id: 'claude-session' }, { key: 'session_id', id: 'claude-session' }],
|
||||
['codex', { session_id: 'codex-session' }, { key: 'session_id', id: 'codex-session' }],
|
||||
@@ -17,7 +22,8 @@ describe('agent session resume metadata', () => {
|
||||
],
|
||||
['opencode', { sessionID: 'opencode-session' }, { key: 'session_id', id: 'opencode-session' }],
|
||||
['droid', { session_id: 'droid-session' }, { key: 'session_id', id: 'droid-session' }],
|
||||
['grok', { sessionId: 'grok-session' }, { key: 'session_id', id: 'grok-session' }]
|
||||
['grok', { sessionId: 'grok-session' }, { key: 'session_id', id: 'grok-session' }],
|
||||
['devin', { session_id: 'devin-session' }, { key: 'session_id', id: 'devin-session' }]
|
||||
] as const)('extracts %s provider session ids', (source, payload, expected) => {
|
||||
expect(extractAgentProviderSession(source, payload)).toEqual(expected)
|
||||
})
|
||||
@@ -29,7 +35,8 @@ describe('agent session resume metadata', () => {
|
||||
['antigravity', { key: 'conversation_id', id: 's1' }, ['agy', '--conversation', 's1']],
|
||||
['opencode', { key: 'session_id', id: 's1' }, ['opencode', '--session', 's1']],
|
||||
['droid', { key: 'session_id', id: 's1' }, ['droid', '--resume', 's1']],
|
||||
['grok', { key: 'session_id', id: 's1' }, ['grok', '--resume', 's1']]
|
||||
['grok', { key: 'session_id', id: 's1' }, ['grok', '--resume', 's1']],
|
||||
['devin', { key: 'session_id', id: 'abc12345' }, ['devin', '--resume', 'abc12345']]
|
||||
] as const)('builds %s resume argv', (agent, providerSession, expected) => {
|
||||
expect(getAgentResumeArgv(agent, providerSession)).toEqual(expected)
|
||||
})
|
||||
@@ -44,4 +51,8 @@ describe('agent session resume metadata', () => {
|
||||
id: 'ok'
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects devin resume when provider session key is not session_id', () => {
|
||||
expect(getAgentResumeArgv('devin', { key: 'conversation_id', id: 'x' })).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -9,7 +9,8 @@ export const RESUMABLE_TUI_AGENTS = [
|
||||
'antigravity',
|
||||
'opencode',
|
||||
'droid',
|
||||
'grok'
|
||||
'grok',
|
||||
'devin'
|
||||
] as const satisfies readonly TuiAgent[]
|
||||
|
||||
export type ResumableTuiAgent = (typeof RESUMABLE_TUI_AGENTS)[number]
|
||||
@@ -122,6 +123,10 @@ export function extractAgentProviderSession(
|
||||
const id = readSessionId(payload, ['sessionId', 'session_id'])
|
||||
return id ? { key: 'session_id', id } : null
|
||||
}
|
||||
case 'devin': {
|
||||
const id = readSessionId(payload, ['session_id', 'sessionId'])
|
||||
return id ? { key: 'session_id', id } : null
|
||||
}
|
||||
case 'amp':
|
||||
case 'cursor':
|
||||
case 'pi':
|
||||
@@ -153,5 +158,7 @@ export function getAgentResumeArgv(
|
||||
return providerSession.key === 'session_id' ? ['droid', '--resume', id] : null
|
||||
case 'grok':
|
||||
return providerSession.key === 'session_id' ? ['grok', '--resume', id] : null
|
||||
case 'devin':
|
||||
return providerSession.key === 'session_id' ? ['devin', '--resume', id] : null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ export const AI_VAULT_AGENTS = [
|
||||
'opencode',
|
||||
'grok',
|
||||
'openclaw',
|
||||
'devin',
|
||||
'droid'
|
||||
] as const satisfies readonly TuiAgent[]
|
||||
|
||||
@@ -33,6 +34,7 @@ export const AI_VAULT_AGENT_LABELS = {
|
||||
opencode: 'OpenCode',
|
||||
grok: 'Grok',
|
||||
openclaw: 'OpenClaw',
|
||||
devin: 'Devin',
|
||||
droid: 'Droid'
|
||||
} as const satisfies Record<AiVaultAgent, string>
|
||||
|
||||
@@ -144,6 +146,7 @@ function buildAgentResumeInvocation(
|
||||
case 'gemini':
|
||||
case 'grok':
|
||||
case 'hermes':
|
||||
case 'devin':
|
||||
case 'openclaw':
|
||||
case 'droid':
|
||||
return `${baseCommand} --resume ${sessionArg}`
|
||||
|
||||
@@ -14,4 +14,10 @@ describe('synthetic agent titles', () => {
|
||||
expect(shouldDriveSyntheticAgentTitleFromHook('codex', 'working')).toBe(false)
|
||||
expect(shouldDriveSyntheticAgentTitleFromHook('codex', 'done')).toBe(true)
|
||||
})
|
||||
|
||||
it('provides Devin titles for hook-driven status updates', () => {
|
||||
expect(getSyntheticAgentTerminalTitle('devin', 'done')).toBe('Devin ready')
|
||||
expect(getSyntheticAgentTerminalTitle('devin', 'waiting')).toBe('Devin - action required')
|
||||
expect(shouldDriveSyntheticAgentTitleFromHook('devin', 'working')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -35,6 +35,11 @@ export const SYNTHETIC_AGENT_TITLE_PROFILES: Record<string, SyntheticAgentTitleP
|
||||
workingLabel: 'Hermes',
|
||||
permissionLabel: 'Hermes - action required',
|
||||
idleLabel: 'Hermes ready'
|
||||
},
|
||||
devin: {
|
||||
workingLabel: 'Devin',
|
||||
permissionLabel: 'Devin - action required',
|
||||
idleLabel: 'Devin ready'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -315,11 +315,10 @@ export const TUI_AGENT_CONFIG: Record<TuiAgent, TuiAgentConfig> = {
|
||||
detectCmd: 'devin',
|
||||
launchCmd: 'devin',
|
||||
expectedProcess: 'devin',
|
||||
// Why: `devin -- <prompt>` auto-submits the prompt (the issue's claim
|
||||
// that it pre-fills without submitting is incorrect per the official
|
||||
// docs at docs.devin.ai/cli/reference/commands). `stdin-after-start`
|
||||
// launches the REPL first, then pastes via bracketed paste so the
|
||||
// user can review before submitting — same as aider, goose, amp, etc.
|
||||
// Why: `devin -- <prompt>` auto-submits immediately (docs.devin.ai/cli).
|
||||
// `stdin-after-start` starts the REPL with no argv prompt; Orca then sends
|
||||
// `followupPrompt` to the PTY as plain input + Enter after startup (not
|
||||
// bracketed paste). Use `draftPrompt` / agent-paste-draft for review-before-send.
|
||||
promptInjectionMode: 'stdin-after-start'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,64 @@ describe('parseWorkspaceSession', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('preserves sleeping agent record origin across hydration', () => {
|
||||
const result = parseWorkspaceSession({
|
||||
activeRepoId: null,
|
||||
activeWorktreeId: null,
|
||||
activeTabId: null,
|
||||
tabsByWorktree: {},
|
||||
terminalLayoutsByTabId: {},
|
||||
sleepingAgentSessionsByPaneKey: {
|
||||
'tab1:pane-1': {
|
||||
paneKey: 'tab1:pane-1',
|
||||
tabId: 'tab1',
|
||||
worktreeId: 'wt',
|
||||
agent: 'devin',
|
||||
providerSession: { key: 'session_id', id: 'devin-session' },
|
||||
prompt: 'continue',
|
||||
state: 'working',
|
||||
capturedAt: 10,
|
||||
updatedAt: 9,
|
||||
origin: 'quit'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
expect(result.ok).toBe(true)
|
||||
if (result.ok) {
|
||||
expect(result.value.sleepingAgentSessionsByPaneKey?.['tab1:pane-1']?.origin).toBe('quit')
|
||||
}
|
||||
})
|
||||
|
||||
it('preserves legacy live sleeping agent origins across hydration', () => {
|
||||
const result = parseWorkspaceSession({
|
||||
activeRepoId: null,
|
||||
activeWorktreeId: null,
|
||||
activeTabId: null,
|
||||
tabsByWorktree: {},
|
||||
terminalLayoutsByTabId: {},
|
||||
sleepingAgentSessionsByPaneKey: {
|
||||
'tab1:pane-1': {
|
||||
paneKey: 'tab1:pane-1',
|
||||
tabId: 'tab1',
|
||||
worktreeId: 'wt',
|
||||
agent: 'codex',
|
||||
providerSession: { key: 'session_id', id: 'codex-session' },
|
||||
prompt: 'continue',
|
||||
state: 'working',
|
||||
capturedAt: 10,
|
||||
updatedAt: 9,
|
||||
origin: 'live'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
expect(result.ok).toBe(true)
|
||||
if (result.ok) {
|
||||
expect(result.value.sleepingAgentSessionsByPaneKey?.['tab1:pane-1']?.origin).toBe('live')
|
||||
}
|
||||
})
|
||||
|
||||
it('drops malformed sleeping agent resume records without failing the whole session', () => {
|
||||
const result = parseWorkspaceSession({
|
||||
activeRepoId: null,
|
||||
|
||||
Reference in New Issue
Block a user