Class: AgentBrowser

Constructors

new AgentBrowser()

new AgentBrowser(agentBrowserArgs: {agent: Agent;behaviorConfig: {actionDelay: number;goToDelay: number;telemetry: boolean; };browser: Browser;collectiveMemoryConfig: {apiKey: string;endpoint: string; };inventory: Inventory;logger: Logger; }): AgentBrowser

Parameters

ParameterType
agentBrowserArgsobject
agentBrowserArgs.agentAgent
agentBrowserArgs.behaviorConfig?object
agentBrowserArgs.behaviorConfig.actionDelaynumber
agentBrowserArgs.behaviorConfig.goToDelaynumber
agentBrowserArgs.behaviorConfig.telemetryboolean
agentBrowserArgs.browserBrowser
agentBrowserArgs.collectiveMemoryConfig?object
agentBrowserArgs.collectiveMemoryConfig.apiKeystring
agentBrowserArgs.collectiveMemoryConfig.endpointstring
agentBrowserArgs.inventory?Inventory
agentBrowserArgs.logger?Logger

Returns

AgentBrowser

Defined in

src/agentBrowser.ts:42

Properties

agent

agent: Agent

Defined in

src/agentBrowser.ts:29


browser

browser: Browser

Defined in

src/agentBrowser.ts:30


config

config: {actionDelay: number;goToDelay: number;telemetry: boolean; }

actionDelay

actionDelay: number

goToDelay

goToDelay: number

telemetry

telemetry: boolean

Defined in

src/agentBrowser.ts:32


hdrConfig

hdrConfig: {apiKey: string;endpoint: string; }

apiKey

apiKey: string

endpoint

endpoint: string

Defined in

src/agentBrowser.ts:34


inventory?

optional inventory: Inventory

Defined in

src/agentBrowser.ts:33


logger

logger: Logger

Defined in

src/agentBrowser.ts:31


page

page: undefined | Page

Defined in

src/agentBrowser.ts:35

Methods

browse()

browse<TObjectiveComplete>(browserObjective: {maxIterations: number;objective: string[];startUrl: string; }, responseType: ZodObject<{command: ZodOptional<ZodType<any, ZodTypeDef, any>>;description: ZodString;objectiveComplete: ZodOptional<ZodObject<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, "strip", ZodTypeAny, {kind: "ObjectiveComplete";result: string; }, {kind: "ObjectiveComplete";result: string; }>> | ZodOptional<ZodObject<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["unknownKeys"], TObjectiveComplete["_def"]["catchall"], objectOutputType<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["catchall"], TObjectiveComplete["_def"]["unknownKeys"]>, objectInputType<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["catchall"], TObjectiveComplete["_def"]["unknownKeys"]>>>;progressAssessment: ZodString; }, "strip", ZodTypeAny, { [k in "description" | "progressAssessment" | "command" | "objectiveComplete"]: addQuestionMarks<baseObjectOutputType<Object>, any>[k] }, { [k_1 in "description" | "progressAssessment" | "command" | "objectiveComplete"]: baseObjectInputType<Object>[k_1] }>): Promise<undefined | {content: Promise<string>;result: {kind: "ObjectiveFailed";result: failureReason; };url: string; } | {content: string;kind: "ObjectiveComplete";result: stepResponse;url: string; }>

Type Parameters

Type ParameterDefault type
TObjectiveComplete extends AnyZodObjectZodObject<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, "strip", ZodTypeAny, {kind: "ObjectiveComplete";result: string; }, {kind: "ObjectiveComplete";result: string; }>

Parameters

ParameterType
browserObjectiveobject
browserObjective.maxIterationsnumber
browserObjective.objectivestring[]
browserObjective.startUrlstring
responseTypeZodObject<{command: ZodOptional<ZodType<any, ZodTypeDef, any>>;description: ZodString;objectiveComplete: ZodOptional<ZodObject<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, "strip", ZodTypeAny, {kind: "ObjectiveComplete";result: string; }, {kind: "ObjectiveComplete";result: string; }>> | ZodOptional<ZodObject<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["unknownKeys"], TObjectiveComplete["_def"]["catchall"], objectOutputType<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["catchall"], TObjectiveComplete["_def"]["unknownKeys"]>, objectInputType<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["catchall"], TObjectiveComplete["_def"]["unknownKeys"]>>>;progressAssessment: ZodString; }, "strip", ZodTypeAny, { [k in "description" | "progressAssessment" | "command" | "objectiveComplete"]: addQuestionMarks<baseObjectOutputType<Object>, any>[k] }, { [k_1 in "description" | "progressAssessment" | "command" | "objectiveComplete"]: baseObjectInputType<Object>[k_1] }>

