mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-14 20:10:36 -07:00
e2c3d07c84
This commit acts on the design review feedback:
1. Eliminates dynamic JSON registry instantiation for pipelines.
2. Introduces TS ContextProfiles for strongly-typed declarative wiring.
3. Converts ContextProcessors to pure functions returned by factories (HOFs) holding local state via closures.
4. Converts ContextWorkers to simple {start, stop} lifecycle objects.
5. Removes now-obsolete registry and JSON parsing overhead from Orchestrator.
67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2026 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import type { SidecarConfig, PipelineDef } from './types.js';
|
|
import type { ContextEnvironment } from './environment.js';
|
|
import type { ContextWorker } from '../pipeline.js';
|
|
|
|
// Import factories
|
|
import { createToolMaskingProcessor } from '../processors/toolMaskingProcessor.js';
|
|
import { createBlobDegradationProcessor } from '../processors/blobDegradationProcessor.js';
|
|
import { createNodeTruncationProcessor } from '../processors/nodeTruncationProcessor.js';
|
|
import { createNodeDistillationProcessor } from '../processors/nodeDistillationProcessor.js';
|
|
import { createStateSnapshotProcessor } from '../processors/stateSnapshotProcessor.js';
|
|
import { createStateSnapshotWorker } from '../processors/stateSnapshotWorker.js';
|
|
|
|
export interface ContextProfile {
|
|
config: SidecarConfig;
|
|
buildPipelines: (env: ContextEnvironment) => PipelineDef[];
|
|
buildWorkers: (env: ContextEnvironment) => ContextWorker[];
|
|
}
|
|
|
|
/**
|
|
* The standard default context management profile.
|
|
* Optimized for safety, precision, and reliable summarization.
|
|
*/
|
|
export const defaultSidecarProfile: ContextProfile = {
|
|
config: {
|
|
budget: {
|
|
retainedTokens: 65000,
|
|
maxTokens: 150000,
|
|
},
|
|
},
|
|
|
|
buildPipelines: (env: ContextEnvironment): PipelineDef[] => [
|
|
{
|
|
name: 'Immediate Sanitization',
|
|
triggers: ['new_message'],
|
|
processors: [
|
|
createToolMaskingProcessor('ToolMasking', env, { stringLengthThresholdTokens: 8000 }),
|
|
createBlobDegradationProcessor('BlobDegradation', env),
|
|
],
|
|
},
|
|
{
|
|
name: 'Normalization',
|
|
triggers: ['retained_exceeded'],
|
|
processors: [
|
|
createNodeTruncationProcessor('NodeTruncation', env, { maxTokensPerNode: 3000 }),
|
|
createNodeDistillationProcessor('NodeDistillation', env, { nodeThresholdTokens: 5000 }),
|
|
],
|
|
},
|
|
{
|
|
name: 'Emergency Backstop',
|
|
triggers: ['gc_backstop'],
|
|
processors: [
|
|
createStateSnapshotProcessor('StateSnapshotSync', env, { target: 'max' }),
|
|
],
|
|
},
|
|
],
|
|
|
|
buildWorkers: (env: ContextEnvironment): ContextWorker[] => [
|
|
createStateSnapshotWorker('StateSnapshotAsync', env, { type: 'accumulate' })
|
|
]
|
|
};
|