@wenathlan/extension 1.1.63 → 1.1.64
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 +4 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +404 -1
- package/dist/index.js.map +4 -4
- package/dist/memory.d.ts +28 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/planreview.d.ts +87 -0
- package/dist/planreview.d.ts.map +1 -0
- package/dist/policy.d.ts +47 -0
- package/dist/policy.d.ts.map +1 -1
- package/dist/protocol.d.ts +135 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/surfaces.d.ts +59 -0
- package/dist/surfaces.d.ts.map +1 -0
- package/dist/types.d.ts +181 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/extension/dist/background.js +669 -2
- package/extension/dist/background.js.map +4 -4
- package/extension/dist/dashboardpage.html +13 -0
- package/extension/dist/dashboardpage.js +129 -0
- package/extension/dist/dashboardpage.js.map +7 -0
- package/extension/dist/manifest.json +5 -2
- package/extension/dist/offscreen.js +1 -0
- package/extension/dist/offscreen.js.map +2 -2
- package/extension/dist/optionspage.html +14 -0
- package/extension/dist/optionspage.js +118 -0
- package/extension/dist/optionspage.js.map +7 -0
- package/extension/dist/pagebridge.js.map +1 -1
- package/extension/dist/popup.html +4 -1
- package/extension/dist/popup.js +167 -0
- package/extension/dist/popup.js.map +3 -3
- package/extension/dist/sidepanel.html +7 -2
- package/extension/dist/sidepanel.js +279 -0
- package/extension/dist/sidepanel.js.map +2 -2
- package/extension/manifest.json +5 -2
- package/package.json +1 -1
|
@@ -5106,6 +5106,59 @@ var sessionmemory = class {
|
|
|
5106
5106
|
async exportsessionbundle(exportedat) {
|
|
5107
5107
|
return { kind: "sessionbundle", notes: await this.getsitenotes(), summaries: await this.listrunsummaries(), corrections: await this.getcorrections(), exportedat };
|
|
5108
5108
|
}
|
|
5109
|
+
/**
|
|
5110
|
+
* Interface surface stores of the 1.1.64 family live here, scoped per profile workspace: the commandpalette usage counts the recent first ranking reads, the taskinput history of natural language goals, the onboarding completion state, the per surface layout preferences, the logstream filter preferences and the stepapprove resolution history per origin.
|
|
5111
|
+
*/
|
|
5112
|
+
/** Returns every commandpalette usage record so the ranking lifts the recent commands first. */
|
|
5113
|
+
async getpaletteusage() {
|
|
5114
|
+
return await this.adapter.get("paletteusage") ?? [];
|
|
5115
|
+
}
|
|
5116
|
+
/** Replaces the commandpalette usage records after one use: the count grows and the last use time moves so the ranking reads both. */
|
|
5117
|
+
async setpaletteusage(records) {
|
|
5118
|
+
return this.adapter.set("paletteusage", records);
|
|
5119
|
+
}
|
|
5120
|
+
/** Returns the stored taskinput history, newest first. */
|
|
5121
|
+
async gettaskinputs() {
|
|
5122
|
+
return await this.adapter.get("taskinputs") ?? [];
|
|
5123
|
+
}
|
|
5124
|
+
/** Adds one taskinput submission to the per profile history; the retention window stays a user setting. */
|
|
5125
|
+
async addtaskinput(entry) {
|
|
5126
|
+
const retention = (await this.getsettings())?.taskinputretention;
|
|
5127
|
+
const history2 = [entry, ...await this.gettaskinputs()];
|
|
5128
|
+
await this.adapter.set("taskinputs", retention === void 0 ? history2 : history2.filter((candidate) => entry.at - candidate.at < retention));
|
|
5129
|
+
}
|
|
5130
|
+
/** Returns the onboarding completion state; an absent state means the walkthrough never ran. */
|
|
5131
|
+
async getonboardingstate() {
|
|
5132
|
+
return this.adapter.get("onboarding");
|
|
5133
|
+
}
|
|
5134
|
+
/** Stores the onboarding completion state; a done walkthrough never runs again on its own. */
|
|
5135
|
+
async setonboardingstate(state) {
|
|
5136
|
+
return this.adapter.set("onboarding", state);
|
|
5137
|
+
}
|
|
5138
|
+
/** Returns the layout preferences of one surface; an absent preference set returns undefined. */
|
|
5139
|
+
async getsurfacelayout(surface) {
|
|
5140
|
+
return this.adapter.get(`surfacelayout:${surface}`);
|
|
5141
|
+
}
|
|
5142
|
+
/** Stores the layout preferences of one surface, scoped per profile workspace. */
|
|
5143
|
+
async setsurfacelayout(layout) {
|
|
5144
|
+
return this.adapter.set(`surfacelayout:${layout.surface}`, layout);
|
|
5145
|
+
}
|
|
5146
|
+
/** Returns the stored logstream filter preferences of the live view. */
|
|
5147
|
+
async getlogstreamfilters() {
|
|
5148
|
+
return this.adapter.get("logstreamfilters");
|
|
5149
|
+
}
|
|
5150
|
+
/** Stores the logstream filter preferences of the live view. */
|
|
5151
|
+
async setlogstreamfilters(filter) {
|
|
5152
|
+
return this.adapter.set("logstreamfilters", filter);
|
|
5153
|
+
}
|
|
5154
|
+
/** Returns every stored stepapprove resolution, newest first, with its human provenance. */
|
|
5155
|
+
async getstepapproveresolutions() {
|
|
5156
|
+
return await this.adapter.get("stepapproveresolutions") ?? [];
|
|
5157
|
+
}
|
|
5158
|
+
/** Records one stepapprove resolution in the per origin history. */
|
|
5159
|
+
async addstepapproveresolution(resolution) {
|
|
5160
|
+
await this.adapter.set("stepapproveresolutions", [resolution, ...await this.getstepapproveresolutions()]);
|
|
5161
|
+
}
|
|
5109
5162
|
};
|
|
5110
5163
|
function mediakindof(record2) {
|
|
5111
5164
|
if ("pages" in record2) return "pdf";
|
|
@@ -10617,6 +10670,48 @@ function retrydispatchgate(input) {
|
|
|
10617
10670
|
if (!input.reviewed) return { allowed: false, reason: `The retry of the step ${input.stepid} passes only through a new reviewed dispatch; an automatic retry never bypasses the review.` };
|
|
10618
10671
|
return { allowed: true, reason: `The retry of the step ${input.stepid} dispatches again through the full consent gate chain: the session, the plan and the origin gates all recheck the step.` };
|
|
10619
10672
|
}
|
|
10673
|
+
function paletteactiongate(input) {
|
|
10674
|
+
if (input.action.permission !== void 0 && !input.granted.includes(input.action.permission)) return { allowed: false, reason: `The ${input.action.command} command needs the ${input.action.permission} capability granted before the palette lists it; the palette never offers an action the current capability set refuses.` };
|
|
10675
|
+
if (input.action.session === true && !input.sessionactive) return { allowed: false, reason: `The ${input.action.command} command needs an active browser session before the palette lists it; the palette never offers a run action without its session.` };
|
|
10676
|
+
return { allowed: true, reason: `The ${input.action.command} command rides its granted permissions and lists in the palette.` };
|
|
10677
|
+
}
|
|
10678
|
+
function taskinputproposalgate(input) {
|
|
10679
|
+
if (input.direct) return { allowed: false, reason: "The taskinput never executes a goal directly; every natural language goal routes through the same proposal flow as the api and becomes a reviewed plan first." };
|
|
10680
|
+
if (input.text.trim() === "") return { allowed: false, reason: "The taskinput submission needs its natural language goal; an empty goal never reaches the proposal flow." };
|
|
10681
|
+
if (input.origin.trim() === "") return { allowed: false, reason: "The taskinput submission needs its active origin scope; a goal without an origin never reaches the proposal flow." };
|
|
10682
|
+
return { allowed: true, reason: `The taskinput goal for ${input.origin} rides the same proposal flow as the api: the observation, the capabilities and the plan review all recheck it.` };
|
|
10683
|
+
}
|
|
10684
|
+
function planreviewgate(input) {
|
|
10685
|
+
if (input.state === "approved") return { allowed: true, reason: "The plan already passed its review: the approval is the review of record and the execution proceeds." };
|
|
10686
|
+
if (!input.reviewed) return { allowed: false, reason: "The pending plan has no plancard review yet; every step renders its card with the risk class, the environment and the options before any execution." };
|
|
10687
|
+
return { allowed: true, reason: "The plancard review of the pending plan is open; the resolution of each step stays a distinct human action." };
|
|
10688
|
+
}
|
|
10689
|
+
function stepapprovegate(input) {
|
|
10690
|
+
if (input.stepids.length === 0) return { allowed: false, reason: "A stepapprove resolution names its single step." };
|
|
10691
|
+
if (input.stepids.length > 1) return { allowed: false, reason: `One human action resolves exactly one step; the batch of ${input.stepids.length} steps refuses in full because no batch approval exists.` };
|
|
10692
|
+
if (input.surface === "background") return { allowed: false, reason: `The ${input.resolution} resolution of the step ${input.stepids[0]} needs its distinct human action from a surface; the background never resolves a review on its own.` };
|
|
10693
|
+
if (input.resolution === "edit") return { allowed: true, reason: `The user edits the step ${input.stepids[0]} from the ${input.surface} before approving; the corrected shape rides the plan and the resolution keeps its human provenance.` };
|
|
10694
|
+
return { allowed: true, reason: `The user ${input.resolution === "approve" ? "approved" : "rejected"} the step ${input.stepids[0]} from the ${input.surface}; one distinct human action resolved the step alone.` };
|
|
10695
|
+
}
|
|
10696
|
+
function diffpreviewgate(input) {
|
|
10697
|
+
if (input.risk !== "sensitive") return { allowed: false, reason: `The ${input.risk} step changes no page or browser state; the diffpreview compares the observed before state with the predicted after state of write class steps only.` };
|
|
10698
|
+
return { allowed: true, reason: "The write class step changes page or browser state, so the diffpreview compares its observed before state with its predicted after state." };
|
|
10699
|
+
}
|
|
10700
|
+
function onboardingconsentgate(input) {
|
|
10701
|
+
if (input.consentevents.length === 0) return { allowed: true, reason: "The onboarding completion writes its single consent scoped event; no consent event exists yet." };
|
|
10702
|
+
if (input.consentevents.length === 1) return { allowed: false, reason: `The onboarding already wrote its single consent scoped event ${input.consentevents[0]}; a walkthrough never writes a second one.` };
|
|
10703
|
+
return { allowed: false, reason: `The onboarding found ${input.consentevents.length} consent scoped events; a walkthrough writes exactly one and the extra events refuse.` };
|
|
10704
|
+
}
|
|
10705
|
+
function logbufferboundvalid(bound) {
|
|
10706
|
+
if (bound === void 0) return { allowed: true, reason: "No logstream buffer bound is configured, so the live window keeps every event while the full history stays in memory." };
|
|
10707
|
+
if (!Number.isInteger(bound) || bound <= 0) return { allowed: false, reason: "The logstream buffer bound stays a positive whole number of events the user chose; no engine cap exists." };
|
|
10708
|
+
return { allowed: true, reason: `The logstream buffer bound of ${bound} event${bound === 1 ? "" : "s"} stays the user configured choice; the full history stays in memory.` };
|
|
10709
|
+
}
|
|
10710
|
+
function logstreamegressgate(input) {
|
|
10711
|
+
if (input.entries === 0) return { allowed: false, reason: "The audit excerpt names no event of the logstream; an empty range never copies." };
|
|
10712
|
+
if (!input.verified) return { allowed: false, reason: "The logstream chain failed its live verification; the audit excerpt refuses the copy because only a verified range leaves the stream." };
|
|
10713
|
+
return { allowed: true, reason: `The logstream chain verifies across the ${input.entries} event${input.entries === 1 ? "" : "s"} of the range; the audit excerpt copies as one verified record.` };
|
|
10714
|
+
}
|
|
10620
10715
|
|
|
10621
10716
|
// progress.ts
|
|
10622
10717
|
function emptyprogress(planid, now) {
|
|
@@ -10867,7 +10962,7 @@ function maskexport(record2, shapes) {
|
|
|
10867
10962
|
}
|
|
10868
10963
|
|
|
10869
10964
|
// version.ts
|
|
10870
|
-
var packageversion = "1.1.
|
|
10965
|
+
var packageversion = "1.1.64";
|
|
10871
10966
|
|
|
10872
10967
|
// types.ts
|
|
10873
10968
|
var protocolversion = packageversion;
|
|
@@ -11844,6 +11939,9 @@ function environmentreport(input) {
|
|
|
11844
11939
|
function transparencyreport(input) {
|
|
11845
11940
|
return { version: protocolversion, posture: "denydefault", grants: input.grants, windows: input.windows, connectallow: input.connectallow, permdiffs: input.permdiffs, safedefaults: input.safedefaults, vault: input.vault };
|
|
11846
11941
|
}
|
|
11942
|
+
function surfacesnapshot(input) {
|
|
11943
|
+
return { version: protocolversion, surface: input.surface, palette: input.palette, timeline: input.timeline, logstream: input.logstream, plancards: input.plancards, ...input.onboarding !== void 0 ? { onboarding: input.onboarding } : {} };
|
|
11944
|
+
}
|
|
11847
11945
|
|
|
11848
11946
|
// capture.ts
|
|
11849
11947
|
var capturekinds = ["shotview", "shotfullpage", "shotelement", "shotregion", "contactsheet"];
|
|
@@ -13091,6 +13189,9 @@ function rejectedcorrectionof(input) {
|
|
|
13091
13189
|
if (input.stepid.trim() === "" || input.reason.trim() === "") throw new Error("The rejected correction needs its step and its rejection reason.");
|
|
13092
13190
|
return { id: input.id ?? randomid(), origin: input.origin, kind: input.kind, stepid: input.stepid, source: "rejected", original: input.original, reason: input.reason, at: input.now };
|
|
13093
13191
|
}
|
|
13192
|
+
function matchingcorrections(corrections, proposal) {
|
|
13193
|
+
return corrections.filter((entry) => entry.origin === proposal.origin && entry.kind === proposal.kind);
|
|
13194
|
+
}
|
|
13094
13195
|
function consentmemoryof(input) {
|
|
13095
13196
|
if (input.origin.trim() === "") throw new Error("The consent memory entry needs its origin.");
|
|
13096
13197
|
if (input.boundary.trim() === "") throw new Error("The consent memory entry needs the boundary the prompt named.");
|
|
@@ -13180,6 +13281,263 @@ function tabsessionrefof(input) {
|
|
|
13180
13281
|
return { tabid: input.tabid, sessionid: input.sessionid, ...input.runid !== void 0 && input.runid.trim() !== "" ? { runid: input.runid } : {}, origin: input.origin, updatedat: input.now };
|
|
13181
13282
|
}
|
|
13182
13283
|
|
|
13284
|
+
// surfaces.ts
|
|
13285
|
+
function surfacepalette() {
|
|
13286
|
+
return [
|
|
13287
|
+
{ id: "starttask", label: "Start task", keywords: ["task", "objective", "run", "goal", "plan"], action: { command: "starttask", surface: "popup" } },
|
|
13288
|
+
{ id: "pauserun", label: "Pause run", keywords: ["pause", "hold", "stop", "run"], action: { command: "pauserun", surface: "popup", session: true } },
|
|
13289
|
+
{ id: "resumerun", label: "Resume run", keywords: ["resume", "continue", "unpause", "run"], action: { command: "resumerun", surface: "popup", session: true } },
|
|
13290
|
+
{ id: "cancelrun", label: "Cancel run", keywords: ["cancel", "stop", "rollback", "queued"], action: { command: "cancelrun", surface: "popup", session: true } },
|
|
13291
|
+
{ id: "resumesession", label: "Resume session", keywords: ["session", "resume", "grid", "reopen"], action: { command: "resumesession", surface: "sidepanel" } },
|
|
13292
|
+
{ id: "stepapprove", label: "Review step", keywords: ["approve", "reject", "edit", "step", "review", "plancard"], action: { command: "stepapprove", surface: "sidepanel", session: true } },
|
|
13293
|
+
{ id: "diffpreview", label: "Preview step diff", keywords: ["diff", "preview", "before", "after", "write"], action: { command: "diffpreview", surface: "sidepanel", session: true } },
|
|
13294
|
+
{ id: "historysearch", label: "Search history", keywords: ["history", "search", "notes", "summaries", "corpus"], action: { command: "historysearch", surface: "dashboardpage" } },
|
|
13295
|
+
{ id: "revokeconsent", label: "Revoke consent", keywords: ["revoke", "consent", "allowlist", "origin", "grant"], action: { command: "revokeconsent", surface: "dashboardpage", session: true } },
|
|
13296
|
+
{ id: "opentransparencypage", label: "Open transparency page", keywords: ["transparency", "grants", "permissions", "diff"], action: { command: "opentransparencypage", surface: "optionspage" } },
|
|
13297
|
+
{ id: "opendashboardpage", label: "Open dashboard", keywords: ["dashboard", "sessions", "runs", "notes", "full"], action: { command: "opendashboardpage", surface: "dashboardpage" } },
|
|
13298
|
+
{ id: "openoptionspage", label: "Open options", keywords: ["options", "settings", "preferences", "configure"], action: { command: "openoptionspage", surface: "optionspage" } },
|
|
13299
|
+
{ id: "copyauditexcerpt", label: "Copy audit excerpt", keywords: ["audit", "excerpt", "copy", "verified", "range"], action: { command: "copyauditexcerpt", surface: "dashboardpage" } },
|
|
13300
|
+
{ id: "replayonboarding", label: "Replay onboarding", keywords: ["onboarding", "tour", "walkthrough", "replay", "first"], action: { command: "replayonboarding", surface: "onboarding" } }
|
|
13301
|
+
];
|
|
13302
|
+
}
|
|
13303
|
+
function palettecommandsof(entries, input) {
|
|
13304
|
+
return entries.filter((entry) => paletteactiongate({ action: entry.action, granted: input.granted, sessionactive: input.sessionactive }).allowed);
|
|
13305
|
+
}
|
|
13306
|
+
function fuzzyentryscore(entry, query) {
|
|
13307
|
+
const text2 = query.trim().toLowerCase();
|
|
13308
|
+
if (text2 === "") return 1;
|
|
13309
|
+
const id = entry.id.toLowerCase();
|
|
13310
|
+
const label = entry.label.toLowerCase();
|
|
13311
|
+
if (id === text2 || label === text2) return 100;
|
|
13312
|
+
let score = 0;
|
|
13313
|
+
if (id.includes(text2)) score += 40;
|
|
13314
|
+
if (label.includes(text2)) score += 30;
|
|
13315
|
+
for (const keyword of entry.keywords) {
|
|
13316
|
+
const lower = keyword.toLowerCase();
|
|
13317
|
+
if (lower === text2) score += 20;
|
|
13318
|
+
else if (lower.includes(text2)) score += 10;
|
|
13319
|
+
}
|
|
13320
|
+
if (score === 0 && text2.length > 1) {
|
|
13321
|
+
for (const haystack of [label, id]) {
|
|
13322
|
+
let cursor = 0;
|
|
13323
|
+
let matched = true;
|
|
13324
|
+
for (const letter of text2) {
|
|
13325
|
+
const found = haystack.indexOf(letter, cursor);
|
|
13326
|
+
if (found === -1) {
|
|
13327
|
+
matched = false;
|
|
13328
|
+
break;
|
|
13329
|
+
}
|
|
13330
|
+
cursor = found + 1;
|
|
13331
|
+
}
|
|
13332
|
+
if (matched) {
|
|
13333
|
+
score += 15;
|
|
13334
|
+
break;
|
|
13335
|
+
}
|
|
13336
|
+
}
|
|
13337
|
+
}
|
|
13338
|
+
return score;
|
|
13339
|
+
}
|
|
13340
|
+
function palettequery(entries, input) {
|
|
13341
|
+
const text2 = input.text.trim();
|
|
13342
|
+
const matches = entries.map((entry) => ({ entry, score: fuzzyentryscore(entry, text2) })).filter((match) => match.score > 0);
|
|
13343
|
+
const lastusedof = (command) => input.usage.find((record2) => record2.command === command)?.lastusedat ?? 0;
|
|
13344
|
+
const countof = (command) => input.usage.find((record2) => record2.command === command)?.count ?? 0;
|
|
13345
|
+
const recentwindow = input.recentwindow;
|
|
13346
|
+
const ranked = matches.sort((left, right) => {
|
|
13347
|
+
if (right.score !== left.score) return right.score - left.score;
|
|
13348
|
+
const leftrecent = recentwindow === void 0 ? 0 : countof(left.entry.action.command) > 0 && lastusedof(left.entry.action.command) >= lastusedof(right.entry.action.command) ? 1 : 0;
|
|
13349
|
+
const rightrecent = recentwindow === void 0 ? 0 : countof(right.entry.action.command) > 0 && lastusedof(right.entry.action.command) >= lastusedof(left.entry.action.command) ? 1 : 0;
|
|
13350
|
+
if (rightrecent !== leftrecent) return rightrecent - leftrecent;
|
|
13351
|
+
return lastusedof(right.entry.action.command) - lastusedof(left.entry.action.command);
|
|
13352
|
+
});
|
|
13353
|
+
return ranked.map((match) => ({ entry: match.entry, score: match.score, reason: match.score >= 100 ? `The query matches the ${match.entry.id} command exactly.` : `The query matches the label or the keywords of the ${match.entry.id} command${countof(match.entry.action.command) > 0 ? ` and its ${countof(match.entry.action.command)} recorded use${countof(match.entry.action.command) === 1 ? "" : "s"} rank it first among equals` : ""}.` }));
|
|
13354
|
+
}
|
|
13355
|
+
function paletteuseafter(usage, command, now) {
|
|
13356
|
+
const existing = usage.find((record2) => record2.command === command);
|
|
13357
|
+
if (existing === void 0) return [{ command, count: 1, lastusedat: now }, ...usage];
|
|
13358
|
+
return usage.map((record2) => record2.command === command ? { ...record2, count: record2.count + 1, lastusedat: now } : record2);
|
|
13359
|
+
}
|
|
13360
|
+
function taskinputof(input) {
|
|
13361
|
+
if (input.text.trim() === "") throw new Error("The taskinput needs its natural language goal.");
|
|
13362
|
+
if (input.origin.trim() === "") throw new Error("The taskinput needs its active origin scope.");
|
|
13363
|
+
return { id: randomid(), text: input.text.trim(), context: input.context ?? "", origin: input.origin.trim(), surface: input.surface, at: input.at };
|
|
13364
|
+
}
|
|
13365
|
+
function onboardingsteps() {
|
|
13366
|
+
return [
|
|
13367
|
+
{ id: "origingrants", surface: "popup", title: "Origin grants", body: "Devthink denies automation by default; grant one exact origin at a time from the popup and every run stays inside the granted origins.", completion: "origingrantscompleted" },
|
|
13368
|
+
{ id: "planreview", surface: "sidepanel", title: "Plan review", body: "Every task becomes a plan of reviewed steps; read the plancards of each risk class and approve, reject or edit one step at a time.", completion: "planreviewcompleted" },
|
|
13369
|
+
{ id: "runcontrol", surface: "sidepanel", title: "Run control", body: "Runs start, pause, resume and cancel under your hand; a cancelled run rolls only its queued steps back while the executed steps stay sealed.", completion: "runcontrolcompleted" },
|
|
13370
|
+
{ id: "logaudit", surface: "dashboardpage", title: "Log audit", body: "The immutable log chains every step transition with masked values; open the dashboard, verify the chain and copy a verified range as an audit excerpt.", completion: "logauditcompleted" }
|
|
13371
|
+
];
|
|
13372
|
+
}
|
|
13373
|
+
function onboardingstart(previous, now) {
|
|
13374
|
+
return { stepscompleted: [], done: false, startedat: now };
|
|
13375
|
+
}
|
|
13376
|
+
function onboardingcomplete(state, stepid, now) {
|
|
13377
|
+
const steps = onboardingsteps();
|
|
13378
|
+
const step = steps.find((candidate) => candidate.id === stepid);
|
|
13379
|
+
if (step === void 0) throw new Error(`The onboarding knows no ${stepid} step.`);
|
|
13380
|
+
const completed = state.stepscompleted.includes(stepid) ? state.stepscompleted : [...state.stepscompleted, stepid];
|
|
13381
|
+
const done = steps.every((candidate) => completed.includes(candidate.id));
|
|
13382
|
+
if (!done) return { state: { ...state, stepscompleted: completed, done: false } };
|
|
13383
|
+
const consentevent = "onboardingconsentgranted";
|
|
13384
|
+
return { state: { stepscompleted: completed, done: true, ...state.startedat !== void 0 ? { startedat: state.startedat } : {}, consentevent, completedat: now }, consentevent };
|
|
13385
|
+
}
|
|
13386
|
+
function broadcastframeof(input) {
|
|
13387
|
+
if (input.summary.trim() === "") throw new Error("The broadcast frame needs its summary.");
|
|
13388
|
+
return { channel: input.channel, surface: input.surface, summary: input.summary, at: input.at };
|
|
13389
|
+
}
|
|
13390
|
+
function broadcastchannelof(kind) {
|
|
13391
|
+
if (["session", "proposal", "approval", "action", "stop", "pause", "resume", "complete", "cancel", "error", "capability"].includes(kind)) return "runstate";
|
|
13392
|
+
if (["notes", "scratchpad", "summary", "recall", "correction", "consentmemory", "search", "vault", "gate", "grant", "revoke", "expiry", "deny"].includes(kind)) return "sessions";
|
|
13393
|
+
if (["configure", "transparency"].includes(kind)) return "settings";
|
|
13394
|
+
return "logstream";
|
|
13395
|
+
}
|
|
13396
|
+
function busrouteaction(action, input) {
|
|
13397
|
+
const entry = surfacepalette().find((candidate) => candidate.action.command === action.command);
|
|
13398
|
+
if (entry === void 0) return { dispatched: false, gate: "commandbus", reason: `The ${action.surface} asked for the unknown ${action.command} command; the bus routes only catalog commands.` };
|
|
13399
|
+
const permission = paletteactiongate({ action: entry.action, granted: input.granted, sessionactive: input.sessionactive });
|
|
13400
|
+
if (!permission.allowed) return { dispatched: false, gate: "paletteactiongate", reason: permission.reason ?? "The command misses its granted permission." };
|
|
13401
|
+
if (action.command === "starttask") {
|
|
13402
|
+
const proposal = taskinputproposalgate({ text: input.text ?? "", origin: input.origin ?? "", direct: false });
|
|
13403
|
+
if (!proposal.allowed) return { dispatched: false, gate: "taskinputproposalgate", reason: proposal.reason ?? "The task submission refuses." };
|
|
13404
|
+
}
|
|
13405
|
+
if (action.command === "stepapprove" || action.command === "diffpreview") {
|
|
13406
|
+
const review = planreviewgate({ reviewed: input.planreviewed, state: input.planstate });
|
|
13407
|
+
if (!review.allowed) return { dispatched: false, gate: "planreviewgate", reason: review.reason ?? "The plan review stays open." };
|
|
13408
|
+
}
|
|
13409
|
+
return { dispatched: true, gate: "commandbus", reason: `The ${action.command} action of the ${action.surface} routed through its policy gates and dispatches.` };
|
|
13410
|
+
}
|
|
13411
|
+
|
|
13412
|
+
// planreview.ts
|
|
13413
|
+
function plancardsof(input) {
|
|
13414
|
+
return input.plan.steps.map((step) => ({
|
|
13415
|
+
stepid: step.id,
|
|
13416
|
+
kind: step.kind,
|
|
13417
|
+
risk: step.risk,
|
|
13418
|
+
environment: step.environment ?? defaultenvironment(step),
|
|
13419
|
+
options: step.options ?? "",
|
|
13420
|
+
summary: step.summary,
|
|
13421
|
+
corrections: matchingcorrections(input.corrections, { origin: input.plan.origin, kind: step.kind }).map((entry) => ({ id: entry.id, source: entry.source, reason: entry.reason })),
|
|
13422
|
+
editable: input.plan.state === "pending"
|
|
13423
|
+
}));
|
|
13424
|
+
}
|
|
13425
|
+
function plancardgroups(cards) {
|
|
13426
|
+
const order = ["sensitive", "interaction", "read"];
|
|
13427
|
+
return order.map((risk) => ({ risk, cards: cards.filter((card) => card.risk === risk), expanded: risk === "sensitive" })).filter((group) => group.cards.length > 0);
|
|
13428
|
+
}
|
|
13429
|
+
function stepresolutionof(input) {
|
|
13430
|
+
if (input.stepid.trim() === "") throw new Error("The stepapprove resolution needs its step.");
|
|
13431
|
+
if (input.resolution === "edit" && (input.edited ?? "").trim() === "") throw new Error("The edited resolution needs its corrected step shape.");
|
|
13432
|
+
return { stepid: input.stepid, planid: input.planid, origin: input.origin, resolution: input.resolution, surface: input.surface, ...input.edited !== void 0 && input.edited.trim() !== "" ? { edited: input.edited } : {}, at: input.at };
|
|
13433
|
+
}
|
|
13434
|
+
function resolutionlogeventof(resolution) {
|
|
13435
|
+
return {
|
|
13436
|
+
kind: "review",
|
|
13437
|
+
stepid: resolution.stepid,
|
|
13438
|
+
summary: resolution.resolution === "edit" ? `The user edited the step ${resolution.stepid} of the plan ${resolution.planid} from the ${resolution.surface} before approving; the corrected shape rides the plan.` : `The user ${resolution.resolution === "approve" ? "approved" : "rejected"} the step ${resolution.stepid} of the plan ${resolution.planid} from the ${resolution.surface}; one distinct human action resolved the step alone.`
|
|
13439
|
+
};
|
|
13440
|
+
}
|
|
13441
|
+
function maskverdictsof(state, sensitivefields) {
|
|
13442
|
+
const verdicts = {};
|
|
13443
|
+
for (const [field, value] of Object.entries(state)) {
|
|
13444
|
+
if (sensitivefields.includes(field)) verdicts[field] = `The ${field} value stays masked (${value.length} characters) and never renders in the clear.`;
|
|
13445
|
+
}
|
|
13446
|
+
return verdicts;
|
|
13447
|
+
}
|
|
13448
|
+
function diffpreviewof(input) {
|
|
13449
|
+
const changes = [];
|
|
13450
|
+
const fields = [.../* @__PURE__ */ new Set([...Object.keys(input.before), ...Object.keys(input.after)])];
|
|
13451
|
+
for (const field of fields) {
|
|
13452
|
+
const hasbefore = Object.prototype.hasOwnProperty.call(input.before, field);
|
|
13453
|
+
const hasafter = Object.prototype.hasOwnProperty.call(input.after, field);
|
|
13454
|
+
const beforevalue = input.before[field];
|
|
13455
|
+
const aftervalue = input.after[field];
|
|
13456
|
+
if (hasbefore && !hasafter && beforevalue !== void 0) changes.push({ field, kind: "removed", before: beforevalue });
|
|
13457
|
+
else if (!hasbefore && hasafter && aftervalue !== void 0) changes.push({ field, kind: "added", after: aftervalue });
|
|
13458
|
+
else if (hasbefore && hasafter && beforevalue !== void 0 && aftervalue !== void 0 && beforevalue !== aftervalue) changes.push({ field, kind: "changed", before: beforevalue, after: aftervalue });
|
|
13459
|
+
}
|
|
13460
|
+
return { stepid: input.stepid, before: input.before, after: input.after, changes, maskverdicts: input.maskverdicts ?? {}, provenance: input.provenance };
|
|
13461
|
+
}
|
|
13462
|
+
function stepstimelinenodes(input) {
|
|
13463
|
+
const completed = input.progress?.completedsteps ?? [];
|
|
13464
|
+
const outcomes = input.progress?.outcomes ?? [];
|
|
13465
|
+
const environments = input.progress?.environments;
|
|
13466
|
+
const turnarounds = input.progress?.turnarounds;
|
|
13467
|
+
const gatewaits = input.progress?.gatewaits;
|
|
13468
|
+
let activeset = false;
|
|
13469
|
+
let blocked = false;
|
|
13470
|
+
return input.plan.steps.map((step) => {
|
|
13471
|
+
const outcome = [...outcomes].reverse().find((candidate) => candidate.stepid === step.id);
|
|
13472
|
+
const gatewait = gatewaits?.[step.id];
|
|
13473
|
+
let status;
|
|
13474
|
+
if (outcome !== void 0) status = outcome.ok ? "done" : "failed";
|
|
13475
|
+
else if (gatewait !== void 0) status = "waiting";
|
|
13476
|
+
else if (completed.includes(step.id)) status = "done";
|
|
13477
|
+
else if (input.plan.state === "cancelled" || input.plan.state === "expired") status = "halted";
|
|
13478
|
+
else if (input.plan.state === "rejected") status = "halted";
|
|
13479
|
+
else if (input.plan.state === "approved" && !activeset && !blocked) {
|
|
13480
|
+
status = "running";
|
|
13481
|
+
activeset = true;
|
|
13482
|
+
} else status = "pending";
|
|
13483
|
+
if (status === "waiting") blocked = true;
|
|
13484
|
+
const active = status === "running";
|
|
13485
|
+
return {
|
|
13486
|
+
stepid: step.id,
|
|
13487
|
+
kind: step.kind,
|
|
13488
|
+
status,
|
|
13489
|
+
...turnarounds?.[step.id] !== void 0 ? { durationms: turnarounds[step.id] } : {},
|
|
13490
|
+
...environments?.[step.id] !== void 0 ? { environment: environments[step.id] } : step.environment !== void 0 ? { environment: step.environment } : {},
|
|
13491
|
+
active,
|
|
13492
|
+
anchor: `#step-${step.id}`,
|
|
13493
|
+
...outcome !== void 0 ? { resultsummary: outcome.summary } : {}
|
|
13494
|
+
};
|
|
13495
|
+
});
|
|
13496
|
+
}
|
|
13497
|
+
var logstreamgenesis = "0".repeat(64);
|
|
13498
|
+
async function logstreameventof(input) {
|
|
13499
|
+
if (input.summary.trim() === "") throw new Error("The logstream event needs its summary.");
|
|
13500
|
+
const id = randomid();
|
|
13501
|
+
const hash = await entryhashof({ previous: input.previous, entry: { id, runid: "surfaces", kind: "step", summary: input.summary, origin: input.origin, ...input.stepid !== void 0 ? { stepid: input.stepid } : {}, at: input.at } });
|
|
13502
|
+
return { id, level: input.level, source: input.source, origin: input.origin, summary: input.summary, ...input.stepid !== void 0 ? { stepid: input.stepid } : {}, masked: input.masked, maskverdict: input.maskverdict, hash, at: input.at };
|
|
13503
|
+
}
|
|
13504
|
+
function appendlogstreamevent(events, event) {
|
|
13505
|
+
return [...events, event];
|
|
13506
|
+
}
|
|
13507
|
+
function filterlogstream(events, filter) {
|
|
13508
|
+
return events.filter((event) => (filter.level === void 0 || event.level === filter.level) && (filter.origin === void 0 || filter.origin === "" || event.origin === filter.origin) && (filter.stepid === void 0 || filter.stepid === "" || event.stepid === filter.stepid));
|
|
13509
|
+
}
|
|
13510
|
+
function livebufferof(events, bound) {
|
|
13511
|
+
if (bound === void 0) return events;
|
|
13512
|
+
if (!Number.isInteger(bound) || bound <= 0) return events;
|
|
13513
|
+
return events.slice(-bound);
|
|
13514
|
+
}
|
|
13515
|
+
async function verifylogstream(events) {
|
|
13516
|
+
for (let index = 0; index < events.length; index += 1) {
|
|
13517
|
+
const event = events[index];
|
|
13518
|
+
if (event === void 0) continue;
|
|
13519
|
+
const predecessor = events[index - 1];
|
|
13520
|
+
const expectedprevious = index === 0 || predecessor === void 0 ? logstreamgenesis : predecessor.hash.current;
|
|
13521
|
+
if (event.hash.previous !== expectedprevious) return { valid: false, brokenat: index, reason: `The logstream chain breaks at the event ${event.id}: its previous hash does not link to its predecessor.` };
|
|
13522
|
+
const recomputed = await entryhashof({ previous: event.hash.previous, entry: { id: event.id, runid: "surfaces", kind: "step", summary: event.summary, origin: event.origin, ...event.stepid !== void 0 ? { stepid: event.stepid } : {}, at: event.at } });
|
|
13523
|
+
if (recomputed.current !== event.hash.current) return { valid: false, brokenat: index, reason: `The logstream chain breaks at the event ${event.id}: its own hash does not reproduce.` };
|
|
13524
|
+
}
|
|
13525
|
+
return { valid: true, reason: `The logstream chain of ${events.length} event${events.length === 1 ? "" : "s"} verifies link by link.` };
|
|
13526
|
+
}
|
|
13527
|
+
async function auditexcerptof(events, input) {
|
|
13528
|
+
if (input.from < 0 || input.to <= input.from || input.to > events.length) return { ok: false, text: "", reason: `The excerpt range ${input.from} to ${input.to} names no contiguous slice of the ${events.length} event${events.length === 1 ? "" : "s"}.` };
|
|
13529
|
+
const range = events.slice(input.from, input.to);
|
|
13530
|
+
const verification = await verifylogstream(range);
|
|
13531
|
+
if (!verification.valid) return { ok: false, text: "", reason: `The excerpt refuses the copy: ${verification.reason}` };
|
|
13532
|
+
const text2 = range.map((event) => `[${event.at}] ${event.level} ${event.source}${event.stepid !== void 0 ? ` step ${event.stepid}` : ""} ${event.origin} \u2014 ${event.summary}${event.masked ? ` (${event.maskverdict})` : ""}`).join("\n");
|
|
13533
|
+
return { ok: true, text: text2, reason: `The excerpt copied the verified range ${input.from} to ${input.to} of the logstream.` };
|
|
13534
|
+
}
|
|
13535
|
+
function loglevelof(kind) {
|
|
13536
|
+
if (kind === "error") return "error";
|
|
13537
|
+
if (["deny", "revoke", "stop", "quarantine", "phish", "defer", "schema", "expiry"].includes(kind)) return "warn";
|
|
13538
|
+
return "info";
|
|
13539
|
+
}
|
|
13540
|
+
|
|
13183
13541
|
// llm.ts
|
|
13184
13542
|
var defaultrefusalmarkers = ["i cannot", "i can't", "i'm unable", "refusal:", "cannot comply"];
|
|
13185
13543
|
function buildrequest(input) {
|
|
@@ -15378,6 +15736,31 @@ function extensionpage(sender) {
|
|
|
15378
15736
|
}
|
|
15379
15737
|
async function audit(kind, summary, extra = {}) {
|
|
15380
15738
|
await memory.addaudi({ id: randomid(), kind, at: Date.now(), summary, ...extra });
|
|
15739
|
+
await recordsurfaceevent(kind, summary, extra);
|
|
15740
|
+
}
|
|
15741
|
+
var surfacechannel = typeof BroadcastChannel === "function" ? new BroadcastChannel("devthinksurfaces") : void 0;
|
|
15742
|
+
var logstreamhistory = [];
|
|
15743
|
+
var recentframes = [];
|
|
15744
|
+
async function recordsurfaceevent(kind, summary, extra = {}) {
|
|
15745
|
+
try {
|
|
15746
|
+
const session = await memory.getsession();
|
|
15747
|
+
const origin = session?.origin ?? "";
|
|
15748
|
+
if (origin === "") return;
|
|
15749
|
+
const at = Date.now();
|
|
15750
|
+
const lastevent = logstreamhistory[logstreamhistory.length - 1];
|
|
15751
|
+
const previous = lastevent !== void 0 ? lastevent.hash.current : logstreamgenesis;
|
|
15752
|
+
const event = await logstreameventof({ level: loglevelof(kind), source: "background", origin, summary, ...extra.stepid !== void 0 ? { stepid: extra.stepid } : {}, masked: extra.masked === true, maskverdict: extra.masked === true ? extra.maskverdict ?? "The source payload stayed masked before it streamed." : "The source payload carries no masked value.", previous, at });
|
|
15753
|
+
logstreamhistory = appendlogstreamevent(logstreamhistory, event);
|
|
15754
|
+
const frame = broadcastframeof({ channel: broadcastchannelof(kind), surface: "background", summary, at });
|
|
15755
|
+
recentframes = [...recentframes, frame];
|
|
15756
|
+
surfacechannel?.postMessage(frame);
|
|
15757
|
+
} catch {
|
|
15758
|
+
}
|
|
15759
|
+
}
|
|
15760
|
+
async function broadcastsurfaceframe(input) {
|
|
15761
|
+
const frame = broadcastframeof({ ...input, at: Date.now() });
|
|
15762
|
+
recentframes = [...recentframes, frame];
|
|
15763
|
+
surfacechannel?.postMessage(frame);
|
|
15381
15764
|
}
|
|
15382
15765
|
function stepoptions6(step) {
|
|
15383
15766
|
try {
|
|
@@ -21145,6 +21528,7 @@ var commandschemas = {
|
|
|
21145
21528
|
sessions: { note: "object", scratch: "object", summary: "object", recall: "object", correction: "object", consent: "object", grid: "object", search: "object", cancel: "object", retry: "object", error: "object", settings: "object", bundle: "object" },
|
|
21146
21529
|
environments: { action: "string", grants: "array", requestcapability: "boolean", pool: "object", offscreenclose: "boolean", sandbox: "object", settings: "object", render: "object", sandboxhost: "object" },
|
|
21147
21530
|
transparency: {},
|
|
21531
|
+
surface: { palette: "object", task: "object", onboarding: "object", bus: "object", broadcast: "object", layout: "object", logstream: "object", approve: "object", diff: "object", review: "object", timeline: "object", dashboard: "object", settings: "object" },
|
|
21148
21532
|
execute: { stepid: "string" },
|
|
21149
21533
|
configure: { endpoint: "string" }
|
|
21150
21534
|
};
|
|
@@ -21371,6 +21755,279 @@ async function handlesessionscommand(message) {
|
|
|
21371
21755
|
}
|
|
21372
21756
|
throw new Error("The sessions command carries no note, scratch, summary, recall, correction, consent, grid, search, cancel, retry, error, settings or bundle action.");
|
|
21373
21757
|
}
|
|
21758
|
+
async function grantedcapabilities() {
|
|
21759
|
+
const report = await memory.getcapabilities();
|
|
21760
|
+
const granted = ["activeTab", "storage", "scripting", "sidePanel"];
|
|
21761
|
+
if (report?.tabs) granted.push("tabs");
|
|
21762
|
+
if (report?.downloads) granted.push("downloads");
|
|
21763
|
+
if (report?.clipboardread) granted.push("clipboardRead");
|
|
21764
|
+
if (report?.clipboardwrite) granted.push("clipboardWrite");
|
|
21765
|
+
if (await offscreengranted()) granted.push("offscreen");
|
|
21766
|
+
return granted;
|
|
21767
|
+
}
|
|
21768
|
+
async function surfacesnapshotof(surface) {
|
|
21769
|
+
const settings = await memory.getsettings();
|
|
21770
|
+
const session = await memory.getsession();
|
|
21771
|
+
const sessionactive = Boolean(session && !session.stoppedat && session.expiresat > Date.now());
|
|
21772
|
+
const granted = await grantedcapabilities();
|
|
21773
|
+
const plan = await memory.getplan();
|
|
21774
|
+
const progress = await memory.getprogress();
|
|
21775
|
+
const onboarding = await memory.getonboardingstate();
|
|
21776
|
+
const palette = palettequery(palettecommandsof(surfacepalette(), { granted, sessionactive }), { text: "", usage: await memory.getpaletteusage(), ...settings?.paletterecents !== void 0 ? { recentwindow: settings.paletterecents } : {} });
|
|
21777
|
+
const verification = await verifylogstream(logstreamhistory);
|
|
21778
|
+
return surfacesnapshot({
|
|
21779
|
+
surface,
|
|
21780
|
+
palette,
|
|
21781
|
+
timeline: plan ? stepstimelinenodes({ plan, ...progress !== void 0 && progress.planid === plan.id ? { progress } : {}, now: Date.now() }) : [],
|
|
21782
|
+
logstream: { events: livebufferof(logstreamhistory, settings?.logstreambuffer).map((event) => ({ id: event.id, level: event.level, source: event.source, origin: event.origin, summary: event.summary, ...event.stepid !== void 0 ? { stepid: event.stepid } : {}, masked: event.masked, maskverdict: event.maskverdict, at: event.at })), chainvalid: verification.valid, reason: verification.reason },
|
|
21783
|
+
plancards: plan !== void 0 ? plancardgroups(plancardsof({ plan, corrections: await memory.getcorrections() })) : [],
|
|
21784
|
+
...onboarding !== void 0 ? { onboarding: { stepscompleted: onboarding.stepscompleted, done: onboarding.done } } : {}
|
|
21785
|
+
});
|
|
21786
|
+
}
|
|
21787
|
+
async function handlesurfacecommand(message) {
|
|
21788
|
+
const input = message;
|
|
21789
|
+
const now = Date.now();
|
|
21790
|
+
const session = await memory.getsession();
|
|
21791
|
+
const sessionactive = Boolean(session && !session.stoppedat && session.expiresat > now);
|
|
21792
|
+
const settings = await memory.getsettings();
|
|
21793
|
+
const plan = await memory.getplan();
|
|
21794
|
+
const surfaceof = (value, fallback) => ["popup", "sidepanel", "dashboardpage", "optionspage", "onboarding"].includes(value ?? "") ? value : fallback;
|
|
21795
|
+
if (input.palette !== void 0) {
|
|
21796
|
+
const granted = await grantedcapabilities();
|
|
21797
|
+
const entries = surfacepalette();
|
|
21798
|
+
if (input.palette.used !== void 0) {
|
|
21799
|
+
const command = input.palette.used.command?.trim() ?? "";
|
|
21800
|
+
if (command === "") throw new Error("The palette use record needs its command.");
|
|
21801
|
+
const usage = paletteuseafter(await memory.getpaletteusage(), command, now);
|
|
21802
|
+
const record2 = usage[0];
|
|
21803
|
+
if (record2 === void 0) throw new Error("The palette use record never landed.");
|
|
21804
|
+
await memory.setpaletteusage(usage);
|
|
21805
|
+
await audit("palette", `The user ran the ${command} command from the commandpalette; its ${record2.count} recorded use${record2.count === 1 ? "" : "s"} rank it first among equal matches.`, { ...session ? { sessionid: session.id } : {} });
|
|
21806
|
+
return { usage: record2 };
|
|
21807
|
+
}
|
|
21808
|
+
if (input.palette.query !== void 0) {
|
|
21809
|
+
const matches = palettequery(palettecommandsof(entries, { granted, sessionactive }), { text: input.palette.query.text ?? "", usage: await memory.getpaletteusage(), ...settings?.paletterecents !== void 0 ? { recentwindow: settings.paletterecents } : {} });
|
|
21810
|
+
return { matches };
|
|
21811
|
+
}
|
|
21812
|
+
return { entries: palettecommandsof(entries, { granted, sessionactive }) };
|
|
21813
|
+
}
|
|
21814
|
+
if (input.task !== void 0) {
|
|
21815
|
+
if (input.task.submit !== void 0) {
|
|
21816
|
+
if (!session || session.stoppedat || session.expiresat <= now) throw new Error("Start a current browser session before submitting a task goal.");
|
|
21817
|
+
const { tab, origin } = await activecontext();
|
|
21818
|
+
if (session.tabid !== tab.id || session.origin !== origin) throw new Error("The selected tab or origin no longer matches the approved session.");
|
|
21819
|
+
const version = await memory.getobservationversion();
|
|
21820
|
+
const storedobservation = version !== void 0 ? await memory.getobservation(version) : void 0;
|
|
21821
|
+
const context = storedobservation ? `${storedobservation.observation.title}: ${storedobservation.observation.textpreview}` : tab.title ?? "";
|
|
21822
|
+
const submission = taskinputof({ text: input.task.submit.text ?? "", context, origin, surface: surfaceof(input.task.submit.surface, "popup"), at: now });
|
|
21823
|
+
await memory.addtaskinput(submission);
|
|
21824
|
+
const proposed = await propose(submission.text, false);
|
|
21825
|
+
await audit("surface", `The ${submission.surface} taskinput submitted a natural language goal for ${origin} with the active origin and the page outline attached; the goal routed through the same proposal flow as the api and the plan ${proposed.id} now awaits its plancard review.`, { sessionid: session.id, planid: proposed.id });
|
|
21826
|
+
await broadcastsurfaceframe({ channel: "runstate", surface: "background", summary: `A taskinput goal became the plan ${proposed.id} and awaits review.` });
|
|
21827
|
+
return { submission, plan: proposed, status: "ready" };
|
|
21828
|
+
}
|
|
21829
|
+
if (input.task.history === true) return { history: await memory.gettaskinputs() };
|
|
21830
|
+
if (input.task.status === true) return { status: plan === void 0 ? "idle" : plan.state === "pending" ? "ready" : plan.state === "approved" ? "ready" : "failed" };
|
|
21831
|
+
}
|
|
21832
|
+
if (input.onboarding !== void 0) {
|
|
21833
|
+
const state = await memory.getonboardingstate();
|
|
21834
|
+
if (input.onboarding.complete !== void 0) {
|
|
21835
|
+
const stepid = input.onboarding.complete.stepid?.trim() ?? "";
|
|
21836
|
+
const current = state ?? onboardingstart(void 0, now);
|
|
21837
|
+
const completion = onboardingcomplete(current, stepid, now);
|
|
21838
|
+
if (completion.consentevent !== void 0) {
|
|
21839
|
+
const consentgate = onboardingconsentgate({ consentevents: current.consentevent !== void 0 ? [current.consentevent] : [] });
|
|
21840
|
+
if (!consentgate.allowed) throw new Error(consentgate.reason);
|
|
21841
|
+
const origin = session?.origin ?? "onboarding";
|
|
21842
|
+
await memory.addconsentmemoryentry(consentmemoryof({ origin, decision: "grant", boundary: "onboarding", kinds: [], now }));
|
|
21843
|
+
}
|
|
21844
|
+
await memory.setonboardingstate(completion.state);
|
|
21845
|
+
await audit("onboarding", completion.consentevent !== void 0 ? `The user finished the onboarding walkthrough and its completion wrote the single consent scoped event ${completion.consentevent}; the walkthrough never writes a second one.` : `The user completed the ${stepid} step of the onboarding walkthrough; ${completion.state.stepscompleted.length} of ${onboardingsteps().length} steps stand done.`, { ...session ? { sessionid: session.id } : {} });
|
|
21846
|
+
await broadcastsurfaceframe({ channel: "settings", surface: "background", summary: completion.consentevent !== void 0 ? "The onboarding walkthrough completed." : `The onboarding step ${stepid} completed.` });
|
|
21847
|
+
return { steps: onboardingsteps(), state: completion.state, ...completion.consentevent !== void 0 ? { consentevent: completion.consentevent } : {} };
|
|
21848
|
+
}
|
|
21849
|
+
if (input.onboarding.replay === true) {
|
|
21850
|
+
const replayed = onboardingstart(state, now);
|
|
21851
|
+
await memory.setonboardingstate(replayed);
|
|
21852
|
+
await audit("onboarding", "The user replayed the onboarding walkthrough on demand from the optionspage; the replay restarts the steps and writes no second consent event.", {});
|
|
21853
|
+
return { steps: onboardingsteps(), state: replayed };
|
|
21854
|
+
}
|
|
21855
|
+
return { steps: onboardingsteps(), ...state ? { state } : {} };
|
|
21856
|
+
}
|
|
21857
|
+
if (input.bus !== void 0 && input.bus.action !== void 0) {
|
|
21858
|
+
const surface = surfaceof(input.bus.action.surface, "popup");
|
|
21859
|
+
const command = input.bus.action.command?.trim() ?? "";
|
|
21860
|
+
const action = { surface, command, ...input.bus.action.stepid !== void 0 && input.bus.action.stepid.trim() !== "" ? { stepid: input.bus.action.stepid } : {}, ...input.bus.action.payload !== void 0 && input.bus.action.payload.trim() !== "" ? { payload: input.bus.action.payload } : {} };
|
|
21861
|
+
const granted = await grantedcapabilities();
|
|
21862
|
+
const route = busrouteaction(action, { sessionactive, granted, planreviewed: Boolean(plan && plan.state === "approved"), planstate: plan?.state === "pending" ? "pending" : "approved", text: input.bus.action.payload ?? "", origin: session?.origin ?? "" });
|
|
21863
|
+
if (!route.dispatched) throw new Error(route.reason);
|
|
21864
|
+
await audit("surface", `The ${surface} routed the ${command} action through the command bus: ${route.reason}`, { ...session ? { sessionid: session.id } : {}, ...plan ? { planid: plan.id } : {} });
|
|
21865
|
+
if (command === "starttask") {
|
|
21866
|
+
if (!sessionactive) await handlerequest({ kind: "startsession" }, {});
|
|
21867
|
+
const goal = (input.bus.action.payload ?? "").trim();
|
|
21868
|
+
if (goal !== "") await propose(goal, false);
|
|
21869
|
+
} else if (command === "pauserun") await handlerequest({ kind: "pausesession" }, {});
|
|
21870
|
+
else if (command === "resumerun") await handlerequest({ kind: "resumesession" }, {});
|
|
21871
|
+
else if (command === "cancelrun") {
|
|
21872
|
+
if (plan) await handlerequest({ kind: "sessions", cancel: { runid: plan.id } }, {}).catch(() => {
|
|
21873
|
+
});
|
|
21874
|
+
} else if (command === "revokeconsent") {
|
|
21875
|
+
if (session) await handlerequest({ kind: "security", allowlist: { remove: { origin: session.origin } } }, {}).catch(() => {
|
|
21876
|
+
});
|
|
21877
|
+
}
|
|
21878
|
+
await broadcastsurfaceframe({ channel: "runstate", surface, summary: `The ${command} action of the ${surface} dispatched through the command bus.` });
|
|
21879
|
+
return { route, palette: palettecommandsof(surfacepalette(), { granted, sessionactive }) };
|
|
21880
|
+
}
|
|
21881
|
+
if (input.broadcast !== void 0 && input.broadcast.frames === true) {
|
|
21882
|
+
const bound = settings?.logstreambuffer;
|
|
21883
|
+
const boundgate = logbufferboundvalid(bound);
|
|
21884
|
+
if (!boundgate.allowed) throw new Error(boundgate.reason);
|
|
21885
|
+
return { frames: bound === void 0 ? recentframes : recentframes.slice(-bound), logstream: livebufferof(logstreamhistory, bound), total: logstreamhistory.length };
|
|
21886
|
+
}
|
|
21887
|
+
if (input.layout !== void 0) {
|
|
21888
|
+
if (input.layout.set !== void 0) {
|
|
21889
|
+
const surface = surfaceof(input.layout.set.surface, "popup");
|
|
21890
|
+
const preferences = input.layout.set.preferences ?? {};
|
|
21891
|
+
await memory.setsurfacelayout({ surface, preferences, updatedat: now });
|
|
21892
|
+
await audit("surface", `The user saved the layout preferences of the ${surface} with ${Object.keys(preferences).length} key${Object.keys(preferences).length === 1 ? "" : "s"}; the preferences scope per profile workspace and take effect without a reload.`, { ...session ? { sessionid: session.id } : {} });
|
|
21893
|
+
return { layout: { surface, preferences, updatedat: now } };
|
|
21894
|
+
}
|
|
21895
|
+
if (input.layout.get !== void 0) return { layout: await memory.getsurfacelayout(surfaceof(input.layout.get.surface, "popup")) };
|
|
21896
|
+
}
|
|
21897
|
+
if (input.logstream !== void 0) {
|
|
21898
|
+
if (input.logstream.read !== void 0) {
|
|
21899
|
+
const stored = await memory.getlogstreamfilters();
|
|
21900
|
+
const requested = input.logstream.read.filters;
|
|
21901
|
+
const level = requested?.level !== void 0 && requested.level !== "" ? requested.level : stored?.level;
|
|
21902
|
+
const origin = requested?.origin !== void 0 && requested.origin !== "" ? requested.origin : stored?.origin;
|
|
21903
|
+
const stepid = requested?.stepid !== void 0 && requested.stepid !== "" ? requested.stepid : stored?.stepid;
|
|
21904
|
+
const filter = {};
|
|
21905
|
+
if (level !== void 0 && level !== "") filter.level = level;
|
|
21906
|
+
if (origin !== void 0 && origin !== "") filter.origin = origin;
|
|
21907
|
+
if (stepid !== void 0 && stepid !== "") filter.stepid = stepid;
|
|
21908
|
+
const verification = await verifylogstream(logstreamhistory);
|
|
21909
|
+
return { events: filterlogstream(livebufferof(logstreamhistory, settings?.logstreambuffer), filter), chain: verification, total: logstreamhistory.length };
|
|
21910
|
+
}
|
|
21911
|
+
if (input.logstream.excerpt !== void 0) {
|
|
21912
|
+
const from = input.logstream.excerpt.from ?? 0;
|
|
21913
|
+
const to = input.logstream.excerpt.to ?? logstreamhistory.length;
|
|
21914
|
+
const excerpt = await auditexcerptof(logstreamhistory, { from, to });
|
|
21915
|
+
const gate = logstreamegressgate({ verified: excerpt.ok, entries: Math.max(0, Math.min(to, logstreamhistory.length) - Math.max(0, from)) });
|
|
21916
|
+
if (!gate.allowed) throw new Error(gate.reason);
|
|
21917
|
+
await audit("logstream", `The user copied the verified range ${from} to ${to} of the live logstream as an audit excerpt; the copy left the stream only after the chain verified.`, { ...session ? { sessionid: session.id } : {} });
|
|
21918
|
+
return { excerpt: excerpt.text, reason: excerpt.reason };
|
|
21919
|
+
}
|
|
21920
|
+
if (input.logstream.filters?.set !== void 0) {
|
|
21921
|
+
const requested = input.logstream.filters.set;
|
|
21922
|
+
const filter = {};
|
|
21923
|
+
if (requested?.level !== void 0 && requested.level !== "") filter.level = requested.level;
|
|
21924
|
+
if (requested?.origin !== void 0 && requested.origin !== "") filter.origin = requested.origin;
|
|
21925
|
+
if (requested?.stepid !== void 0 && requested.stepid !== "") filter.stepid = requested.stepid;
|
|
21926
|
+
await memory.setlogstreamfilters(filter);
|
|
21927
|
+
await audit("surface", `The user saved the logstream filter preferences${Object.keys(filter).length > 0 ? ` for ${Object.entries(filter).map(([key, value]) => `${key} ${value}`).join(" and ")}` : ""}; the live view reopens with them.`, {});
|
|
21928
|
+
return { filters: filter };
|
|
21929
|
+
}
|
|
21930
|
+
}
|
|
21931
|
+
if (input.approve !== void 0 && input.approve.resolve !== void 0) {
|
|
21932
|
+
const stepid = input.approve.resolve.stepid?.trim() ?? "";
|
|
21933
|
+
const resolution = input.approve.resolve.resolution === "approve" || input.approve.resolve.resolution === "edit" ? input.approve.resolve.resolution : input.approve.resolve.resolution === "reject" ? "reject" : void 0;
|
|
21934
|
+
if (resolution === void 0) throw new Error("The stepapprove resolution needs its approve, reject or edit decision.");
|
|
21935
|
+
const surface = surfaceof(input.approve.resolve.surface, "sidepanel");
|
|
21936
|
+
if (!plan || !["pending", "approved"].includes(plan.state)) throw new Error("The stepapprove resolution serves the pending or approved plan under review.");
|
|
21937
|
+
const step = plan.steps.find((candidate) => candidate.id === stepid);
|
|
21938
|
+
if (!step) throw new Error(`No step ${stepid} of the plan ${plan.id} exists to resolve.`);
|
|
21939
|
+
const gate = stepapprovegate({ stepids: [stepid], resolution, surface });
|
|
21940
|
+
if (!gate.allowed) throw new Error(gate.reason);
|
|
21941
|
+
const record2 = stepresolutionof({ stepid, planid: plan.id, origin: plan.origin, resolution, surface, ...resolution === "edit" && input.approve.resolve.edited !== void 0 ? { edited: input.approve.resolve.edited } : {}, at: now });
|
|
21942
|
+
await memory.addstepapproveresolution(record2);
|
|
21943
|
+
const event = resolutionlogeventof(record2);
|
|
21944
|
+
if (resolution === "edit") {
|
|
21945
|
+
const edited = input.approve.resolve.edited ?? "";
|
|
21946
|
+
try {
|
|
21947
|
+
const shape = JSON.parse(edited);
|
|
21948
|
+
const editedkind = shape.kind;
|
|
21949
|
+
const editedsummary = shape.summary;
|
|
21950
|
+
if (typeof editedkind !== "string" || editedkind.trim() === "" || typeof editedsummary !== "string" || editedsummary.trim() === "") throw new Error("The edited step shape needs its kind and summary.");
|
|
21951
|
+
await memory.setplan({ ...plan, steps: plan.steps.map((candidate) => candidate.id === stepid ? { ...candidate, kind: editedkind, summary: editedsummary, ...shape.target !== void 0 ? { target: shape.target } : {}, ...shape.value !== void 0 ? { value: shape.value } : {}, ...shape.options !== void 0 ? { options: shape.options } : {} } : candidate) });
|
|
21952
|
+
await memory.addcorrection(editedcorrectionof({ origin: plan.origin, kind: step.kind, stepid, original: JSON.stringify({ kind: step.kind, summary: step.summary, ...step.target !== void 0 ? { target: step.target } : {}, ...step.value !== void 0 ? { value: step.value } : {}, ...step.options !== void 0 ? { options: step.options } : {} }), corrected: edited, reason: `The user edited the step ${stepid} from the ${surface} before approving.`, now }));
|
|
21953
|
+
} catch (error) {
|
|
21954
|
+
throw new Error(error instanceof Error ? error.message : "The edited step shape failed to parse.");
|
|
21955
|
+
}
|
|
21956
|
+
}
|
|
21957
|
+
if (resolution === "reject") await memory.addcorrection(rejectedcorrectionof({ origin: plan.origin, kind: step.kind, stepid, original: JSON.stringify({ kind: step.kind, summary: step.summary }), reason: `The user rejected the step ${stepid} from the ${surface}.`, now }));
|
|
21958
|
+
await appendrunevent("review", event.summary, session, plan.origin, stepid);
|
|
21959
|
+
await audit("approval", event.summary, { ...session ? { sessionid: session.id } : {}, planid: plan.id, stepid });
|
|
21960
|
+
await broadcastsurfaceframe({ channel: "runstate", surface, summary: `The step ${stepid} resolved with a ${resolution} from the ${surface}.` });
|
|
21961
|
+
return { resolution: record2, cards: plancardsof({ plan: await memory.getplan() ?? plan, corrections: await memory.getcorrections() }) };
|
|
21962
|
+
}
|
|
21963
|
+
if (input.diff !== void 0 && input.diff.preview !== void 0) {
|
|
21964
|
+
const stepid = input.diff.preview.stepid?.trim() ?? "";
|
|
21965
|
+
if (!plan) throw new Error("The diffpreview serves the plan under review.");
|
|
21966
|
+
const step = plan.steps.find((candidate) => candidate.id === stepid);
|
|
21967
|
+
if (!step) throw new Error(`No step ${stepid} of the plan ${plan.id} exists to preview.`);
|
|
21968
|
+
const gate = diffpreviewgate({ risk: step.risk });
|
|
21969
|
+
if (!gate.allowed) throw new Error(gate.reason);
|
|
21970
|
+
if (!session) throw new Error("The diffpreview needs its session to observe the before state.");
|
|
21971
|
+
const before = input.diff.preview.before ?? {};
|
|
21972
|
+
const options = stepoptions6(step);
|
|
21973
|
+
const predicted = { ...Object.fromEntries(Object.entries(options).filter(([, value]) => typeof value === "string" || typeof value === "number" || typeof value === "boolean").map(([key, value]) => [key, String(value)])), ...step.value !== void 0 ? { value: step.value } : {}, ...step.target !== void 0 ? { target: step.target } : {} };
|
|
21974
|
+
const after = Object.keys(input.diff.preview.after ?? {}).length > 0 ? input.diff.preview.after : predicted;
|
|
21975
|
+
const payload = JSON.stringify({ before, after });
|
|
21976
|
+
let provenance = "inline";
|
|
21977
|
+
if (settings?.diffpreviewbytes !== void 0 && payload.length >= settings.diffpreviewbytes && await offscreengranted()) {
|
|
21978
|
+
try {
|
|
21979
|
+
const answer = await chrome.runtime.sendMessage({ kind: "offscreen", action: "parse", request: { id: randomid(), runid: plan.id, stepid, task: "diffpreview", payload, transferables: [] } });
|
|
21980
|
+
if (answer?.ok === true) provenance = "offscreenworker";
|
|
21981
|
+
} catch {
|
|
21982
|
+
}
|
|
21983
|
+
}
|
|
21984
|
+
const sensitivefields = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])].filter((field) => defaultmaskshapes.some((shape) => field.toLowerCase().includes(shape)));
|
|
21985
|
+
const preview = diffpreviewof({ stepid, before, after, maskverdicts: maskverdictsof({ ...before, ...after }, sensitivefields), provenance });
|
|
21986
|
+
await audit("diff", `The user opened the diffpreview of the write class step ${stepid} of the plan ${plan.id}: ${preview.changes.filter((change) => change.kind === "added").length} added, ${preview.changes.filter((change) => change.kind === "changed").length} changed and ${preview.changes.filter((change) => change.kind === "removed").length} removed field${preview.changes.length === 1 ? "" : "s"}${preview.maskverdicts && Object.keys(preview.maskverdicts).length > 0 ? ` with ${Object.keys(preview.maskverdicts).length} masked value${Object.keys(preview.maskverdicts).length === 1 ? "" : "s"} carrying their mask verdicts` : ""}${provenance === "offscreenworker" ? "; the generation offloaded to the offscreen worker pool" : ""}.`, { ...session ? { sessionid: session.id } : {}, planid: plan.id, stepid });
|
|
21987
|
+
return { preview };
|
|
21988
|
+
}
|
|
21989
|
+
if (input.review !== void 0) {
|
|
21990
|
+
const corrections = await memory.getcorrections();
|
|
21991
|
+
const cards = plan ? plancardsof({ plan, corrections }) : [];
|
|
21992
|
+
if (input.review.groups !== void 0 || input.review.cards !== void 0) return { cards, groups: plancardgroups(cards) };
|
|
21993
|
+
return { cards };
|
|
21994
|
+
}
|
|
21995
|
+
if (input.timeline !== void 0 && input.timeline.nodes === true) {
|
|
21996
|
+
if (!plan) return { nodes: [] };
|
|
21997
|
+
const progress = await memory.getprogress();
|
|
21998
|
+
return { nodes: stepstimelinenodes({ plan, ...progress !== void 0 && progress.planid === plan.id ? { progress } : {}, now }) };
|
|
21999
|
+
}
|
|
22000
|
+
if (input.dashboard !== void 0 && input.dashboard.view === true) {
|
|
22001
|
+
const view = await memory.gettransparencyview();
|
|
22002
|
+
const report = transparencyreport({ grants: transparencygrants({ allowlist: view.allowlist, profiles: view.profiles }), windows: windowhistory(view.windows), connectallow: connectallowlist(view.connectallow), permdiffs: view.permdiffs, safedefaults: view.safedefaults, vault: vaultview(view.vault) });
|
|
22003
|
+
const onboarding = await memory.getonboardingstate();
|
|
22004
|
+
return { sessionview: await sessionviewof(), transparency: report, onboarding: onboarding ?? { stepscompleted: [], done: false }, environments: await environmentviewof(), security: await securityviewof() };
|
|
22005
|
+
}
|
|
22006
|
+
if (input.snapshot !== void 0) return await surfacesnapshotof(surfaceof(input.snapshot.surface, "popup"));
|
|
22007
|
+
if (input.settings !== void 0) {
|
|
22008
|
+
const current = settings ?? {};
|
|
22009
|
+
if (input.settings.logstreambuffer !== void 0) {
|
|
22010
|
+
const boundgate = logbufferboundvalid(input.settings.logstreambuffer);
|
|
22011
|
+
if (!boundgate.allowed) throw new Error(boundgate.reason);
|
|
22012
|
+
}
|
|
22013
|
+
if (input.settings.paletterecents !== void 0 && (!Number.isInteger(input.settings.paletterecents) || input.settings.paletterecents < 0)) throw new Error("The palette recent window stays a whole number of commands the user chose.");
|
|
22014
|
+
if (input.settings.taskinputretention !== void 0 && input.settings.taskinputretention <= 0) throw new Error("The taskinput history retention stays a positive user value in milliseconds.");
|
|
22015
|
+
if (input.settings.diffpreviewbytes !== void 0 && input.settings.diffpreviewbytes <= 0) throw new Error("The diffpreview byte ceiling stays a positive user value.");
|
|
22016
|
+
const next = {
|
|
22017
|
+
...current,
|
|
22018
|
+
...input.settings.paletterecents !== void 0 ? { paletterecents: input.settings.paletterecents } : {},
|
|
22019
|
+
...input.settings.logstreambuffer !== void 0 ? { logstreambuffer: input.settings.logstreambuffer } : {},
|
|
22020
|
+
...input.settings.taskinputretention !== void 0 ? { taskinputretention: input.settings.taskinputretention } : {},
|
|
22021
|
+
...input.settings.paletteshortcut !== void 0 ? { paletteshortcut: input.settings.paletteshortcut } : {},
|
|
22022
|
+
...input.settings.diffpreviewbytes !== void 0 ? { diffpreviewbytes: input.settings.diffpreviewbytes } : {}
|
|
22023
|
+
};
|
|
22024
|
+
await memory.setsettings(next);
|
|
22025
|
+
await audit("configure", `The user set the interface surface options${input.settings.paletterecents !== void 0 ? ` with the palette recent window of ${input.settings.paletterecents}` : ""}${input.settings.logstreambuffer !== void 0 ? ` and the logstream live buffer bound of ${input.settings.logstreambuffer}` : ""}${input.settings.paletteshortcut !== void 0 ? ` and the palette shortcut ${input.settings.paletteshortcut}` : ""}${input.settings.diffpreviewbytes !== void 0 ? ` and the diffpreview byte ceiling of ${input.settings.diffpreviewbytes}` : ""}; every write takes effect without reloading the extension.`, { ...session ? { sessionid: session.id } : {} });
|
|
22026
|
+
await broadcastsurfaceframe({ channel: "settings", surface: "optionspage", summary: "The interface surface options changed and take effect without a reload." });
|
|
22027
|
+
return { settings: next };
|
|
22028
|
+
}
|
|
22029
|
+
throw new Error("The surface command carries no palette, task, onboarding, bus, broadcast, layout, logstream, approve, diff, review, timeline, dashboard, snapshot or settings action.");
|
|
22030
|
+
}
|
|
21374
22031
|
async function handlerequest(message, sender) {
|
|
21375
22032
|
const originverdict = origincheckof({ ...sender.id !== void 0 ? { senderid: sender.id } : {}, ...sender.origin !== void 0 ? { senderorigin: sender.origin } : {}, extensionid: chrome.runtime.id, connectallow: await memory.getconnectallow() });
|
|
21376
22033
|
const inboundgate = origincheckgate({ verdict: originverdict });
|
|
@@ -21506,7 +22163,7 @@ async function handlerequest(message, sender) {
|
|
|
21506
22163
|
const livetab = session ? await chrome.tabs.get(session.tabid).catch(() => void 0) : void 0;
|
|
21507
22164
|
const waitprofile = session ? waitprofiles.find((record2) => record2.origin === session.origin) : void 0;
|
|
21508
22165
|
const livestate = { phase: livetab?.status === "loading" ? "loading" : "complete", ...navrecords[0] ? { finalurl: navrecords[0].finalurl, redirects: navrecords[0].chain } : {} };
|
|
21509
|
-
return { config: await memory.getconfig(), session, plan, progress: plan && progress?.planid === plan.id ? progress : void 0, diagnostic: await memory.getdiagnostic(), audit: await memory.getaudit(), capabilities: await refreshcapabilities(), outcomes: await memory.getoutcomes(), holds: heldkeysreport({ tabid: session?.tabid ?? 0, holds }), dialogs: await memory.getdialogs(), retries: await memory.getretries(), ...signals ? { signals: signalsreport({ signals }) } : { signals: signalsreport({}) }, banners: await memory.getbanners(), mutationevents: await memory.getmutationevents(), focusevents: await memory.getfocusevents(), diffs: await memory.getdiffs(), selectors: await memory.getselectors(), ...a11y ? { a11y } : {}, ...reader ? { reader } : {}, ...map ? { map } : {}, trail: trailreport({ ...session ? { sessionid: session.id } : {}, trail }), navrecords, ratestates, safeties, curated, waitprofiles, auths, navcontrol, navqueues, artifacts, navstate: livestate, ...waitprofile ? { waitprofile } : {}, offline: !navigator.onLine, tabs, windows, layouts: layoutreport({ layouts }), tabgroups, tabmetas, badges, snapshots, closedtabs, tabwatchevents, clones, tasktabgauge: taskgauge, ...controltab ? { controltab } : {}, tabreport: report, profiles, tickets, wizards: wizardreport({ ...session ? { sessionid: session.id } : {}, wizards, picks }), picks, errorreports, captchas, detections, ...codeentry !== void 0 ? { codeentry: true } : {}, datasets, imports, extractsessions, streams, exports, provenances, taskrules, sheetendpoints: sheetgrants, downloads, netlogs, clipconsents, clips, quarantines, cleanuprules, cleanupruns, capturecounters, inventory, mimefilters, scanhooks, captures: capturemetadata, capturepairs, capturepolicy: runsettings?.capturepolicy ?? "manual", media: mediarecords, imagebatches, recordingconsents, recordingactive: [...activerecordings.values()].map((active) => ({ id: active.record.id, kind: active.record.kind, scope: active.record.scope, startedat: active.record.startedat, stopat: active.stopat })), recordingwindow: runsettings?.recordingwindow, calls, endpoints, fetchconsents, apikeys, callretention: runsettings?.callretention, fetchesactive: activefetches.size, exchanges, channels, subscriptions, apimap, messages: messagecount, webrequestgrant: runsettings?.webrequestgrant === true, bodyretention: runsettings?.bodyretention, timelineretention: runsettings?.timelineretention, timeline, consoleconsents: await memory.getconsoleconsents(), rotationtargets: await memory.getrotationtargets(), levelsummaries: await memory.getlevelsummaries(), cdpsessions: await memory.getcdpsessions(), cdpcommands: await memory.getcdpcommands(), cdpeventrules: await memory.getcdpeventrules(), breakpoints: await memory.getbreakpoints(), pauses: await memory.getpauses(), watchexpressions: await memory.getwatchexpressions(), scriptoverrides: await memory.getscriptoverrides(), debuggergrants: await memory.getdebuggergrants(), pauseretention: runsettings?.pauseretention, breakpointceiling: runsettings?.breakpointceiling, cdpattached: [...activecdpsessions.values()].filter((active) => active.session.detachedat === void 0).length, profileretention: runsettings?.profileretention, traceceiling: runsettings?.traceceiling, profile: profilereport({ flows: await memory.getflowmetrics(), heaps: await memory.getheaprecords(), samples: await memory.getgrowsamples(), trends: await memory.gettrends(), profiles: await memory.getcpuprofiles(), shifts: await memory.getshiftentries(), traces: await memory.gettracerecords(), sourcemaps: await memory.getsourcemaps(), consents: await memory.getsourcemapconsents() }), profileactive: activememorytrackers.size + activeprofiletargets.size, profiletargets: [...activeprofiletargets.values()].flatMap((entry) => entry.targets), socketsactive: activesockets.size, emulation: emulationreport({ ...plan && await loademulationstate(plan.id) !== void 0 ? { state: await loademulationstate(plan.id) } : {}, devices: await memory.getdevicepresets(), networks: await memory.getnetworkpresets(), locations: await memory.getlocationpresets(), agents: await memory.getagentpresets(), blackbox: await memory.getblackboxrules(), permissions: await memory.getpermissionoverrides(), consents: await memory.getlocationconsents() }), emulatedlayers: plan ? layernames(await loademulationstate(plan.id)) : [], emulationretention: runsettings?.emulationretention, traffic, tokens, authflows, activerules: [...activerules.values()].reduce((total, ruleset) => total + ruleset.blocks.filter((rule) => rule.revertedat === void 0).length + ruleset.mocks.filter((rule) => rule.revertedat === void 0).length + ruleset.rewrites.filter((rule) => rule.revertedat === void 0).length + (ruleset.proxy !== void 0 && ruleset.proxy.revertedat === void 0 ? 1 : 0), 0), sessionmemory: sessionreport({ records: sessionrecords, events: await memory.getsessionevents(), folders: await memory.getsessionfolders(), diffs: await memory.getsessiondiffs(), ...autosnapshot !== void 0 ? { auto: autosnapshot.interval } : {}, ...crashed ? { crashed: true } : {} }), autosnapshotstate: autosnapshot, sessionretention: runsettings?.sessionretention, trigger: triggerlist({ rules: await memory.gettriggerules(), workflows: await memory.listworkflows(), queue: await memory.gettriggerqueue() }), triggerretention: runsettings?.triggerretention, workflow: workflowreport({ workflows: await memory.listworkflows(), runs: await memory.listworkflowruns(), templates: await memory.getsteptemplates(), ...newestworkflowrun !== void 0 ? { log: await memory.getrunlog(newestworkflowrun.id), scopes: await memory.getrunscopes(newestworkflowrun.id), provenance: await memory.getworkflowprovenance(newestworkflowrun.id), control: await memory.listcontroldecisions(newestworkflowrun.id) } : {} }), runlogretention: runsettings?.runlogretention, runhistoryretention: runsettings?.runhistoryretention, editor: editorstate({ versions: await memory.listworkflowversions(), diffs: await memory.listversiondiffs(), history: await memory.gethistory(), overrides: await memory.listsiteoverrides(), imports: (await memory.listworkflowimports()).map((entry) => ({ id: entry.id, workflowid: entry.record.id, name: entry.record.name, version: entry.record.version, steps: entry.record.steps.length, risk: entry.record.risk, importedat: entry.importedat, ...entry.filename !== void 0 ? { filename: entry.filename } : {} })), backgroundruns: await memory.getbackgroundruns(), watchdog: { ...runsettings?.watchdog !== void 0 ? { config: runsettings.watchdog } : {}, events: await memory.listwatchdogevents() } }), ...taskstate !== void 0 ? { taskstate } : {}, ...stitchprogress.size > 0 ? { stitchprogress: [...stitchprogress.values()] } : {}, mcp: await mcpstateof(), llm: await llmstateof(), swarm: await swarmstateof(), environments: await environmentviewof(), security: await securityviewof(), sessionview: await sessionviewof(), sessionpreferences: { ...runsettings?.recallwindow !== void 0 ? { recallwindow: runsettings.recallwindow } : {}, ...runsettings?.noteretention !== void 0 ? { noteretention: runsettings.noteretention } : {}, ...runsettings?.scratchpadretention !== void 0 ? { scratchpadretention: runsettings.scratchpadretention } : {}, ...runsettings?.summaryretention !== void 0 ? { summaryretention: runsettings.summaryretention } : {}, ...runsettings?.correctionretention !== void 0 ? { correctionretention: runsettings.correctionretention } : {}, ...runsettings?.summarywindow !== void 0 ? { summarywindow: runsettings.summarywindow } : {}, ...runsettings?.historyindex !== void 0 ? { historyindex: runsettings.historyindex } : {}, ...runsettings?.cancelrollback !== void 0 ? { cancelrollback: runsettings.cancelrollback } : {} } };
|
|
22166
|
+
return { config: await memory.getconfig(), session, plan, progress: plan && progress?.planid === plan.id ? progress : void 0, diagnostic: await memory.getdiagnostic(), audit: await memory.getaudit(), capabilities: await refreshcapabilities(), outcomes: await memory.getoutcomes(), holds: heldkeysreport({ tabid: session?.tabid ?? 0, holds }), dialogs: await memory.getdialogs(), retries: await memory.getretries(), ...signals ? { signals: signalsreport({ signals }) } : { signals: signalsreport({}) }, banners: await memory.getbanners(), mutationevents: await memory.getmutationevents(), focusevents: await memory.getfocusevents(), diffs: await memory.getdiffs(), selectors: await memory.getselectors(), ...a11y ? { a11y } : {}, ...reader ? { reader } : {}, ...map ? { map } : {}, trail: trailreport({ ...session ? { sessionid: session.id } : {}, trail }), navrecords, ratestates, safeties, curated, waitprofiles, auths, navcontrol, navqueues, artifacts, navstate: livestate, ...waitprofile ? { waitprofile } : {}, offline: !navigator.onLine, tabs, windows, layouts: layoutreport({ layouts }), tabgroups, tabmetas, badges, snapshots, closedtabs, tabwatchevents, clones, tasktabgauge: taskgauge, ...controltab ? { controltab } : {}, tabreport: report, profiles, tickets, wizards: wizardreport({ ...session ? { sessionid: session.id } : {}, wizards, picks }), picks, errorreports, captchas, detections, ...codeentry !== void 0 ? { codeentry: true } : {}, datasets, imports, extractsessions, streams, exports, provenances, taskrules, sheetendpoints: sheetgrants, downloads, netlogs, clipconsents, clips, quarantines, cleanuprules, cleanupruns, capturecounters, inventory, mimefilters, scanhooks, captures: capturemetadata, capturepairs, capturepolicy: runsettings?.capturepolicy ?? "manual", media: mediarecords, imagebatches, recordingconsents, recordingactive: [...activerecordings.values()].map((active) => ({ id: active.record.id, kind: active.record.kind, scope: active.record.scope, startedat: active.record.startedat, stopat: active.stopat })), recordingwindow: runsettings?.recordingwindow, calls, endpoints, fetchconsents, apikeys, callretention: runsettings?.callretention, fetchesactive: activefetches.size, exchanges, channels, subscriptions, apimap, messages: messagecount, webrequestgrant: runsettings?.webrequestgrant === true, bodyretention: runsettings?.bodyretention, timelineretention: runsettings?.timelineretention, timeline, consoleconsents: await memory.getconsoleconsents(), rotationtargets: await memory.getrotationtargets(), levelsummaries: await memory.getlevelsummaries(), cdpsessions: await memory.getcdpsessions(), cdpcommands: await memory.getcdpcommands(), cdpeventrules: await memory.getcdpeventrules(), breakpoints: await memory.getbreakpoints(), pauses: await memory.getpauses(), watchexpressions: await memory.getwatchexpressions(), scriptoverrides: await memory.getscriptoverrides(), debuggergrants: await memory.getdebuggergrants(), pauseretention: runsettings?.pauseretention, breakpointceiling: runsettings?.breakpointceiling, cdpattached: [...activecdpsessions.values()].filter((active) => active.session.detachedat === void 0).length, profileretention: runsettings?.profileretention, traceceiling: runsettings?.traceceiling, profile: profilereport({ flows: await memory.getflowmetrics(), heaps: await memory.getheaprecords(), samples: await memory.getgrowsamples(), trends: await memory.gettrends(), profiles: await memory.getcpuprofiles(), shifts: await memory.getshiftentries(), traces: await memory.gettracerecords(), sourcemaps: await memory.getsourcemaps(), consents: await memory.getsourcemapconsents() }), profileactive: activememorytrackers.size + activeprofiletargets.size, profiletargets: [...activeprofiletargets.values()].flatMap((entry) => entry.targets), socketsactive: activesockets.size, emulation: emulationreport({ ...plan && await loademulationstate(plan.id) !== void 0 ? { state: await loademulationstate(plan.id) } : {}, devices: await memory.getdevicepresets(), networks: await memory.getnetworkpresets(), locations: await memory.getlocationpresets(), agents: await memory.getagentpresets(), blackbox: await memory.getblackboxrules(), permissions: await memory.getpermissionoverrides(), consents: await memory.getlocationconsents() }), emulatedlayers: plan ? layernames(await loademulationstate(plan.id)) : [], emulationretention: runsettings?.emulationretention, traffic, tokens, authflows, activerules: [...activerules.values()].reduce((total, ruleset) => total + ruleset.blocks.filter((rule) => rule.revertedat === void 0).length + ruleset.mocks.filter((rule) => rule.revertedat === void 0).length + ruleset.rewrites.filter((rule) => rule.revertedat === void 0).length + (ruleset.proxy !== void 0 && ruleset.proxy.revertedat === void 0 ? 1 : 0), 0), sessionmemory: sessionreport({ records: sessionrecords, events: await memory.getsessionevents(), folders: await memory.getsessionfolders(), diffs: await memory.getsessiondiffs(), ...autosnapshot !== void 0 ? { auto: autosnapshot.interval } : {}, ...crashed ? { crashed: true } : {} }), autosnapshotstate: autosnapshot, sessionretention: runsettings?.sessionretention, trigger: triggerlist({ rules: await memory.gettriggerules(), workflows: await memory.listworkflows(), queue: await memory.gettriggerqueue() }), triggerretention: runsettings?.triggerretention, workflow: workflowreport({ workflows: await memory.listworkflows(), runs: await memory.listworkflowruns(), templates: await memory.getsteptemplates(), ...newestworkflowrun !== void 0 ? { log: await memory.getrunlog(newestworkflowrun.id), scopes: await memory.getrunscopes(newestworkflowrun.id), provenance: await memory.getworkflowprovenance(newestworkflowrun.id), control: await memory.listcontroldecisions(newestworkflowrun.id) } : {} }), runlogretention: runsettings?.runlogretention, runhistoryretention: runsettings?.runhistoryretention, editor: editorstate({ versions: await memory.listworkflowversions(), diffs: await memory.listversiondiffs(), history: await memory.gethistory(), overrides: await memory.listsiteoverrides(), imports: (await memory.listworkflowimports()).map((entry) => ({ id: entry.id, workflowid: entry.record.id, name: entry.record.name, version: entry.record.version, steps: entry.record.steps.length, risk: entry.record.risk, importedat: entry.importedat, ...entry.filename !== void 0 ? { filename: entry.filename } : {} })), backgroundruns: await memory.getbackgroundruns(), watchdog: { ...runsettings?.watchdog !== void 0 ? { config: runsettings.watchdog } : {}, events: await memory.listwatchdogevents() } }), ...taskstate !== void 0 ? { taskstate } : {}, ...stitchprogress.size > 0 ? { stitchprogress: [...stitchprogress.values()] } : {}, mcp: await mcpstateof(), llm: await llmstateof(), swarm: await swarmstateof(), environments: await environmentviewof(), security: await securityviewof(), sessionview: await sessionviewof(), surfacepreferences: { ...runsettings?.paletterecents !== void 0 ? { paletterecents: runsettings.paletterecents } : {}, ...runsettings?.paletteshortcut !== void 0 ? { paletteshortcut: runsettings.paletteshortcut } : {}, ...runsettings?.logstreambuffer !== void 0 ? { logstreambuffer: runsettings.logstreambuffer } : {}, ...runsettings?.taskinputretention !== void 0 ? { taskinputretention: runsettings.taskinputretention } : {}, ...runsettings?.diffpreviewbytes !== void 0 ? { diffpreviewbytes: runsettings.diffpreviewbytes } : {} }, sessionpreferences: { ...runsettings?.recallwindow !== void 0 ? { recallwindow: runsettings.recallwindow } : {}, ...runsettings?.noteretention !== void 0 ? { noteretention: runsettings.noteretention } : {}, ...runsettings?.scratchpadretention !== void 0 ? { scratchpadretention: runsettings.scratchpadretention } : {}, ...runsettings?.summaryretention !== void 0 ? { summaryretention: runsettings.summaryretention } : {}, ...runsettings?.correctionretention !== void 0 ? { correctionretention: runsettings.correctionretention } : {}, ...runsettings?.summarywindow !== void 0 ? { summarywindow: runsettings.summarywindow } : {}, ...runsettings?.historyindex !== void 0 ? { historyindex: runsettings.historyindex } : {}, ...runsettings?.cancelrollback !== void 0 ? { cancelrollback: runsettings.cancelrollback } : {} } };
|
|
21510
22167
|
}
|
|
21511
22168
|
case "capabilities":
|
|
21512
22169
|
return refreshcapabilities();
|
|
@@ -24578,6 +25235,8 @@ async function handlerequest(message, sender) {
|
|
|
24578
25235
|
}
|
|
24579
25236
|
case "sessions":
|
|
24580
25237
|
return handlesessionscommand(message);
|
|
25238
|
+
case "surface":
|
|
25239
|
+
return handlesurfacecommand(message);
|
|
24581
25240
|
case "security": {
|
|
24582
25241
|
const input2 = message;
|
|
24583
25242
|
const now = Date.now();
|
|
@@ -25629,6 +26288,14 @@ chrome.runtime.onStartup.addListener(() => {
|
|
|
25629
26288
|
void runwatchdog().catch(() => {
|
|
25630
26289
|
});
|
|
25631
26290
|
});
|
|
26291
|
+
chrome.runtime.onInstalled.addListener((details) => {
|
|
26292
|
+
void (async () => {
|
|
26293
|
+
if (details.reason !== "install") return;
|
|
26294
|
+
await memory.setonboardingstate(onboardingstart(await memory.getonboardingstate(), Date.now()));
|
|
26295
|
+
await audit("onboarding", "Devthink installed for the first time and the onboarding walkthrough started; it walks the origin grants, the plan review, the run control and the log audit once.", {});
|
|
26296
|
+
})().catch(() => {
|
|
26297
|
+
});
|
|
26298
|
+
});
|
|
25632
26299
|
async function pauseinterruptedworkflowruns() {
|
|
25633
26300
|
for (const run of await memory.listworkflowruns()) {
|
|
25634
26301
|
if (run.state !== "running") continue;
|