Evidence: check completeness with real observations
Check requirements against App-defined evidence semantics instead of treating a model saying it is done as a real receipt.
A Checklist selects a registered isSatisfied by requirement.kind. isSatisfied checks one item, isComplete checks all of them, and missing returns unmet requirements. An unknown kind is rejected; predicates must synchronously return boolean. The Kit does not infer that a file was delivered or a transaction was committed; the App must define those through real results.
EvidenceProjection narrows observations that carry sources by sourceIds. When nothing is selected, or the array is empty, the full evidence is kept, and unknown tools also keep their original observations; this is not the same as filtering by permission, which should happen before the source is read. The default tool selection reads toolId and then falls back to the tool the observation itself provides; the App can supply toolId() explicitly.
Progressive examples for the same business case
Check whether real material has been read
Beginner · Node.js
import { Evidence } from '@jangts/agent-core/kits/evidence';
type Observation = { sourceId: string; read: boolean };
type Requirement = { id: string; kind: 'source-read'; sourceId: string };
const checklist = Evidence.defineEvidenceChecklist<Observation, Requirement>([
{ kind: 'source-read', description: '资料读取已成功', isSatisfied: (seen, need) => seen.read && seen.sourceId === need.sourceId },
]);
console.log(checklist.isComplete({ observations: [{ sourceId: 'manual', read: true }], requirements: [{ id: 'need-manual', kind: 'source-read', sourceId: 'manual' }] }));import { Evidence } from '@jangts/agent-core/kits/evidence';
const checklist = Evidence.defineEvidenceChecklist([
{ kind: 'source-read', description: '资料读取已成功', isSatisfied: (seen, need) => seen.read && seen.sourceId === need.sourceId },
]);
console.log(checklist.isComplete({ observations: [{ sourceId: 'manual', read: true }], requirements: [{ id: 'need-manual', kind: 'source-read', sourceId: 'manual' }] }));Return gaps from the same checklist, then limit the sources used for review
Configuration · Node.js
import { Evidence } from '@jangts/agent-core/kits/evidence';
type Observation = { sourceId: string; read: boolean };
type Requirement = { id: string; kind: 'source-read'; sourceId: string };
const checklist = Evidence.defineEvidenceChecklist<Observation, Requirement>([
{ kind: 'source-read', description: '资料读取已成功', isSatisfied: (seen, need) => seen.read && seen.sourceId === need.sourceId },
]);
console.log(checklist.missing({ observations: [], requirements: [{ id: 'need-manual', kind: 'source-read', sourceId: 'manual' }] }));
type ToolObservation = { toolId: string; sources: { id: string; text: string }[] };
const projection = Evidence.defineEvidenceProjection<ToolObservation, { id: string; text: string }>({
sourceId: source => source.id,
providers: { search: { sources: row => row.sources, withSources: (row, sources) => ({ ...row, sources }) } },
});
console.log(projection.project({ observations: [{ toolId: 'search', sources: [{ id: 'manual', text: '使用指南' }, { id: 'faq', text: '常见问题' }] }], sourceIds: ['manual'] }));import { Evidence } from '@jangts/agent-core/kits/evidence';
const checklist = Evidence.defineEvidenceChecklist([
{ kind: 'source-read', description: '资料读取已成功', isSatisfied: (seen, need) => seen.read && seen.sourceId === need.sourceId },
]);
console.log(checklist.missing({ observations: [], requirements: [{ id: 'need-manual', kind: 'source-read', sourceId: 'manual' }] }));
const projection = Evidence.defineEvidenceProjection({
sourceId: source => source.id,
providers: { search: { sources: row => row.sources, withSources: (row, sources) => ({ ...row, sources }) } },
});
console.log(projection.project({ observations: [{ toolId: 'search', sources: [{ id: 'manual', text: '使用指南' }, { id: 'faq', text: '常见问题' }] }], sourceIds: ['manual'] }));