Skip to content
中文

contextSelectionCatalog ​

SUPPORT · constant · Runtime value

Import ​

ts
import { contextSelectionCatalog } from '@jangts/agent-core/support';
js
import { contextSelectionCatalog } from '@jangts/agent-core/support';

Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/context.

Definition ​

ts
const contextSelectionCatalog: { sequence: { validate: () => void; choose: ({ candidates }: SelectionInput) => Promise<SelectionResult>; }; fixed: { validate: (selection: ContextSelection) => void; choose: ({ selection, candidates }: SelectionInput) => Promise<SelectionResult>; }; auto: { validate: (selection: ContextSelection) => void; choose: ({ selection, candidates }: SelectionInput) => Promise<SelectionResult>; }; model: { validate: (selection: ContextSelection, selectors: readonly ContextSelector[]) => void; choose: (input: SelectionInput) => Promise<SelectionResult>; }; }

Field structure ​

FieldTypeRequiredDescription
sequence{ validate: () => void; choose: ({ candidates }: SelectionInput) => Promise<SelectionResult>; }RequiredSee the type definition and usage context.
fixed{ validate: (selection: ContextSelection) => void; choose: ({ selection, candidates }: SelectionInput) => Promise<SelectionResult>; }RequiredSee the type definition and usage context.
auto{ validate: (selection: ContextSelection) => void; choose: ({ selection, candidates }: SelectionInput) => Promise<SelectionResult>; }RequiredSee the type definition and usage context.
model{ validate: (selection: ContextSelection, selectors: readonly ContextSelector[]) => void; choose: (input: SelectionInput) => Promise<SelectionResult>; }RequiredSee the type definition and usage context.

Examples ​

Process in registered order ​

Beginner · Node.js

ts
import { Support } from '@jangts/agent-core';
Support.validateContextSelection({ mode: 'sequence' }, []);
console.log(Object.keys(Support.contextSelectionCatalog));
js
import { Support } from '@jangts/agent-core';
Support.validateContextSelection({ mode: 'sequence' }, []);
console.log(Object.keys(Support.contextSelectionCatalog));

Choose a policy per scenario with exact overrides ​

Configuration · Node.js

ts
import { Support } from '@jangts/agent-core';
const localOnly = { mode: 'fixed' as const, kind: 'trim' as const };
const preserveMore = { mode: 'auto' as const, maxTrimLossRatio: 0.1, reserveCalls: 2 };
Support.validateContextSelection(localOnly, []);
Support.validateContextSelection(preserveMore, []);
console.log(localOnly, preserveMore);
js
import { Support } from '@jangts/agent-core';
const localOnly = { mode: 'fixed', kind: 'trim' };
const preserveMore = { mode: 'auto', maxTrimLossRatio: 0.1, reserveCalls: 2 };
Support.validateContextSelection(localOnly, []);
Support.validateContextSelection(preserveMore, []);
console.log(localOnly, preserveMore);

API reference, usage examples and developer guides.