UNPKG

agentlang

Version:

The easiest way to build the most reliable AI agents - enterprise-grade teams of AI agents that collaborate with each other and humans

545 lines 26.8 kB
import { Statement, RelNodes, PropertyDefinition, RecordSchemaDefinition, Expr, RbacSpecEntries, WorkflowHeader } from '../language/generated/ast.js'; import { Path, CrudType } from './util.js'; import { ActiveSessionInfo } from './auth/defs.js'; import { FkSpec } from './defs.js'; import { CasePattern } from '../language/syntax.js'; import { AgentCondition, AgentGlossaryEntry, AgentScenario } from './agents/common.js'; import { Environment } from './interpreter.js'; export declare class ModuleEntry { name: string; moduleName: string; private taggedAsPublic; constructor(name: string, moduleName: string); getFqName(): string; setPublic(flag: boolean): ModuleEntry; isPublic(): boolean; } export type AttributeSpec = { type: string; properties?: Map<string, any> | undefined; }; export type RecordSchema = Map<string, AttributeSpec>; export declare function newRecordSchema(): RecordSchema; type Meta = Map<string, any>; export declare function newMeta(): Meta; export declare enum RecordType { RECORD = 0, ENTITY = 1, EVENT = 2, RELATIONSHIP = 3, AGENT = 4 } export type TriggerInfo = { eventName: string; async: boolean; }; export declare function enumAttributeSpec(values: Set<string>): AttributeSpec; export declare function oneOfAttributeSpec(ref: string): AttributeSpec; export declare class Record extends ModuleEntry { schema: RecordSchema; meta: Meta | undefined; type: RecordType; parentEntryName: string | undefined; afterTriggers: Map<CrudType, TriggerInfo> | undefined; beforeTriggers: Map<CrudType, TriggerInfo> | undefined; compositeUqAttributes: Array<string> | undefined; oneOfRefAttributes: Array<string> | undefined; protected rbac: RbacSpecification[] | undefined; constructor(name: string, moduleName: string, scm?: RecordSchemaDefinition, parentEntryName?: string); protected addMetaAttributes(): Record; private addOneOfRefAttribute; addAfterTrigger(te: any): Record; addBeforeTrigger(te: any): Record; getCompositeUniqueAttributes(): Array<string> | undefined; getPreTriggerInfo(crudType: CrudType): TriggerInfo | undefined; getPostTriggerInfo(crudType: CrudType): TriggerInfo | undefined; addMeta(k: string, v: any): void; getMeta(k: string): any; getFullTextSearchAttributes(): string[] | undefined; addAttribute(n: string, attrSpec: AttributeSpec): Record; removeAttribute(n: string): Record; reorderAttributes(desiredOrder: string[]): void; addSystemAttribute(n: string, attrSpec: AttributeSpec): Record; findAttribute(predic: Function): AttributeEntry | undefined; hasRefTo(modName: string, entryName: string): boolean; getRefOnAttribute(attrName: string): [string, string] | undefined; getIdAttributeName(): string | undefined; getFkAttributeSpecs(): FkSpec[]; toString(): string; toString_(internParentSchema?: boolean): string; getUserAttributes(): RecordSchema; getUserAttributeNames(): string[]; } export declare const PlaceholderRecordEntry: Record; export declare enum RbacPermissionFlag { CREATE = 0, READ = 1, UPDATE = 2, DELETE = 3 } type RbacExpression = { lhs: string; rhs: string; }; export declare class RbacSpecification { private static EmptyRoles; resource: string; roles: Set<string>; permissions: Set<RbacPermissionFlag>; expression: RbacExpression | undefined; constructor(); static from(def: RbacSpecEntries): RbacSpecification; setResource(s: string): RbacSpecification; hasResource(): boolean; setPermissions(perms: Array<string>): RbacSpecification; hasPermissions(): boolean; hasCreatePermission(): boolean; hasReadPermission(): boolean; hasUpdatePermission(): boolean; hasDeletePermission(): boolean; setRoles(roles: Array<string>): RbacSpecification; removeRoles(): RbacSpecification; setExpression(lhs: string, rhs: string): RbacSpecification; removeExpression(): RbacSpecification; toString(): string; } export declare class Agent extends Record { type: RecordType; attributes: InstanceAttributes; constructor(name: string, moduleName: string, attrs?: InstanceAttributes); setName(n: string): Agent; setLLM(llm: string): Agent; getLLM(): string; private removeAgentAttribute; removeLLM(): Agent; setInstruction(s: string): Agent; getInstruction(): string; removeInstruction(): Agent; setType(type: 'chat' | 'planner'): Agent; getType(): string; removeType(): Agent; private setStrings; private getStrings; setTools(tools: string[]): Agent; getTools(): string[] | undefined; removeTools(): Agent; setDocuments(docs: string[]): Agent; getDocuments(): string[] | undefined; removeDocuments(): Agent; setFlows(flows: string[]): Agent; getFlows(): string[] | undefined; getAgentFqName(): string; setDirectives(conds: AgentCondition[]): Agent; removeDirectives(): Agent; getDirectives(): AgentCondition[] | undefined; setScenarios(scenarios: AgentScenario[]): Agent; getScenarios(): AgentScenario[] | undefined; removeScenarios(): Agent; setGlossary(glossary: AgentGlossaryEntry[]): Agent; getGlossary(): AgentGlossaryEntry[] | undefined; removeGlossary(): Agent; setResponseSchema(entryName: string): Agent; getResponseSchema(): string | undefined; removeResponseSchema(): Agent; toString(): string; static Suffix: string; static EscapeName(n: string): string; static NormalizeName(n: string): string; getName(): string; } export declare class Entity extends Record { type: RecordType; constructor(name: string, moduleName: string, scm?: RecordSchemaDefinition, parentEntryName?: string); setRbacSpecifications(rbac: RbacSpecification[]): Entity; getRbacSpecifications(): RbacSpecification[] | undefined; isConfigEntity(): boolean; } export declare class Event extends Record { type: RecordType; isSystemDefined(): boolean; } declare enum RelType { CONTAINS = 0, BETWEEN = 1 } export type RelationshipNode = { path: Path; alias: string; origName: string; origAlias: string | undefined; }; export declare function newRelNodeEntry(nodeFqName: string, alias?: string): RelationshipNode; export declare class Relationship extends Record { type: RecordType; relType: RelType; node1: RelationshipNode; node2: RelationshipNode; properties: Map<string, any> | undefined; constructor(name: string, typ: string, node1: RelationshipNode, node2: RelationshipNode, moduleName: string, scm?: RecordSchemaDefinition, props?: Map<string, any>); private updateSchemaWithNodeAttributes; joinNodesAttributeName(): string; setBetweenRef(inst: Instance, refPath: string, isQuery?: boolean): void; isContains(): boolean; isBetween(): boolean; parentNode(): RelationshipNode; childNode(): RelationshipNode; hasBooleanFlagSet(flag: string): boolean; private setProperty; isOneToOne(): boolean; isOneToMany(): boolean; isManyToMany(): boolean; setOneToOne(flag?: boolean): Relationship; setOneToMany(flag?: boolean): Relationship; setManyToMany(flag?: boolean): Relationship; isFirstNode(inst: Instance): boolean; getAliasFor(inst: Instance): string; getInverseAliasFor(inst: Instance): string; isFirstNodeName(fqName: string): boolean; getAliasForName(fqName: string): string; getInverseAliasForName(fqName: string): string; isParent(inst: Instance): boolean; getParentFqName(): string; getChildFqName(): string; toString(): string; } export declare class Workflow extends ModuleEntry { statements: Statement[]; isPrePost: boolean; constructor(name: string, patterns: Statement[], moduleName: string, isPrePost?: boolean); addStatement(stmtCode: string): Promise<Workflow>; setStatementAtHelper(statements: Statement[], newStmt: Statement | undefined, index: number[]): Workflow; setStatementAt(stmtCode: string, index: number | number[]): Promise<Workflow>; removeStatementAt(index: number | number[]): Workflow; private statementsToStringsHelper; statementsToStrings(): string[]; setPublic(flag: boolean): ModuleEntry; toString(): string; } export type FlowGraphNode = { label: string; type: 'action' | 'condition'; on?: string[] | undefined; next: string[]; }; export declare class Flow extends ModuleEntry { flowSteps: string[]; constructor(name: string, moduleName: string, flow?: string); getFlow(): string; removeStep(index: number): Flow; insertStep(index: number, s: string): Flow; appendStep(s: string): Flow; stepsCount(): number; toGraph(): FlowGraphNode[]; static asFlowName(n: string): string; static normaliseFlowName(n: string): string; toString(): string; } export declare class Scenario extends ModuleEntry { def: AgentScenario; constructor(name: string, moduleName: string, scn: AgentScenario); toString(): string; } export declare class Directive extends ModuleEntry { private def; constructor(name: string, moduleName: string, def: AgentCondition); toString(): string; } export declare class GlossaryEntry extends ModuleEntry { private def; constructor(name: string, moduleName: string, def: AgentGlossaryEntry); toString(): string; } export declare function flowGraphNext(graph: FlowGraphNode[], currentNode?: FlowGraphNode, onCondition?: string): FlowGraphNode | undefined; type BackoffStrategy = 'e' | 'l' | 'c'; type BackoffMagnitude = 'ms' | 's' | 'm'; export type RetryBackoff = { strategy: BackoffStrategy | undefined; delay: number | undefined; magnitude: BackoffMagnitude | undefined; factor: number | undefined; }; export declare class Retry extends ModuleEntry { attempts: number; private backoff; constructor(name: string, moduleName: string, attempts: number); setExponentialBackoff(): Retry; isExponentialBackoff(): boolean; setLinearBackoff(): Retry; isLinearBackoff(): boolean; setConstantBackoff(): Retry; isConstantBackoff(): boolean; setBackoffDelay(n: number): Retry; setBackoffMagnitudeAsMilliseconds(): Retry; backoffMagnitudeIsMilliseconds(): boolean; setBackoffMagnitudeAsSeconds(): Retry; backoffMagnitudeIsSeconds(): boolean; setBackoffMagnitudeAsMinutes(): Retry; backoffMagnitudeIsMinutes(): boolean; setBackoffFactor(n: number): Retry; getNextDelayMs(attempt: number): number; private normalizeDelay; private backoffToString; toString(): string; } export declare class Decision extends ModuleEntry { cases: string[]; constructor(name: string, moduleName: string, cases: string[]); casePatterns(): Promise<CasePattern[]>; joinedCases(): string; toString(): string; } declare class StandaloneStatement extends ModuleEntry { stmt: Statement; constructor(stmt: Statement, moduleName: string); toString(): string; } export declare function isEmptyWorkflow(wf: Workflow): boolean; export declare class Module { name: string; entries: ModuleEntry[]; constructor(name: string); addEntry(entry: ModuleEntry): ModuleEntry; getConfigEntity(): Entity | undefined; addAgent(agentEntry: Agent): Agent; getAgent(agentName: string): Agent | undefined; removeAgent(agentName: string): boolean; addFlow(name: string, flowString?: string): Flow; getFlow(name: string): Flow | undefined; getAllFlows(): Flow[]; removeFlow(name: string): boolean; addRawDecision(name: string, cases: string[]): Decision; addDecision(decision: Decision): Module; getDecision(name: string): Decision | undefined; getAllDecisions(): Decision[]; getAllDecisionsForAgent(agentName: string): Decision[]; removeDecision(name: string): boolean; addScenario(name: string, scn: AgentScenario): Scenario; getScenario(name: string): Scenario | undefined; getAllScenarios(): Scenario[]; getAllScenariosForAgent(agentName: string): Scenario[]; removeScenario(name: string): Module; addDirective(name: string, cond: AgentCondition): Directive; getDirective(name: string): Directive | undefined; getAllDirectives(): Directive[]; getAllDirectivesForAgent(agentName: string): Directive[]; removeDirective(name: string): Module; addGlossaryEntry(name: string, ge: AgentGlossaryEntry): GlossaryEntry; getGlossaryEntry(name: string): GlossaryEntry | undefined; getAllGlossaryEntries(): GlossaryEntry[]; getAllGlossaryEntriesForAgent(agentName: string): GlossaryEntry[]; removeGlossaryEntry(name: string): Module; addRetry(retry: Retry): Module; getRetry(name: string): Retry | undefined; addStandaloneStatement(stmt: Statement): StandaloneStatement; getStandaloneStatement(name: string): StandaloneStatement | undefined; private getEntryIndex; hasEntry(entryName: string): boolean; getEntry(entryName: string): ModuleEntry; getEntrySafe(entryName: string): ModuleEntry | undefined; getRecord(recordName: string): Record; removeEntry(entryName: string): boolean; removeEvent(name: string): boolean; private getEntriesOfType; getEntityEntries(): Entity[]; getEventEntries(): Event[]; getRecordEntries(): Record[]; getAgents(): Agent[]; getAgentNames(): string[]; getRelationshipEntries(): Relationship[]; private getRelationshipEntriesOfType; getBetweenRelationshipEntries(): Relationship[]; getContainsRelationshipEntries(): Relationship[]; getBetweenRelationshipEntriesThatNeedStore(): Relationship[]; getWorkflowForEvent(eventName: string): Workflow | undefined; eventIsPublic(eventName: string): boolean; isPrePostEvent(eventName: string): boolean; isEntryOfType(t: RecordType, name: string): boolean; isEntity(name: string): boolean; isEvent(name: string): boolean; isRecord(name: string): boolean; isRelationship(name: string): boolean; getEntityNames(): string[]; getEventNames(): string[]; getRecordNames(): string[]; getRelationshipNames(): string[]; isContainsRelationship(entryName: string): boolean; isBetweenRelationship(entryName: string): boolean; toString(): string; } declare global { var al_moduleDb: Map<string, Module> | undefined; } export declare function getActiveModuleName(): string; export declare function addModule(name: string): Module; export declare function removeModule(name: string): boolean; export declare function getModuleNames(): string[]; export declare function getUserModuleNames(): string[]; export declare function isModule(name: string): boolean; export declare function fetchModule(moduleName: string): Module; export declare function allModuleNames(): string[]; export declare function fetchModuleEntry(entryName: string, moduleName: string): ModuleEntry; export declare const builtInTypes: Set<string>; export declare const propertyNames: Set<string>; export declare function isBuiltInType(type: string): boolean; export declare function isValidType(type: string): boolean; export declare function defaultAttributes(schema: RecordSchema): Map<string, any>; export declare function passwordAttributes(schema: RecordSchema): Set<string> | undefined; export declare function objectAttributes(schema: RecordSchema): Array<string> | undefined; export declare function isIdAttribute(attrSpec: AttributeSpec): boolean; export declare function asIdAttribute(attrSpec: AttributeSpec): AttributeSpec; export declare function isUniqueAttribute(attrSpec: AttributeSpec): boolean; export declare function asUniqueAttribute(attrSpec: AttributeSpec): AttributeSpec; export declare function isIndexedAttribute(attrSpec: AttributeSpec): boolean; export declare function asIndexedAttribute(attrSpec: AttributeSpec): AttributeSpec; export declare function isOptionalAttribute(attrSpec: AttributeSpec): boolean; export declare function asOptionalAttribute(attrSpec: AttributeSpec): AttributeSpec; export declare function isArrayAttribute(attrSpec: AttributeSpec): boolean; export declare function isObjectAttribute(attrSpec: AttributeSpec): boolean; export declare function isNumericAttribute(attrSpec: AttributeSpec): boolean; export declare function getAttributeExpr(attrSpec: AttributeSpec): Expr | undefined; export declare function getEnumValues(attrSpec: AttributeSpec): Set<string> | undefined; export declare function getOneOfRef(attrSpec: AttributeSpec): string | undefined; export declare function getAttributeDefaultValue(attrSpec: AttributeSpec): any | undefined; export declare function setDefaultAttributeValue(attrSpec: AttributeSpec, value: any): AttributeSpec; export declare function getAttributeLength(attrSpec: AttributeSpec): number | undefined; export declare function getFkSpec(attrSpec: AttributeSpec): string | undefined; export declare function getRefSpec(attrSpec: AttributeSpec): string | undefined; export declare function addEntity(name: string, moduleName?: string, scm?: RecordSchemaDefinition, ext?: string): Entity; export declare function addEvent(name: string, moduleName?: string, scm?: RecordSchemaDefinition, ext?: string): Event; export declare function addRecord(name: string, moduleName?: string, scm?: RecordSchemaDefinition, ext?: string): Record; export declare function addRelationship(name: string, type: 'contains' | 'between', nodes: RelNodes | RelationshipNode[], moduleName?: string, scm?: RecordSchemaDefinition, props?: PropertyDefinition[]): Relationship; export declare function addBetweenRelationship(name: string, moduleName: string, nodes: RelationshipNode[]): Relationship; export declare function addContainsRelationship(name: string, moduleName: string, nodes: RelationshipNode[]): Relationship; export declare function addAgent(name: string, attrs: InstanceAttributes, moduleName: string): Agent; export type PrePostTag = '@after' | '@before'; export type PrePostOpr = 'create' | 'update' | 'delete'; export type ThinWfHeader = { tag: PrePostTag; prefix: PrePostOpr; name: string; }; export declare function addWorkflow(name: string, moduleName?: string, statements?: Statement[], hdr?: WorkflowHeader | ThinWfHeader, ispub?: boolean): Workflow; export declare function addAfterCreateWorkflow(entityName: string, moduleName?: string, statements?: Statement[]): Workflow; export declare function addAfterUpdateWorkflow(entityName: string, moduleName?: string, statements?: Statement[]): Workflow; export declare function addAfterDeleteWorkflow(entityName: string, moduleName?: string, statements?: Statement[]): Workflow; export declare function addBeforeCreateWorkflow(entityName: string, moduleName?: string, statements?: Statement[]): Workflow; export declare function addBeforeUpdateWorkflow(entityName: string, moduleName?: string, statements?: Statement[]): Workflow; export declare function addBeforeDeleteWorkflow(entityName: string, moduleName?: string, statements?: Statement[]): Workflow; export declare function prePostWorkflowName(tag: PrePostTag, opr: PrePostOpr, entityName: string, moduleName?: string): string; export declare function untangleWorkflowName(name: string): string; export declare function parsePrePostWorkflowName(name: string): ThinWfHeader; export declare function getWorkflow(eventInstance: Instance): Workflow; export declare function getWorkflowForEvent(eventName: string, moduleName?: string): Workflow; export declare function getEntity(name: string, moduleName: string): Entity | undefined; export declare function isEntity(fqName: string): boolean; export declare function isEvent(fqName: string): boolean; export declare function isRecord(fqName: string): boolean; export declare function isRelationship(fqName: string): boolean; export declare function getEvent(name: string, moduleName: string): Event; export declare function getRecord(name: string, moduleName: string): Record; export declare function getRelationship(name: string, moduleName: string): Relationship; export declare function getAllBetweenRelationships(): Relationship[]; export declare function getAllChildRelationships(parentFqName: string): Relationship[]; export declare function getAllBetweenRelationshipsForEntity(moduleName: string, entityName: string, allBetweenRels?: Relationship[]): Relationship[]; export declare function getAllOneToOneRelationshipsForEntity(moduleName: string, entityName: string, allBetweenRels?: Relationship[]): Relationship[]; export declare function getAllOneToManyRelationshipsForEntity(moduleName: string, entityName: string, allBetweenRels?: Relationship[]): Relationship[]; export declare function getAllManyToOneRelationshipsForEntity(moduleName: string, entityName: string, allBetweenRels?: Relationship[]): Relationship[]; export declare function getAllManyToManyRelationshipsForEntity(moduleName: string, entityName: string, allBetweenRels?: Relationship[]): Relationship[]; export declare function getEntrySchema(name: string, moduleName: string): RecordSchema; export declare function removeEntity(name: string, moduleName?: string): boolean; export declare function removeRecord(name: string, moduleName?: string): boolean; export declare function removeRelationship(name: string, moduleName?: string): boolean; export declare function removeWorkflow(name: string, moduleName?: string): boolean; export declare function removeEvent(name: string, moduleName?: string): boolean; export type InstanceAttributes = Map<string, any>; export declare function newInstanceAttributes(): InstanceAttributes; export declare class Instance { record: Record; name: string; moduleName: string; attributes: InstanceAttributes; queryAttributes: InstanceAttributes | undefined; queryAttributeValues: InstanceAttributes | undefined; relatedInstances: Map<string, Instance[]> | undefined; private contextData; private ___id; constructor(record: Record, moduleName: string, name: string, attributes: InstanceAttributes, queryAttributes?: InstanceAttributes, queryAttributeValues?: InstanceAttributes); static EmptyInstance(name: string, moduleName: string): Instance; static newWithAttributes(inst: Instance, newAttrs: InstanceAttributes): Instance; static IsInstance(obj: any): boolean; static clone(inst: Instance): Instance; getId(): string; metaAttributeValues(): any; normalizeAttributes(attrs: InstanceAttributes): InstanceAttributes; requireAudit(): boolean; lookup(k: string): any; lookupQueryVal(k: string): any; getPath(): string; asSerializableObject(): object; static isSerializableObject(obj: any): boolean; static DeserializeAttributes(attrs: InstanceAttributes): InstanceAttributes; static FromSerializableObject(obj: any, record?: Record): Instance; asObject(): object; static fromObject(name: string, moduleName: string, obj: object): Instance; static asSerializableValue(v: any, forSerialization: boolean): any; attributesAsObject(forSerialization?: boolean): object; static stringifyObjects(attributes: InstanceAttributes): object; attributesWithStringifiedObjects(): object; queryAttributesAsObject(): object; queryAttributeValuesAsObject(): object; addQuery(attrName: string, op?: string, attrVal?: any): void; mergeAttributes(newAttrs: InstanceAttributes): Instance; attachRelatedInstances(relName: string, insts: Instance | Instance[]): void; detachAllRelatedInstance(): void; mergeRelatedInstances(): void; getRelatedInstances(relName: string): Instance[] | undefined; getAllUserAttributeNames(): string[]; getFqName(): string; addContextData(k: string, v: any): Instance; getContextData(k: string, notFoundValue?: any): any; setAuthContext(sesssionInfo: ActiveSessionInfo): Instance; getAuthContext(): ActiveSessionInfo | undefined; getAuthContextUserId(): string; getExprAttributes(): Map<string, Expr> | undefined; cast<T>(): T; get(k: string): any; } export declare function maybeInstanceAsString(result: any): string; export declare function objectAsInstanceAttributes(obj: object | undefined): InstanceAttributes; export type AttributeEntry = { name: string; spec: AttributeSpec; }; export declare function findIdAttribute(inst: Instance): AttributeEntry | undefined; export declare function makeInstance(moduleName: string, entryName: string, attributes: InstanceAttributes, queryAttributes?: InstanceAttributes, queryAttributeValues?: InstanceAttributes, queryAll?: boolean): Instance; export declare function isEventInstance(inst: Instance): boolean; export declare function isEntityInstance(inst: Instance): boolean; export declare function isRecordInstance(inst: Instance): boolean; export declare function getAllModuleEntries(f: Function): Map<string, string[]>; export declare function getAllEventNames(): Map<string, string[]>; export declare function getAllEntityNames(): Map<string, string[]>; export declare function isBetweenRelationship(relName: string, moduleName: string): boolean; export declare function isContainsRelationship(relName: string, moduleName: string): boolean; export type BetweenInstanceNodeValuesResult = { node1: any; node2: any; entry: Relationship; }; export declare function getBetweenInstanceNodeValues(inst: Instance): BetweenInstanceNodeValuesResult; export declare function isInstanceOfType(obj: any, fqName: string): boolean; export declare function assertInstance(obj: any): void; export declare function defineAgentEvent(moduleName: string, agentName: string, instruction?: string): void; export declare function isTimer(eventInst: Instance): boolean; export declare function isAgent(fqName: string): boolean; export declare function isAgentEvent(record: Record): boolean; export declare function isAgentEventInstance(eventInst: Instance): boolean; export declare function eventAgentName(eventInst: Instance): string | undefined; export declare function instanceToObject<Type>(inst: Instance, obj: any): Type; export declare function getEntityRbacRules(entityFqName: string): RbacSpecification[] | undefined; export declare function asJSONSchema(fqName: string): string; export declare function getDecision(name: string, moduleName: string): Decision | undefined; export declare function fetchRefTarget(entityFqName: string, attrName: string): [string, string, boolean]; export declare function getAttributeNames(entityFqName: string): Array<string>; export declare function maybeSetMetaAttributes(attrs: InstanceAttributes, env: Environment, inUpdateMode?: boolean): void; export {}; //# sourceMappingURL=module.d.ts.map