Returns

Promise<undefined | {content: Promise<string>;result: {kind: "ObjectiveFailed";result: failureReason; };url: string; } | {content: string;kind: "ObjectiveComplete";result: stepResponse;url: string; }>

Defined in

src/agentBrowser.ts:221


close()

close(): Promise<void>

Returns

Promise<void>

Defined in

src/agentBrowser.ts:327


followPath()

followPath<TObjectiveComplete>(memorySequenceId: string, page: Page, browserObjective: {maxIterations: number;objective: string[];startUrl: string; }, responseSchema: ZodObject<{description: ZodString;objectiveComplete: ZodObject<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, "strip", ZodTypeAny, {kind: "ObjectiveComplete";result: string; }, {kind: "ObjectiveComplete";result: string; }> | TObjectiveComplete;progressAssessment: ZodString; }, "strip", ZodTypeAny, { [k in "description" | "progressAssessment" | "objectiveComplete"]: addQuestionMarks<baseObjectOutputType<Object>, any>[k] }, { [k_1 in "description" | "progressAssessment" | "objectiveComplete"]: baseObjectInputType<Object>[k_1] }>): Promise<undefined | {content: string;kind: "ObjectiveComplete";result: stepResponse;url: string; }>

Type Parameters

Type ParameterDefault type
TObjectiveComplete extends AnyZodObjectZodObject<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, "strip", ZodTypeAny, {kind: "ObjectiveComplete";result: string; }, {kind: "ObjectiveComplete";result: string; }>

Parameters

ParameterType
memorySequenceIdstring
pagePage
browserObjectiveobject
browserObjective.maxIterationsnumber
browserObjective.objectivestring[]
browserObjective.startUrlstring
responseSchemaZodObject<{description: ZodString;objectiveComplete: ZodObject<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, "strip", ZodTypeAny, {kind: "ObjectiveComplete";result: string; }, {kind: "ObjectiveComplete";result: string; }> | TObjectiveComplete;progressAssessment: ZodString; }, "strip", ZodTypeAny, { [k in "description" | "progressAssessment" | "objectiveComplete"]: addQuestionMarks<baseObjectOutputType<Object>, any>[k] }, { [k_1 in "description" | "progressAssessment" | "objectiveComplete"]: baseObjectInputType<Object>[k_1] }>

Returns

Promise<undefined | {content: string;kind: "ObjectiveComplete";result: stepResponse;url: string; }>

Defined in

src/agentBrowser.ts:110


followRoute()

followRoute(page: Page, memories: {actionStep: {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; };objectiveState: ObjectiveState; }[]): Promise<void>

Parameters

ParameterType
pagePage
memories{actionStep: {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; };objectiveState: ObjectiveState; }[]

Returns

Promise<void>

Defined in

src/agentBrowser.ts:169


memorize()

memorize(state: {ariaTree: string;kind: "ObjectiveState";objective: string;progress: string[];url: string; }, action: ModelResponseType): Promise<void>

Parameters

ParameterType
stateobject
state.ariaTreestring
state.kind"ObjectiveState"
state.objectivestring
state.progressstring[]
state.urlstring
actionModelResponseType

Returns

Promise<void>

Defined in

src/agentBrowser.ts:301


performMemory()

performMemory(page: Page, memory: {actionStep: {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; };objectiveState: ObjectiveState; }): Promise<undefined | {content: Promise<string>;result: {kind: "ObjectiveFailed";result: failureReason; };url: string; }>

Parameters

ParameterType
pagePage
memoryobject
memory.actionStepobject
memory.actionStep.command?any
memory.actionStep.descriptionstring
memory.actionStep.objectiveComplete?{kind: "ObjectiveComplete";result: string; } | {}
memory.actionStep.progressAssessmentstring
memory.objectiveStateobject
memory.objectiveState.ariaTreestring
memory.objectiveState.kind"ObjectiveState"
memory.objectiveState.objectivestring
memory.objectiveState.progressstring[]
memory.objectiveState.urlstring

