ScopeDescription
KIT · type · Type contract
Plain description with mutable arrays, for documentation and model-facing catalogs.
Import
ts
import type { ScopeDescription } from '@jangts/agent-core/kits/domains';js
/** @typedef {import('@jangts/agent-core/kits/domains').ScopeDescription} ScopeDescription */Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/kits/domains, @jangts/agent-core/kits.
Definition
Type: ScopeDescription<Definition>
Type expression
ts
type ScopeDescription<Definition extends ScopeDefinition> = Omit<
RegisteredScope<Definition>,
'goalIds' | 'queryScopeIds' | 'knowledgeTopicIds' | 'toolIds' | 'aliases' | 'evidence'
> & {
goalIds: string[];
queryScopeIds: string[];
knowledgeTopicIds: string[];
toolIds: string[];
aliases: string[];
evidence: RegisteredScopeEvidence<Definition>[];
};Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
Definition | ScopeDefinition | — |
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
id | Readonly<Omit<Readonly<ScopeDefinition & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ScopeListKey> & RegisteredScopeLists<Definition> & { evidence: ScopeEvidenceList<Definition>; }>["id"] | Required | Unique scope id, matched against the policy's idPattern when configured. |
description | Readonly<Omit<Readonly<ScopeDefinition & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ScopeListKey> & RegisteredScopeLists<Definition> & { evidence: ScopeEvidenceList<Definition>; }>["description"] | Required | Non-blank description. |
category | Readonly<Omit<Readonly<ScopeDefinition & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ScopeListKey> & RegisteredScopeLists<Definition> & { evidence: ScopeEvidenceList<Definition>; }>["category"] | Required | Scope category; validated against policy.categories when that is set. |
contextTier | Readonly<Omit<Readonly<ScopeDefinition & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ScopeListKey> & RegisteredScopeLists<Definition> & { evidence: ScopeEvidenceList<Definition>; }>["contextTier"] | undefined | Optional | App-declared context tier, passed through for the App's own policy. |
goalIds | string[] | Required | See the type definition and usage context. |
queryScopeIds | string[] | Required | See the type definition and usage context. |
knowledgeTopicIds | string[] | Required | See the type definition and usage context. |
toolIds | string[] | Required | See the type definition and usage context. |
aliases | string[] | Required | See the type definition and usage context. |
evidence | Readonly<RegistrationData<NonNullable<Definition["evidence"]>[number]>>[] | Required | See the type definition and usage context. |
Examples
- Domain Tools: tool declarations and scope relationships: One list provides the available tools, allowed delegates, scope aliases, sources, and tool relationships.
Register one tool that explains an interface
Beginner · Node.js
ts
import { IntentRegistry, ScopeRegistry } from '@jangts/agent-core/kits/domains';
const tools = IntentRegistry.create([
{ id: 'explain', description: '根据资料解释 SDK', delegates: ['read', 'reply'], asIntent: true },
]);
console.log(tools.ids(), tools.allows('explain', 'read'));
const scopes = ScopeRegistry.create([
{ id: 'sdk', description: 'SDK 说明资料', category: 'knowledge' },
]);
console.log(scopes.require('sdk').knowledgeTopicIds);js
import { IntentRegistry, ScopeRegistry } from '@jangts/agent-core/kits/domains';
const tools = IntentRegistry.create([
{ id: 'explain', description: '根据资料解释 SDK', delegates: ['read', 'reply'], asIntent: true },
]);
console.log(tools.ids(), tools.allows('explain', 'read'));
const scopes = ScopeRegistry.create([
{ id: 'sdk', description: 'SDK 说明资料', category: 'knowledge' },
]);
console.log(scopes.require('sdk').knowledgeTopicIds);Add constraints and scope relationships while keeping the same query entry
Configuration · Node.js
ts
import { IntentRegistry, ScopeRegistry } from '@jangts/agent-core/kits/domains';
const tools = new IntentRegistry({ idPattern: /^[a-z-]+$/, delegates: ['read', 'reply'] })
.registerAll([{ id: 'explain', description: '根据资料解释 SDK', delegates: ['read', 'reply'], asIntent: '用户希望了解 SDK 接口或用法。' }]).seal();
const scopes = ScopeRegistry.create([
{ id: 'sdk', description: 'SDK 说明资料', category: 'knowledge', aliases: ['agent-core'], goalIds: ['explain'], knowledgeTopicIds: ['manual'], toolIds: ['read-source'] },
], { categories: ['knowledge'], requireGoals: true, requireSources: true });
console.log(tools.describe(), scopes.normalize('agent-core'));
console.log(scopes.acceptsTool('agent-core', 'explain'), scopes.topics('sdk'));js
import { IntentRegistry, ScopeRegistry } from '@jangts/agent-core/kits/domains';
const tools = new IntentRegistry({ idPattern: /^[a-z-]+$/, delegates: ['read', 'reply'] })
.registerAll([{ id: 'explain', description: '根据资料解释 SDK', delegates: ['read', 'reply'], asIntent: '用户希望了解 SDK 接口或用法。' }]).seal();
const scopes = ScopeRegistry.create([
{ id: 'sdk', description: 'SDK 说明资料', category: 'knowledge', aliases: ['agent-core'], goalIds: ['explain'], knowledgeTopicIds: ['manual'], toolIds: ['read-source'] },
], { categories: ['knowledge'], requireGoals: true, requireSources: true });
console.log(tools.describe(), scopes.normalize('agent-core'));
console.log(scopes.acceptsTool('agent-core', 'explain'), scopes.topics('sdk'));