@wenathlan/extension 1.1.62 → 1.1.63
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/environments.d.ts +10 -0
- package/dist/environments.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +553 -1
- package/dist/index.js.map +4 -4
- package/dist/memory.d.ts +99 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/policy.d.ts +54 -0
- package/dist/policy.d.ts.map +1 -1
- package/dist/sessioninterface.d.ts +213 -0
- package/dist/sessioninterface.d.ts.map +1 -0
- package/dist/types.d.ts +198 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/extension/dist/background.js +727 -2
- package/extension/dist/background.js.map +4 -4
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/offscreen.js +4 -0
- package/extension/dist/offscreen.js.map +2 -2
- package/extension/dist/pagebridge.js.map +1 -1
- package/extension/dist/popup.html +1 -1
- package/extension/dist/popup.js +26 -0
- package/extension/dist/popup.js.map +2 -2
- package/extension/dist/sidepanel.html +1 -1
- package/extension/dist/sidepanel.js +414 -219
- package/extension/dist/sidepanel.js.map +3 -3
- package/extension/dist/transparencypage.html +1 -0
- package/extension/dist/transparencypage.js +42 -0
- package/extension/dist/transparencypage.js.map +2 -2
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -4900,6 +4900,212 @@ var sessionmemory = class {
|
|
|
4900
4900
|
phishverdicts: await this.getphishverdicts()
|
|
4901
4901
|
};
|
|
4902
4902
|
}
|
|
4903
|
+
/**
|
|
4904
|
+
* Session interface persistence of the 1.1.63 family.
|
|
4905
|
+
* The five session stores live here, scoped per profile workspace: the sitenotes per origin with sensitive bodies sealed at rest, the append only scratchpad entries per task with their step provenance, the distilled runsummaries per run and origin, the correctionmemory entries per origin and kind captured from plan review, and the consentmemory entries per origin with every grant, denial, expiry and revocation carrying its boundary; beside them the semanticrecall index with fingerprint deduplication answers ranked queries inside the run scope, the incremental historysearch corpus indexes session metadata, notes and summaries as they are written, the errorsurface payloads of failed steps keep their retry hints with the policy verdict, the per tab session references isolate parallel tabs, and the export bundles notes, summaries and corrections as one audit bundle.
|
|
4906
|
+
* The recall seam stays documented: the local fingerprint index answers every query today while a future remote recall backend can take the same shapes behind the seam without touching the callers.
|
|
4907
|
+
*/
|
|
4908
|
+
/** Replaces the stored site notes; a sensitive note carries its sealedbody only so the plain body never persists. */
|
|
4909
|
+
async setsitenotes(notes) {
|
|
4910
|
+
return this.adapter.set("sitenotes", notes);
|
|
4911
|
+
}
|
|
4912
|
+
/** Returns the stored site notes, oldest update first. */
|
|
4913
|
+
async getsitenotes() {
|
|
4914
|
+
return await this.adapter.get("sitenotes") ?? [];
|
|
4915
|
+
}
|
|
4916
|
+
/** Reads the site notes of one origin only; the read gate keeps the origin inside the session grants. */
|
|
4917
|
+
async readsitenotes(origin) {
|
|
4918
|
+
return (await this.getsitenotes()).filter((note) => note.origin === origin);
|
|
4919
|
+
}
|
|
4920
|
+
/** Writes one site note: a note of the same id keeps its latest edit while a new note joins the store. */
|
|
4921
|
+
async writesitenote(note) {
|
|
4922
|
+
const notes = await this.getsitenotes();
|
|
4923
|
+
await this.setsitenotes(notes.some((candidate) => candidate.id === note.id) ? notes.map((candidate) => candidate.id === note.id ? note : candidate) : [...notes, note]);
|
|
4924
|
+
}
|
|
4925
|
+
/** Removes one site note by its id. */
|
|
4926
|
+
async removesitenote(id) {
|
|
4927
|
+
await this.setsitenotes((await this.getsitenotes()).filter((note) => note.id !== id));
|
|
4928
|
+
}
|
|
4929
|
+
/** Expires the site notes past the user configured window; an absent window keeps every note. */
|
|
4930
|
+
async expiresitenotes(retention, now) {
|
|
4931
|
+
if (retention === void 0) return await this.getsitenotes();
|
|
4932
|
+
const kept = (await this.getsitenotes()).filter((note) => now - note.updatedat < retention);
|
|
4933
|
+
await this.setsitenotes(kept);
|
|
4934
|
+
return kept;
|
|
4935
|
+
}
|
|
4936
|
+
/** Replaces the stored scratchpad entries per task. */
|
|
4937
|
+
async setscratchpad(entries) {
|
|
4938
|
+
return this.adapter.set("scratchpad", entries);
|
|
4939
|
+
}
|
|
4940
|
+
/** Returns every stored scratchpad entry, newest first. */
|
|
4941
|
+
async getscratchpadall() {
|
|
4942
|
+
return await this.adapter.get("scratchpad") ?? [];
|
|
4943
|
+
}
|
|
4944
|
+
/** Appends one scratchpad entry: the pad stays append only so no later write rewrites an earlier entry. */
|
|
4945
|
+
async appendscratchentry(entry) {
|
|
4946
|
+
await this.setscratchpad([entry, ...await this.getscratchpadall()]);
|
|
4947
|
+
}
|
|
4948
|
+
/** Reads the scratchpad of one task session, newest first; entries of another task never cross the boundary. */
|
|
4949
|
+
async readscratchpad(taskid, sessionid) {
|
|
4950
|
+
return (await this.getscratchpadall()).filter((entry) => entry.taskid === taskid && entry.sessionid === sessionid);
|
|
4951
|
+
}
|
|
4952
|
+
/** Prunes the scratchpad entries past the user configured window; an absent window keeps every entry. */
|
|
4953
|
+
async prunescratchentries(window2, now) {
|
|
4954
|
+
if (window2 === void 0) return await this.getscratchpadall();
|
|
4955
|
+
const kept = (await this.getscratchpadall()).filter((entry) => now - entry.at < window2);
|
|
4956
|
+
await this.setscratchpad(kept);
|
|
4957
|
+
return kept;
|
|
4958
|
+
}
|
|
4959
|
+
/** Stores one distilled run summary of a completed run. */
|
|
4960
|
+
async setrunsummary(summary) {
|
|
4961
|
+
return this.adapter.set(`runsummary:${summary.runid}`, summary);
|
|
4962
|
+
}
|
|
4963
|
+
/** Returns the stored run summary of one run; an absent summary returns undefined. */
|
|
4964
|
+
async getrunsummary(runid) {
|
|
4965
|
+
return this.adapter.get(`runsummary:${runid}`);
|
|
4966
|
+
}
|
|
4967
|
+
/** Lists the stored run summaries, oldest distillation first, optionally filtered by origin. */
|
|
4968
|
+
async listrunsummaries(origin) {
|
|
4969
|
+
const index = await this.adapter.get("runsummaryindex") ?? [];
|
|
4970
|
+
const summaries = [];
|
|
4971
|
+
for (const runid of index) {
|
|
4972
|
+
const summary = await this.getrunsummary(runid);
|
|
4973
|
+
if (summary) summaries.push(summary);
|
|
4974
|
+
}
|
|
4975
|
+
const filtered = origin === void 0 ? summaries : summaries.filter((summary) => summary.origins.includes(origin));
|
|
4976
|
+
return filtered.sort((one, two) => one.distilledat - two.distilledat);
|
|
4977
|
+
}
|
|
4978
|
+
/** Tracks one run in the run summary index so the listing reads every stored summary. */
|
|
4979
|
+
async trackrunsummary(runid) {
|
|
4980
|
+
const index = await this.adapter.get("runsummaryindex") ?? [];
|
|
4981
|
+
if (!index.includes(runid)) await this.adapter.set("runsummaryindex", [...index, runid]);
|
|
4982
|
+
}
|
|
4983
|
+
/** Expires the run summaries past the user configured window; an absent window keeps every summary. */
|
|
4984
|
+
async expirerunsummaries(retention, now) {
|
|
4985
|
+
const summaries = await this.listrunsummaries();
|
|
4986
|
+
if (retention === void 0) return summaries;
|
|
4987
|
+
const kept = [];
|
|
4988
|
+
for (const summary of summaries) {
|
|
4989
|
+
if (now - summary.distilledat > retention) await this.adapter.set(`runsummary:${summary.runid}`, { ...summary, steps: [], kinds: [], origins: summary.origins });
|
|
4990
|
+
else kept.push(summary);
|
|
4991
|
+
}
|
|
4992
|
+
return kept;
|
|
4993
|
+
}
|
|
4994
|
+
/** Replaces the semantic recall index with its fingerprint deduplicated entries. */
|
|
4995
|
+
async setrecallindex(index) {
|
|
4996
|
+
return this.adapter.set("recallindex", index);
|
|
4997
|
+
}
|
|
4998
|
+
/** Returns the stored semantic recall index entries, newest first. */
|
|
4999
|
+
async getrecallindex() {
|
|
5000
|
+
return await this.adapter.get("recallindex") ?? [];
|
|
5001
|
+
}
|
|
5002
|
+
/** Adds one recall index entry with fingerprint deduplication: a repeated extraction keeps its first entry. */
|
|
5003
|
+
async addrecallentry(entry) {
|
|
5004
|
+
const index = await this.getrecallindex();
|
|
5005
|
+
if (index.some((candidate) => candidate.fingerprint === entry.fingerprint && candidate.origin === entry.origin)) return;
|
|
5006
|
+
await this.setrecallindex([entry, ...index]);
|
|
5007
|
+
}
|
|
5008
|
+
/** Answers one semantic recall query across the extraction stores: the local index ranks by text similarity inside the run scope and returns the provenance of every match. */
|
|
5009
|
+
async semanticrecall(query, scope, rank) {
|
|
5010
|
+
return rank(await this.getrecallindex(), query, scope);
|
|
5011
|
+
}
|
|
5012
|
+
/** Expires the recall index entries past the user configured window; the extraction records themselves stay for the audit trail. */
|
|
5013
|
+
async expirerecallentries(window2, now) {
|
|
5014
|
+
if (window2 === void 0) return await this.getrecallindex();
|
|
5015
|
+
const kept = (await this.getrecallindex()).filter((entry) => now - entry.at < window2);
|
|
5016
|
+
await this.setrecallindex(kept);
|
|
5017
|
+
return kept;
|
|
5018
|
+
}
|
|
5019
|
+
/** Replaces the stored correction memory entries per origin and kind. */
|
|
5020
|
+
async setcorrections(corrections) {
|
|
5021
|
+
return this.adapter.set("corrections", corrections);
|
|
5022
|
+
}
|
|
5023
|
+
/** Returns the stored correction memory entries, newest first, optionally filtered by origin and kind. */
|
|
5024
|
+
async getcorrections(filter) {
|
|
5025
|
+
const entries = await this.adapter.get("corrections") ?? [];
|
|
5026
|
+
return entries.filter((entry) => (filter?.origin === void 0 || entry.origin === filter.origin) && (filter?.kind === void 0 || entry.kind === filter.kind));
|
|
5027
|
+
}
|
|
5028
|
+
/** Records one correction memory entry captured from a plan review edit or rejection. */
|
|
5029
|
+
async addcorrection(entry) {
|
|
5030
|
+
await this.setcorrections([entry, ...await this.adapter.get("corrections") ?? []]);
|
|
5031
|
+
}
|
|
5032
|
+
/** Expires the correction memory entries past the user configured window; an absent window keeps every correction. */
|
|
5033
|
+
async expirecorrectionentries(window2, now) {
|
|
5034
|
+
if (window2 === void 0) return await this.getcorrections();
|
|
5035
|
+
const kept = (await this.getcorrections()).filter((entry) => now - entry.at < window2);
|
|
5036
|
+
await this.setcorrections(kept);
|
|
5037
|
+
return kept;
|
|
5038
|
+
}
|
|
5039
|
+
/** Replaces the stored consent memory entries per origin. */
|
|
5040
|
+
async setconsentmemory(entries) {
|
|
5041
|
+
return this.adapter.set("consentmemory", entries);
|
|
5042
|
+
}
|
|
5043
|
+
/** Returns the stored consent memory entries, newest first, optionally filtered by origin. */
|
|
5044
|
+
async getconsentmemory(origin) {
|
|
5045
|
+
const entries = await this.adapter.get("consentmemory") ?? [];
|
|
5046
|
+
return origin === void 0 ? entries : entries.filter((entry) => entry.origin === origin);
|
|
5047
|
+
}
|
|
5048
|
+
/** Records one consent memory entry per origin: every grant, denial, expiry and revocation lands with its boundary and kinds. */
|
|
5049
|
+
async addconsentmemoryentry(entry) {
|
|
5050
|
+
await this.setconsentmemory([entry, ...await this.adapter.get("consentmemory") ?? []]);
|
|
5051
|
+
}
|
|
5052
|
+
/** Replaces the stored error surface payloads of failed steps. */
|
|
5053
|
+
async seterrorsurfaces(surfaces) {
|
|
5054
|
+
return this.adapter.set("errorsurfaces", surfaces);
|
|
5055
|
+
}
|
|
5056
|
+
/** Returns the stored error surface payloads, newest first, optionally filtered by step. */
|
|
5057
|
+
async geterrorsurfaces(stepid) {
|
|
5058
|
+
const surfaces = await this.adapter.get("errorsurfaces") ?? [];
|
|
5059
|
+
return stepid === void 0 ? surfaces : surfaces.filter((surface) => surface.stepid === stepid);
|
|
5060
|
+
}
|
|
5061
|
+
/** Records one error surface payload of a failed step with its retry hint and the policy verdict. */
|
|
5062
|
+
async adderrorsurface(surface) {
|
|
5063
|
+
await this.seterrorsurfaces([surface, ...await this.adapter.get("errorsurfaces") ?? []].slice(0, 500));
|
|
5064
|
+
}
|
|
5065
|
+
/** Replaces the incremental history search corpus of session metadata, notes and run summaries. */
|
|
5066
|
+
async sethistoryindex(corpus) {
|
|
5067
|
+
return this.adapter.set("historyindex", corpus);
|
|
5068
|
+
}
|
|
5069
|
+
/** Returns the incremental history search corpus, newest entry first. */
|
|
5070
|
+
async gethistoryindex() {
|
|
5071
|
+
return await this.adapter.get("historyindex") ?? [];
|
|
5072
|
+
}
|
|
5073
|
+
/** Adds one corpus entry to the incremental history index on each store write. */
|
|
5074
|
+
async addhistoryentry(entry) {
|
|
5075
|
+
const corpus = await this.gethistoryindex();
|
|
5076
|
+
await this.sethistoryindex([entry, ...corpus.filter((candidate) => !(candidate.source === entry.source && candidate.id === entry.id))]);
|
|
5077
|
+
}
|
|
5078
|
+
/** Answers one history search query against the incremental corpus with the matched terms highlighted. */
|
|
5079
|
+
async historysearch(query, search) {
|
|
5080
|
+
return search(await this.gethistoryindex(), query);
|
|
5081
|
+
}
|
|
5082
|
+
/** Stores one per tab session reference so parallel tabs never collide inside the session stores. */
|
|
5083
|
+
async settabsession(ref) {
|
|
5084
|
+
return this.adapter.set(`tabsession:${ref.tabid}`, ref);
|
|
5085
|
+
}
|
|
5086
|
+
/** Returns the per tab session reference of one tab; an absent reference returns undefined. */
|
|
5087
|
+
async gettabsession(tabid2) {
|
|
5088
|
+
return this.adapter.get(`tabsession:${tabid2}`);
|
|
5089
|
+
}
|
|
5090
|
+
/** Lists every per tab session reference so the sessiongrid reads the per tab lock state of concurrent sessions. */
|
|
5091
|
+
async listtabsessions() {
|
|
5092
|
+
const tabs = await this.adapter.get("tabsessionindex") ?? [];
|
|
5093
|
+
const refs = [];
|
|
5094
|
+
for (const tabid2 of tabs) {
|
|
5095
|
+
const ref = await this.gettabsession(tabid2);
|
|
5096
|
+
if (ref) refs.push(ref);
|
|
5097
|
+
}
|
|
5098
|
+
return refs;
|
|
5099
|
+
}
|
|
5100
|
+
/** Tracks one tab in the per tab session index so the listing reads every isolated reference. */
|
|
5101
|
+
async tracktabsession(tabid2) {
|
|
5102
|
+
const tabs = await this.adapter.get("tabsessionindex") ?? [];
|
|
5103
|
+
if (!tabs.includes(tabid2)) await this.adapter.set("tabsessionindex", [...tabs, tabid2]);
|
|
5104
|
+
}
|
|
5105
|
+
/** Exports the site notes, the run summaries and the correction memory as one audit bundle: sensitive note bodies stay sealed in the export. */
|
|
5106
|
+
async exportsessionbundle(exportedat) {
|
|
5107
|
+
return { kind: "sessionbundle", notes: await this.getsitenotes(), summaries: await this.listrunsummaries(), corrections: await this.getcorrections(), exportedat };
|
|
5108
|
+
}
|
|
4903
5109
|
};
|
|
4904
5110
|
function mediakindof(record2) {
|
|
4905
5111
|
if ("pages" in record2) return "pdf";
|
|
@@ -5181,6 +5387,11 @@ function isolatedinjection(step) {
|
|
|
5181
5387
|
}
|
|
5182
5388
|
return { world: "ISOLATED", code: step.value, args };
|
|
5183
5389
|
}
|
|
5390
|
+
var runsummarytask = "runsummary";
|
|
5391
|
+
function summaryrequestof(input) {
|
|
5392
|
+
if (input.payload.trim() === "") throw new Error("The runsummary request needs its payload reference.");
|
|
5393
|
+
return { id: input.id, runid: input.runid, stepid: input.sessionid, task: runsummarytask, payload: input.payload, transferables: [], sentat: input.sentat };
|
|
5394
|
+
}
|
|
5184
5395
|
|
|
5185
5396
|
// toolcatalog.ts
|
|
5186
5397
|
var toolcatalogversion = 1;
|
|
@@ -10367,6 +10578,45 @@ function untrustedrendergate(input) {
|
|
|
10367
10578
|
if (input.environment === "sandboxframe") return { allowed: true, reason: "The extracted markup renders inside the sandboxframe under its nonce with scripts and handlers stripped; the untrusted content never reenters the page context." };
|
|
10368
10579
|
return { allowed: false, reason: `The extracted markup grades untrusted and refuses to render inside the ${input.environment}; every untrusted render routes through the sandboxframe.` };
|
|
10369
10580
|
}
|
|
10581
|
+
function sitenotesreadgate(input) {
|
|
10582
|
+
if (input.grants.includes(input.origin)) return { allowed: true, reason: `The session granted ${input.origin}, so the site notes of the origin read.` };
|
|
10583
|
+
return { allowed: false, reason: `The session never granted ${input.origin}; the site notes of the origin refuse the read.` };
|
|
10584
|
+
}
|
|
10585
|
+
function sitenoteswritegate(input) {
|
|
10586
|
+
if (!input.consent) return { allowed: false, reason: `The site note write for ${input.origin} needs the explicit consent of the user; no note lands without a reviewed write.` };
|
|
10587
|
+
return { allowed: true, reason: `The user consented to the site note write for ${input.origin}; the note keeps its author provenance and its timestamps.` };
|
|
10588
|
+
}
|
|
10589
|
+
function scratchpadscopegate(input) {
|
|
10590
|
+
if (input.taskid !== input.entrytaskid || input.sessionid !== input.entrysessionid) return { allowed: false, reason: `The scratchpad entry belongs to the task ${input.entrytaskid} of the session ${input.entrysessionid}; the task ${input.taskid} of the session ${input.sessionid} never crosses that boundary.` };
|
|
10591
|
+
return { allowed: true, reason: `The scratchpad entry belongs to the task ${input.taskid} of the session ${input.sessionid} that asks for it.` };
|
|
10592
|
+
}
|
|
10593
|
+
function memoryreadscopegate(input) {
|
|
10594
|
+
if (input.phase === "planning" || input.phase === "prompting") return { allowed: true, reason: `The ${input.phase} phase reads the correction and consent memory so the proposal and the prompt carry the prior decisions.` };
|
|
10595
|
+
return { allowed: false, reason: `The ${input.phase} phase reads no correction or consent memory; the history serves the planning and the prompting alone.` };
|
|
10596
|
+
}
|
|
10597
|
+
function semanticrecallscopegate(input) {
|
|
10598
|
+
if (input.origin === void 0) return { allowed: true, reason: `The recall query names no origin, so it ranks the ${input.scope.length} origin${input.scope.length === 1 ? "" : "s"} of the run scope only.` };
|
|
10599
|
+
if (!input.scope.includes(input.origin)) return { allowed: false, reason: `The recall query asks for ${input.origin} while the run scope holds ${input.scope.length > 0 ? input.scope.join(", ") : "no origin"}; a recall across origins outside the run scope refuses.` };
|
|
10600
|
+
return { allowed: true, reason: `The recall query asks for ${input.origin} inside the run scope; the ranking stays scoped.` };
|
|
10601
|
+
}
|
|
10602
|
+
function summarywindowvalid(window2) {
|
|
10603
|
+
if (window2 === void 0) return { allowed: true, reason: "No runsummary window is configured, so the distillation keeps every step with no fixed cap." };
|
|
10604
|
+
if (!Number.isInteger(window2) || window2 < 0) return { allowed: false, reason: "The runsummary window stays a whole number of steps the user chose; no engine cap exists." };
|
|
10605
|
+
return { allowed: true, reason: `The runsummary window of ${window2} step${window2 === 1 ? "" : "s"} stays the user configured choice; no engine cap exists.` };
|
|
10606
|
+
}
|
|
10607
|
+
function sessionretentionvalid(window2) {
|
|
10608
|
+
if (window2 === void 0) return { allowed: true, reason: "No retention window is configured, so the session store keeps every record forever." };
|
|
10609
|
+
if (!Number.isFinite(window2) || window2 <= 0) return { allowed: false, reason: "The retention window stays a positive user value in milliseconds; no engine boundary expires a record." };
|
|
10610
|
+
return { allowed: true, reason: `The retention window of ${window2} milliseconds stays the user configured choice.` };
|
|
10611
|
+
}
|
|
10612
|
+
function cancelrungate(input) {
|
|
10613
|
+
if (input.rollbackscope === "none") return { allowed: true, reason: `The cancelrun stops the run with no rollback; the ${input.queuedstepids.length} queued step${input.queuedstepids.length === 1 ? "" : "s"} stay as the run left them and the ${input.executedstepids.length} executed step${input.executedstepids.length === 1 ? "" : "s"} stay in the sealed log.` };
|
|
10614
|
+
return { allowed: true, reason: `The cancelrun rolls the ${input.queuedstepids.length} queued step${input.queuedstepids.length === 1 ? "" : "s"} back${input.queuedstepids.length > 0 ? ` (${input.queuedstepids.join(", ")})` : ""} while the ${input.executedstepids.length} executed step${input.executedstepids.length === 1 ? "" : "s"} stay untouched in the sealed log.` };
|
|
10615
|
+
}
|
|
10616
|
+
function retrydispatchgate(input) {
|
|
10617
|
+
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
|
+
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
|
+
}
|
|
10370
10620
|
|
|
10371
10621
|
// progress.ts
|
|
10372
10622
|
function emptyprogress(planid, now) {
|
|
@@ -10617,7 +10867,7 @@ function maskexport(record2, shapes) {
|
|
|
10617
10867
|
}
|
|
10618
10868
|
|
|
10619
10869
|
// version.ts
|
|
10620
|
-
var packageversion = "1.1.
|
|
10870
|
+
var packageversion = "1.1.63";
|
|
10621
10871
|
|
|
10622
10872
|
// types.ts
|
|
10623
10873
|
var protocolversion = packageversion;
|
|
@@ -12736,6 +12986,200 @@ function endcall(input) {
|
|
|
12736
12986
|
return { contexts: input.contexts.map((candidate) => candidate.callid === input.callid ? context : candidate), context };
|
|
12737
12987
|
}
|
|
12738
12988
|
|
|
12989
|
+
// sessioninterface.ts
|
|
12990
|
+
function textfingerprint(text2) {
|
|
12991
|
+
let hash = 2166136261;
|
|
12992
|
+
for (let index = 0; index < text2.length; index += 1) {
|
|
12993
|
+
hash ^= text2.charCodeAt(index);
|
|
12994
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
12995
|
+
}
|
|
12996
|
+
return hash.toString(16).padStart(8, "0");
|
|
12997
|
+
}
|
|
12998
|
+
function keystreambyte(id, position) {
|
|
12999
|
+
let hash = 2166136261;
|
|
13000
|
+
const source = `${id}:${position}`;
|
|
13001
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
13002
|
+
hash ^= source.charCodeAt(index);
|
|
13003
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
13004
|
+
}
|
|
13005
|
+
return hash & 255;
|
|
13006
|
+
}
|
|
13007
|
+
function sealnotebody(id, body) {
|
|
13008
|
+
const sealed = Array.from(body, (character, index) => String.fromCharCode(character.charCodeAt(0) ^ keystreambyte(id, index))).join("");
|
|
13009
|
+
return `sealed:${btoa(sealed)}`;
|
|
13010
|
+
}
|
|
13011
|
+
function opennotebody(id, sealedbody) {
|
|
13012
|
+
if (!sealedbody.startsWith("sealed:")) return "";
|
|
13013
|
+
try {
|
|
13014
|
+
const sealed = atob(sealedbody.slice("sealed:".length));
|
|
13015
|
+
return Array.from(sealed, (character, index) => String.fromCharCode(character.charCodeAt(0) ^ keystreambyte(id, index))).join("");
|
|
13016
|
+
} catch {
|
|
13017
|
+
return "";
|
|
13018
|
+
}
|
|
13019
|
+
}
|
|
13020
|
+
function sitenoteof(input) {
|
|
13021
|
+
if (input.origin.trim() === "") throw new Error("The site note needs its origin.");
|
|
13022
|
+
if (input.title.trim() === "") throw new Error("The site note needs its title.");
|
|
13023
|
+
if (input.body.trim() === "") throw new Error("The site note needs its body.");
|
|
13024
|
+
const id = input.id ?? randomid();
|
|
13025
|
+
if (input.sensitive === true) return { id, origin: input.origin, title: input.title.trim(), sealedbody: sealnotebody(id, input.body), author: input.author, sensitive: true, createdat: input.now, updatedat: input.now };
|
|
13026
|
+
return { id, origin: input.origin, title: input.title.trim(), body: input.body, author: input.author, sensitive: false, createdat: input.now, updatedat: input.now };
|
|
13027
|
+
}
|
|
13028
|
+
function notebodyof(note) {
|
|
13029
|
+
if (note.sensitive) return note.sealedbody !== void 0 ? opennotebody(note.id, note.sealedbody) : "";
|
|
13030
|
+
return note.body ?? "";
|
|
13031
|
+
}
|
|
13032
|
+
function editnote(note, input) {
|
|
13033
|
+
if (input.title.trim() === "") throw new Error("The site note keeps a non empty title.");
|
|
13034
|
+
if (input.body.trim() === "") throw new Error("The site note keeps a non empty body.");
|
|
13035
|
+
if (note.sensitive) return { ...note, title: input.title.trim(), sealedbody: sealnotebody(note.id, input.body), updatedat: input.now, author: input.author };
|
|
13036
|
+
return { ...note, title: input.title.trim(), body: input.body, updatedat: input.now, author: input.author };
|
|
13037
|
+
}
|
|
13038
|
+
function scratchentryof(input) {
|
|
13039
|
+
if (input.taskid.trim() === "") throw new Error("The scratchpad entry needs its task.");
|
|
13040
|
+
if (input.text.trim() === "") throw new Error("The scratchpad entry needs its text.");
|
|
13041
|
+
return { id: input.id ?? randomid(), taskid: input.taskid, sessionid: input.sessionid, text: input.text, ...input.stepid !== void 0 && input.stepid.trim() !== "" ? { stepid: input.stepid } : {}, author: input.author, at: input.now };
|
|
13042
|
+
}
|
|
13043
|
+
function distillrunsummary(input) {
|
|
13044
|
+
const steps = input.outcomes.map((outcome) => {
|
|
13045
|
+
const step = input.plan.steps.find((candidate) => candidate.id === outcome.stepid);
|
|
13046
|
+
return { stepid: outcome.stepid, kind: step?.kind ?? "unknown", ok: outcome.ok, summary: outcome.summary };
|
|
13047
|
+
});
|
|
13048
|
+
const windowed = input.window !== void 0 && Number.isInteger(input.window) && input.window >= 0 ? steps.slice(Math.max(0, steps.length - input.window)) : steps;
|
|
13049
|
+
const kinds = [...new Set(windowed.map((step) => step.kind))];
|
|
13050
|
+
return { runid: input.plan.id, sessionid: input.sessionid, origins: [...new Set(input.origins)], kinds, steps: windowed, ...input.window !== void 0 && Number.isInteger(input.window) && input.window >= 0 ? { window: input.window } : {}, task: "runsummary", provenance: input.provenance, distilledat: input.now };
|
|
13051
|
+
}
|
|
13052
|
+
function summaryhistoryentry(summary) {
|
|
13053
|
+
return { source: "summary", id: summary.runid, title: `Run summary of ${summary.runid}`, text: `${summary.origins.join(" ")} ${summary.kinds.join(" ")} ${summary.steps.map((step) => step.summary).join(" ")}`, outcome: summary.steps.every((step) => step.ok) ? "completed" : "failed", at: summary.distilledat };
|
|
13054
|
+
}
|
|
13055
|
+
function notehistoryentry(note) {
|
|
13056
|
+
return { source: "note", id: note.id, ...note.origin !== "" ? { origin: note.origin } : {}, title: note.title, text: note.sensitive ? note.title : `${note.title} ${note.body ?? ""}`, at: note.updatedat };
|
|
13057
|
+
}
|
|
13058
|
+
function recallentryof(input) {
|
|
13059
|
+
if (input.text.trim() === "") throw new Error("The recall index entry needs its text.");
|
|
13060
|
+
if (input.stepid.trim() === "" || input.runid.trim() === "") throw new Error("The recall index entry needs its run and step provenance.");
|
|
13061
|
+
const normalized = input.text.trim().replace(/\s+/g, " ");
|
|
13062
|
+
return { fingerprint: textfingerprint(normalized), origin: input.origin, runid: input.runid, stepid: input.stepid, text: normalized, at: input.at };
|
|
13063
|
+
}
|
|
13064
|
+
function termsof(text2) {
|
|
13065
|
+
return new Set(text2.toLowerCase().split(/[^a-z0-9]+/).filter((term) => term.length > 1));
|
|
13066
|
+
}
|
|
13067
|
+
function rankrecall(index, query, scope) {
|
|
13068
|
+
if (query.text.trim() === "") return [];
|
|
13069
|
+
const terms = termsof(query.text);
|
|
13070
|
+
const scoped = query.origin !== void 0 && query.origin.trim() !== "" ? [query.origin] : scope.origins;
|
|
13071
|
+
const matches = [];
|
|
13072
|
+
for (const entry of index) {
|
|
13073
|
+
if (!scoped.includes(entry.origin)) continue;
|
|
13074
|
+
const entryterms = termsof(entry.text);
|
|
13075
|
+
let shared = 0;
|
|
13076
|
+
for (const term of terms) if (entryterms.has(term)) shared += 1;
|
|
13077
|
+
const union = (/* @__PURE__ */ new Set([...terms, ...entryterms])).size;
|
|
13078
|
+
const score = union === 0 ? 0 : shared / union;
|
|
13079
|
+
if (score <= 0) continue;
|
|
13080
|
+
matches.push({ entry, score, reason: `The extraction of ${entry.origin} shares ${shared} term${shared === 1 ? "" : "s"} with the query at the score ${score.toFixed(3)}; the match carries the run ${entry.runid} and the step ${entry.stepid}.` });
|
|
13081
|
+
}
|
|
13082
|
+
const ranked = matches.sort((one, two) => two.score - one.score);
|
|
13083
|
+
return query.limit !== void 0 && Number.isInteger(query.limit) && query.limit >= 0 ? ranked.slice(0, query.limit) : ranked;
|
|
13084
|
+
}
|
|
13085
|
+
function editedcorrectionof(input) {
|
|
13086
|
+
if (input.stepid.trim() === "" || input.kind.trim() === "") throw new Error("The correction needs its step and kind.");
|
|
13087
|
+
if (input.original === input.corrected) throw new Error("The correction needs a changed step shape.");
|
|
13088
|
+
return { id: input.id ?? randomid(), origin: input.origin, kind: input.kind, stepid: input.stepid, source: "edited", original: input.original, corrected: input.corrected, reason: input.reason, at: input.now };
|
|
13089
|
+
}
|
|
13090
|
+
function rejectedcorrectionof(input) {
|
|
13091
|
+
if (input.stepid.trim() === "" || input.reason.trim() === "") throw new Error("The rejected correction needs its step and its rejection reason.");
|
|
13092
|
+
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
|
+
}
|
|
13094
|
+
function consentmemoryof(input) {
|
|
13095
|
+
if (input.origin.trim() === "") throw new Error("The consent memory entry needs its origin.");
|
|
13096
|
+
if (input.boundary.trim() === "") throw new Error("The consent memory entry needs the boundary the prompt named.");
|
|
13097
|
+
return { id: input.id ?? randomid(), origin: input.origin, decision: input.decision, boundary: input.boundary, kinds: [...new Set(input.kinds)], at: input.now, ...input.expiresat !== void 0 ? { expiresat: input.expiresat } : {} };
|
|
13098
|
+
}
|
|
13099
|
+
function consentadvisoryverdict(entries, origin, kind) {
|
|
13100
|
+
const matching = entries.filter((entry) => entry.origin === origin && entry.kinds.includes(kind));
|
|
13101
|
+
const latest = matching[matching.length - 1];
|
|
13102
|
+
if (latest === void 0) return { advisory: false, reason: `No prior decision exists for the ${kind} kind on ${origin}; the prompt opens fresh.` };
|
|
13103
|
+
if (latest.decision === "deny") return { advisory: true, reason: `The consent memory holds a prior denial of the ${kind} kind on ${origin} from ${new Date(latest.at).toISOString()}; the denial carries the same weight as a grant and the record stays advisory only.` };
|
|
13104
|
+
return { advisory: true, reason: `The consent memory holds a prior ${latest.decision} of the ${kind} kind on ${origin} with the boundary ${latest.boundary}; the record advises the new prompt and never auto grants.` };
|
|
13105
|
+
}
|
|
13106
|
+
function rollbacksplit(plan, progress) {
|
|
13107
|
+
const executed = progress && progress.planid === plan?.id ? progress.completedsteps : [];
|
|
13108
|
+
const executedset = new Set(executed);
|
|
13109
|
+
const queued = (plan?.steps ?? []).map((step) => step.id).filter((id) => !executedset.has(id));
|
|
13110
|
+
return { executedstepids: executed, queuedstepids: queued };
|
|
13111
|
+
}
|
|
13112
|
+
function rollbackof(plan, progress, preference) {
|
|
13113
|
+
const split = rollbacksplit(plan, progress);
|
|
13114
|
+
if (preference === "none") return { scope: "none", label: `Stop the run ${plan?.id ?? ""} without a rollback; the ${split.queuedstepids.length} queued step${split.queuedstepids.length === 1 ? "" : "s"} stay as the run left them.`, queuedstepids: split.queuedstepids };
|
|
13115
|
+
return { scope: "queued", label: `Cancel the run ${plan?.id ?? ""} and roll its ${split.queuedstepids.length} queued step${split.queuedstepids.length === 1 ? "" : "s"} back${split.queuedstepids.length > 0 ? ` (${split.queuedstepids.join(", ")})` : ""} while the ${split.executedstepids.length} executed step${split.executedstepids.length === 1 ? "" : "s"} stay untouched in the sealed log.`, queuedstepids: split.queuedstepids };
|
|
13116
|
+
}
|
|
13117
|
+
function cancelrunactionof(input) {
|
|
13118
|
+
return { runid: input.runid, sessionid: input.sessionid, rollback: rollbackof(input.plan, input.progress, input.preference) };
|
|
13119
|
+
}
|
|
13120
|
+
function errorsurfaceof(input) {
|
|
13121
|
+
if (input.message.trim() === "") throw new Error("The error surface needs its message in plain language.");
|
|
13122
|
+
return { stepid: input.stepid, runid: input.runid, cause: input.cause, message: input.message, retry: { allowed: input.retryallowed, reason: input.retryreason }, context: input.context, at: input.now };
|
|
13123
|
+
}
|
|
13124
|
+
function classifyfailure(input) {
|
|
13125
|
+
if (input.gatewait) return "gate";
|
|
13126
|
+
if (input.policyrefused) return "policy";
|
|
13127
|
+
if (/\b(network|offline|timeout|timed out|fetch failed|socket|dns|connection)\b/i.test(input.message)) return "network";
|
|
13128
|
+
return "page";
|
|
13129
|
+
}
|
|
13130
|
+
function sessiongridrows(input) {
|
|
13131
|
+
const rows = [];
|
|
13132
|
+
if (input.session && input.plan && ["pending", "approved"].includes(input.plan.state)) {
|
|
13133
|
+
const split = rollbacksplit(input.plan, input.progress);
|
|
13134
|
+
const held = input.locks.some((lock) => lock.runid === input.plan?.id);
|
|
13135
|
+
const origins = [.../* @__PURE__ */ new Set([input.session.origin, ...input.session.grants ?? []])];
|
|
13136
|
+
const actions = ["cancelrun"];
|
|
13137
|
+
if (input.session.pausedat !== void 0) actions.push("resume");
|
|
13138
|
+
rows.push({ sessionid: input.session.id, runid: input.plan.id, origins, state: "live", outcome: `${split.executedstepids.length} of ${input.plan.steps.length} reviewed steps executed`, steps: input.plan.steps.length, completed: split.executedstepids.length, lock: held ? "held" : "free", tabid: input.session.tabid, updatedat: input.plan.createdat, actions });
|
|
13139
|
+
}
|
|
13140
|
+
for (const log of input.logs) {
|
|
13141
|
+
const summary = input.summaries.find((candidate) => candidate.runid === log.runid);
|
|
13142
|
+
const tabsession = input.tabsessions.find((candidate) => candidate.runid === log.runid);
|
|
13143
|
+
const held = input.locks.some((lock) => lock.runid === log.runid);
|
|
13144
|
+
rows.push({ sessionid: log.sessionid, runid: log.runid, origins: [...new Set(log.entries.map((entry) => entry.origin).filter((origin) => origin !== ""))], state: "saved", outcome: summary !== void 0 ? summary.steps.every((step) => step.ok) ? "completed" : "failed" : log.seal !== void 0 ? "sealed" : "open", steps: summary?.steps.length ?? log.entries.filter((entry) => entry.kind === "step").length, completed: summary?.steps.filter((step) => step.ok).length ?? log.entries.filter((entry) => entry.kind === "step").length, lock: held ? "held" : "free", ...log.seal !== void 0 ? { sealhash: log.seal.sealhash.current } : {}, ...tabsession !== void 0 ? { tabid: tabsession.tabid } : {}, updatedat: log.updatedat, actions: ["reopen"] });
|
|
13145
|
+
}
|
|
13146
|
+
return rows.sort((one, two) => two.updatedat - one.updatedat);
|
|
13147
|
+
}
|
|
13148
|
+
function historyqueryof(value) {
|
|
13149
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
13150
|
+
const candidate = value;
|
|
13151
|
+
if (typeof candidate.text !== "string" || candidate.text.trim() === "") return void 0;
|
|
13152
|
+
const origin = typeof candidate.origin === "string" && candidate.origin.trim() !== "" ? candidate.origin.trim() : void 0;
|
|
13153
|
+
const from = typeof candidate.from === "number" && Number.isFinite(candidate.from) ? candidate.from : void 0;
|
|
13154
|
+
const to = typeof candidate.to === "number" && Number.isFinite(candidate.to) ? candidate.to : void 0;
|
|
13155
|
+
if (from !== void 0 && to !== void 0 && from > to) return void 0;
|
|
13156
|
+
const outcome = typeof candidate.outcome === "string" && candidate.outcome.trim() !== "" ? candidate.outcome.trim() : void 0;
|
|
13157
|
+
return { text: candidate.text.trim(), ...origin !== void 0 ? { origin } : {}, ...from !== void 0 ? { from } : {}, ...to !== void 0 ? { to } : {}, ...outcome !== void 0 ? { outcome } : {} };
|
|
13158
|
+
}
|
|
13159
|
+
function historysearch(corpus, query) {
|
|
13160
|
+
const terms = query.text.toLowerCase().split(/[^a-z0-9]+/).filter((term) => term.length > 1);
|
|
13161
|
+
const hits = [];
|
|
13162
|
+
for (const entry of corpus) {
|
|
13163
|
+
if (query.origin !== void 0 && entry.origin !== query.origin) continue;
|
|
13164
|
+
if (query.from !== void 0 && entry.at < query.from) continue;
|
|
13165
|
+
if (query.to !== void 0 && entry.at > query.to) continue;
|
|
13166
|
+
if (query.outcome !== void 0 && entry.outcome !== query.outcome) continue;
|
|
13167
|
+
const haystack = `${entry.title} ${entry.text}`.toLowerCase();
|
|
13168
|
+
const matched = terms.filter((term) => haystack.includes(term));
|
|
13169
|
+
if (matched.length === 0) continue;
|
|
13170
|
+
const position = haystack.indexOf(matched[0] ?? "");
|
|
13171
|
+
const start = Math.max(0, position - 40);
|
|
13172
|
+
const excerpt = `${start > 0 ? "\u2026" : ""}${`${entry.title} ${entry.text}`.slice(start, start + 160)}${start + 160 < `${entry.title} ${entry.text}`.length ? "\u2026" : ""}`;
|
|
13173
|
+
hits.push({ source: entry.source, id: entry.id, title: entry.title, excerpt, highlights: [...new Set(matched)], ...entry.origin !== void 0 ? { origin: entry.origin } : {}, ...entry.outcome !== void 0 ? { outcome: entry.outcome } : {}, at: entry.at });
|
|
13174
|
+
}
|
|
13175
|
+
return hits.sort((one, two) => two.at - one.at);
|
|
13176
|
+
}
|
|
13177
|
+
function tabsessionrefof(input) {
|
|
13178
|
+
if (!Number.isInteger(input.tabid) || input.tabid < 0) throw new Error("The per tab session reference needs its tab.");
|
|
13179
|
+
if (input.sessionid.trim() === "") throw new Error("The per tab session reference needs its session.");
|
|
13180
|
+
return { tabid: input.tabid, sessionid: input.sessionid, ...input.runid !== void 0 && input.runid.trim() !== "" ? { runid: input.runid } : {}, origin: input.origin, updatedat: input.now };
|
|
13181
|
+
}
|
|
13182
|
+
|
|
12739
13183
|
// llm.ts
|
|
12740
13184
|
var defaultrefusalmarkers = ["i cannot", "i can't", "i'm unable", "refusal:", "cannot comply"];
|
|
12741
13185
|
function buildrequest(input) {
|
|
@@ -15471,6 +15915,10 @@ async function startsession() {
|
|
|
15471
15915
|
const { tab, origin } = await activecontext();
|
|
15472
15916
|
const session = { id: randomid(), tabid: tab.id, origin, startedat: Date.now(), expiresat: Date.now() + sessionduration, grants: [origin] };
|
|
15473
15917
|
await memory.setsession(session);
|
|
15918
|
+
await memory.settabsession(tabsessionrefof({ tabid: session.tabid, sessionid: session.id, origin, now: session.startedat }));
|
|
15919
|
+
await memory.tracktabsession(session.tabid);
|
|
15920
|
+
await memory.addconsentmemoryentry(consentmemoryof({ origin, decision: "grant", boundary: `the session expiry at ${new Date(session.expiresat).toISOString()}`, kinds: ["observe"], now: session.startedat }));
|
|
15921
|
+
if ((await memory.getsettings())?.historyindex !== false) await memory.addhistoryentry({ source: "session", id: session.id, origin, title: `Session of ${origin}`, text: `session ${origin} started ${new Date(session.startedat).toISOString()}`, at: session.startedat });
|
|
15474
15922
|
await memory.addallowlistorigin({ origin, profileid: runstateprofile, grantedat: session.startedat });
|
|
15475
15923
|
const scope = scopegrantof({ origin, kinds: ["observe"], boundary: `the session expiry at ${new Date(session.expiresat).toISOString()}`, now: session.startedat });
|
|
15476
15924
|
let runlog = openrunlog({ runid: session.id, sessionid: session.id, now: session.startedat });
|
|
@@ -20420,6 +20868,8 @@ async function executeaction(step, session, plan, tabid2, origin, settings, verd
|
|
|
20420
20868
|
}
|
|
20421
20869
|
await audit("deny", `The ${step.kind} step ${step.id} on ${origin} was denied without navigation: ${securityverdict.reason}`, { ...session ? { sessionid: session.id } : {}, ...plan ? { planid: plan.id } : {}, stepid: step.id });
|
|
20422
20870
|
if (securityverdict.suspended && session) {
|
|
20871
|
+
await memory.addconsentmemoryentry(consentmemoryof({ origin, decision: "expire", boundary: "the consent window boundary that expired mid step", kinds: [step.kind], now: Date.now() })).catch(() => {
|
|
20872
|
+
});
|
|
20423
20873
|
await appendrunevent("expiry", `The consent window of ${origin} expired mid step and the run suspended at the step ${step.id}; a new explicit prompt renews it.`, session, origin, step.id).catch(() => {
|
|
20424
20874
|
});
|
|
20425
20875
|
await audit("expiry", `The consent window of ${origin} expired mid step and the run suspended at the step ${step.id}; the executor refuses to resume without a new explicit prompt.`, { sessionid: session.id, ...plan ? { planid: plan.id } : {}, stepid: step.id });
|
|
@@ -20559,6 +21009,17 @@ async function executeaction(step, session, plan, tabid2, origin, settings, verd
|
|
|
20559
21009
|
const auditkind = stepauditkind(step, Boolean(output?.ok));
|
|
20560
21010
|
await audit(auditkind, summary, { ...session ? { sessionid: session.id } : {}, ...plan ? { planid: plan.id } : {}, stepid: step.id });
|
|
20561
21011
|
await memory.addoutcome(outcome);
|
|
21012
|
+
if (session && plan) await memory.appendscratchentry(scratchentryof({ taskid: plan.id, sessionid: session.id, text: `${step.kind} ${step.id} ${outcome.ok ? "completed" : "failed"}: ${summary}`, stepid: step.id, author: "agent", now: Date.now() })).catch(() => {
|
|
21013
|
+
});
|
|
21014
|
+
if (plan) await memory.addrecallentry(recallentryof({ origin, runid: plan.id, stepid: step.id, text: summary, at: Date.now() })).catch(() => {
|
|
21015
|
+
});
|
|
21016
|
+
let stepretry;
|
|
21017
|
+
if (!outcome.ok && plan) {
|
|
21018
|
+
const surface = errorsurfaceof({ stepid: step.id, runid: plan.id, message: summary, cause: classifyfailure({ message: summary, policyrefused: false, gatewait: false }), retryallowed: true, retryreason: "The failed step may dispatch again through the full consent gate chain.", context: { origin, kind: step.kind, environment: routing.environment }, now: Date.now() });
|
|
21019
|
+
await memory.adderrorsurface(surface).catch(() => {
|
|
21020
|
+
});
|
|
21021
|
+
stepretry = { allowed: true, reason: `The ${surface.cause} failure of the step ${step.id} may retry through a new reviewed dispatch; the retry rides the full consent gate chain and never bypasses the review.` };
|
|
21022
|
+
}
|
|
20562
21023
|
if (session) await appendrunevent("step", `The ${step.kind} step ${step.id} ${outcome.ok ? "completed" : "failed"} on ${origin}: ${summary}${securityverdict.classification.sensitive ? ` The step grades ${securityverdict.classification.reason}` : ""}`, session, origin, step.id).catch(() => {
|
|
20563
21024
|
});
|
|
20564
21025
|
if (output?.ok && plan && mode === "plan") {
|
|
@@ -20590,11 +21051,36 @@ async function executeaction(step, session, plan, tabid2, origin, settings, verd
|
|
|
20590
21051
|
const done = { ...plan, state: "completed", completedat: Date.now() };
|
|
20591
21052
|
await memory.setplan(done);
|
|
20592
21053
|
await closeplanrun(done.id, session?.id ?? "");
|
|
21054
|
+
await distillcompletedrun(done, tracked, session, settings).catch(() => {
|
|
21055
|
+
});
|
|
20593
21056
|
await audit("complete", "Every reviewed step of the approved plan has executed.", { ...session ? { sessionid: session.id } : {}, planid: done.id });
|
|
20594
21057
|
}
|
|
20595
21058
|
}
|
|
21059
|
+
if (stepretry !== void 0 && output !== void 0) return { ...output, retry: stepretry };
|
|
21060
|
+
if (stepretry !== void 0) return { ok: false, summary, retry: stepretry };
|
|
20596
21061
|
return output ?? { ok: false, summary };
|
|
20597
21062
|
}
|
|
21063
|
+
async function distillcompletedrun(plan, progress, session, settings) {
|
|
21064
|
+
const log = await memory.getimmutablelog(plan.id);
|
|
21065
|
+
const origins = [.../* @__PURE__ */ new Set([session?.origin ?? "", ...(log?.entries ?? []).map((entry) => entry.origin).filter((entryorigin) => entryorigin !== "")])].filter((entryorigin) => entryorigin !== "");
|
|
21066
|
+
let provenance = "inline";
|
|
21067
|
+
const inline = distillrunsummary({ plan, outcomes: progress.outcomes ?? [], origins, sessionid: session?.id ?? "", ...settings?.summarywindow !== void 0 ? { window: settings.summarywindow } : {}, provenance: "inline", now: Date.now() });
|
|
21068
|
+
const ready = await ensureoffscreendocument(plan.id).catch(() => false);
|
|
21069
|
+
if (ready) {
|
|
21070
|
+
const request = summaryrequestof({ id: randomid(), runid: plan.id, sessionid: session?.id ?? "", payload: JSON.stringify({ runid: plan.id, steps: inline.steps.length, window: settings?.summarywindow }), sentat: Date.now() });
|
|
21071
|
+
try {
|
|
21072
|
+
const answer = await chrome.runtime.sendMessage({ kind: "offscreen", action: "summary", request: { id: request.id, runid: request.runid, stepid: request.stepid, task: runsummarytask, payload: request.payload, transferables: [] } });
|
|
21073
|
+
if (answer && answer.ok !== false) provenance = "offscreenworker";
|
|
21074
|
+
} catch {
|
|
21075
|
+
}
|
|
21076
|
+
}
|
|
21077
|
+
const summary = { ...inline, provenance };
|
|
21078
|
+
await memory.setrunsummary(summary);
|
|
21079
|
+
await memory.trackrunsummary(plan.id);
|
|
21080
|
+
if (settings?.historyindex !== false) await memory.addhistoryentry(summaryhistoryentry(summary));
|
|
21081
|
+
await audit("summary", `The run summary of ${plan.id} distilled ${summary.steps.length} step outcome${summary.steps.length === 1 ? "" : "s"} across ${summary.origins.length} origin${summary.origins.length === 1 ? "" : "s"} as one ${provenance === "offscreenworker" ? "offscreen worker task" : "inline distillation"}${summary.window !== void 0 ? ` inside the user configured window of ${summary.window} steps` : " with no window cap"}.`, { ...session ? { sessionid: session.id } : {}, planid: plan.id });
|
|
21082
|
+
return summary;
|
|
21083
|
+
}
|
|
20598
21084
|
async function previewstep(stepid) {
|
|
20599
21085
|
const session = await memory.getsession();
|
|
20600
21086
|
const plan = await memory.getplan();
|
|
@@ -20656,6 +21142,7 @@ async function provenancereportValue() {
|
|
|
20656
21142
|
}
|
|
20657
21143
|
var commandschemas = {
|
|
20658
21144
|
security: { allowlist: "object", profile: "object", consent: "object", revoke: "object", mask: "object", read: "object", export: "object", settings: "object", gate: "object", vault: "object", connectallow: "object", ratelimit: "object", redact: "object" },
|
|
21145
|
+
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" },
|
|
20659
21146
|
environments: { action: "string", grants: "array", requestcapability: "boolean", pool: "object", offscreenclose: "boolean", sandbox: "object", settings: "object", render: "object", sandboxhost: "object" },
|
|
20660
21147
|
transparency: {},
|
|
20661
21148
|
execute: { stepid: "string" },
|
|
@@ -20669,6 +21156,221 @@ function schemavalidation(message) {
|
|
|
20669
21156
|
if (schema === void 0) return [];
|
|
20670
21157
|
return schemacheck({ command, schema }).errors;
|
|
20671
21158
|
}
|
|
21159
|
+
async function sessionviewof() {
|
|
21160
|
+
const session = await memory.getsession();
|
|
21161
|
+
const plan = await memory.getplan();
|
|
21162
|
+
const settings = await memory.getsettings();
|
|
21163
|
+
const progress = await memory.getprogress();
|
|
21164
|
+
const notes = await memory.getsitenotes();
|
|
21165
|
+
const scratch = plan && session ? await memory.readscratchpad(plan.id, session.id) : [];
|
|
21166
|
+
const summaries = await memory.listrunsummaries();
|
|
21167
|
+
const corrections = await memory.getcorrections();
|
|
21168
|
+
const consentmemory = await memory.getconsentmemory();
|
|
21169
|
+
const index = await memory.getrecallindex();
|
|
21170
|
+
const scope = session ? [.../* @__PURE__ */ new Set([session.origin, ...session.grants ?? []])] : [];
|
|
21171
|
+
const recall = rankrecall(index, { text: plan?.objective ?? session?.origin ?? "" }, { origins: scope }).slice(0, 5);
|
|
21172
|
+
const errors = (await memory.geterrorsurfaces()).slice(0, 20);
|
|
21173
|
+
const rows = sessiongridrows({ ...session !== void 0 ? { session } : {}, ...plan !== void 0 ? { plan } : {}, ...progress !== void 0 ? { progress } : {}, logs: await memory.listimmutablelogs(), summaries, locks: await memory.getrunlocks(), tabsessions: await memory.listtabsessions() });
|
|
21174
|
+
return {
|
|
21175
|
+
grid: rows.map((row) => ({ sessionid: row.sessionid, runid: row.runid, origins: row.origins, state: row.state, outcome: row.outcome, steps: row.steps, completed: row.completed, lock: row.lock, ...row.tabid !== void 0 ? { tabid: row.tabid } : {}, ...row.sealhash !== void 0 ? { sealhash: row.sealhash } : {}, updatedat: row.updatedat, actions: row.actions })),
|
|
21176
|
+
notes: notes.map((note) => ({ id: note.id, origin: note.origin, title: note.title, body: notebodyof(note), author: note.author, sensitive: note.sensitive, updatedat: note.updatedat })),
|
|
21177
|
+
scratchpad: scratch.map((entry) => ({ id: entry.id, taskid: entry.taskid, text: entry.text, ...entry.stepid !== void 0 ? { stepid: entry.stepid } : {}, author: entry.author, at: entry.at })),
|
|
21178
|
+
summaries: summaries.map((summary) => ({ runid: summary.runid, origins: summary.origins, kinds: summary.kinds, steps: summary.steps.length, provenance: summary.provenance, distilledat: summary.distilledat })),
|
|
21179
|
+
corrections: corrections.slice(0, 20).map((entry) => ({ id: entry.id, origin: entry.origin, kind: entry.kind, stepid: entry.stepid, source: entry.source, reason: entry.reason, at: entry.at })),
|
|
21180
|
+
consentmemory: consentmemory.slice(0, 20).map((entry) => ({ id: entry.id, origin: entry.origin, decision: entry.decision, boundary: entry.boundary, kinds: entry.kinds, at: entry.at, ...entry.expiresat !== void 0 ? { expiresat: entry.expiresat } : {} })),
|
|
21181
|
+
recall: recall.map((match) => ({ origin: match.entry.origin, runid: match.entry.runid, stepid: match.entry.stepid, score: match.score, reason: match.reason })),
|
|
21182
|
+
errors: errors.map((surface) => ({ stepid: surface.stepid, runid: surface.runid, cause: surface.cause, message: surface.message, retry: surface.retry, at: surface.at })),
|
|
21183
|
+
emptystates: [
|
|
21184
|
+
{ surface: "sessiongrid", message: rows.length === 0 ? "No session exists yet; start the first run by describing an objective and reviewing the plan the agent proposes." : "" },
|
|
21185
|
+
{ surface: "historysearch", message: "No history matches yet; start with a first query such as an origin, a note title or a kind the runs executed." },
|
|
21186
|
+
{ surface: "sitenotes", message: notes.length === 0 ? `No site note exists${session ? ` for ${session.origin}` : ""} yet; write the first note with a title and a body and the note flow keeps it per origin with its author provenance.` : "" },
|
|
21187
|
+
{ surface: "scratchpad", message: scratch.length === 0 ? "The scratchpad holds no entry yet; the agent appends its per task notes here while the reviewed steps run, and every entry carries its step provenance." : "" }
|
|
21188
|
+
].filter((state) => state.message !== ""),
|
|
21189
|
+
...settings?.cancelrollback !== void 0 ? { cancelrollback: settings.cancelrollback } : {},
|
|
21190
|
+
historyindex: settings?.historyindex !== false
|
|
21191
|
+
};
|
|
21192
|
+
}
|
|
21193
|
+
async function handlesessionscommand(message) {
|
|
21194
|
+
const input = message;
|
|
21195
|
+
const now = Date.now();
|
|
21196
|
+
const session = await memory.getsession();
|
|
21197
|
+
const plan = await memory.getplan();
|
|
21198
|
+
const settings = await memory.getsettings();
|
|
21199
|
+
if (input.note !== void 0) {
|
|
21200
|
+
if (input.note.add !== void 0) {
|
|
21201
|
+
const origin = input.note.add.origin?.trim() || session?.origin || "";
|
|
21202
|
+
if (origin === "") throw new Error("The site note needs its origin.");
|
|
21203
|
+
const writegate = sitenoteswritegate({ consent: input.note.add.consent === true, origin });
|
|
21204
|
+
if (!writegate.allowed) throw new Error(writegate.reason);
|
|
21205
|
+
const note = sitenoteof({ origin, title: input.note.add.title ?? "", body: input.note.add.body ?? "", author: "user", ...input.note.add.sensitive === true ? { sensitive: true } : {}, now });
|
|
21206
|
+
await memory.writesitenote(note);
|
|
21207
|
+
if (settings?.historyindex !== false) await memory.addhistoryentry(notehistoryentry(note));
|
|
21208
|
+
await audit("notes", `The user wrote the site note ${note.id} for ${origin}${note.sensitive ? " with its body sealed at rest" : ""}; the note keeps its author provenance and its timestamps.`, { ...session ? { sessionid: session.id } : {} });
|
|
21209
|
+
return { ...await sessionviewof(), note };
|
|
21210
|
+
}
|
|
21211
|
+
if (input.note.edit !== void 0) {
|
|
21212
|
+
const id = input.note.edit.id?.trim() ?? "";
|
|
21213
|
+
const note = (await memory.getsitenotes()).find((candidate) => candidate.id === id);
|
|
21214
|
+
if (!note) throw new Error(`No site note ${id} exists to edit.`);
|
|
21215
|
+
const writegate = sitenoteswritegate({ consent: true, origin: note.origin });
|
|
21216
|
+
if (!writegate.allowed) throw new Error(writegate.reason);
|
|
21217
|
+
const edited = editnote(note, { title: input.note.edit.title ?? note.title, body: input.note.edit.body ?? notebodyof(note), author: "user", now });
|
|
21218
|
+
await memory.writesitenote(edited);
|
|
21219
|
+
if (settings?.historyindex !== false) await memory.addhistoryentry(notehistoryentry(edited));
|
|
21220
|
+
await audit("notes", `The user edited the site note ${edited.id} of ${edited.origin}; the edit keeps the created timestamp and names its author.`, { ...session ? { sessionid: session.id } : {} });
|
|
21221
|
+
return { ...await sessionviewof(), note: edited };
|
|
21222
|
+
}
|
|
21223
|
+
if (input.note.remove !== void 0) {
|
|
21224
|
+
const id = input.note.remove.id?.trim() ?? "";
|
|
21225
|
+
await memory.removesitenote(id);
|
|
21226
|
+
await audit("notes", `The user removed the site note ${id}.`, { ...session ? { sessionid: session.id } : {} });
|
|
21227
|
+
return { ...await sessionviewof(), removed: id };
|
|
21228
|
+
}
|
|
21229
|
+
if (input.note.list !== void 0) {
|
|
21230
|
+
const origin = input.note.list.origin?.trim() || session?.origin || "";
|
|
21231
|
+
if (origin === "") throw new Error("The site note read needs its origin.");
|
|
21232
|
+
const readgate = sitenotesreadgate({ origin, grants: session ? [.../* @__PURE__ */ new Set([session.origin, ...session.grants ?? []])] : [] });
|
|
21233
|
+
if (!readgate.allowed) throw new Error(readgate.reason);
|
|
21234
|
+
return { notes: (await memory.readsitenotes(origin)).map((note) => ({ id: note.id, origin: note.origin, title: note.title, body: notebodyof(note), author: note.author, sensitive: note.sensitive, updatedat: note.updatedat })) };
|
|
21235
|
+
}
|
|
21236
|
+
}
|
|
21237
|
+
if (input.scratch !== void 0) {
|
|
21238
|
+
if (!session || !plan) throw new Error("The scratchpad serves the running task of an active session.");
|
|
21239
|
+
const taskid = input.scratch.append?.taskid?.trim() || input.scratch.read?.taskid?.trim() || plan.id;
|
|
21240
|
+
const scopegate2 = scratchpadscopegate({ taskid, sessionid: session.id, entrytaskid: taskid, entrysessionid: session.id });
|
|
21241
|
+
if (!scopegate2.allowed) throw new Error(scopegate2.reason);
|
|
21242
|
+
if (input.scratch.append !== void 0) {
|
|
21243
|
+
const entry = scratchentryof({ taskid, sessionid: session.id, text: input.scratch.append.text ?? "", ...input.scratch.append.stepid !== void 0 && input.scratch.append.stepid.trim() !== "" ? { stepid: input.scratch.append.stepid } : {}, author: "user", now });
|
|
21244
|
+
await memory.appendscratchentry(entry);
|
|
21245
|
+
await audit("scratchpad", `The user appended one scratchpad entry to the task ${taskid}${entry.stepid !== void 0 ? ` beside the step ${entry.stepid}` : ""}; the pad stays append only.`, { sessionid: session.id, planid: taskid });
|
|
21246
|
+
return { ...await sessionviewof(), entry };
|
|
21247
|
+
}
|
|
21248
|
+
if (input.scratch.read !== void 0) return { scratchpad: await memory.readscratchpad(taskid, session.id) };
|
|
21249
|
+
}
|
|
21250
|
+
if (input.summary !== void 0) {
|
|
21251
|
+
if (input.summary.read !== void 0) {
|
|
21252
|
+
const runid = input.summary.read.runid?.trim() || plan?.id || "";
|
|
21253
|
+
const summary = await memory.getrunsummary(runid);
|
|
21254
|
+
if (!summary) throw new Error(`No run summary exists for the run ${runid}.`);
|
|
21255
|
+
return { summary };
|
|
21256
|
+
}
|
|
21257
|
+
if (input.summary.list !== void 0) return { summaries: await memory.listrunsummaries(input.summary.list.origin?.trim() || void 0) };
|
|
21258
|
+
}
|
|
21259
|
+
if (input.recall !== void 0 && input.recall.query !== void 0) {
|
|
21260
|
+
const text2 = input.recall.query.text?.trim() ?? "";
|
|
21261
|
+
if (text2 === "") throw new Error("The semantic recall query needs its text.");
|
|
21262
|
+
const scope = session ? [.../* @__PURE__ */ new Set([session.origin, ...session.grants ?? []])] : [];
|
|
21263
|
+
const scopegate2 = semanticrecallscopegate({ origin: input.recall.query.origin?.trim() || void 0, scope });
|
|
21264
|
+
if (!scopegate2.allowed) throw new Error(scopegate2.reason);
|
|
21265
|
+
const matches = await memory.semanticrecall({ text: text2, ...input.recall.query.origin !== void 0 && input.recall.query.origin.trim() !== "" ? { origin: input.recall.query.origin.trim() } : {}, ...input.recall.query.limit !== void 0 ? { limit: input.recall.query.limit } : {} }, { origins: scope }, rankrecall);
|
|
21266
|
+
await audit("recall", `The semantic recall ranked ${matches.length} past extraction${matches.length === 1 ? "" : "s"} by text similarity inside the ${scope.length} origin scope${scope.length === 1 ? "" : "s"} of the run; every match carries its run and step provenance.`, { ...session ? { sessionid: session.id } : {} });
|
|
21267
|
+
return { matches };
|
|
21268
|
+
}
|
|
21269
|
+
if (input.correction !== void 0 && input.correction.list !== void 0) {
|
|
21270
|
+
const readgate = memoryreadscopegate({ phase: plan && plan.state === "pending" ? "planning" : "prompting" });
|
|
21271
|
+
if (!readgate.allowed) throw new Error(readgate.reason);
|
|
21272
|
+
return { corrections: await memory.getcorrections({ ...input.correction.list.origin !== void 0 ? { origin: input.correction.list.origin } : {}, ...input.correction.list.kind !== void 0 ? { kind: input.correction.list.kind } : {} }) };
|
|
21273
|
+
}
|
|
21274
|
+
if (input.consent !== void 0 && input.consent.list !== void 0) {
|
|
21275
|
+
const readgate = memoryreadscopegate({ phase: "prompting" });
|
|
21276
|
+
if (!readgate.allowed) throw new Error(readgate.reason);
|
|
21277
|
+
const origin = input.consent.list.origin?.trim() || session?.origin || "";
|
|
21278
|
+
const entries = await memory.getconsentmemory(origin === "" ? void 0 : origin);
|
|
21279
|
+
const advisory = consentadvisoryverdict(entries, origin, "observe");
|
|
21280
|
+
return { entries, advisory: advisory.reason };
|
|
21281
|
+
}
|
|
21282
|
+
if (input.grid !== void 0) {
|
|
21283
|
+
if (input.grid.rows !== void 0) return { grid: (await sessionviewof()).grid };
|
|
21284
|
+
if (input.grid.open !== void 0) {
|
|
21285
|
+
const runid = input.grid.open.runid?.trim() ?? "";
|
|
21286
|
+
const view = await sessionviewof();
|
|
21287
|
+
const row = view.grid.find((candidate) => candidate.runid === runid);
|
|
21288
|
+
if (!row) throw new Error(`No session grid row exists for the run ${runid}.`);
|
|
21289
|
+
if (row.tabid !== void 0) await chrome.sidePanel.open({ tabId: row.tabid }).catch(() => {
|
|
21290
|
+
});
|
|
21291
|
+
await audit("session", `The user opened the session grid row of the run ${runid} from the interface deep link.`, { ...session ? { sessionid: session.id } : {}, planid: runid });
|
|
21292
|
+
return { opened: runid };
|
|
21293
|
+
}
|
|
21294
|
+
if (input.grid.resume !== void 0) {
|
|
21295
|
+
const runid = input.grid.resume.runid?.trim() ?? "";
|
|
21296
|
+
if (!session) throw new Error("The resume needs its active session.");
|
|
21297
|
+
if (session.pausedat === void 0) throw new Error("The session of the run stays active; nothing to resume.");
|
|
21298
|
+
const { pausedat, ...resumedsession } = session;
|
|
21299
|
+
void pausedat;
|
|
21300
|
+
await memory.setsession(resumedsession);
|
|
21301
|
+
await audit("resume", `The user resumed the paused session of the run ${runid} from the session grid.`, { sessionid: session.id, planid: runid });
|
|
21302
|
+
return { ...await sessionviewof(), resumed: runid };
|
|
21303
|
+
}
|
|
21304
|
+
if (input.grid.reopen !== void 0) {
|
|
21305
|
+
const runid = input.grid.reopen.runid?.trim() ?? "";
|
|
21306
|
+
const log = await memory.getimmutablelog(runid);
|
|
21307
|
+
if (!log) throw new Error(`No sealed run exists for the run ${runid}.`);
|
|
21308
|
+
const read = await readverifiedlog(log);
|
|
21309
|
+
if (!read.ok) throw new Error(read.reason);
|
|
21310
|
+
await audit("session", `The user reopened the sealed run ${runid} from the session grid; the chain verification passed and the log link stays intact.`, { ...session ? { sessionid: session.id } : {}, planid: runid });
|
|
21311
|
+
return { reopened: runid, entries: read.entries.length, ...log.seal !== void 0 ? { sealhash: log.seal.sealhash.current } : {} };
|
|
21312
|
+
}
|
|
21313
|
+
}
|
|
21314
|
+
if (input.search !== void 0 && input.search.query !== void 0) {
|
|
21315
|
+
if (settings?.historyindex === false) throw new Error("The historysearch index building stays off in the user preferences; the search box needs the index on.");
|
|
21316
|
+
const query = historyqueryof(input.search.query);
|
|
21317
|
+
if (!query) throw new Error("The history search needs its text with a coherent time range.");
|
|
21318
|
+
const hits = await memory.historysearch(query, historysearch);
|
|
21319
|
+
await audit("search", `The history search matched ${hits.length} entr${hits.length === 1 ? "y" : "ies"} of the corpus${query.origin !== void 0 ? ` for ${query.origin}` : ""}${query.outcome !== void 0 ? ` with the outcome ${query.outcome}` : ""}; every hit highlights its matched terms.`, { ...session ? { sessionid: session.id } : {} });
|
|
21320
|
+
return { hits };
|
|
21321
|
+
}
|
|
21322
|
+
if (input.cancel !== void 0) {
|
|
21323
|
+
const runid = input.cancel.runid?.trim() || plan?.id || "";
|
|
21324
|
+
if (runid === "") throw new Error("The cancelrun needs its run.");
|
|
21325
|
+
const progress = await memory.getprogress();
|
|
21326
|
+
const preference = input.cancel.rollback === "none" ? "none" : input.cancel.rollback === "queued" ? "queued" : settings?.cancelrollback;
|
|
21327
|
+
const action = cancelrunactionof({ runid, sessionid: session?.id ?? "", plan: plan && plan.id === runid ? plan : void 0, progress, preference });
|
|
21328
|
+
const split = rollbacksplit(plan && plan.id === runid ? plan : void 0, progress);
|
|
21329
|
+
const cancelgate = cancelrungate({ queuedstepids: action.rollback.queuedstepids, executedstepids: split.executedstepids, rollbackscope: action.rollback.scope });
|
|
21330
|
+
if (!cancelgate.allowed) throw new Error(cancelgate.reason);
|
|
21331
|
+
if (plan && plan.id === runid && ["pending", "approved"].includes(plan.state)) await memory.setplan({ ...plan, state: "cancelled" });
|
|
21332
|
+
if (session) await appendrunevent("cancel", `The user cancelled the run ${runid}: ${action.rollback.label}`, session, session.origin).catch(() => {
|
|
21333
|
+
});
|
|
21334
|
+
await audit("cancel", `The user cancelled the run ${runid}: ${action.rollback.label}`, { ...session ? { sessionid: session.id } : {}, planid: runid });
|
|
21335
|
+
return { ...await sessionviewof(), cancelled: action };
|
|
21336
|
+
}
|
|
21337
|
+
if (input.retry !== void 0) {
|
|
21338
|
+
const stepid = input.retry.stepid?.trim() ?? "";
|
|
21339
|
+
if (stepid === "") throw new Error("The retry needs its step.");
|
|
21340
|
+
const retrygate = retrydispatchgate({ reviewed: true, stepid });
|
|
21341
|
+
if (!retrygate.allowed) throw new Error(retrygate.reason);
|
|
21342
|
+
const output = await executestep(stepid);
|
|
21343
|
+
await audit("retry", `The user retried the step ${stepid} through a new reviewed dispatch: ${output.summary}`, { ...session ? { sessionid: session.id } : {}, ...plan ? { planid: plan.id } : {}, stepid });
|
|
21344
|
+
return output;
|
|
21345
|
+
}
|
|
21346
|
+
if (input.error !== void 0) return { errors: await memory.geterrorsurfaces(input.error.stepid?.trim() || void 0) };
|
|
21347
|
+
if (input.settings !== void 0) {
|
|
21348
|
+
const patch = { ...settings };
|
|
21349
|
+
for (const field of ["noteretention", "scratchpadretention", "summaryretention", "correctionretention", "recallwindow"]) {
|
|
21350
|
+
const value = input.settings[field];
|
|
21351
|
+
if (value === void 0) continue;
|
|
21352
|
+
const gate = sessionretentionvalid(value);
|
|
21353
|
+
if (!gate.allowed) throw new Error(gate.reason);
|
|
21354
|
+
patch[field] = value;
|
|
21355
|
+
}
|
|
21356
|
+
if (input.settings.summarywindow !== void 0) {
|
|
21357
|
+
const windowgate = summarywindowvalid(input.settings.summarywindow);
|
|
21358
|
+
if (!windowgate.allowed) throw new Error(windowgate.reason);
|
|
21359
|
+
patch.summarywindow = input.settings.summarywindow;
|
|
21360
|
+
}
|
|
21361
|
+
if (input.settings.historyindex !== void 0) patch.historyindex = input.settings.historyindex === true;
|
|
21362
|
+
if (input.settings.cancelrollback !== void 0) patch.cancelrollback = input.settings.cancelrollback === "none" ? "none" : "queued";
|
|
21363
|
+
await memory.setsettings(patch);
|
|
21364
|
+
await audit("configure", `The user updated the session interface preferences: notes retention ${patch.noteretention !== void 0 ? `${patch.noteretention} milliseconds` : "every note stays"}, scratchpad retention ${patch.scratchpadretention !== void 0 ? `${patch.scratchpadretention} milliseconds` : "every entry stays"}, summaries retention ${patch.summaryretention !== void 0 ? `${patch.summaryretention} milliseconds` : "every summary stays"}, corrections retention ${patch.correctionretention !== void 0 ? `${patch.correctionretention} milliseconds` : "every correction stays"}, recall window ${patch.recallwindow !== void 0 ? `${patch.recallwindow} milliseconds` : "the whole index"}, summary window ${patch.summarywindow !== void 0 ? `${patch.summarywindow} steps` : "no cap"}, historysearch index ${patch.historyindex !== false ? "on" : "off"} and cancelrun rollback ${patch.cancelrollback ?? "queued"}.`, {});
|
|
21365
|
+
return { ...await sessionviewof(), configured: true };
|
|
21366
|
+
}
|
|
21367
|
+
if (input.bundle !== void 0 && input.bundle.export === true) {
|
|
21368
|
+
const bundle = await memory.exportsessionbundle(now);
|
|
21369
|
+
await audit("export", `The user exported the session audit bundle: ${bundle.notes.length} note${bundle.notes.length === 1 ? "" : "s"}, ${bundle.summaries.length} run summar${bundle.summaries.length === 1 ? "y" : "ies"} and ${bundle.corrections.length} correction${bundle.corrections.length === 1 ? "" : "s"}; sensitive note bodies stay sealed in the export.`, { ...session ? { sessionid: session.id } : {} });
|
|
21370
|
+
return { bundle };
|
|
21371
|
+
}
|
|
21372
|
+
throw new Error("The sessions command carries no note, scratch, summary, recall, correction, consent, grid, search, cancel, retry, error, settings or bundle action.");
|
|
21373
|
+
}
|
|
20672
21374
|
async function handlerequest(message, sender) {
|
|
20673
21375
|
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() });
|
|
20674
21376
|
const inboundgate = origincheckgate({ verdict: originverdict });
|
|
@@ -20804,7 +21506,7 @@ async function handlerequest(message, sender) {
|
|
|
20804
21506
|
const livetab = session ? await chrome.tabs.get(session.tabid).catch(() => void 0) : void 0;
|
|
20805
21507
|
const waitprofile = session ? waitprofiles.find((record2) => record2.origin === session.origin) : void 0;
|
|
20806
21508
|
const livestate = { phase: livetab?.status === "loading" ? "loading" : "complete", ...navrecords[0] ? { finalurl: navrecords[0].finalurl, redirects: navrecords[0].chain } : {} };
|
|
20807
|
-
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() };
|
|
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 } : {} } };
|
|
20808
21510
|
}
|
|
20809
21511
|
case "capabilities":
|
|
20810
21512
|
return refreshcapabilities();
|
|
@@ -20833,7 +21535,12 @@ async function handlerequest(message, sender) {
|
|
|
20833
21535
|
const rejected = { ...plan, state: "rejected" };
|
|
20834
21536
|
await memory.setplan(rejected);
|
|
20835
21537
|
const current = await memory.getsession();
|
|
21538
|
+
for (const step of plan.steps) {
|
|
21539
|
+
await memory.addcorrection(rejectedcorrectionof({ origin: current?.origin ?? "", kind: step.kind, stepid: step.id, original: JSON.stringify({ kind: step.kind, target: step.target, value: step.value, summary: step.summary }), reason: "The user rejected the reviewed plan during plan review.", now: Date.now() })).catch(() => {
|
|
21540
|
+
});
|
|
21541
|
+
}
|
|
20836
21542
|
await audit("approval", "The user rejected the plan.", { ...current ? { sessionid: current.id } : {}, planid: rejected.id });
|
|
21543
|
+
await audit("correction", `The rejection captured ${plan.steps.length} correction entr${plan.steps.length === 1 ? "y" : "ies"} in the correction memory, one per rejected step with its rejection reason.`, { ...current ? { sessionid: current.id } : {}, planid: rejected.id });
|
|
20837
21544
|
return rejected;
|
|
20838
21545
|
}
|
|
20839
21546
|
case "preview":
|
|
@@ -23190,6 +23897,14 @@ async function handlerequest(message, sender) {
|
|
|
23190
23897
|
await memory.setplan(plan);
|
|
23191
23898
|
await memory.setprogress(resetforplan(await memory.getprogress(), plan, Date.now()));
|
|
23192
23899
|
await memory.setreplans(replans.map((candidate) => candidate.id === replan.id ? { ...candidate, state: "approved" } : candidate));
|
|
23900
|
+
const originaltail = draft.steps.filter((step) => !replan.completedstepids.includes(step.id));
|
|
23901
|
+
for (let index = 0; index < originaltail.length && index < replan.tail.length; index += 1) {
|
|
23902
|
+
const before = originaltail[index];
|
|
23903
|
+
const after = replan.tail[index];
|
|
23904
|
+
if (before === void 0 || after === void 0) continue;
|
|
23905
|
+
await memory.addcorrection(editedcorrectionof({ origin: session?.origin ?? "", kind: after.kind, stepid: after.id, original: JSON.stringify({ kind: before.kind, target: before.target, value: before.value, summary: before.summary }), corrected: JSON.stringify({ kind: after.kind, target: after.target, value: after.value, summary: after.summary }), reason: `The plan review replaced the failed tail step ${before.id} with the revised step ${after.id} of the replan ${replan.id}.`, now: Date.now() })).catch(() => {
|
|
23906
|
+
});
|
|
23907
|
+
}
|
|
23193
23908
|
await audit("model", `The user approved the fresh review of the replan ${replan.id}: ${completed.length} completed step${completed.length === 1 ? "" : "s"} stay and the ${replan.tail.length} revised step${replan.tail.length === 1 ? "" : "s"} became the changed tail of a pending plan that still passes the same plan review.`, { planid: plan.id, ...session ? { sessionid: session.id } : {} });
|
|
23194
23909
|
return llmstateof();
|
|
23195
23910
|
}
|
|
@@ -23861,6 +24576,8 @@ async function handlerequest(message, sender) {
|
|
|
23861
24576
|
await audit("transparency", `The transparencypage read its transparency report in one memory read: ${report.grants.length} grant row${report.grants.length === 1 ? "" : "s"} with revoke actions, ${report.windows.length} consent window${report.windows.length === 1 ? "" : "s"}, ${report.connectallow.length} connectallow entr${report.connectallow.length === 1 ? "y" : "ies"}, ${report.permdiffs.length} permdiff record${report.permdiffs.length === 1 ? "" : "s"} and ${report.vault.length} vault label${report.vault.length === 1 ? "" : "s"}.`, {});
|
|
23862
24577
|
return report;
|
|
23863
24578
|
}
|
|
24579
|
+
case "sessions":
|
|
24580
|
+
return handlesessionscommand(message);
|
|
23864
24581
|
case "security": {
|
|
23865
24582
|
const input2 = message;
|
|
23866
24583
|
const now = Date.now();
|
|
@@ -23891,6 +24608,8 @@ async function handlerequest(message, sender) {
|
|
|
23891
24608
|
const existing = profiles.find((candidate) => candidate.origin === origin);
|
|
23892
24609
|
const updated = profilekind({ profile: existing ?? originprofileof({ origin, now }), kind, decision, now });
|
|
23893
24610
|
await memory.saveoriginprofile(updated);
|
|
24611
|
+
if (decision === "deny") await memory.addconsentmemoryentry(consentmemoryof({ origin, decision: "deny", boundary: "the origin profile the user edits", kinds: [kind], now })).catch(() => {
|
|
24612
|
+
});
|
|
23894
24613
|
await audit("grant", `The origin profile of ${origin} now ${decision === "grant" ? "grants" : "denies"} the ${kind} kind the user reviewed; ${updated.grants.length} grant${updated.grants.length === 1 ? "" : "s"} and ${updated.denials.length} denial${updated.denials.length === 1 ? "" : "s"} on the origin.`, { ...session ? { sessionid: session.id } : {} });
|
|
23895
24614
|
return { ...await securityviewof(), profile: updated };
|
|
23896
24615
|
}
|
|
@@ -23905,6 +24624,8 @@ async function handlerequest(message, sender) {
|
|
|
23905
24624
|
const kinds = (input2.consent.open.kinds ?? []).map((kind) => kind.trim()).filter((kind) => kind !== "");
|
|
23906
24625
|
const window2 = openconsentwindow({ sessionid: session.id, origin, duration, kinds: kinds.length > 0 ? kinds : ["observe"], now });
|
|
23907
24626
|
await memory.setconsentwindows([window2, ...(await memory.getconsentwindows()).map((candidate) => candidate.sessionid === session.id && candidate.origin === origin && candidate.state === "active" ? { ...candidate, state: "closed", closedat: now } : candidate)]);
|
|
24627
|
+
await memory.addconsentmemoryentry(consentmemoryof({ origin, decision: "grant", boundary: window2.boundary, kinds: window2.kinds, expiresat: window2.expiresat, now })).catch(() => {
|
|
24628
|
+
});
|
|
23908
24629
|
await appendrunevent("grant", `The consent prompt opened the window ${window2.id} for ${origin} with the boundary ${window2.boundary}.`, session, origin).catch(() => {
|
|
23909
24630
|
});
|
|
23910
24631
|
await audit("grant", `The user answered the consent prompt for ${origin} with the window ${window2.id} and the boundary ${window2.boundary}; no grant ever outlives its named boundary.`, { sessionid: session.id });
|
|
@@ -23921,6 +24642,8 @@ async function handlerequest(message, sender) {
|
|
|
23921
24642
|
if (!durationgate.allowed) throw new Error(durationgate.reason);
|
|
23922
24643
|
const { renewed, closed } = renewconsentwindow({ window: current, duration, kinds: current.kinds, now });
|
|
23923
24644
|
await memory.setconsentwindows([renewed, closed, ...(await memory.getconsentwindows()).filter((candidate) => candidate.id !== windowid)]);
|
|
24645
|
+
await memory.addconsentmemoryentry(consentmemoryof({ origin: current.origin, decision: "grant", boundary: renewed.boundary, kinds: renewed.kinds, expiresat: renewed.expiresat, now })).catch(() => {
|
|
24646
|
+
});
|
|
23924
24647
|
await appendrunevent("grant", `The consent window of ${current.origin} renewed through a new explicit prompt with the boundary ${renewed.boundary}; the old window stays closed in the history.`, session, current.origin).catch(() => {
|
|
23925
24648
|
});
|
|
23926
24649
|
await audit("grant", `The user renewed the consent window of ${current.origin} through a new explicit prompt with the boundary ${renewed.boundary}.`, { sessionid: session.id });
|
|
@@ -23949,6 +24672,8 @@ async function handlerequest(message, sender) {
|
|
|
23949
24672
|
const queued = (plan2?.steps ?? []).map((step) => step.id).filter((id) => !completed.has(id));
|
|
23950
24673
|
const revocation = revokerun({ sessionid: session.id, runid, ...pendingstepid !== void 0 ? { pendingstepid } : {}, ...queued.length > 0 ? { queuedstepids: queued } : {}, actor: "user", ...input2.revoke.reason !== void 0 ? { reason: input2.revoke.reason } : {}, now });
|
|
23951
24674
|
await memory.addrevocation(revocation);
|
|
24675
|
+
await memory.addconsentmemoryentry(consentmemoryof({ origin: session.origin, decision: "revoke", boundary: "the mid run revocation of the user", kinds: ["observe"], now })).catch(() => {
|
|
24676
|
+
});
|
|
23952
24677
|
if (plan2 && plan2.id === runid && ["pending", "approved"].includes(plan2.state)) await memory.setplan({ ...plan2, state: "cancelled" });
|
|
23953
24678
|
if (plan2 && plan2.id === runid && pendingstepid !== void 0) await memory.setprogress(recordrevocation(progress, runid, pendingstepid, { haltedstepids: revocation.haltedstepids, revokedstepid: pendingstepid, reason: revocation.reason }, now));
|
|
23954
24679
|
await appendrunevent("revoke", `The user revoked the run ${runid}: the pending step ${pendingstepid ?? "none"} and every queued step halted without executing (${revocation.haltedstepids.join(", ")}).`, session, session.origin, pendingstepid).catch(() => {
|