Returns

Promise<undefined | {content: Promise<string>;result: {kind: "ObjectiveFailed";result: failureReason; };url: string; }>

Defined in

src/agentBrowser.ts:71


remember()

remember(state: {ariaTree: string;kind: "ObjectiveState";objective: string;progress: string[];url: string; }): Promise<{actionStep: {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; };objectiveState: ObjectiveState; }[]>

Parameters

ParameterType
stateobject
state.ariaTreestring
state.kind"ObjectiveState"
state.objectivestring
state.progressstring[]
state.urlstring

Returns

Promise<{actionStep: {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; };objectiveState: ObjectiveState; }[]>

Defined in

src/agentBrowser.ts:186


reset()

reset(): void

Returns

void

Defined in

src/agentBrowser.ts:296


returnErrorState()

returnErrorState(page: Page, failureReason: string): Promise<{content: Promise<string>;result: {kind: "ObjectiveFailed";result: failureReason; };url: string; }>

Parameters

ParameterType
pagePage
failureReasonstring

Returns

Promise<{content: Promise<string>;result: {kind: "ObjectiveFailed";result: failureReason; };url: string; }>

content

content: Promise<string>

result

result: {kind: "ObjectiveFailed";result: failureReason; }

result.kind

kind: string = "ObjectiveFailed"

result.result

result: string = failureReason

url

url: string

Defined in

src/agentBrowser.ts:315


step()

step<TObjectiveComplete>(page: Page, currentObjective: string, responseType: ZodObject<{command: ZodOptional<ZodType<any, ZodTypeDef, any>>;description: ZodString;objectiveComplete: ZodOptional<ZodObject<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, "strip", ZodTypeAny, {kind: "ObjectiveComplete";result: string; }, {kind: "ObjectiveComplete";result: string; }>> | ZodOptional<ZodObject<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["unknownKeys"], TObjectiveComplete["_def"]["catchall"], objectOutputType<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["catchall"], TObjectiveComplete["_def"]["unknownKeys"]>, objectInputType<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["catchall"], TObjectiveComplete["_def"]["unknownKeys"]>>>;progressAssessment: ZodString; }, "strip", ZodTypeAny, { [k in "description" | "progressAssessment" | "command" | "objectiveComplete"]: addQuestionMarks<baseObjectOutputType<Object>, any>[k] }, { [k_1 in "description" | "progressAssessment" | "command" | "objectiveComplete"]: baseObjectInputType<Object>[k_1] }>): Promise<any>

Type Parameters

Type ParameterDefault type
TObjectiveComplete extends AnyZodObjectZodObject<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, "strip", ZodTypeAny, {kind: "ObjectiveComplete";result: string; }, {kind: "ObjectiveComplete";result: string; }>

Parameters

ParameterType
pagePage
currentObjectivestring
responseTypeZodObject<{command: ZodOptional<ZodType<any, ZodTypeDef, any>>;description: ZodString;objectiveComplete: ZodOptional<ZodObject<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, "strip", ZodTypeAny, {kind: "ObjectiveComplete";result: string; }, {kind: "ObjectiveComplete";result: string; }>> | ZodOptional<ZodObject<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["unknownKeys"], TObjectiveComplete["_def"]["catchall"], objectOutputType<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["catchall"], TObjectiveComplete["_def"]["unknownKeys"]>, objectInputType<extendShape<{kind: ZodLiteral<"ObjectiveComplete">;result: ZodString; }, TObjectiveComplete["shape"]>, TObjectiveComplete["_def"]["catchall"], TObjectiveComplete["_def"]["unknownKeys"]>>>;progressAssessment: ZodString; }, "strip", ZodTypeAny, { [k in "description" | "progressAssessment" | "command" | "objectiveComplete"]: addQuestionMarks<baseObjectOutputType<Object>, any>[k] }, { [k_1 in "description" | "progressAssessment" | "command" | "objectiveComplete"]: baseObjectInputType<Object>[k_1] }>

Returns

Promise<any>

Defined in

src/agentBrowser.ts:190