@radaros/browser 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +15 -2
- package/dist/index.js +33 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _radaros_core from '@radaros/core';
|
|
2
|
+
import { ModelProvider, UnifiedMemoryConfig, LogLevel, EventBus, MemoryManager, ToolDef } from '@radaros/core';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Secure credential store for BrowserAgent.
|
|
@@ -124,6 +125,13 @@ interface BrowserAgentConfig {
|
|
|
124
125
|
* Pass `true` for defaults or a `HumanizeConfig` for fine control.
|
|
125
126
|
*/
|
|
126
127
|
humanize?: boolean | HumanizeConfig;
|
|
128
|
+
/**
|
|
129
|
+
* Unified memory config — persist browser sessions, decisions, and
|
|
130
|
+
* summaries of past runs. Same config as Agent and VoiceAgent.
|
|
131
|
+
*/
|
|
132
|
+
memory?: UnifiedMemoryConfig;
|
|
133
|
+
/** Skills — pre-packaged or learned tool bundles. */
|
|
134
|
+
skills?: Array<_radaros_core.Skill | string>;
|
|
127
135
|
logLevel?: LogLevel;
|
|
128
136
|
eventBus?: EventBus;
|
|
129
137
|
}
|
|
@@ -132,8 +140,10 @@ interface BrowserRunOpts {
|
|
|
132
140
|
startUrl?: string;
|
|
133
141
|
/** Per-run model API key override */
|
|
134
142
|
apiKey?: string;
|
|
135
|
-
/** Session identifier for event tracking */
|
|
143
|
+
/** Session identifier for memory persistence and event tracking */
|
|
136
144
|
sessionId?: string;
|
|
145
|
+
/** User identifier for memory personalization */
|
|
146
|
+
userId?: string;
|
|
137
147
|
/** Path to save storageState (cookies/auth) after the run completes */
|
|
138
148
|
saveStorageState?: string;
|
|
139
149
|
}
|
|
@@ -225,7 +235,10 @@ declare class BrowserAgent {
|
|
|
225
235
|
private credentials?;
|
|
226
236
|
private stealth?;
|
|
227
237
|
private humanize?;
|
|
238
|
+
private memoryManager;
|
|
228
239
|
private logger;
|
|
240
|
+
/** Access the MemoryManager (if memory is configured). */
|
|
241
|
+
get memory(): MemoryManager | null;
|
|
229
242
|
constructor(config: BrowserAgentConfig);
|
|
230
243
|
run(task: string, opts?: BrowserRunOpts): Promise<BrowserRunOutput>;
|
|
231
244
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/browser-agent.ts
|
|
2
|
-
import { EventBus, Logger } from "@radaros/core";
|
|
2
|
+
import { EventBus, Logger, MemoryManager } from "@radaros/core";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
// src/stealth.ts
|
|
@@ -594,7 +594,12 @@ var BrowserAgent = class {
|
|
|
594
594
|
credentials;
|
|
595
595
|
stealth;
|
|
596
596
|
humanize;
|
|
597
|
+
memoryManager = null;
|
|
597
598
|
logger;
|
|
599
|
+
/** Access the MemoryManager (if memory is configured). */
|
|
600
|
+
get memory() {
|
|
601
|
+
return this.memoryManager;
|
|
602
|
+
}
|
|
598
603
|
constructor(config) {
|
|
599
604
|
this.name = config.name;
|
|
600
605
|
this.model = config.model;
|
|
@@ -616,15 +621,30 @@ var BrowserAgent = class {
|
|
|
616
621
|
prefix: `BrowserAgent:${config.name}`,
|
|
617
622
|
level: config.logLevel ?? "silent"
|
|
618
623
|
});
|
|
624
|
+
if (config.memory) {
|
|
625
|
+
this.memoryManager = new MemoryManager(config.memory);
|
|
626
|
+
}
|
|
619
627
|
}
|
|
620
628
|
async run(task, opts) {
|
|
621
629
|
const startTime = Date.now();
|
|
622
630
|
const startUrl = opts?.startUrl ?? this.defaultStartUrl;
|
|
631
|
+
const sessionId = opts?.sessionId ?? `browser_${Date.now()}`;
|
|
632
|
+
const userId = opts?.userId;
|
|
623
633
|
const browser = new BrowserProvider();
|
|
624
634
|
const steps = [];
|
|
625
635
|
const actionHistory = [];
|
|
636
|
+
let extraInstructions = this.instructions ?? "";
|
|
637
|
+
if (this.memoryManager) {
|
|
638
|
+
await this.memoryManager.ensureReady();
|
|
639
|
+
const memoryContext = await this.memoryManager.buildContext(sessionId, userId, task, this.name);
|
|
640
|
+
if (memoryContext) {
|
|
641
|
+
extraInstructions = extraInstructions ? `${extraInstructions}
|
|
642
|
+
|
|
643
|
+
${memoryContext}` : memoryContext;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
626
646
|
const credentialKeys = this.credentials?.keys();
|
|
627
|
-
const systemPrompt = buildSystemPrompt(this.viewport,
|
|
647
|
+
const systemPrompt = buildSystemPrompt(this.viewport, extraInstructions || void 0, credentialKeys);
|
|
628
648
|
let lastActionKey = "";
|
|
629
649
|
let repeatCount = 0;
|
|
630
650
|
try {
|
|
@@ -811,6 +831,17 @@ var BrowserAgent = class {
|
|
|
811
831
|
durationMs: Date.now() - startTime,
|
|
812
832
|
videoPath
|
|
813
833
|
};
|
|
834
|
+
if (this.memoryManager) {
|
|
835
|
+
const sessionId = opts?.sessionId ?? `browser_${startTime}`;
|
|
836
|
+
const userId = opts?.userId;
|
|
837
|
+
const actionSummary = steps.map((s) => summarizeAction(s.action)).join("; ");
|
|
838
|
+
const messages = [
|
|
839
|
+
{ role: "user", content: `Task: ${outcome.result}` },
|
|
840
|
+
{ role: "assistant", content: `Actions: ${actionSummary}. Result: ${outcome.result}` }
|
|
841
|
+
];
|
|
842
|
+
this.memoryManager.appendMessages(sessionId, messages, this.model).catch((e) => this.logger.warn("Memory persist failed", { error: String(e) }));
|
|
843
|
+
this.memoryManager.afterRun(sessionId, userId, messages, this.model, this.name);
|
|
844
|
+
}
|
|
814
845
|
this.eventBus.emit("browser.done", {
|
|
815
846
|
result: output.result,
|
|
816
847
|
success: outcome.success,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radaros/browser",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"typescript": "^5.6.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@radaros/core": "^0.3.
|
|
31
|
+
"@radaros/core": "^0.3.10",
|
|
32
32
|
"playwright": ">=1.40.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependenciesMeta": {
|