speculative partial fix for typed configs

This commit is contained in:
Your Name
2026-04-06 21:10:58 +00:00
parent 1774abebe9
commit dd7190bf9c
9 changed files with 350 additions and 53 deletions
@@ -0,0 +1,115 @@
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { ProcessorRegistry } from './registry.js';
import { ToolMaskingProcessor } from '../processors/toolMaskingProcessor.js';
import { BlobDegradationProcessor } from '../processors/blobDegradationProcessor.js';
import { SemanticCompressionProcessor } from '../processors/semanticCompressionProcessor.js';
import { HistorySquashingProcessor } from '../processors/historySquashingProcessor.js';
import { StateSnapshotProcessor } from '../processors/stateSnapshotProcessor.js';
import { EmergencyTruncationProcessor } from '../processors/emergencyTruncationProcessor.js';
export function registerBuiltInProcessors() {
ProcessorRegistry.register({
id: 'ToolMaskingProcessor',
schema: {
type: 'object',
properties: {
processorId: { const: 'ToolMaskingProcessor' },
options: {
type: 'object',
properties: { stringLengthThresholdTokens: { type: 'number' } },
required: ['stringLengthThresholdTokens']
}
},
required: ['processorId', 'options']
},
create: (env, opts) => new ToolMaskingProcessor(env, opts as any)
});
ProcessorRegistry.register({
id: 'BlobDegradationProcessor',
schema: {
type: 'object',
properties: {
processorId: { const: 'BlobDegradationProcessor' },
options: { type: 'object' }
},
required: ['processorId']
},
create: (env) => new BlobDegradationProcessor(env)
});
ProcessorRegistry.register({
id: 'SemanticCompressionProcessor',
schema: {
type: 'object',
properties: {
processorId: { const: 'SemanticCompressionProcessor' },
options: {
type: 'object',
properties: { nodeThresholdTokens: { type: 'number' } },
required: ['nodeThresholdTokens']
}
},
required: ['processorId', 'options']
},
create: (env, opts) => new SemanticCompressionProcessor(env, opts as any)
});
ProcessorRegistry.register({
id: 'HistorySquashingProcessor',
schema: {
type: 'object',
properties: {
processorId: { const: 'HistorySquashingProcessor' },
options: {
type: 'object',
properties: { maxTokensPerNode: { type: 'number' } },
required: ['maxTokensPerNode']
}
},
required: ['processorId', 'options']
},
create: (env, opts) => new HistorySquashingProcessor(env, opts as any)
});
ProcessorRegistry.register({
id: 'StateSnapshotProcessor',
schema: {
type: 'object',
properties: {
processorId: { const: 'StateSnapshotProcessor' },
options: {
type: 'object',
properties: {
model: { type: 'string' },
systemInstruction: { type: 'string' },
triggerDeficitTokens: { type: 'number' }
}
}
},
required: ['processorId']
},
create: (env, opts) => StateSnapshotProcessor.create(env, opts as any)
});
ProcessorRegistry.register({
id: 'EmergencyTruncationProcessor',
schema: {
type: 'object',
properties: {
processorId: { const: 'EmergencyTruncationProcessor' },
options: { type: 'object' }
},
required: ['processorId']
},
create: (env, opts) => EmergencyTruncationProcessor.create(env, opts as any)
});
}
// Automatically register them upon import
registerBuiltInProcessors();