Skip to content
中文

ReflectionLogReader ​

KIT · interface · Type contract

Structural port: the App supplies its own FileLogReader, trusted scope and current authorization.

Import ​

ts
import type { ReflectionLogReader } from '@jangts/agent-core/kits/reflection';
js
/** @typedef {import('@jangts/agent-core/kits/reflection').ReflectionLogReader} ReflectionLogReader */

Other public entry points:@jangts/agent-core/types, @jangts/agent-core/kits, @jangts/agent-core/kits/reflection.

Definition ​

ts
interface ReflectionLogReader

Field structure ​

FieldTypeRequiredDescription
listRuns(query: { traceId?: string; cursor?: string; limit?: number; signal?: AbortSignal; }) => Promise<Page<{ path: string; manifest: Readonly<Record<string, unknown>>; }>>RequiredList runs the caller may inspect.
readEvents(query: { run: string; sources?: readonly ("app" | "core" | "client")[]; types?: readonly string[]; cursor?: string; limit?: number; signal?: AbortSignal; }) => Promise<Page<Record<string, unknown>>>RequiredRead the events of one run.

Member index ​

MemberPurpose
listRunsList runs the caller may inspect.
readEventsRead the events of one run.

Member details ​

listRuns ​

List runs the caller may inspect.

ts
ReflectionLogReader.listRuns(query: { traceId?: string; cursor?: string; limit?: number; signal?: AbortSignal; }): Promise<Page<{ path: string; manifest: Readonly<Record<string, unknown>>; }>>

List runs the caller may inspect.

ParameterTypePassingDescription
query{ traceId?: string; cursor?: string; limit?: number; signal?: AbortSignal; }Required—
Fields of query
FieldTypeRequiredDescription
traceIdstring | undefinedOptionalSee the type definition and usage context.
cursorstring | undefinedOptionalSee the type definition and usage context.
limitnumber | undefinedOptionalSee the type definition and usage context.
signalAbortSignal | undefinedOptionalSee the type definition and usage context.

Returns: Promise<Page<{ path: string; manifest: Readonly<Record<string, unknown>>; }>>.

Awaited value: Page<{ path: string; manifest: Readonly<Record<string, unknown>>; }>.

Return value structure
FieldTypeRequiredDescription
items{ path: string; manifest: Readonly<Record<string, unknown>>; }[]RequiredSee the type definition and usage context.
statusstringRequiredSee the type definition and usage context.
cursorstring | undefinedOptionalSee the type definition and usage context.
issues{ code: string; }[]RequiredSee the type definition and usage context.
issuesOmittednumberRequiredSee the type definition and usage context.
coverage{ exhausted: boolean; captureIncomplete?: boolean; }RequiredSee the type definition and usage context.

readEvents ​

Read the events of one run.

ts
ReflectionLogReader.readEvents(query: { run: string; sources?: readonly ("app" | "core" | "client")[]; types?: readonly string[]; cursor?: string; limit?: number; signal?: AbortSignal; }): Promise<Page<Record<string, unknown>>>

Read the events of one run.

ParameterTypePassingDescription
query{ run: string; sources?: readonly ("app" | "core" | "client")[]; types?: readonly string[]; cursor?: string; limit?: number; signal?: AbortSignal; }Required—
Fields of query
FieldTypeRequiredDescription
runstringRequiredSee the type definition and usage context.
sourcesreadonly ("app" | "core" | "client")[] | undefinedOptionalSee the type definition and usage context.
typesreadonly string[] | undefinedOptionalSee the type definition and usage context.
cursorstring | undefinedOptionalSee the type definition and usage context.
limitnumber | undefinedOptionalSee the type definition and usage context.
signalAbortSignal | undefinedOptionalSee the type definition and usage context.

Returns: Promise<Page<Record<string, unknown>>>.

Awaited value: Page<Record<string, unknown>>.

Return value structure
FieldTypeRequiredDescription
itemsRecord<string, unknown>[]RequiredSee the type definition and usage context.
statusstringRequiredSee the type definition and usage context.
cursorstring | undefinedOptionalSee the type definition and usage context.
issues{ code: string; }[]RequiredSee the type definition and usage context.
issuesOmittednumberRequiredSee the type definition and usage context.
coverage{ exhausted: boolean; captureIncomplete?: boolean; }RequiredSee the type definition and usage context.

Examples ​

Bind the reflection model, evidence source, and authorization ​

Beginner · Node.js

ts
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 });
}
js
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.

ts
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 });
}
js
import { defineReflectionLogSource } from '@jangts/agent-core/kits/reflection';
export function logSource(reader, traceId, authorize) {
    return defineReflectionLogSource({ reader, traceId, id: 'authorized-history', authorize });
}

API reference, usage examples and developer guides.