mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-20 00:32:31 -07:00
32 lines
916 B
TypeScript
32 lines
916 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2026 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import type { Content } from '@google/genai';
|
|
import type { Episode, ConcreteNode } from './types.js';
|
|
import { toIr } from './toIr.js';
|
|
import { fromIr } from './fromIr.js';
|
|
import type { ContextTokenCalculator } from '../utils/contextTokenCalculator.js';
|
|
|
|
export class IrMapper {
|
|
/**
|
|
* Translates a flat Gemini Content[] array into our rich Episodic Intermediate Representation.
|
|
* Groups adjacent function calls and responses into unified ToolExecution nodes.
|
|
*/
|
|
static toIr(
|
|
history: readonly Content[],
|
|
tokenCalculator: ContextTokenCalculator,
|
|
): Episode[] {
|
|
return toIr(history, tokenCalculator);
|
|
}
|
|
|
|
/**
|
|
* Re-serializes a flat array of ConcreteNodes back into a flat Gemini Content[] array.
|
|
*/
|
|
static fromIr(ship: readonly ConcreteNode[]): Content[] {
|
|
return fromIr(ship);
|
|
}
|
|
}
|