@rtrvr-ai/rover 1.1.0 → 1.1.1
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/README.md +38 -15
- package/dist/embed.js +16 -16
- package/dist/index.d.ts +25 -2
- package/dist/rover.js +379 -33
- package/dist/worker/rover-worker.js +41 -25
- package/package.json +1 -1
|
@@ -795,7 +795,6 @@ function buildRoverRuntimeContext(config2) {
|
|
|
795
795
|
const compactExternalTabs = normalizeRuntimeExternalTabs(runtimeContext.externalTabs).slice(0, 8);
|
|
796
796
|
return {
|
|
797
797
|
mode: "rover_embed",
|
|
798
|
-
embeddedDomain: String(runtimeContext.embeddedDomain || "").trim() || void 0,
|
|
799
798
|
agentName: normalizeAgentName(runtimeContext.agentName) || "Rover",
|
|
800
799
|
externalNavigationPolicy: runtimeContext.externalNavigationPolicy || config2.externalNavigationPolicy,
|
|
801
800
|
tabIdContract: runtimeContext.tabIdContract || "tree_index_mapped_by_tab_order",
|
|
@@ -803,7 +802,6 @@ function buildRoverRuntimeContext(config2) {
|
|
|
803
802
|
};
|
|
804
803
|
}
|
|
805
804
|
function buildExternalPlaceholderPageData(params) {
|
|
806
|
-
const embedded = params.embeddedDomain || "the configured domain";
|
|
807
805
|
const agentName = normalizeAgentName(params.agentName) || "Rover";
|
|
808
806
|
const reason = params.reason || "external_domain_inaccessible";
|
|
809
807
|
const title = params.title || "External Tab (Inaccessible)";
|
|
@@ -813,7 +811,7 @@ function buildExternalPlaceholderPageData(params) {
|
|
|
813
811
|
url,
|
|
814
812
|
title,
|
|
815
813
|
contentType: "text/html",
|
|
816
|
-
content: `${agentName} is
|
|
814
|
+
content: `${agentName} is running in virtual external-tab mode. Live DOM control and accessibility-tree access are unavailable here.${reasonLine}`,
|
|
817
815
|
metadata: {
|
|
818
816
|
inaccessible: true,
|
|
819
817
|
external: true,
|
|
@@ -865,8 +863,9 @@ function createAgentContext(config2, bridgeRpc2, tabularStore2) {
|
|
|
865
863
|
const RETRY_DELAYS = [1e3, 3e3];
|
|
866
864
|
const MAX_RETRIES3 = RETRY_DELAYS.length;
|
|
867
865
|
const ACTIVE_TAB_CACHE_TTL_MS = 250;
|
|
866
|
+
const EXTERNAL_PAGE_CACHE_TTL_MS = 45e3;
|
|
868
867
|
const callExtensionRouter = async (action, data) => {
|
|
869
|
-
const token = config2.
|
|
868
|
+
const token = config2.authToken || config2.apiKey;
|
|
870
869
|
if (!token) {
|
|
871
870
|
throw createRoverError({
|
|
872
871
|
code: "MISSING_API_KEY",
|
|
@@ -950,13 +949,19 @@ function createAgentContext(config2, bridgeRpc2, tabularStore2) {
|
|
|
950
949
|
const normalizedUrl = String(url || "").trim();
|
|
951
950
|
if (!normalizedUrl)
|
|
952
951
|
throw new Error("external page data requires url");
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
|
|
952
|
+
const cacheTabId = Number(options?.tabId) || 0;
|
|
953
|
+
const cacheKey = `${cacheTabId}:${normalizedUrl}`;
|
|
954
|
+
const nowMs = Date.now();
|
|
955
|
+
const cachedData = externalPageDataCache.get(cacheKey);
|
|
956
|
+
if (cachedData && nowMs - cachedData.ts <= EXTERNAL_PAGE_CACHE_TTL_MS) {
|
|
957
|
+
return cachedData.data;
|
|
956
958
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
+
externalPageDataCache.delete(cacheKey);
|
|
960
|
+
const cachedError = externalPageDataErrorCache.get(cacheKey);
|
|
961
|
+
if (cachedError && nowMs - cachedError.ts <= EXTERNAL_PAGE_CACHE_TTL_MS) {
|
|
962
|
+
throw new Error(cachedError.message || "external page data fetch failed");
|
|
959
963
|
}
|
|
964
|
+
externalPageDataErrorCache.delete(cacheKey);
|
|
960
965
|
if (externalPageDataDisabledReason) {
|
|
961
966
|
throw new Error(externalPageDataDisabledReason);
|
|
962
967
|
}
|
|
@@ -973,12 +978,12 @@ function createAgentContext(config2, bridgeRpc2, tabularStore2) {
|
|
|
973
978
|
try {
|
|
974
979
|
const response = await callExtensionRouter(SUB_AGENTS.roverExternalPageData, payload);
|
|
975
980
|
const pageData = response?.data || response;
|
|
976
|
-
externalPageDataCache.set(cacheKey, pageData);
|
|
981
|
+
externalPageDataCache.set(cacheKey, { data: pageData, ts: nowMs });
|
|
977
982
|
return pageData;
|
|
978
983
|
} catch (error) {
|
|
979
984
|
const envelope = toRoverErrorEnvelope(error, "external page data fetch failed");
|
|
980
985
|
const normalizedMessage = envelope?.message || "external page data fetch failed";
|
|
981
|
-
externalPageDataErrorCache.set(cacheKey, normalizedMessage);
|
|
986
|
+
externalPageDataErrorCache.set(cacheKey, { message: normalizedMessage, ts: nowMs });
|
|
982
987
|
if (envelope.code === "PERMISSION_DENIED" || envelope.code === "MISSING_API_KEY" || envelope.code === "INVALID_API_KEY") {
|
|
983
988
|
externalPageDataDisabledReason = `${envelope.code}: ${normalizedMessage}`;
|
|
984
989
|
}
|
|
@@ -1023,7 +1028,6 @@ function createAgentContext(config2, bridgeRpc2, tabularStore2) {
|
|
|
1023
1028
|
tabId: numericTabId,
|
|
1024
1029
|
url: pageUrl,
|
|
1025
1030
|
title: localPageData?.title,
|
|
1026
|
-
embeddedDomain: runtimeContext?.embeddedDomain,
|
|
1027
1031
|
agentName: runtimeContext?.agentName,
|
|
1028
1032
|
reason: `cloud_fetch_disabled:${externalPageDataDisabledReason}`
|
|
1029
1033
|
});
|
|
@@ -1037,7 +1041,6 @@ function createAgentContext(config2, bridgeRpc2, tabularStore2) {
|
|
|
1037
1041
|
tabId: numericTabId,
|
|
1038
1042
|
url: pageUrl,
|
|
1039
1043
|
title: localPageData?.title,
|
|
1040
|
-
embeddedDomain: runtimeContext?.embeddedDomain,
|
|
1041
1044
|
agentName: runtimeContext?.agentName,
|
|
1042
1045
|
reason: `policy_blocked:${ruleCheck.reason || "blocked"}`
|
|
1043
1046
|
});
|
|
@@ -1070,7 +1073,6 @@ function createAgentContext(config2, bridgeRpc2, tabularStore2) {
|
|
|
1070
1073
|
tabId: numericTabId,
|
|
1071
1074
|
url: pageUrl,
|
|
1072
1075
|
title: localPageData?.title,
|
|
1073
|
-
embeddedDomain: runtimeContext?.embeddedDomain,
|
|
1074
1076
|
agentName: runtimeContext?.agentName,
|
|
1075
1077
|
reason: `cloud_fetch_failed:${envelope?.code || "unknown"}`
|
|
1076
1078
|
});
|
|
@@ -4158,13 +4160,6 @@ var RPC_TIMEOUT_MS = 3e4;
|
|
|
4158
4160
|
var DETACHED_EXTERNAL_TAB_MAX_AGE_MS = 9e4;
|
|
4159
4161
|
var MAX_CHATLOG_ENTRIES2 = 24;
|
|
4160
4162
|
var MAX_CHATLOG_MESSAGE_CHARS2 = 1e3;
|
|
4161
|
-
function resolveEmbeddedDomain(config2) {
|
|
4162
|
-
const domains = Array.isArray(config2?.allowedDomains) ? config2.allowedDomains : [];
|
|
4163
|
-
const first = String(domains[0] || "").trim();
|
|
4164
|
-
if (!first)
|
|
4165
|
-
return void 0;
|
|
4166
|
-
return first.replace(/^\*?\./, "").replace(/^=/, "");
|
|
4167
|
-
}
|
|
4168
4163
|
function resolveAgentName(config2) {
|
|
4169
4164
|
const raw = String(config2?.ui?.agent?.name || "").trim();
|
|
4170
4165
|
if (!raw)
|
|
@@ -4186,6 +4181,14 @@ function extractWebToolsConfig(config2) {
|
|
|
4186
4181
|
return void 0;
|
|
4187
4182
|
return config2.tools.web;
|
|
4188
4183
|
}
|
|
4184
|
+
function resolveRuntimeExternalNavigationPolicy(config2) {
|
|
4185
|
+
if (!config2)
|
|
4186
|
+
return void 0;
|
|
4187
|
+
if (config2.externalNavigationPolicy === "open_new_tab_notice" || config2.externalNavigationPolicy === "block" || config2.externalNavigationPolicy === "allow") {
|
|
4188
|
+
return config2.externalNavigationPolicy;
|
|
4189
|
+
}
|
|
4190
|
+
return void 0;
|
|
4191
|
+
}
|
|
4189
4192
|
function buildRoverRuntimeContext2(params) {
|
|
4190
4193
|
const externalTabs = params.tabs.map((tab, index) => {
|
|
4191
4194
|
if (!tab.external && tab.accessMode !== "external_placeholder" && tab.accessMode !== "external_scraped") {
|
|
@@ -4202,7 +4205,6 @@ function buildRoverRuntimeContext2(params) {
|
|
|
4202
4205
|
}).filter((tab) => !!tab).slice(0, 8);
|
|
4203
4206
|
return {
|
|
4204
4207
|
mode: "rover_embed",
|
|
4205
|
-
embeddedDomain: params.embeddedDomain,
|
|
4206
4208
|
agentName: params.agentName,
|
|
4207
4209
|
externalNavigationPolicy: params.externalNavigationPolicy,
|
|
4208
4210
|
tabIdContract: "tree_index_mapped_by_tab_order",
|
|
@@ -4856,6 +4858,13 @@ function deriveDirectToolRunOutcome(result) {
|
|
|
4856
4858
|
if (!result || typeof result !== "object") {
|
|
4857
4859
|
return { taskComplete: false };
|
|
4858
4860
|
}
|
|
4861
|
+
const topLevelStatus = String(result.status || "").trim().toLowerCase();
|
|
4862
|
+
if (topLevelStatus === "failure" || topLevelStatus === "failed" || topLevelStatus === "error") {
|
|
4863
|
+
return { taskComplete: false };
|
|
4864
|
+
}
|
|
4865
|
+
if (topLevelStatus === "waiting_input" || topLevelStatus === "needs_input" || topLevelStatus === "pending_user_input") {
|
|
4866
|
+
return { taskComplete: false, needsUserInput: true };
|
|
4867
|
+
}
|
|
4859
4868
|
if (result.error) {
|
|
4860
4869
|
return { taskComplete: false };
|
|
4861
4870
|
}
|
|
@@ -4870,6 +4879,9 @@ function deriveDirectToolRunOutcome(result) {
|
|
|
4870
4879
|
if (Array.isArray(output.questions) && output.questions.length > 0) {
|
|
4871
4880
|
return { taskComplete: false, needsUserInput: true };
|
|
4872
4881
|
}
|
|
4882
|
+
if (output.error) {
|
|
4883
|
+
return { taskComplete: false };
|
|
4884
|
+
}
|
|
4873
4885
|
if (typeof output.taskComplete === "boolean") {
|
|
4874
4886
|
return { taskComplete: !!output.taskComplete };
|
|
4875
4887
|
}
|
|
@@ -4884,10 +4896,16 @@ function deriveDirectToolRunOutcome(result) {
|
|
|
4884
4896
|
if (taskStatus === "completed" || taskStatus === "complete" || taskStatus === "done" || taskStatus === "success") {
|
|
4885
4897
|
return { taskComplete: true };
|
|
4886
4898
|
}
|
|
4899
|
+
if (taskStatus === "failure" || taskStatus === "failed" || taskStatus === "error") {
|
|
4900
|
+
return { taskComplete: false };
|
|
4901
|
+
}
|
|
4887
4902
|
}
|
|
4888
4903
|
if (output.success === false) {
|
|
4889
4904
|
return { taskComplete: false };
|
|
4890
4905
|
}
|
|
4906
|
+
if (String(output.status || "").trim().toLowerCase() === "failure") {
|
|
4907
|
+
return { taskComplete: false };
|
|
4908
|
+
}
|
|
4891
4909
|
}
|
|
4892
4910
|
if (output != null) {
|
|
4893
4911
|
return { taskComplete: true };
|
|
@@ -4960,13 +4978,11 @@ async function handleUserMessage(text, options) {
|
|
|
4960
4978
|
if (!tabularStore) {
|
|
4961
4979
|
tabularStore = new TabularStore(`rover-${trajectoryId}`);
|
|
4962
4980
|
}
|
|
4963
|
-
const embeddedDomain = resolveEmbeddedDomain(config);
|
|
4964
4981
|
const agentName = resolveAgentName(config);
|
|
4965
4982
|
const runtimeContext = buildRoverRuntimeContext2({
|
|
4966
4983
|
tabs: tabsForRun,
|
|
4967
|
-
embeddedDomain,
|
|
4968
4984
|
agentName,
|
|
4969
|
-
externalNavigationPolicy: config
|
|
4985
|
+
externalNavigationPolicy: resolveRuntimeExternalNavigationPolicy(config)
|
|
4970
4986
|
});
|
|
4971
4987
|
const ctx = createAgentContext({
|
|
4972
4988
|
...config,
|