Files
orca/src/shared/agent-status-run-capability.ts
T
Neil 4bdeff3ec3 chore: remove verified unused Orca code (#27175)
* chore: remove verified unused Orca code

* chore: remove translations orphaned by dead code cleanup
2026-10-10 02:01:24 -07:00

45 lines
1.5 KiB
TypeScript

export const AGENT_STATUS_RUNS_RUNTIME_CAPABILITY = 'agent-status.runs.v1' as const
export const AGENT_STATUS_CAPABILITIES = [AGENT_STATUS_RUNS_RUNTIME_CAPABILITY] as const
export type AgentStatusCapability = (typeof AGENT_STATUS_CAPABILITIES)[number]
const MAX_CAPABILITIES = 256
const MAX_CAPABILITY_LENGTH = 128
/** Encode the status capabilities independently from advertising them on any transport. */
export function serializeAgentStatusCapabilities(
capabilities: ReadonlySet<AgentStatusCapability>
): string[] {
return AGENT_STATUS_CAPABILITIES.filter((capability) => capabilities.has(capability))
}
/** Unknown capability strings are ignored so mixed-version peers remain compatible. */
export function deserializeAgentStatusCapabilities(
value: unknown
): Set<AgentStatusCapability> | null {
if (
!Array.isArray(value) ||
value.length > MAX_CAPABILITIES ||
!value.every(
(capability) =>
typeof capability === 'string' &&
capability.length > 0 &&
capability.length <= MAX_CAPABILITY_LENGTH
)
) {
return null
}
const capabilities = new Set<AgentStatusCapability>()
for (const capability of value) {
if (capability === AGENT_STATUS_RUNS_RUNTIME_CAPABILITY) {
capabilities.add(capability)
}
}
return capabilities
}
export function hasAgentStatusRunCapability(value: unknown): boolean {
return (
deserializeAgentStatusCapabilities(value)?.has(AGENT_STATUS_RUNS_RUNTIME_CAPABILITY) === true
)
}