mirror of
https://github.com/stablyai/orca.git
synced 2026-10-02 16:02:15 +00:00
fix(agents): restore title-owner API after merge
This commit is contained in:
@@ -18,6 +18,11 @@ type TitleProfileMatch = {
|
||||
|
||||
type TitleLabelProfileMatch = Pick<TitleProfileMatch, 'profile'>
|
||||
|
||||
export type CompatibleAgentOwnerOptions = {
|
||||
/** Whether the owner comes from explicit launch intent. */
|
||||
ownerIsLaunch?: boolean
|
||||
}
|
||||
|
||||
const COMPATIBLE_IDLE_TITLE_RE = /(?<![\w./\\-])(?:ready|idle|done)(?![\w-])/i
|
||||
|
||||
/**
|
||||
@@ -114,7 +119,8 @@ function hasIdleSuffix(title: string, sourceProfile: SyntheticAgentTitleProfile)
|
||||
*/
|
||||
export function resolveCompatibleAgentTypeForOwner(
|
||||
incomingAgentType: AgentType | null | undefined,
|
||||
ownerAgentType: AgentType | null | undefined
|
||||
ownerAgentType: AgentType | null | undefined,
|
||||
_options?: CompatibleAgentOwnerOptions
|
||||
): AgentType | undefined {
|
||||
if (!incomingAgentType) {
|
||||
return undefined
|
||||
@@ -137,7 +143,8 @@ export function resolveCompatibleAgentTypeForOwner(
|
||||
*/
|
||||
export function normalizeCompatibleAgentTitleForOwner(
|
||||
title: string,
|
||||
ownerAgentType: AgentType | null | undefined
|
||||
ownerAgentType: AgentType | null | undefined,
|
||||
_options?: CompatibleAgentOwnerOptions
|
||||
): string {
|
||||
const ownerProfile = getSyntheticAgentTitleProfile(ownerAgentType)
|
||||
if (!ownerProfile?.titleIdentityGroup) {
|
||||
@@ -188,11 +195,16 @@ export function normalizeCompatibleAgentTitleForOwner(
|
||||
*/
|
||||
export function normalizeCompatibleAgentStatusEntryForOwner(
|
||||
entry: AgentStatusEntry,
|
||||
ownerAgentType: AgentType | null | undefined
|
||||
ownerAgentType: AgentType | null | undefined,
|
||||
options?: CompatibleAgentOwnerOptions
|
||||
): AgentStatusEntry {
|
||||
const agentType = resolveCompatibleAgentTypeForOwner(entry.agentType, ownerAgentType)
|
||||
const agentType = resolveCompatibleAgentTypeForOwner(entry.agentType, ownerAgentType, options)
|
||||
const terminalTitle = entry.terminalTitle
|
||||
? normalizeCompatibleAgentTitleForOwner(entry.terminalTitle, agentType ?? ownerAgentType)
|
||||
? normalizeCompatibleAgentTitleForOwner(
|
||||
entry.terminalTitle,
|
||||
agentType ?? ownerAgentType,
|
||||
options
|
||||
)
|
||||
: entry.terminalTitle
|
||||
if (agentType === entry.agentType && terminalTitle === entry.terminalTitle) {
|
||||
return entry
|
||||
@@ -203,3 +215,19 @@ export function normalizeCompatibleAgentStatusEntryForOwner(
|
||||
...(terminalTitle ? { terminalTitle } : {})
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns whether two agents share the same title identity group. */
|
||||
export function shareCompatibleTitleIdentityGroup(
|
||||
left: AgentType | null | undefined,
|
||||
right: AgentType | null | undefined
|
||||
): boolean {
|
||||
if (!left || !right) {
|
||||
return false
|
||||
}
|
||||
if (left === right) {
|
||||
return true
|
||||
}
|
||||
const leftGroup = getSyntheticAgentTitleProfile(left)?.titleIdentityGroup
|
||||
const rightGroup = getSyntheticAgentTitleProfile(right)?.titleIdentityGroup
|
||||
return Boolean(leftGroup && leftGroup === rightGroup)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user