2026-04-06 21:10:58 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2026 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
2026-04-07 04:46:04 +00:00
|
|
|
|
2026-04-07 04:03:54 +00:00
|
|
|
import type { ProcessorRegistry } from './registry.js';
|
2026-04-06 21:10:58 +00:00
|
|
|
import './builtins.js';
|
|
|
|
|
|
2026-04-07 03:58:50 +00:00
|
|
|
export function getSidecarConfigSchema(registry: ProcessorRegistry) {
|
|
|
|
|
return {
|
2026-04-07 04:46:04 +00:00
|
|
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
|
|
|
title: 'SidecarConfig',
|
|
|
|
|
description: 'The Data-Driven Schema for the Context Manager.',
|
|
|
|
|
type: 'object',
|
|
|
|
|
required: ['budget', 'gcBackstop', 'pipelines'],
|
2026-04-07 03:58:50 +00:00
|
|
|
properties: {
|
|
|
|
|
budget: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'object',
|
|
|
|
|
description: 'Defines the token ceilings and limits for the pipeline.',
|
|
|
|
|
required: ['retainedTokens', 'maxTokens'],
|
2026-04-06 21:10:58 +00:00
|
|
|
properties: {
|
2026-04-07 03:58:50 +00:00
|
|
|
retainedTokens: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'number',
|
|
|
|
|
description:
|
|
|
|
|
'The ideal token count the pipeline tries to shrink down to.',
|
2026-04-06 21:10:58 +00:00
|
|
|
},
|
2026-04-07 03:58:50 +00:00
|
|
|
maxTokens: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'number',
|
|
|
|
|
description:
|
|
|
|
|
'The absolute maximum token count allowed before synchronous truncation kicks in.',
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-04-07 03:58:50 +00:00
|
|
|
},
|
|
|
|
|
gcBackstop: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'object',
|
|
|
|
|
description:
|
|
|
|
|
"Defines what happens when the pipeline fails to compress under 'maxTokens'",
|
|
|
|
|
required: ['strategy', 'target'],
|
2026-04-07 03:58:50 +00:00
|
|
|
properties: {
|
|
|
|
|
strategy: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'string',
|
|
|
|
|
enum: ['truncate', 'compress', 'rollingSummarizer'],
|
2026-04-06 21:10:58 +00:00
|
|
|
},
|
2026-04-07 03:58:50 +00:00
|
|
|
target: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'string',
|
|
|
|
|
enum: ['incremental', 'freeNTokens', 'max'],
|
2026-04-06 21:10:58 +00:00
|
|
|
},
|
2026-04-07 03:58:50 +00:00
|
|
|
freeTokensTarget: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'number',
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-04-07 03:58:50 +00:00
|
|
|
},
|
|
|
|
|
pipelines: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'array',
|
|
|
|
|
description: 'The execution graphs for context manipulation.',
|
2026-04-07 03:58:50 +00:00
|
|
|
items: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'object',
|
|
|
|
|
required: ['name', 'triggers', 'execution', 'processors'],
|
2026-04-07 03:58:50 +00:00
|
|
|
properties: {
|
|
|
|
|
name: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'string',
|
2026-04-07 03:58:50 +00:00
|
|
|
},
|
|
|
|
|
triggers: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'array',
|
2026-04-07 03:58:50 +00:00
|
|
|
items: {
|
|
|
|
|
anyOf: [
|
|
|
|
|
{
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'string',
|
|
|
|
|
enum: ['on_turn', 'post_turn', 'budget_exceeded'],
|
2026-04-07 03:58:50 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'object',
|
|
|
|
|
required: ['type', 'intervalMs'],
|
2026-04-07 03:58:50 +00:00
|
|
|
properties: {
|
|
|
|
|
type: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'string',
|
|
|
|
|
const: 'timer',
|
2026-04-07 03:58:50 +00:00
|
|
|
},
|
|
|
|
|
intervalMs: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'number',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2026-04-07 03:58:50 +00:00
|
|
|
},
|
|
|
|
|
execution: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'string',
|
|
|
|
|
enum: ['blocking', 'background'],
|
2026-04-07 03:58:50 +00:00
|
|
|
},
|
|
|
|
|
processors: {
|
2026-04-07 04:46:04 +00:00
|
|
|
type: 'array',
|
2026-04-07 03:58:50 +00:00
|
|
|
items: {
|
2026-04-07 04:46:04 +00:00
|
|
|
oneOf: registry.getSchemas(),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-04-07 03:58:50 +00:00
|
|
|
};
|
|
|
|
|
}
|