@browserbasehq/stagehand 3.0.8-alpha-0149ad50074dd78904613508baf67cbbe19d66e5 → 3.0.8-alpha-088c4cc31dc924bb232a9d5a09ab42cd961c2d36
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.js +52 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28127,7 +28127,7 @@ var ActCache = class {
|
|
|
28127
28127
|
};
|
|
28128
28128
|
});
|
|
28129
28129
|
}
|
|
28130
|
-
tryReplay(context, page, timeout) {
|
|
28130
|
+
tryReplay(context, page, timeout, llmClientOverride) {
|
|
28131
28131
|
return __async(this, null, function* () {
|
|
28132
28132
|
var _a4;
|
|
28133
28133
|
if (!this.enabled) return null;
|
|
@@ -28180,7 +28180,13 @@ var ActCache = class {
|
|
|
28180
28180
|
}
|
|
28181
28181
|
}
|
|
28182
28182
|
});
|
|
28183
|
-
return yield this.replayCachedActions(
|
|
28183
|
+
return yield this.replayCachedActions(
|
|
28184
|
+
context,
|
|
28185
|
+
entry,
|
|
28186
|
+
page,
|
|
28187
|
+
timeout,
|
|
28188
|
+
llmClientOverride
|
|
28189
|
+
);
|
|
28184
28190
|
});
|
|
28185
28191
|
}
|
|
28186
28192
|
store(context, result) {
|
|
@@ -28230,12 +28236,13 @@ var ActCache = class {
|
|
|
28230
28236
|
});
|
|
28231
28237
|
return (0, import_crypto.createHash)("sha256").update(payload).digest("hex");
|
|
28232
28238
|
}
|
|
28233
|
-
replayCachedActions(context, entry, page, timeout) {
|
|
28239
|
+
replayCachedActions(context, entry, page, timeout, llmClientOverride) {
|
|
28234
28240
|
return __async(this, null, function* () {
|
|
28235
28241
|
const handler = this.getActHandler();
|
|
28236
28242
|
if (!handler) {
|
|
28237
28243
|
throw new StagehandNotInitializedError("act()");
|
|
28238
28244
|
}
|
|
28245
|
+
const effectiveClient = llmClientOverride != null ? llmClientOverride : this.getDefaultLlmClient();
|
|
28239
28246
|
const execute = () => __async(this, null, function* () {
|
|
28240
28247
|
var _a4, _b, _c;
|
|
28241
28248
|
const actionResults = [];
|
|
@@ -28244,7 +28251,7 @@ var ActCache = class {
|
|
|
28244
28251
|
action,
|
|
28245
28252
|
page,
|
|
28246
28253
|
this.domSettleTimeoutMs,
|
|
28247
|
-
|
|
28254
|
+
effectiveClient,
|
|
28248
28255
|
void 0,
|
|
28249
28256
|
context.variables
|
|
28250
28257
|
);
|
|
@@ -28482,7 +28489,7 @@ var AgentCache = class {
|
|
|
28482
28489
|
};
|
|
28483
28490
|
});
|
|
28484
28491
|
}
|
|
28485
|
-
tryReplay(context) {
|
|
28492
|
+
tryReplay(context, llmClientOverride) {
|
|
28486
28493
|
return __async(this, null, function* () {
|
|
28487
28494
|
if (!this.enabled) return null;
|
|
28488
28495
|
const {
|
|
@@ -28515,7 +28522,7 @@ var AgentCache = class {
|
|
|
28515
28522
|
url: { value: context.startUrl, type: "string" }
|
|
28516
28523
|
}
|
|
28517
28524
|
});
|
|
28518
|
-
return yield this.replayAgentCacheEntry(context, entry);
|
|
28525
|
+
return yield this.replayAgentCacheEntry(context, entry, llmClientOverride);
|
|
28519
28526
|
});
|
|
28520
28527
|
}
|
|
28521
28528
|
/**
|
|
@@ -28534,9 +28541,9 @@ var AgentCache = class {
|
|
|
28534
28541
|
* and await `result` even when the response comes from cache, maintaining
|
|
28535
28542
|
* API consistency regardless of whether the result was cached or live.
|
|
28536
28543
|
*/
|
|
28537
|
-
tryReplayAsStream(context) {
|
|
28544
|
+
tryReplayAsStream(context, llmClientOverride) {
|
|
28538
28545
|
return __async(this, null, function* () {
|
|
28539
|
-
const result = yield this.tryReplay(context);
|
|
28546
|
+
const result = yield this.tryReplay(context, llmClientOverride);
|
|
28540
28547
|
if (!result) return null;
|
|
28541
28548
|
return this.createCachedStreamResult(result);
|
|
28542
28549
|
});
|
|
@@ -28762,17 +28769,23 @@ var AgentCache = class {
|
|
|
28762
28769
|
}
|
|
28763
28770
|
return value;
|
|
28764
28771
|
}
|
|
28765
|
-
replayAgentCacheEntry(context, entry) {
|
|
28772
|
+
replayAgentCacheEntry(context, entry, llmClientOverride) {
|
|
28766
28773
|
return __async(this, null, function* () {
|
|
28767
28774
|
var _a4, _b, _c;
|
|
28768
28775
|
const ctx = this.getContext();
|
|
28769
28776
|
const handler = this.getActHandler();
|
|
28770
28777
|
if (!ctx || !handler) return null;
|
|
28778
|
+
const effectiveClient = llmClientOverride != null ? llmClientOverride : this.getDefaultLlmClient();
|
|
28771
28779
|
try {
|
|
28772
28780
|
const updatedSteps = [];
|
|
28773
28781
|
let stepsChanged = false;
|
|
28774
28782
|
for (const step of (_a4 = entry.steps) != null ? _a4 : []) {
|
|
28775
|
-
const replayedStep = (_b = yield this.executeAgentReplayStep(
|
|
28783
|
+
const replayedStep = (_b = yield this.executeAgentReplayStep(
|
|
28784
|
+
step,
|
|
28785
|
+
ctx,
|
|
28786
|
+
handler,
|
|
28787
|
+
effectiveClient
|
|
28788
|
+
)) != null ? _b : step;
|
|
28776
28789
|
stepsChanged || (stepsChanged = replayedStep !== step);
|
|
28777
28790
|
updatedSteps.push(replayedStep);
|
|
28778
28791
|
}
|
|
@@ -28805,20 +28818,22 @@ var AgentCache = class {
|
|
|
28805
28818
|
}
|
|
28806
28819
|
});
|
|
28807
28820
|
}
|
|
28808
|
-
executeAgentReplayStep(step, ctx, handler) {
|
|
28821
|
+
executeAgentReplayStep(step, ctx, handler, llmClient) {
|
|
28809
28822
|
return __async(this, null, function* () {
|
|
28810
28823
|
switch (step.type) {
|
|
28811
28824
|
case "act":
|
|
28812
28825
|
return yield this.replayAgentActStep(
|
|
28813
28826
|
step,
|
|
28814
28827
|
ctx,
|
|
28815
|
-
handler
|
|
28828
|
+
handler,
|
|
28829
|
+
llmClient
|
|
28816
28830
|
);
|
|
28817
28831
|
case "fillForm":
|
|
28818
28832
|
return yield this.replayAgentFillFormStep(
|
|
28819
28833
|
step,
|
|
28820
28834
|
ctx,
|
|
28821
|
-
handler
|
|
28835
|
+
handler,
|
|
28836
|
+
llmClient
|
|
28822
28837
|
);
|
|
28823
28838
|
case "goto":
|
|
28824
28839
|
yield this.replayAgentGotoStep(step, ctx);
|
|
@@ -28850,7 +28865,7 @@ var AgentCache = class {
|
|
|
28850
28865
|
}
|
|
28851
28866
|
});
|
|
28852
28867
|
}
|
|
28853
|
-
replayAgentActStep(step, ctx, handler) {
|
|
28868
|
+
replayAgentActStep(step, ctx, handler, llmClient) {
|
|
28854
28869
|
return __async(this, null, function* () {
|
|
28855
28870
|
const actions = Array.isArray(step.actions) ? step.actions : [];
|
|
28856
28871
|
if (actions.length > 0) {
|
|
@@ -28861,7 +28876,7 @@ var AgentCache = class {
|
|
|
28861
28876
|
action,
|
|
28862
28877
|
page,
|
|
28863
28878
|
this.domSettleTimeoutMs,
|
|
28864
|
-
|
|
28879
|
+
llmClient
|
|
28865
28880
|
);
|
|
28866
28881
|
if (result.success && Array.isArray(result.actions)) {
|
|
28867
28882
|
updatedActions.push(...cloneForCache(result.actions));
|
|
@@ -28878,7 +28893,7 @@ var AgentCache = class {
|
|
|
28878
28893
|
return step;
|
|
28879
28894
|
});
|
|
28880
28895
|
}
|
|
28881
|
-
replayAgentFillFormStep(step, ctx, handler) {
|
|
28896
|
+
replayAgentFillFormStep(step, ctx, handler, llmClient) {
|
|
28882
28897
|
return __async(this, null, function* () {
|
|
28883
28898
|
var _a4;
|
|
28884
28899
|
const actions = Array.isArray(step.actions) && step.actions.length > 0 ? step.actions : (_a4 = step.observeResults) != null ? _a4 : [];
|
|
@@ -28892,7 +28907,7 @@ var AgentCache = class {
|
|
|
28892
28907
|
action,
|
|
28893
28908
|
page,
|
|
28894
28909
|
this.domSettleTimeoutMs,
|
|
28895
|
-
|
|
28910
|
+
llmClient
|
|
28896
28911
|
);
|
|
28897
28912
|
if (result.success && Array.isArray(result.actions)) {
|
|
28898
28913
|
updatedActions.push(...cloneForCache(result.actions));
|
|
@@ -67705,6 +67720,7 @@ var _V3 = class _V3 {
|
|
|
67705
67720
|
);
|
|
67706
67721
|
}
|
|
67707
67722
|
const page = yield this.resolvePage(options == null ? void 0 : options.page);
|
|
67723
|
+
const actCacheLlmClient = (options == null ? void 0 : options.model) ? this.resolveLlmClient(options.model) : void 0;
|
|
67708
67724
|
let actCacheContext = null;
|
|
67709
67725
|
const canUseCache = typeof input === "string" && !this.isAgentReplayRecording() && this.actCache.enabled;
|
|
67710
67726
|
if (canUseCache) {
|
|
@@ -67717,7 +67733,8 @@ var _V3 = class _V3 {
|
|
|
67717
67733
|
const cachedResult = yield this.actCache.tryReplay(
|
|
67718
67734
|
actCacheContext,
|
|
67719
67735
|
page,
|
|
67720
|
-
options == null ? void 0 : options.timeout
|
|
67736
|
+
options == null ? void 0 : options.timeout,
|
|
67737
|
+
actCacheLlmClient
|
|
67721
67738
|
);
|
|
67722
67739
|
if (cachedResult) {
|
|
67723
67740
|
this.addToHistory(
|
|
@@ -68120,7 +68137,13 @@ var _V3 = class _V3 {
|
|
|
68120
68137
|
configSignature: agentConfigSignature,
|
|
68121
68138
|
page: yield this.ctx.awaitActivePage()
|
|
68122
68139
|
}) : null;
|
|
68123
|
-
return {
|
|
68140
|
+
return {
|
|
68141
|
+
handler,
|
|
68142
|
+
resolvedOptions,
|
|
68143
|
+
instruction,
|
|
68144
|
+
cacheContext,
|
|
68145
|
+
llmClient: agentLlmClient
|
|
68146
|
+
};
|
|
68124
68147
|
});
|
|
68125
68148
|
}
|
|
68126
68149
|
agent(options) {
|
|
@@ -68270,13 +68293,16 @@ Do not ask follow up questions, the user will trust your judgement.`
|
|
|
68270
68293
|
args: [instructionOrOptions]
|
|
68271
68294
|
});
|
|
68272
68295
|
if (isStreaming) {
|
|
68273
|
-
const { handler: handler2, resolvedOptions: resolvedOptions2, cacheContext: cacheContext2 } = yield this.prepareAgentExecution(
|
|
68296
|
+
const { handler: handler2, resolvedOptions: resolvedOptions2, cacheContext: cacheContext2, llmClient: llmClient2 } = yield this.prepareAgentExecution(
|
|
68274
68297
|
options,
|
|
68275
68298
|
instructionOrOptions,
|
|
68276
68299
|
agentConfigSignature
|
|
68277
68300
|
);
|
|
68278
68301
|
if (cacheContext2) {
|
|
68279
|
-
const replayed = yield this.agentCache.tryReplayAsStream(
|
|
68302
|
+
const replayed = yield this.agentCache.tryReplayAsStream(
|
|
68303
|
+
cacheContext2,
|
|
68304
|
+
llmClient2
|
|
68305
|
+
);
|
|
68280
68306
|
if (replayed) {
|
|
68281
68307
|
SessionFileLogger.logAgentTaskCompleted({ cacheHit: true });
|
|
68282
68308
|
return replayed;
|
|
@@ -68299,13 +68325,16 @@ Do not ask follow up questions, the user will trust your judgement.`
|
|
|
68299
68325
|
SessionFileLogger.logAgentTaskCompleted();
|
|
68300
68326
|
return streamResult;
|
|
68301
68327
|
}
|
|
68302
|
-
const { handler, resolvedOptions, cacheContext } = yield this.prepareAgentExecution(
|
|
68328
|
+
const { handler, resolvedOptions, cacheContext, llmClient } = yield this.prepareAgentExecution(
|
|
68303
68329
|
options,
|
|
68304
68330
|
instructionOrOptions,
|
|
68305
68331
|
agentConfigSignature
|
|
68306
68332
|
);
|
|
68307
68333
|
if (cacheContext) {
|
|
68308
|
-
const replayed = yield this.agentCache.tryReplay(
|
|
68334
|
+
const replayed = yield this.agentCache.tryReplay(
|
|
68335
|
+
cacheContext,
|
|
68336
|
+
llmClient
|
|
68337
|
+
);
|
|
68309
68338
|
if (replayed) {
|
|
68310
68339
|
SessionFileLogger.logAgentTaskCompleted({ cacheHit: true });
|
|
68311
68340
|
return replayed;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserbasehq/stagehand",
|
|
3
|
-
"version": "3.0.8-alpha-
|
|
3
|
+
"version": "3.0.8-alpha-088c4cc31dc924bb232a9d5a09ab42cd961c2d36",
|
|
4
4
|
"description": "An AI web browsing framework focused on simplicity and extensibility.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|