defineReflectionLogSource
KIT · function · Runtime value
Build a reflection source over a log reader.
Coverage is reported as best-effort: a page is only complete when the reader exhausted the run without capture gaps or omitted issues, and every gap or issue code is surfaced instead of being silently dropped.
Import
import { defineReflectionLogSource } from '@jangts/agent-core/kits/reflection';import { defineReflectionLogSource } from '@jangts/agent-core/kits/reflection';Other public entry points:@jangts/agent-core/types, @jangts/agent-core/kits, @jangts/agent-core/kits/reflection.
Definition
Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
App | — | — |
Call
defineReflectionLogSource<App>(options: { reader: ReflectionLogReader; id: string; traceId?: string; authorize(context: OperationContext<App>): MaybePromise<void>; }): ReflectionSource<App>Build a reflection source over a log reader.
Coverage is reported as best-effort: a page is only complete when the reader exhausted the run without capture gaps or omitted issues, and every gap or issue code is surfaced instead of being silently dropped.
| Type parameter | Constraint | Default type |
|---|---|---|
App | — | — |
| Parameter | Type | Passing | Description |
|---|---|---|---|
options | { reader: ReflectionLogReader; id: string; traceId?: string; authorize(context: OperationContext<App>): MaybePromise<void>; } | Required | — |
Fields of options
| Field | Type | Required | Description |
|---|---|---|---|
reader | ReflectionLogReader | Required | See the type definition and usage context. |
id | string | Required | See the type definition and usage context. |
traceId | string | undefined | Optional | See the type definition and usage context. |
authorize | (context: OperationContext<App>) => MaybePromise<void> | Required | See the type definition and usage context. |
Returns: ReflectionSource<App>.
Return value structure
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Required | Read-only. See the type definition and usage context. |
description | string | Required | Read-only. See the type definition and usage context. |
authorize | (query: ReflectionQuery, context: OperationContext<App>) => MaybePromise<void> | Required | Guards one query; runs before any evidence is read. |
query | (query: ReflectionQuery, context: OperationContext<App>) => Promise<ReflectionPage> | Required | Returns one page; an invalid page shape aborts the reflection. |
Examples
- Log reflection: authorization metadata and evidence reports: The App supplies authorized evidence sources; the reflection task produces a sourced report through ordinary model and tool contracts.
Bind the reflection model, evidence source, and authorization
Beginner · Node.js
import { defineReflection } from '@jangts/agent-core/kits/reflection';
import type { ReflectionSource } from '@jangts/agent-core/kits/reflection';
import type { ModelRunner, OperationContext } from '@jangts/agent-core';
export function review<App>(model: ModelRunner, source: ReflectionSource<App>,
authorize: (question: string, context: OperationContext<App>) => Promise<void>) {
return defineReflection({ model, source, authorize,
maxCalls: 4, reserveCalls: 1, maxPages: 4, maxEvents: 64, maxEvidenceChars: 12000 });
}import { defineReflection } from '@jangts/agent-core/kits/reflection';
export function review(model, source, authorize) {
return defineReflection({ model, source, authorize,
maxCalls: 4, reserveCalls: 1, maxPages: 4, maxEvents: 64, maxEvidenceChars: 12000 });
}Build the same kind of evidence source from a log reader
Configuration · Node.js
The reader's directory scope, shutdown, and retention are managed by the App. The adapted source can be passed into the same defineReflection.
import { defineReflectionLogSource } from '@jangts/agent-core/kits/reflection';
import type { ReflectionLogReader } from '@jangts/agent-core/kits/reflection';
import type { OperationContext } from '@jangts/agent-core';
export function logSource<App>(reader: ReflectionLogReader, traceId: string,
authorize: (context: OperationContext<App>) => Promise<void>) {
return defineReflectionLogSource({ reader, traceId, id: 'authorized-history', authorize });
}import { defineReflectionLogSource } from '@jangts/agent-core/kits/reflection';
export function logSource(reader, traceId, authorize) {
return defineReflectionLogSource({ reader, traceId, id: 'authorized-history', authorize });
}