dsh-agent-enhancer 0.3.29 → 0.4.0
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.en.md +4 -4
- package/README.md +4 -4
- package/lib/client/browser-agent/tab.d.ts.map +1 -1
- package/lib/client/dsh/settings-features.d.ts +0 -1
- package/lib/client/dsh/settings-features.d.ts.map +1 -1
- package/lib/client/dsh/settings.d.ts.map +1 -1
- package/lib/client/locales.d.ts +9 -7
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client.js +21 -41
- package/lib/client.js.map +1 -1
- package/lib/config.d.ts +0 -2
- package/lib/config.d.ts.map +1 -1
- package/lib/host/browser-agent/approval.d.ts +5 -0
- package/lib/host/browser-agent/approval.d.ts.map +1 -1
- package/lib/host/browser-agent/demo-heal.d.ts +2 -16
- package/lib/host/browser-agent/demo-heal.d.ts.map +1 -1
- package/lib/host/browser-agent/demo-recipes.d.ts +18 -8
- package/lib/host/browser-agent/demo-recipes.d.ts.map +1 -1
- package/lib/host/browser-agent/install.d.ts +0 -2
- package/lib/host/browser-agent/install.d.ts.map +1 -1
- package/lib/host/browser-agent/playwright-driver.d.ts +17 -0
- package/lib/host/browser-agent/playwright-driver.d.ts.map +1 -1
- package/lib/host/browser-agent/tools.d.ts.map +1 -1
- package/lib/host/index.d.ts +0 -4
- package/lib/host/index.d.ts.map +1 -1
- package/lib/host/rpc.d.ts +44 -0
- package/lib/host/rpc.d.ts.map +1 -1
- package/lib/index.js +116 -75
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -92,7 +92,6 @@ var DEFAULT_SETTINGS = {
|
|
|
92
92
|
browserAgentBrowser: "auto",
|
|
93
93
|
browserAgentDebugTools: false,
|
|
94
94
|
browserAgentDemonstrate: false,
|
|
95
|
-
browserAgentAutoHeal: false,
|
|
96
95
|
browserAgentIdleClose: "10m",
|
|
97
96
|
webChatBridgeEnabled: true,
|
|
98
97
|
instructionsSkillsEnabled: true,
|
|
@@ -141,7 +140,6 @@ function resolveSettings(value) {
|
|
|
141
140
|
browserAgentBrowser: resolveBrowserAgentBrowser(value?.browserAgentBrowser),
|
|
142
141
|
browserAgentDebugTools: value?.browserAgentDebugTools === true,
|
|
143
142
|
browserAgentDemonstrate: value?.browserAgentDemonstrate === true,
|
|
144
|
-
browserAgentAutoHeal: value?.browserAgentAutoHeal === true,
|
|
145
143
|
browserAgentIdleClose: resolveBrowserAgentIdleClose(value?.browserAgentIdleClose),
|
|
146
144
|
webChatBridgeEnabled: value?.webChatBridgeEnabled ?? true,
|
|
147
145
|
instructionsSkillsEnabled: value?.instructionsSkillsEnabled ?? true,
|
|
@@ -274,6 +272,12 @@ var BrowserApprovalGate = class {
|
|
|
274
272
|
});
|
|
275
273
|
return true;
|
|
276
274
|
}
|
|
275
|
+
/** Drop the grant for one origin, e.g. because its run was denied. */
|
|
276
|
+
revokeOrigin(input) {
|
|
277
|
+
const origin = originOfUrl(input.url);
|
|
278
|
+
if (origin === void 0) return false;
|
|
279
|
+
return this.grants.delete(this.grantKey(input.sessionId, origin));
|
|
280
|
+
}
|
|
277
281
|
/** Active grants, for the panel and for tests. */
|
|
278
282
|
activeGrants() {
|
|
279
283
|
this.pruneGrants();
|
|
@@ -1591,6 +1595,20 @@ async function loadPlaywright() {
|
|
|
1591
1595
|
playwrightModule ??= await import("playwright-core");
|
|
1592
1596
|
return playwrightModule;
|
|
1593
1597
|
}
|
|
1598
|
+
var AGENT_CHROMIUM_ARGS = [
|
|
1599
|
+
"--no-first-run",
|
|
1600
|
+
"--no-default-browser-check",
|
|
1601
|
+
"--disable-default-apps"
|
|
1602
|
+
];
|
|
1603
|
+
function hideWebdriver() {
|
|
1604
|
+
try {
|
|
1605
|
+
Object.defineProperty(Navigator.prototype, "webdriver", {
|
|
1606
|
+
configurable: true,
|
|
1607
|
+
get: () => false
|
|
1608
|
+
});
|
|
1609
|
+
} catch {
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1594
1612
|
var PlaywrightDriver = class {
|
|
1595
1613
|
kind = "playwright";
|
|
1596
1614
|
profileDirOption;
|
|
@@ -1782,10 +1800,12 @@ var PlaywrightDriver = class {
|
|
|
1782
1800
|
this.lastError = "WEBKIT_MISSING: Playwright WebKit is not installed. Run: npx playwright install webkit";
|
|
1783
1801
|
return null;
|
|
1784
1802
|
}
|
|
1785
|
-
|
|
1803
|
+
const context = await webkit.launchPersistentContext(profileDir, {
|
|
1786
1804
|
headless: this.headless,
|
|
1787
1805
|
viewport: this.headless ? { width: 1280, height: 800 } : null
|
|
1788
1806
|
});
|
|
1807
|
+
await context.addInitScript(hideWebdriver);
|
|
1808
|
+
return context;
|
|
1789
1809
|
}
|
|
1790
1810
|
async launchChromium(profileDir, preference, channel) {
|
|
1791
1811
|
const kind = channel === "msedge" ? "edge" : "chrome";
|
|
@@ -1800,15 +1820,17 @@ var PlaywrightDriver = class {
|
|
|
1800
1820
|
return null;
|
|
1801
1821
|
}
|
|
1802
1822
|
const { chromium } = await loadPlaywright();
|
|
1803
|
-
|
|
1823
|
+
const context = await chromium.launchPersistentContext(profileDir, {
|
|
1804
1824
|
executablePath: resolved.executable,
|
|
1805
1825
|
headless: this.headless,
|
|
1806
1826
|
// Avoid Edge/Chrome infobar: "unsupported command-line flag: --no-sandbox".
|
|
1807
1827
|
chromiumSandbox: true,
|
|
1808
1828
|
ignoreDefaultArgs: ["--no-sandbox"],
|
|
1809
1829
|
viewport: this.headless ? { width: 1280, height: 800 } : null,
|
|
1810
|
-
args: [
|
|
1830
|
+
args: [...AGENT_CHROMIUM_ARGS]
|
|
1811
1831
|
});
|
|
1832
|
+
await context.addInitScript(hideWebdriver);
|
|
1833
|
+
return context;
|
|
1812
1834
|
}
|
|
1813
1835
|
stopPreferenceProfiles(activeProfileDir) {
|
|
1814
1836
|
stopAgentBrowserProcesses(activeProfileDir);
|
|
@@ -3367,16 +3389,6 @@ function describeHealProposal(proposal) {
|
|
|
3367
3389
|
}
|
|
3368
3390
|
return lines;
|
|
3369
3391
|
}
|
|
3370
|
-
var AUTO_HEAL_BUDGET = 3;
|
|
3371
|
-
var AUTO_HEAL_WINDOW_MS = 24 * 60 * 6e4;
|
|
3372
|
-
function sameOrigin(a, b) {
|
|
3373
|
-
if (a === void 0 || b === void 0) return false;
|
|
3374
|
-
try {
|
|
3375
|
-
return new URL(a).origin === new URL(b).origin;
|
|
3376
|
-
} catch {
|
|
3377
|
-
return false;
|
|
3378
|
-
}
|
|
3379
|
-
}
|
|
3380
3392
|
function createRepairHooks(input) {
|
|
3381
3393
|
const clock = input.now ?? Date.now;
|
|
3382
3394
|
return {
|
|
@@ -3404,20 +3416,11 @@ function createRepairHooks(input) {
|
|
|
3404
3416
|
});
|
|
3405
3417
|
if (proposal === null) return null;
|
|
3406
3418
|
if (!input.store.recordHeal({ id: recipe.id, proposal }).ok) return null;
|
|
3407
|
-
let autoApplied = false;
|
|
3408
|
-
if (input.autoApply?.() === true) {
|
|
3409
|
-
const recorded = recipe.steps.find((step) => step.tabUrl !== void 0)?.tabUrl;
|
|
3410
|
-
const recent = recipe.autoHeals.filter((at) => now - at < AUTO_HEAL_WINDOW_MS);
|
|
3411
|
-
if (sameOrigin(recorded, pending.target.tabUrl) && recent.length < AUTO_HEAL_BUDGET) {
|
|
3412
|
-
autoApplied = input.store.resolveHeal({ id: recipe.id, accept: true, auto: true, now }).ok;
|
|
3413
|
-
}
|
|
3414
|
-
}
|
|
3415
3419
|
return {
|
|
3416
3420
|
recipeId: recipe.id,
|
|
3417
3421
|
recipeName: recipe.name,
|
|
3418
3422
|
failedAt: proposal.failedAt,
|
|
3419
|
-
lines: describeHealProposal(proposal)
|
|
3420
|
-
autoApplied
|
|
3423
|
+
lines: describeHealProposal(proposal)
|
|
3421
3424
|
};
|
|
3422
3425
|
}
|
|
3423
3426
|
};
|
|
@@ -3455,7 +3458,6 @@ var MAX_RECIPE_NAME = 60;
|
|
|
3455
3458
|
var MAX_RECIPE_STEPS = 200;
|
|
3456
3459
|
var MAX_HISTORY = 5;
|
|
3457
3460
|
var MAX_VARIABLE_LABEL = 60;
|
|
3458
|
-
var MAX_AUTO_HEALS = 3;
|
|
3459
3461
|
var FILE_VERSION = 2;
|
|
3460
3462
|
function metaOf(recipe) {
|
|
3461
3463
|
const site = siteOf(recipe.steps);
|
|
@@ -3468,8 +3470,8 @@ function metaOf(recipe) {
|
|
|
3468
3470
|
variables: recipe.variables,
|
|
3469
3471
|
rev: recipe.rev,
|
|
3470
3472
|
history: recipe.history.length,
|
|
3471
|
-
autoHeals: recipe.autoHeals.length,
|
|
3472
3473
|
unattended: recipe.unattended,
|
|
3474
|
+
...recipe.lastRun === void 0 ? {} : { lastRun: recipe.lastRun },
|
|
3473
3475
|
...site === void 0 ? {} : { site },
|
|
3474
3476
|
...recipe.pendingHeal === void 0 ? {} : { pendingHeal: recipe.pendingHeal }
|
|
3475
3477
|
};
|
|
@@ -3541,6 +3543,22 @@ function prepareRecipeValues(recipe, provided, now = /* @__PURE__ */ new Date())
|
|
|
3541
3543
|
const missing = recipe.variables.filter((variable) => (values[variable.name] ?? "").trim() === "");
|
|
3542
3544
|
return { values, missing, resolved, unknown: matched.unknown };
|
|
3543
3545
|
}
|
|
3546
|
+
function sanitizeRunResult(raw) {
|
|
3547
|
+
if (raw === null || typeof raw !== "object") return void 0;
|
|
3548
|
+
const entry = raw;
|
|
3549
|
+
if (entry.status !== "ok" && entry.status !== "stopped" && entry.status !== "failed") return void 0;
|
|
3550
|
+
const at = Number(entry.at);
|
|
3551
|
+
const performed = Number(entry.performed);
|
|
3552
|
+
const total = Number(entry.total);
|
|
3553
|
+
if (!Number.isFinite(at) || !Number.isFinite(performed) || !Number.isFinite(total)) return void 0;
|
|
3554
|
+
return {
|
|
3555
|
+
at,
|
|
3556
|
+
status: entry.status,
|
|
3557
|
+
performed: Math.max(0, Math.floor(performed)),
|
|
3558
|
+
total: Math.max(0, Math.floor(total)),
|
|
3559
|
+
...typeof entry.reason === "string" && entry.reason !== "" ? { reason: entry.reason.slice(0, 200) } : {}
|
|
3560
|
+
};
|
|
3561
|
+
}
|
|
3544
3562
|
function sanitizeVariables(raw) {
|
|
3545
3563
|
if (!Array.isArray(raw)) return [];
|
|
3546
3564
|
return raw.filter((value) => {
|
|
@@ -3573,10 +3591,6 @@ function sanitizeHistory(raw) {
|
|
|
3573
3591
|
}
|
|
3574
3592
|
return versions.slice(-MAX_HISTORY);
|
|
3575
3593
|
}
|
|
3576
|
-
function sanitizeTimestamps(raw) {
|
|
3577
|
-
if (!Array.isArray(raw)) return [];
|
|
3578
|
-
return raw.filter((value) => typeof value === "number" && Number.isFinite(value) && value > 0).slice(-MAX_AUTO_HEALS * 4);
|
|
3579
|
-
}
|
|
3580
3594
|
function sanitizeProposal(raw) {
|
|
3581
3595
|
if (raw === null || typeof raw !== "object") return void 0;
|
|
3582
3596
|
const entry = raw;
|
|
@@ -3660,7 +3674,6 @@ var DemoRecipeStore = class {
|
|
|
3660
3674
|
variables: [],
|
|
3661
3675
|
rev: 1,
|
|
3662
3676
|
history: [],
|
|
3663
|
-
autoHeals: [],
|
|
3664
3677
|
unattended: false
|
|
3665
3678
|
};
|
|
3666
3679
|
}
|
|
@@ -3762,8 +3775,7 @@ var DemoRecipeStore = class {
|
|
|
3762
3775
|
steps,
|
|
3763
3776
|
updatedAt: now,
|
|
3764
3777
|
rev: current.rev + 1,
|
|
3765
|
-
history: nextVersion(current, "heal", now)
|
|
3766
|
-
autoHeals: input.auto === true ? [...current.autoHeals, now].slice(-MAX_AUTO_HEALS) : current.autoHeals
|
|
3778
|
+
history: nextVersion(current, "heal", now)
|
|
3767
3779
|
};
|
|
3768
3780
|
this.write(recipes.map((recipe) => recipe.id === current.id ? next : recipe));
|
|
3769
3781
|
return { ok: true, recipe: metaOf(next) };
|
|
@@ -3822,6 +3834,15 @@ var DemoRecipeStore = class {
|
|
|
3822
3834
|
this.write(recipes.map((recipe) => recipe.id === current.id ? next : recipe));
|
|
3823
3835
|
return { ok: true, recipe: metaOf(next) };
|
|
3824
3836
|
}
|
|
3837
|
+
/** Record how the last run ended. Not flow content: `rev` does not move. */
|
|
3838
|
+
recordRun(input) {
|
|
3839
|
+
const recipes = this.read();
|
|
3840
|
+
const current = recipes.find((recipe) => recipe.id === input.id);
|
|
3841
|
+
if (current === void 0) return false;
|
|
3842
|
+
const next = { ...current, lastRun: input.result };
|
|
3843
|
+
this.write(recipes.map((recipe) => recipe.id === current.id ? next : recipe));
|
|
3844
|
+
return true;
|
|
3845
|
+
}
|
|
3825
3846
|
/**
|
|
3826
3847
|
* Allow (or stop allowing) this flow to run without per-action cards. Kept
|
|
3827
3848
|
* out of `rev`: it is a policy flag, not flow content.
|
|
@@ -3870,16 +3891,17 @@ var DemoRecipeStore = class {
|
|
|
3870
3891
|
if (typeof recipe.id !== "string" || typeof recipe.name !== "string") return false;
|
|
3871
3892
|
return typeof recipe.createdAt === "number" && typeof recipe.updatedAt === "number";
|
|
3872
3893
|
}).map((recipe) => {
|
|
3873
|
-
const { pendingHeal: rawProposal, ...rest } = recipe;
|
|
3894
|
+
const { pendingHeal: rawProposal, lastRun: rawLastRun, ...rest } = recipe;
|
|
3874
3895
|
const proposal = sanitizeProposal(rawProposal);
|
|
3896
|
+
const lastRun = sanitizeRunResult(rawLastRun);
|
|
3875
3897
|
return {
|
|
3876
3898
|
...rest,
|
|
3877
3899
|
steps: sanitizeRecipeSteps(recipe.steps),
|
|
3878
3900
|
variables: sanitizeVariables(recipe.variables),
|
|
3879
3901
|
rev: Number.isFinite(recipe.rev) && recipe.rev > 0 ? recipe.rev : 1,
|
|
3880
3902
|
history: sanitizeHistory(recipe.history),
|
|
3881
|
-
autoHeals: sanitizeTimestamps(recipe.autoHeals),
|
|
3882
3903
|
unattended: recipe.unattended === true,
|
|
3904
|
+
...lastRun === void 0 ? {} : { lastRun },
|
|
3883
3905
|
...proposal === void 0 ? {} : { pendingHeal: proposal }
|
|
3884
3906
|
};
|
|
3885
3907
|
}).filter((recipe) => recipe.steps.length > 0).slice(0, MAX_RECIPES);
|
|
@@ -5260,10 +5282,9 @@ Action: browser_extract or browser_snapshot next. Do not navigate away unless th
|
|
|
5260
5282
|
...afterCommit.map((row) => {
|
|
5261
5283
|
const vars = row.variables.length === 0 ? "" : `; vars: ${row.variables.map((variable) => variable.name).join(", ")}`;
|
|
5262
5284
|
const heal = row.pendingHeal === void 0 ? "" : `; repair waiting: step ${row.pendingHeal.failedAt}`;
|
|
5263
|
-
const auto = row.autoHeals === 0 ? "" : `; auto-adapted ${row.autoHeals}x`;
|
|
5264
5285
|
const site = row.site === void 0 ? "" : `; site: ${row.site}`;
|
|
5265
5286
|
const unattended2 = row.unattended ? "; unattended: yes" : "";
|
|
5266
|
-
return `- ${row.name} (${row.steps} step(s)${vars}${heal}${
|
|
5287
|
+
return `- ${row.name} (${row.steps} step(s)${vars}${heal}${site}${unattended2})`;
|
|
5267
5288
|
}),
|
|
5268
5289
|
'Action: run one with browser_demo_recipes { action: "run", name: "<name>" }.'
|
|
5269
5290
|
].join("\n");
|
|
@@ -5274,19 +5295,6 @@ Action: browser_extract or browser_snapshot next. Do not navigate away unless th
|
|
|
5274
5295
|
if (id === "") {
|
|
5275
5296
|
return "nothing to remember: no saved flow stopped recently, so there is no repair to store.";
|
|
5276
5297
|
}
|
|
5277
|
-
if (committed?.autoApplied === true) {
|
|
5278
|
-
options.sessions.record({
|
|
5279
|
-
sessionId: sessionIdOf(exec),
|
|
5280
|
-
tool: "browser_demo_recipe",
|
|
5281
|
-
summary: `Auto-adapted saved flow "${committed.recipeName}"`,
|
|
5282
|
-
outcome: "ok"
|
|
5283
|
-
});
|
|
5284
|
-
return [
|
|
5285
|
-
`saved flow: ${committed.recipeName} \u2014 repair applied automatically (\u81EA\u52A8\u9002\u5E94 is on)`,
|
|
5286
|
-
...committed.lines.map((line) => `- ${line}`),
|
|
5287
|
-
"Action: tell the user the flow was updated without asking, and that \u64A4\u9500\u4E0A\u6B21\u4FEE\u6539 in the sidebar restores the previous version."
|
|
5288
|
-
].join("\n");
|
|
5289
|
-
}
|
|
5290
5298
|
if (args.accept !== true) {
|
|
5291
5299
|
const row = store.list().find((candidate) => candidate.id === id);
|
|
5292
5300
|
const proposal = row?.pendingHeal;
|
|
@@ -5338,14 +5346,6 @@ Action: browser_extract or browser_snapshot next. Do not navigate away unless th
|
|
|
5338
5346
|
}
|
|
5339
5347
|
const sessionId = sessionIdOf(exec);
|
|
5340
5348
|
const unattended = recipe.unattended && meta.site !== void 0;
|
|
5341
|
-
if (unattended) {
|
|
5342
|
-
options.approval.grantOrigin({
|
|
5343
|
-
sessionId,
|
|
5344
|
-
url: meta.site,
|
|
5345
|
-
ttlMs: 20 * 6e4,
|
|
5346
|
-
actions: 30
|
|
5347
|
-
});
|
|
5348
|
-
}
|
|
5349
5349
|
options.repair?.commit();
|
|
5350
5350
|
const provided = args.vars !== null && typeof args.vars === "object" ? Object.fromEntries(Object.entries(args.vars).filter(([, value]) => typeof value === "string").map(([key, value]) => [key, String(value)])) : {};
|
|
5351
5351
|
const prepared = prepareRecipeValues(recipe, provided);
|
|
@@ -5361,14 +5361,42 @@ Action: browser_extract or browser_snapshot next. Do not navigate away unless th
|
|
|
5361
5361
|
await ensureConnected();
|
|
5362
5362
|
await ensureSessionTab(sessionId);
|
|
5363
5363
|
const firstUrl = recipe.steps.find((step) => step.tabUrl !== void 0)?.tabUrl;
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5364
|
+
const grantedSite = unattended && meta.site !== void 0 ? options.approval.grantOrigin({ sessionId, url: meta.site, ttlMs: 20 * 6e4, actions: 30 }) ? meta.site : void 0 : void 0;
|
|
5365
|
+
try {
|
|
5366
|
+
await requireMutation(
|
|
5367
|
+
exec,
|
|
5368
|
+
"browser_demo_recipes",
|
|
5369
|
+
`\u8FD0\u884C\u5DF2\u4FDD\u5B58\u6D41\u7A0B\u300C${recipe.name}\u300D\uFF08${recipe.steps.length} \u6B65\uFF09`,
|
|
5370
|
+
firstUrl
|
|
5371
|
+
);
|
|
5372
|
+
} catch (error) {
|
|
5373
|
+
if (grantedSite !== void 0) options.approval.revokeOrigin({ sessionId, url: grantedSite });
|
|
5374
|
+
throw error;
|
|
5375
|
+
}
|
|
5376
|
+
const outcome = await replayDemoSteps(driverOf(options), replaySteps).catch((error) => {
|
|
5377
|
+
store.recordRun({
|
|
5378
|
+
id: recipe.id,
|
|
5379
|
+
result: {
|
|
5380
|
+
at: Date.now(),
|
|
5381
|
+
status: "failed",
|
|
5382
|
+
performed: 0,
|
|
5383
|
+
total: replaySteps.length,
|
|
5384
|
+
reason: error instanceof Error ? error.message.slice(0, 200) : String(error).slice(0, 200)
|
|
5385
|
+
}
|
|
5386
|
+
});
|
|
5387
|
+
throw error;
|
|
5388
|
+
});
|
|
5371
5389
|
const ranAll = outcome.status === "done";
|
|
5390
|
+
store.recordRun({
|
|
5391
|
+
id: recipe.id,
|
|
5392
|
+
result: {
|
|
5393
|
+
at: Date.now(),
|
|
5394
|
+
status: ranAll ? "ok" : "stopped",
|
|
5395
|
+
performed: outcome.performed,
|
|
5396
|
+
total: outcome.total,
|
|
5397
|
+
...ranAll ? {} : { reason: outcome.reason.slice(0, 200) }
|
|
5398
|
+
}
|
|
5399
|
+
});
|
|
5372
5400
|
if (!ranAll) {
|
|
5373
5401
|
const failedStep = recipe.steps[outcome.performed];
|
|
5374
5402
|
const isSecret = /masked|secret field/i.test(outcome.reason) || failedStep !== void 0 && failedStep.kind === "fill" && failedStep.masked;
|
|
@@ -5531,8 +5559,7 @@ function installBrowserAgent(ctx, options) {
|
|
|
5531
5559
|
const repairTracker = new DemoRepairTracker();
|
|
5532
5560
|
const repairHooks = createRepairHooks({
|
|
5533
5561
|
tracker: repairTracker,
|
|
5534
|
-
...recipes === void 0 ? {} : { store: recipes }
|
|
5535
|
-
...options.autoHeal === void 0 ? {} : { autoApply: options.autoHeal }
|
|
5562
|
+
...recipes === void 0 ? {} : { store: recipes }
|
|
5536
5563
|
});
|
|
5537
5564
|
let availabilityCache = null;
|
|
5538
5565
|
const browserAvailability = () => {
|
|
@@ -6054,6 +6081,16 @@ function installBrowserAgent(ctx, options) {
|
|
|
6054
6081
|
pending: [...steps]
|
|
6055
6082
|
}));
|
|
6056
6083
|
const ranAll = outcome.status === "done";
|
|
6084
|
+
recipes.recordRun({
|
|
6085
|
+
id: recipe.id,
|
|
6086
|
+
result: {
|
|
6087
|
+
at: Date.now(),
|
|
6088
|
+
status: ranAll ? "ok" : "stopped",
|
|
6089
|
+
performed: outcome.performed,
|
|
6090
|
+
total: outcome.total,
|
|
6091
|
+
...ranAll ? {} : { reason: outcome.reason.slice(0, 200) }
|
|
6092
|
+
}
|
|
6093
|
+
});
|
|
6057
6094
|
if (!ranAll) {
|
|
6058
6095
|
const failedStep = recipe.steps[outcome.performed];
|
|
6059
6096
|
const isSecret = /masked|secret field/i.test(outcome.reason) || failedStep !== void 0 && failedStep.kind === "fill" && failedStep.masked;
|
|
@@ -18333,6 +18370,13 @@ var demoRecipeHealSchema = z4.strictObject({
|
|
|
18333
18370
|
inserted: z4.number().int().min(0),
|
|
18334
18371
|
reason: z4.string()
|
|
18335
18372
|
});
|
|
18373
|
+
var demoRunResultSchema = z4.strictObject({
|
|
18374
|
+
at: z4.number(),
|
|
18375
|
+
status: z4.enum(["ok", "stopped", "failed"]),
|
|
18376
|
+
performed: z4.number().int(),
|
|
18377
|
+
total: z4.number().int(),
|
|
18378
|
+
reason: z4.string().optional()
|
|
18379
|
+
});
|
|
18336
18380
|
var demoRecipeMetaSchema = z4.strictObject({
|
|
18337
18381
|
id: z4.string().min(1),
|
|
18338
18382
|
name: z4.string().min(1),
|
|
@@ -18348,6 +18392,8 @@ var demoRecipeMetaSchema = z4.strictObject({
|
|
|
18348
18392
|
unattended: z4.boolean(),
|
|
18349
18393
|
/** Origin the flow was recorded on. */
|
|
18350
18394
|
site: z4.string().optional(),
|
|
18395
|
+
/** Last run outcome. */
|
|
18396
|
+
lastRun: demoRunResultSchema.optional(),
|
|
18351
18397
|
/** A repair worked out by the agent, waiting for the user. */
|
|
18352
18398
|
pendingHeal: demoRecipeHealSchema.optional()
|
|
18353
18399
|
});
|
|
@@ -20036,8 +20082,6 @@ var Config = z5.object({
|
|
|
20036
20082
|
browserAgentDebugTools: z5.boolean().default(false).volatile(),
|
|
20037
20083
|
/** "Show me" recorder; observes user actions in the bound tab, default off. */
|
|
20038
20084
|
browserAgentDemonstrate: z5.boolean().default(false).volatile(),
|
|
20039
|
-
/** Keep a repair automatically when the site changed (locator only). Default off. */
|
|
20040
|
-
browserAgentAutoHeal: z5.boolean().default(false).volatile(),
|
|
20041
20085
|
/** Close idle agent tabs after ~10 min; coerced via resolveBrowserAgentIdleClose. */
|
|
20042
20086
|
browserAgentIdleClose: z5.union([z5.boolean(), z5.string()]).default("10m").volatile(),
|
|
20043
20087
|
/** Default off; embeds official web chat + import to work. */
|
|
@@ -20917,6 +20961,7 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
20917
20961
|
history: recipe.history,
|
|
20918
20962
|
unattended: recipe.unattended,
|
|
20919
20963
|
...recipe.site === void 0 ? {} : { site: recipe.site },
|
|
20964
|
+
...recipe.lastRun === void 0 ? {} : { lastRun: { ...recipe.lastRun } },
|
|
20920
20965
|
...recipe.pendingHeal === void 0 ? {} : {
|
|
20921
20966
|
pendingHeal: {
|
|
20922
20967
|
id: recipe.pendingHeal.id,
|
|
@@ -21056,7 +21101,6 @@ function readSettings(config) {
|
|
|
21056
21101
|
browserAgentBrowser: hostBrowserPreference(config.browserAgentBrowser.get()),
|
|
21057
21102
|
browserAgentDebugTools: config.browserAgentDebugTools.get(),
|
|
21058
21103
|
browserAgentDemonstrate: config.browserAgentDemonstrate.get(),
|
|
21059
|
-
browserAgentAutoHeal: config.browserAgentAutoHeal.get(),
|
|
21060
21104
|
browserAgentIdleClose: resolveBrowserAgentIdleClose(config.browserAgentIdleClose.get()),
|
|
21061
21105
|
webChatBridgeEnabled: config.webChatBridgeEnabled.get(),
|
|
21062
21106
|
instructionsSkillsEnabled: config.instructionsSkillsEnabled.get(),
|
|
@@ -21140,15 +21184,13 @@ function apply(ctx, config) {
|
|
|
21140
21184
|
const browserAgentLive = {
|
|
21141
21185
|
enabled: settings().browserAgentEnabled,
|
|
21142
21186
|
browser: settings().browserAgentBrowser,
|
|
21143
|
-
demonstrate: settings().browserAgentDemonstrate
|
|
21144
|
-
autoHeal: settings().browserAgentAutoHeal
|
|
21187
|
+
demonstrate: settings().browserAgentDemonstrate
|
|
21145
21188
|
};
|
|
21146
21189
|
const browserAgent = installBrowserAgent(ctx, {
|
|
21147
21190
|
enabled: () => browserAgentLive.enabled,
|
|
21148
21191
|
browserPreference: () => browserAgentLive.browser,
|
|
21149
21192
|
debugTools: () => settings().browserAgentDebugTools,
|
|
21150
21193
|
demonstrate: () => settings().browserAgentDemonstrate,
|
|
21151
|
-
autoHeal: () => settings().browserAgentAutoHeal,
|
|
21152
21194
|
idleClose: () => settings().browserAgentIdleClose,
|
|
21153
21195
|
recipes: new DemoRecipeStore(join30(pluginDataPackageRoot, "demo-recipes.json")),
|
|
21154
21196
|
profileRoot: pluginDataPackageRoot,
|
|
@@ -21218,7 +21260,6 @@ function apply(ctx, config) {
|
|
|
21218
21260
|
browserAgentLive.enabled = cfg.browserAgentEnabled.get();
|
|
21219
21261
|
browserAgentLive.browser = hostBrowserPreference(cfg.browserAgentBrowser.get());
|
|
21220
21262
|
browserAgentLive.demonstrate = cfg.browserAgentDemonstrate.get();
|
|
21221
|
-
browserAgentLive.autoHeal = cfg.browserAgentAutoHeal.get();
|
|
21222
21263
|
browserAgent.refresh();
|
|
21223
21264
|
if (browserAgentLive.enabled && prevBrowser !== browserAgentLive.browser && browserAgent.driverStatus()?.ready === true) {
|
|
21224
21265
|
void browserAgent.alignToPreference().catch((error) => {
|