Skip to content
中文

ReflectionEvidence ​

KIT · interface · Type contract

Explicit metadata projection, not an arbitrary original event/payload.

Import ​

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

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

Definition ​

ts
interface ReflectionEvidence

Extends or implements: Partial< Pick<DiagnosticIdentity, (typeof reflectionIdentityFields)[number]> >.

Field structure ​

FieldTypeRequiredDescription
idstringRequiredRead-only. Evidence id cited by findings when they rely on this item.
runIdstringRequiredRead-only. Run the item belongs to; queries are scoped by run.
typestringRequiredRead-only. Evidence type, matched against ReflectionQuery.types.
occurredAtMsnumber | undefinedOptionalRead-only. See the type definition and usage context.
sequencenumber | undefinedOptionalRead-only. Ordering key inside the source; ascending.
stageIdstring | undefinedOptionalRead-only. See the type definition and usage context.
statusstring | undefinedOptionalRead-only. See the type definition and usage context.
codestring | undefinedOptionalRead-only. Error or protocol code recorded on the item.
callsnumber | undefinedOptionalRead-only. Model or tool calls represented by the item.
durationMsnumber | undefinedOptionalRead-only. See the type definition and usage context.
inputCharsnumber | undefinedOptionalRead-only. See the type definition and usage context.
outputCharsnumber | undefinedOptionalRead-only. See the type definition and usage context.
expiresAtMsnumber | undefinedOptionalRead-only. Instant after which the item is no longer retained by the source.
spanIdstring | undefinedOptionalRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.

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.