mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-22 09:17:33 -07:00
last minute tidies
This commit is contained in:
@@ -127,6 +127,44 @@ export function createMockEnvironment(
|
||||
* Creates a block of synthetic conversation history designed to consume a specific number of tokens.
|
||||
* Assumes roughly 4 characters per token for standard English text.
|
||||
*/
|
||||
import { InboxSnapshotImpl } from '../sidecar/inbox.js';
|
||||
import type { ContextWorkingBuffer, InboxMessage, ProcessArgs } from '../pipeline.js';
|
||||
|
||||
export class FakeContextWorkingBuffer implements ContextWorkingBuffer {
|
||||
readonly nodes: readonly ConcreteNode[];
|
||||
private readonly nodesById = new Map<string, ConcreteNode>();
|
||||
private readonly nodesByEpisode = new Map<string, ConcreteNode[]>();
|
||||
|
||||
constructor(nodes: readonly ConcreteNode[]) {
|
||||
this.nodes = nodes;
|
||||
for (const node of nodes) {
|
||||
this.nodesById.set(node.id, node);
|
||||
const parentId = node.logicalParentId || 'orphan';
|
||||
const epNodes = this.nodesByEpisode.get(parentId) || [];
|
||||
epNodes.push(node);
|
||||
this.nodesByEpisode.set(parentId, epNodes);
|
||||
}
|
||||
}
|
||||
|
||||
getPristineNode(id: string): ConcreteNode | undefined {
|
||||
return this.nodesById.get(id);
|
||||
}
|
||||
|
||||
getLineage(id: string): readonly ConcreteNode[] {
|
||||
const node = this.nodesById.get(id);
|
||||
if (!node) return [];
|
||||
return this.nodesByEpisode.get(node.logicalParentId || 'orphan') || [];
|
||||
}
|
||||
}
|
||||
|
||||
export function createMockProcessArgs(targets: ConcreteNode[], bufferNodes: ConcreteNode[] = [], inboxMessages: InboxMessage[] = []): ProcessArgs {
|
||||
return {
|
||||
targets,
|
||||
buffer: new FakeContextWorkingBuffer(bufferNodes.length ? bufferNodes : targets),
|
||||
inbox: new InboxSnapshotImpl(inboxMessages),
|
||||
};
|
||||
}
|
||||
|
||||
export function createSyntheticHistory(
|
||||
numTurns: number,
|
||||
tokensPerTurn: number,
|
||||
|
||||
Reference in New Issue
Block a user