import { Gib, Ib } from '@ibgib/ts-gib/dist/types.mjs'; import { IbGib_V1, IbGibRel8ns_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs'; import { Lex } from '@ibgib/helper-gib/dist/helpers/lex-helper.mjs'; import { RobbotData_V1, RobbotRel8ns_V1, RobbotIbGib_V1, RobbotCmdData, RobbotCmdRel8ns, RobbotCmdIbGib, RobbotResultData, RobbotResultRel8ns, RobbotResultIbGib, SemanticHandler, SemanticInfo, RobbotInteractionData_V1, RobbotInteractionType, RobbotPropsData, SemanticHandlerResult } from './robbot-types.mjs'; import { CommentIbGib_V1 } from '../../common/comment/comment-types.mjs'; import { PicIbGib_V1 } from '../../common/pic/pic-types.mjs'; import { ErrorIbGib_V1 } from '../../common/error/error-types.mjs'; import { WitnessWithContextBase_V1 } from '../witness-with-context/witness-with-context-base-v1.mjs'; export interface RobbotBaseParseMetadataResult { robbotClassnameIsh?: string; robbotNameIsh?: string; robbotIdIsh?: string; } /** * ## distinguishing characteristics of robbots * * With any witness ibgib, we are concerned with interpreting an incoming * arg ibgib and producing at least one result ibgib. Most often, there will * be additional ibgibs created, either creating "new" ibgibs via `fork` * transforms, or changing existing ibgibs through `mut8` and `rel8` * transforms. And almost always these will be persisted in at least * one space. * * But Robbots in particular are meant to be increasingly adaptable over time. * * This results in a couple of notes: * * 1. They should be able to handle any incoming ibgib, including primitives. * 2. If they are learning robbots, then they will mutate internally at some rate. * 3. Often robbots' output ibgib(s) will be intended for others' * consumption, in service of others - be they humans or other * biologically living organisms, other robbots or even later versions of * themselves. * * So for example, one of the simplest robbots is one which simply echos the * incoming ibgib arg. * ## architecture * * At the base, any robbot should be able to handle any incoming ibgib. This is * in contrast to, e.g., a Space, which is more rigid in design. * * Certainly there are robbot's who will be more rigid, but this will be an * abstract class on top of this one, and all robbots should be able to react to * all incoming ibgibs. * * Output will default to a simple ok^gib or (ROOT) ib^gib primitive...perhaps * we'll go with ack^gib, but whatever it is, it's just an acknowledgement of * input received. (I'll put it in the constants file). * * Side effects should occur in a parallel execution thread, which ideally would * work in a completely parallel execution context (like a service worker). But * then we have to deal with race conditions and the real solution there is to * abstract to the robbot having its own space and the synchronization happening * exactly like any other sync space. * * For now, we'll spin off a promise with some intermittent `await delay` * calls if they end up called for, effectively the equivalent of the * old-fashioned "ProcessMessages/DoEvents" hack. */ export declare abstract class RobbotBase_V1 = IbGib_V1, TResultData extends any = any, TResultRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1, TResultIbGib extends IbGib_V1 | ErrorIbGib_V1 = IbGib_V1, TData extends RobbotData_V1 = RobbotData_V1, TRel8ns extends RobbotRel8ns_V1 = RobbotRel8ns_V1> extends WitnessWithContextBase_V1 implements RobbotIbGib_V1 { /** * Log context for convenience with logging. (Ignore if you don't want to use this.) * * Often used in conjunction with `logalot`. */ protected lc: string; /** * When the robbot has to get some ibgibs, might as well store them here so * we don't have to get them again from storage. */ protected _cacheIbGibs: { [addr: string]: IbGib_V1; }; protected _semanticHandlers: { [semanticId: string]: SemanticHandler[]; }; /** * lex that the robbot uses to speak. */ protected _robbotLex: Lex | undefined; /** * lex that the robbot uses to interpret humans. */ protected _userLex: Lex | undefined; constructor(initialData?: TData, initialRel8ns?: TRel8ns); /** * At this point in time, the arg has already been intrinsically validated, * as well as the internal state of this robbot. so whatever this robbot's * function is, it should be good to go. * * In the base class, this just returns {@link routeAndDoArg}. If you don't * want to route, then override this. */ protected witnessImpl(arg: TOptionsIbGib): Promise; protected handleSemanticDefault(info: SemanticInfo): Promise; /** * Initializes to default space values. */ protected initialize(): Promise; protected initialize_semanticHandlers(): Promise; protected initialize_lex(): Promise; /** * Base routing executes different if incoming is a cmd options arg, i.e., * if the `data.cmd` is truthy (atow). If {@link isArg} is true, then routes * to {@link doCmdArg}; else routes to {@link doDefault}. * * Override this function to create more advanced custom routing. * * ## notes * * I'm not overly thrilled with this, but it's a watered down version of * what I've implemented in the space witness hierarchy. * * @see {@link isArg} * @see {@link doCmdArg} * @see {@link doDefault}. */ protected routeAndDoArg({ arg, }: { arg: TOptionsIbGib; }): Promise; /** * By default, this routes to {@link doCmdIb}, {@link doCmdGib} & {@link doCmdIbgib}. * Override this and route to other commands before calling this with `super.doCmdArg` * (if you still want to use this function.) * * You can also override the routing */ protected doCmdArg({ arg, }: { arg: RobbotCmdIbGib; }): Promise; protected doCmdIb({ arg, }: { arg: IbGib_V1; }): Promise; protected doCmdGib({ arg, }: { arg: IbGib_V1; }): Promise; protected doCmdIbgib({ arg, }: { arg: IbGib_V1; }): Promise; protected doCmdActivate({ arg, }: { arg: RobbotCmdIbGib; }): Promise; protected doCmdDeactivate({ arg, }: { arg: RobbotCmdIbGib; }): Promise; /** * Stubbed in base class for convenience. Doesn't have to be implemented. */ protected doPic({ ibGib, }: { ibGib: PicIbGib_V1; }): Promise; /** * Stubbed in base class for convenience. Doesn't have to be implemented. */ protected doComment({ ibGib, }: { ibGib: CommentIbGib_V1; }): Promise; /** * Stubbed in base class for convenience. Doesn't have to be implemented. */ protected doDefault({ ibGib, }: { ibGib: TOptionsIbGib; }): Promise; /** * validates against common robbot qualities. * * Override this with a call to `super.validateThis` for custom validation * for descending robbot classes. * * @returns validation errors common to all robbots, if any errors exist. */ protected validateThis(): Promise; /** * builds an arg ibGib. * * wrapper convenience to avoid long generic calls. */ argy = RobbotCmdIbGib>({ argData, ibMetadata, noTimestamp, ibGibs, }: { argData: TCmdOptionsData; ibMetadata?: string; noTimestamp?: boolean; ibGibs?: IbGib_V1[]; }): Promise; /** * builds a result ibGib, if indeed a result ibgib is required. * * This is only useful in robbots that have more structured inputs/outputs. * For those that simply accept any ibgib incoming and return a * primitive like ib^gib or whatever, then this is unnecessary. * * wrapper convenience to avoid long generic calls. */ resulty = RobbotResultIbGib>({ resultData, ibGibs, }: { resultData: TResultData; ibGibs?: IbGib_V1[]; }): Promise; protected getThisAtom(): string; protected parseAddlMetadataString({ ib }: { ib: Ib; }): RobbotBaseParseMetadataResult; /** * by default in base class, this compares exactly the metadata string in a comment * with this robbot.getaddlmetadata result. */ protected isMyComment({ ibGib }: { ibGib: IbGib_V1; }): boolean; /** * gets ibgibs to which this robbot is directly rel8d WRT rel8nNames. * * @returns map of rel8nName -> ibgibs that this robbot is related to. */ protected getRel8dIbGibs({ rel8nNames, }: { rel8nNames?: string[]; }): Promise<{ [rel8nName: string]: IbGib_V1[]; }>; /** * helper function to wrap text in outputPrefix/Suffix * * @returns wrapped text, depending on param values. */ protected getOutputText({ text, skipPrefix, skipSuffix, prefixOverride, suffixOverride, }: { text: string; skipPrefix?: boolean; skipSuffix?: boolean; prefixOverride?: string; suffixOverride?: string; }): Promise; /** * By default, this rel8s to the given ibgibs via this.data.defaultRel8nName */ protected lookAt({ ibGibs }: { ibGibs: IbGib_V1[]; }): Promise; protected getRobbotInteractionData({ type, commentText, subjectTjpGibs, details, expectingResponse, uuid, timestamp, }: { /** * the tyep of interaction. * * @see {@link RobbotInteractionType} */ type: RobbotInteractionType; /** * the comment text of the interaction. * * Does not include any prefix/suffix of the robbot. */ commentText: string; /** * If the interaction has one or more specific target/subject, then this * is where their gibs go. * * ## driving use case * * I need a way from starting with an ibgib and getting its related * interactions. */ subjectTjpGibs?: Gib[]; /** * interaction details. */ details?: any; /** * if interaction intends to evoke a response */ expectingResponse?: boolean; /** * If provided, will be the id of the interaction. */ uuid?: string; /** * if provided, will be the timestamp of the interaction data. */ timestamp?: string; }): Promise; } export interface IbGibRobbotAny extends RobbotBase_V1 { } //# sourceMappingURL=robbot-base-v1.d.mts.map