agent-customs 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +341 -0
- package/README.md +592 -2
- package/bin/agent-customs.mjs +194 -0
- package/package.json +77 -4
- package/site/.well-known/agent-customs-key.json +13 -0
- package/site/certificate.js +944 -0
- package/site/customs/analyze.js +1224 -0
- package/site/customs/auto.js +83 -0
- package/site/customs/canary.js +270 -0
- package/site/customs/canonical.js +123 -0
- package/site/customs/capabilities.js +387 -0
- package/site/customs/diff.js +236 -0
- package/site/customs/english-words.js +153 -0
- package/site/customs/guard-notice.js +226 -0
- package/site/customs/guard-ui.js +105 -0
- package/site/customs/guard.js +259 -0
- package/site/customs/inspect.js +446 -0
- package/site/customs/judge.js +208 -0
- package/site/customs/languages.js +826 -0
- package/site/customs/locks.js +967 -0
- package/site/customs/pins.js +119 -0
- package/site/customs/protocols.js +621 -0
- package/site/customs/receipts.js +154 -0
- package/site/customs/rules.js +1470 -0
- package/site/customs/unicode.js +361 -0
- package/site/runtime/LICENSE.txt +176 -0
- package/site/runtime/generated/graph.gen.mjs +83 -0
- package/site/runtime/generated/validation.gen.mjs +70 -0
- package/site/runtime/hocon.js +262 -0
- package/site/runtime/kernel.js +237 -0
- package/site/runtime/model.js +44 -0
- package/tests/fixtures/official/NOTICE +3 -0
- package/tests/fixtures/official/guesthouse_agentified/agent-manifest.json +86 -0
- package/tests/fixtures/official/guesthouse_agentified/links.json +6 -0
- package/tests/fixtures/official/guesthouse_agentified/tidewhistle_guesthouse.network.json +56 -0
- package/tests/fixtures/official/harbor_tours_agentified/agent-manifest.json +86 -0
- package/tests/fixtures/official/harbor_tours_agentified/links.json +6 -0
- package/tests/fixtures/official/harbor_tours_agentified/marrow_point_harbor_tours.network.json +56 -0
- package/tests/fixtures/official/pizza_restaurant_agentified/agent-manifest.json +78 -0
- package/tests/fixtures/official/pizza_restaurant_agentified/links.json +6 -0
- package/tests/fixtures/official/pizza_restaurant_agentified/pizza_restaurant_website_assistant.network.json +156 -0
- package/tools/bench.mjs +731 -0
- package/tools/external-heldout.mjs +337 -0
- package/tools/fs-fetch.mjs +19 -0
- package/tools/heldout-corpus.mjs +135 -0
- package/tools/inspect-local.mjs +88 -0
- package/tools/round2-corpus.mjs +395 -0
- package/tools/round3-corpus.mjs +192 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// english-words.js: common English words, for telling English text from other languages.
|
|
2
|
+
//
|
|
3
|
+
// languages.js counts how many words of a sentence are English. Words are listed in their
|
|
4
|
+
// base form, and isEnglishWord also accepts the usual endings ("visitors", "booked",
|
|
5
|
+
// "warmly", "shopping"). The list includes the words agentic sites use most: shops, food,
|
|
6
|
+
// travel and the web.
|
|
7
|
+
|
|
8
|
+
const WORDS = `
|
|
9
|
+
a about above after again against ago all almost already also always am an and any are as at away back be because been
|
|
10
|
+
before being below between both but by can could did do does doing down during each either else even ever every few for
|
|
11
|
+
from further had has have having he her here hers herself him himself his how i if in into is it its itself just last
|
|
12
|
+
least less like many may maybe me might mine more most much must my myself neither never next no nor not now of off often
|
|
13
|
+
on once only or other our ours ourselves out over own perhaps please same shall she should since so some still such than
|
|
14
|
+
that the their theirs them themselves then there these they this those though through thus to too under until up upon us
|
|
15
|
+
very was we well were what whatever when whenever where wherever whether which while who whoever whole whom whose why will
|
|
16
|
+
with within without would yet you your yours yourself yourselves yes ok okay hello hi bye thanks thank sorry
|
|
17
|
+
|
|
18
|
+
accept act add admit advise afford agree aim allow answer appear apply arrange arrive ask attach attend avoid bake bear
|
|
19
|
+
beat become begin believe belong bend bet bite blow boil book borrow bother break bring browse build burn buy calculate
|
|
20
|
+
call cancel care carry catch cause change charge chat check choose clean clear click climb close collect combine come
|
|
21
|
+
compare complain complete confirm connect consider contact contain continue control convert cook copy correct cost count
|
|
22
|
+
cover create cross cut dance deal decide decline deliver depend describe deserve design destroy develop die dig discover
|
|
23
|
+
discuss display divide do download drag draw dream dress drink drive drop earn eat edit email enable encourage end enjoy
|
|
24
|
+
enter escape estimate examine exchange exist expect explain explore express extend fail fall feed feel fetch fight fill
|
|
25
|
+
find finish fit fix flow fly fold follow forget forgive form freeze fry gather get give go greet grill grow guarantee
|
|
26
|
+
guess guide handle hang happen hate have hear heat help hide hire hit hold hope host hurry identify ignore imagine improve
|
|
27
|
+
include increase inform inspect install intend introduce invite involve join judge jump keep kick kill knock know land last
|
|
28
|
+
laugh lay lead learn leave lend let lie lift like limit link list listen live load lock look lose love make manage mark
|
|
29
|
+
match matter mean measure meet melt mention mind miss mix move need note notice obtain occur offer open operate order
|
|
30
|
+
organise organize own pack paint park pass pay perform pick place plan play point post pour practise practice pray prefer
|
|
31
|
+
prepare present press prevent print process produce promise protect prove provide publish pull purchase push put quote
|
|
32
|
+
raise reach read realise realize receive recognise recognize recommend record reduce refer refund refuse register relax
|
|
33
|
+
release rely remain remember remind remove rent repair repeat replace reply report represent request require rescue
|
|
34
|
+
reserve reset respond rest restore return reveal review ride ring rise roast run rush save say scan search see seem select
|
|
35
|
+
sell send serve set settle shake shape share shine shop shout show shut sign sing sink sit skip sleep slide smell smile
|
|
36
|
+
solve sort sound speak spell spend spread stand start stay steal step stick stop store study submit succeed suffer suggest
|
|
37
|
+
suit supply support suppose surprise survive swim switch take talk taste teach tell tend test text thank think throw tick
|
|
38
|
+
tie touch tour track trade train translate travel treat trust try turn type understand unlock update upgrade upload urge
|
|
39
|
+
use validate value verify view visit vote wait wake walk want warn wash waste watch wear welcome win wish wonder work worry
|
|
40
|
+
wrap write
|
|
41
|
+
|
|
42
|
+
ability access account action activity actor address admin adult advantage advice afternoon age agency agent agreement
|
|
43
|
+
air airport alarm album amount anger animal answer apartment app appeal apple application appointment area argument arm
|
|
44
|
+
army arrival art article artist aspect assistant attack attempt attention audience author autumn average baby background
|
|
45
|
+
bag bakery balance ball band bank bar base basket bath bathroom battery beach bean bear beauty bed bedroom beef beer
|
|
46
|
+
beginning behaviour behavior benefit bike bill bird birth birthday biscuit bit blog blood board boat body bonus book
|
|
47
|
+
booking boot border bottle bottom bowl box boy brain branch brand bread breakfast brick bridge brother budget bug building
|
|
48
|
+
bus business butter button cafe cake calendar call camera camp campaign capital car card care career carpet case cash
|
|
49
|
+
castle cat category cause ceiling cell centre center century chain chair challenge champion chance change channel chapter
|
|
50
|
+
character charge chart chat cheese chef chicken child chocolate choice church cinema circle citizen city claim class
|
|
51
|
+
client climate clock clothes cloud club coach coast coat code coffee coin collection college colour color column comment
|
|
52
|
+
community company competition complaint computer concert condition conference connection contact content context contract
|
|
53
|
+
control conversation cookie copy corner cost cottage counter country county couple course court cousin cover cream credit
|
|
54
|
+
crime crowd cup currency curtain customer cycle dad damage danger data date daughter day deal death debt decision degree
|
|
55
|
+
delivery demand department deposit design desk dessert detail device diet difference dinner direction director discount
|
|
56
|
+
discussion dish disk distance doctor document dog dollar door double download dream dress drink driver drop duty ear earth
|
|
57
|
+
east economy edge education effect effort egg election element email employee end energy engine engineer entrance entry
|
|
58
|
+
environment equipment error event evening evidence exam example exchange exercise exit experience expert eye face fact
|
|
59
|
+
factory family fan farm father fault favour favor fear feature fee feedback feeling festival field figure file film filter
|
|
60
|
+
finger fire fish flat flight floor flour flower fly focus food foot football force forest form format forum frame freedom
|
|
61
|
+
friend front fruit fuel fun function future gallery game garage garden gas gate gift girl glass goal gold golf government
|
|
62
|
+
grade grain grass ground group growth guest guide guitar gym habit hair half hall hand head health heart heat height
|
|
63
|
+
help hero highway hill history hobby hole holiday home honey hope horse hospital host hotel hour house household human
|
|
64
|
+
husband ice idea image impact income industry information ingredient input insurance interest internet interview invoice
|
|
65
|
+
island issue item jacket job joke journey judge juice key keyboard kid kind king kitchen knife knowledge label lake land
|
|
66
|
+
language laptop law lawyer layer leader leaf lesson letter level library licence license life light limit line link lip
|
|
67
|
+
list loaf location lock login loss lot love lunch machine magazine mail manager map market marriage match material matter
|
|
68
|
+
meal meaning meat media medicine meeting member memory menu message metal method middle milk mind minute mirror mistake
|
|
69
|
+
mobile mode model moment money month mood morning mother motor mountain mouse mouth movie mum museum music name nation
|
|
70
|
+
nature neck network news newspaper night noise north nose note notice number nurse object ocean offer office officer oil
|
|
71
|
+
operation opinion option orange order organisation organization outcome output owner package page pain painting pair
|
|
72
|
+
pancake panel paper parent park part partner party passenger password past pasta path patient pattern payment peace pen
|
|
73
|
+
pencil people pepper percent period person pet phone photo phrase piano picture pie piece pilot pizza place plan plane
|
|
74
|
+
planet plant plastic plate platform player pocket poem point police policy pool pop population position post pot potato
|
|
75
|
+
pound power practice prayer preference presence president pressure price pride priest print priority prison privacy
|
|
76
|
+
prize problem process product profile profit program programme progress project promise property proposal protection pub
|
|
77
|
+
purpose quality quantity queen question queue race radio rain range rate reader reality reason receipt recipe record
|
|
78
|
+
region relation relationship release religion rent repair report request research reservation resource respect response
|
|
79
|
+
rest restaurant result review reward rice right ring risk river road rock role roof room rule safety salad salary sale
|
|
80
|
+
salt sample sandwich satisfaction sauce scale scene schedule school science score screen sea search season seat second
|
|
81
|
+
secret section security selection sense series service session setting shape share sheet shelf shirt shoe shop shopping
|
|
82
|
+
shot shoulder side sign signal silver singer sister site situation size skill skin sky sleep slice snack snow society sock
|
|
83
|
+
software soil soldier solution son song sort soul sound soup source south space speaker speech speed spirit sport spot
|
|
84
|
+
spring square staff stage stair standard star start state statement station status step stock stomach stone storage store
|
|
85
|
+
storm story strategy street strength stress structure student studio study style subject success sugar suggestion suit
|
|
86
|
+
summary summer sun supermarket supply support surface surprise survey sweet symbol system table tablet tag talent target
|
|
87
|
+
task taste tax tea teacher team technology teeth telephone television temperature tennis term test text theatre theater
|
|
88
|
+
theme theory thing thought ticket time tip title toast today toilet tomorrow tone tonight tool tooth top topic total tour
|
|
89
|
+
tourist town toy track trade traffic train training transport trip trouble truck truth turn type uncle union unit
|
|
90
|
+
university update user vacation valley value van variety vegetable vehicle version video view village visit visitor voice
|
|
91
|
+
volume wall war warning water wave way weakness weather web website wedding week weekend weight west wheel while wife
|
|
92
|
+
wind window wine wing winner winter woman wood word worker world writer year yesterday youth zone
|
|
93
|
+
|
|
94
|
+
able actual afraid alive alone amazing angry annual another available average awful bad basic beautiful best better big
|
|
95
|
+
bitter black blank blind blue bold bored boring bottom brave brief bright brilliant broad broken brown busy calm capable
|
|
96
|
+
careful central cheap chief chosen civil classic clean clear clever close cold comfortable common complete complex
|
|
97
|
+
confident considerable constant cool correct crazy creative critical crucial curious current cute daily dangerous dark
|
|
98
|
+
dead dear deep delicious dense different difficult digital direct dirty double dry due dull eager early easy eastern
|
|
99
|
+
economic effective electric electronic empty entire equal essential even evil exact excellent excited exciting expensive
|
|
100
|
+
expert extra extreme fair false familiar famous fancy fantastic far fast fat favourite favorite federal female few final
|
|
101
|
+
financial fine firm fit flat flexible foreign formal former free frequent fresh friendly front full funny general gentle
|
|
102
|
+
genuine giant glad global golden good gorgeous grand great green grey gray guilty half handy happy hard healthy heavy
|
|
103
|
+
helpful hidden high historic holy honest hot huge human hungry ideal ill illegal important impossible independent
|
|
104
|
+
individual initial inner innocent instant interesting internal international key kind large late latest lazy leading
|
|
105
|
+
legal light likely little live local lonely long loose loud lovely low lucky magic main major male manual many massive
|
|
106
|
+
medical medium mental middle mild military minor missing mobile modern modest moral narrow national native natural near
|
|
107
|
+
nearby neat necessary negative nervous new nice noble normal northern notable numerous obvious official old online only
|
|
108
|
+
open opposite optional ordinary organic original other outdoor outer overall own painful pale particular past perfect
|
|
109
|
+
personal physical plain pleasant plenty polite political poor popular positive possible powerful practical precious
|
|
110
|
+
premium present pretty previous primary prime prior private professional proper proud public pure quick quiet rapid rare
|
|
111
|
+
raw ready real recent red regional regular relevant remote responsible rich right rough round royal rude sad safe same
|
|
112
|
+
scared seasonal secret secure senior sensitive separate serious several severe sexy shallow sharp short shy sick significant
|
|
113
|
+
silent silly similar simple single slight slow small smart smooth social soft solid sorry southern spare special specific
|
|
114
|
+
spicy square stable standard steady sticky stiff straight strange strict strong stupid successful sudden sufficient
|
|
115
|
+
suitable super sure surprised sweet tall tasty technical temporary terrible thick thin tight tiny tired top total tough
|
|
116
|
+
traditional true typical ugly unable unique unknown unusual upper upset urgent useful usual valid valuable various vast
|
|
117
|
+
vegan vegetarian visible vital warm weak wealthy weekly weird welcome west western wet white whole wide wild willing
|
|
118
|
+
wise wonderful wooden working worried worse worst wrong young
|
|
119
|
+
|
|
120
|
+
one two three four five six seven eight nine ten eleven twelve twenty thirty forty fifty hundred thousand million first
|
|
121
|
+
second third fourth fifth once twice
|
|
122
|
+
|
|
123
|
+
ai api app assistant bot browser cart chatbot checkout cookie customs dashboard database developer domain email faq guard
|
|
124
|
+
html http https inbox inspect inspection json login logout manifest online prompt runtime script server signup sitemap
|
|
125
|
+
spec subscription token url username webpage website www github google wifi
|
|
126
|
+
bagel baguette barista bistro brownie burger cappuccino catering cheesecake cinnamon croissant cupcake donut doughnut
|
|
127
|
+
espresso fries gluten grocery latte muffin pastry pharmacy sourdough vanilla waffle tapas
|
|
128
|
+
puzzle maze loop quiz riddle trivia
|
|
129
|
+
pm etc eg ie vs mr mrs ms dr st nd rd th kg km cm mm ml min mins hr hrs sec secs
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
/** The common English words, in base form. */
|
|
133
|
+
export const ENGLISH_WORDS = new Set(WORDS.split(/\s+/).filter(Boolean));
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Whether a lower-case word is a common English word, allowing for the usual endings.
|
|
137
|
+
*
|
|
138
|
+
* :param word: One word in lower case.
|
|
139
|
+
* :return: True when the word or its base form is in the list.
|
|
140
|
+
*/
|
|
141
|
+
export function isEnglishWord(word) {
|
|
142
|
+
if (ENGLISH_WORDS.has(word)) return true;
|
|
143
|
+
const forms = [
|
|
144
|
+
word.replace(/'s$/, ""), word.replace(/s$/, ""), word.replace(/es$/, ""), word.replace(/ies$/, "y"),
|
|
145
|
+
word.replace(/ied$/, "y"), word.replace(/ed$/, ""), word.replace(/d$/, ""), word.replace(/ing$/, ""),
|
|
146
|
+
word.replace(/ing$/, "e"), word.replace(/ly$/, ""), word.replace(/ily$/, "y"), word.replace(/er$/, ""),
|
|
147
|
+
word.replace(/ers$/, ""), word.replace(/est$/, ""), word.replace(/ness$/, ""), word.replace(/ment$/, ""),
|
|
148
|
+
word.replace(/ful$/, ""), word.replace(/less$/, ""), word.replace(/al$/, ""),
|
|
149
|
+
// shopping, stopped, bigger: a doubled last consonant before the ending.
|
|
150
|
+
word.replace(/([bdgklmnprt])\1(?:ing|ed|er|est)$/, "$1"),
|
|
151
|
+
];
|
|
152
|
+
return forms.some((form) => form !== word && form.length > 1 && ENGLISH_WORDS.has(form));
|
|
153
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// guard-notice.js: what the visitor sees after the guard decides about a partner network.
|
|
2
|
+
// A notice goes into the chat, just after the partner's consent card, or into a corner of
|
|
3
|
+
// the page when the page has no runtime chat. It gives the decision, the full list of what
|
|
4
|
+
// Agent Customs found and a link to the full report.
|
|
5
|
+
//
|
|
6
|
+
// Self-contained (inline styles), so any site can use it without our stylesheet. Every word
|
|
7
|
+
// in the notice is Agent Customs' own: rule titles, verdicts and counts. Nothing written by
|
|
8
|
+
// the inspected network is shown, not even its decoded hidden text. So even a page tool that
|
|
9
|
+
// reads the whole page cannot hand that network's words to the AI. The full report shows
|
|
10
|
+
// them, on the Agent Customs page.
|
|
11
|
+
|
|
12
|
+
export const DEFAULT_REPORT_PAGE = "https://montbaga.github.io/agent-customs/";
|
|
13
|
+
|
|
14
|
+
const SEVERITY_ORDER = ["spec", "critical", "high", "medium", "low", "info"];
|
|
15
|
+
const TONE = { ok: "var(--ok, #8fd1a6)", caution: "var(--caution, #e9c46a)", warn: "var(--warn, #f0a35e)", bad: "var(--bad, #f2665a)" };
|
|
16
|
+
const SEVERITY = {
|
|
17
|
+
spec: { label: "Spec", color: TONE.bad }, critical: { label: "Critical", color: TONE.bad },
|
|
18
|
+
high: { label: "High", color: TONE.warn }, medium: { label: "Medium", color: TONE.caution },
|
|
19
|
+
low: { label: "Low", color: "#9aa6bd" }, info: { label: "Info", color: "#9aa6bd" },
|
|
20
|
+
};
|
|
21
|
+
const SHOWN = 6; // items shown before "Show more"
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The Agent Customs page that shows the full report, with the network's address filled in.
|
|
25
|
+
* The visitor still presses Inspect there, so nothing is contacted until they choose to.
|
|
26
|
+
*
|
|
27
|
+
* :param report: The guard's report.
|
|
28
|
+
* :param page: The Agent Customs page to open.
|
|
29
|
+
* :return: The link.
|
|
30
|
+
*/
|
|
31
|
+
export function reportLink(report, page = DEFAULT_REPORT_PAGE) {
|
|
32
|
+
const link = new URL(page);
|
|
33
|
+
link.searchParams.set("inspect", report.target.url);
|
|
34
|
+
return link.href;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* What the notice says, as plain data, for every decision the guard makes.
|
|
39
|
+
*
|
|
40
|
+
* :param report: The guard's report, with report.guard.decision set.
|
|
41
|
+
* :param options.reportPage: The page "See the full report" opens.
|
|
42
|
+
* :return: {tone, title, stamp, lines, items: [{severity, label, title, count}], link, url}
|
|
43
|
+
*/
|
|
44
|
+
export function noticeContent(report, { reportPage = DEFAULT_REPORT_PAGE } = {}) {
|
|
45
|
+
const decision = report.guard?.decision;
|
|
46
|
+
const who = `"${report.target.network}" from ${report.target.host}`;
|
|
47
|
+
const changed = Boolean(report.drift?.changed);
|
|
48
|
+
const pinned = Boolean(report.guard?.pinned);
|
|
49
|
+
let tone, title, lines;
|
|
50
|
+
if (decision === "refused") {
|
|
51
|
+
tone = "bad";
|
|
52
|
+
title = `Blocked ${who}`;
|
|
53
|
+
lines = [report.verdict.code === "INVALID"
|
|
54
|
+
? "Its files do not follow the Open Agentic Web spec, so it was refused before it could run. Nothing from it ran."
|
|
55
|
+
: "Agent Customs inspected it before it could run, and refused it. Nothing from it ran.",
|
|
56
|
+
"Your assistant was told why, in Agent Customs' own words."];
|
|
57
|
+
} else if (decision === "declined") {
|
|
58
|
+
tone = "warn";
|
|
59
|
+
title = `Turned away ${who}`;
|
|
60
|
+
lines = [changed
|
|
61
|
+
? "It changed since you approved it, and you chose not to let the new version run. Nothing from it ran."
|
|
62
|
+
: "It was held for review, and you chose not to let it run. Nothing from it ran."];
|
|
63
|
+
} else if (decision === "admitted after review") {
|
|
64
|
+
tone = "warn";
|
|
65
|
+
title = `Let in ${who}`;
|
|
66
|
+
lines = [changed
|
|
67
|
+
? "You let the changed version run after review. It is now the approved version in this browser."
|
|
68
|
+
: "You let it run after review. This version is now approved in this browser, and if it changes, you will be asked again."];
|
|
69
|
+
} else {
|
|
70
|
+
tone = report.verdict.code === "CLEARED" ? "ok" : "caution";
|
|
71
|
+
title = `Checked ${who}`;
|
|
72
|
+
lines = [report.drift && !changed
|
|
73
|
+
? "It matches the version approved in this browser, so it ran."
|
|
74
|
+
: pinned
|
|
75
|
+
? "It passed inspection, so it ran. This version is now approved in this browser, and if it changes, you will be asked first."
|
|
76
|
+
: "It passed inspection, so it ran."];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Every distinct finding, worst first, plus any spec check that failed.
|
|
80
|
+
const groups = new Map();
|
|
81
|
+
const add = (severity, text) => {
|
|
82
|
+
const key = `${severity}|${text}`;
|
|
83
|
+
const g = groups.get(key) || { severity, label: SEVERITY[severity]?.label || severity, title: text, count: 0 };
|
|
84
|
+
g.count += 1;
|
|
85
|
+
groups.set(key, g);
|
|
86
|
+
};
|
|
87
|
+
for (const c of report.conformance?.checks || []) if (c.status === "fail") add("spec", c.title);
|
|
88
|
+
for (const f of report.findings || []) add(f.severity, f.title);
|
|
89
|
+
const items = [...groups.values()].sort((a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity));
|
|
90
|
+
if (changed) lines.push(`${report.drift.changes.length} change(s) since you approved it: the full report lists each one.`);
|
|
91
|
+
|
|
92
|
+
return { tone, title, stamp: report.verdict.stamp, lines, items, link: reportLink(report, reportPage), url: report.target.url };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Show the notice for one decision.
|
|
97
|
+
*
|
|
98
|
+
* :param report: The guard's report.
|
|
99
|
+
* :param options.reportPage: The page "See the full report" opens in a new tab.
|
|
100
|
+
* :param options.openReport: (url) => void. Shows the full report on this page instead.
|
|
101
|
+
* :return: true once the notice is on the page.
|
|
102
|
+
*/
|
|
103
|
+
export function showGuardNotice(report, { reportPage, openReport } = {}) {
|
|
104
|
+
const c = noticeContent(report, { reportPage });
|
|
105
|
+
const tone = TONE[c.tone];
|
|
106
|
+
const ink = `color-mix(in oklab, ${tone} 72%, currentColor)`;
|
|
107
|
+
const box = el("section", "", `margin:10px 0;padding:12px 14px 12px 16px;border-radius:14px;border:1px solid color-mix(in oklab, ${tone} 45%, transparent);border-left:4px solid ${tone};background:color-mix(in oklab, ${tone} 9%, transparent);font-family:inherit;font-size:14px;line-height:1.5;max-width:680px;overflow-wrap:anywhere`);
|
|
108
|
+
box.className = "customs-notice";
|
|
109
|
+
box.dataset.decision = report.guard?.decision || "";
|
|
110
|
+
box.dataset.verdict = report.verdict.code;
|
|
111
|
+
box.setAttribute("role", "status");
|
|
112
|
+
box.setAttribute("aria-label", `Agent Customs: ${c.title}`);
|
|
113
|
+
|
|
114
|
+
const head = el("div", "", "display:flex;align-items:center;justify-content:space-between;gap:10px");
|
|
115
|
+
head.append(el("span", "Agent Customs", `font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:${ink}`),
|
|
116
|
+
el("span", c.stamp, `flex:none;font:700 11px/1 ui-monospace,"Geist Mono",Menlo,Consolas,monospace;letter-spacing:.08em;text-transform:uppercase;color:${ink};border:2px double ${tone};border-radius:6px;padding:4px 7px;transform:rotate(-3deg)`));
|
|
117
|
+
box.append(head, el("p", c.title, "margin:6px 0 4px;font-size:15px;font-weight:600"));
|
|
118
|
+
for (const line of c.lines) box.append(el("p", line, "margin:0 0 4px;opacity:.88"));
|
|
119
|
+
|
|
120
|
+
if (c.items.length) {
|
|
121
|
+
box.append(el("p", c.items.length === 1 ? "What Agent Customs found:" : `What Agent Customs found (${c.items.length}):`, "margin:10px 0 6px;font-weight:600;font-size:13px"));
|
|
122
|
+
const list = el("ul", "", "list-style:none;margin:0 0 4px;padding:0;display:grid;gap:5px");
|
|
123
|
+
const more = el("ul", "", "list-style:none;margin:6px 0 0;padding:0;display:grid;gap:5px");
|
|
124
|
+
c.items.forEach((item, i) => (i < SHOWN || c.items.length <= SHOWN + 1 ? list : more).append(itemRow(item)));
|
|
125
|
+
box.append(list);
|
|
126
|
+
if (more.children.length) {
|
|
127
|
+
const details = el("details", "", "margin:2px 0 0");
|
|
128
|
+
details.append(el("summary", `Show ${more.children.length} more`, "cursor:pointer;font-size:13px;opacity:.85"), more);
|
|
129
|
+
box.append(details);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const actions = el("div", "", "display:flex;flex-wrap:wrap;align-items:center;gap:6px 16px;margin-top:10px");
|
|
134
|
+
const link = el("a", "See the full report", `font-weight:600;color:inherit;text-decoration:underline;text-decoration-color:${tone};text-underline-offset:3px`);
|
|
135
|
+
link.href = c.link;
|
|
136
|
+
if (openReport) {
|
|
137
|
+
link.addEventListener("click", (event) => { event.preventDefault(); openReport(c.url); });
|
|
138
|
+
} else {
|
|
139
|
+
link.target = "_blank";
|
|
140
|
+
link.rel = "noopener noreferrer";
|
|
141
|
+
link.append(el("span", " (opens Agent Customs)", "font-weight:400;opacity:.75"));
|
|
142
|
+
}
|
|
143
|
+
actions.append(link);
|
|
144
|
+
box.append(actions);
|
|
145
|
+
|
|
146
|
+
place(box);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Show that a lock kept a secret back or blocked an unsafe runtime reply (locks.js).
|
|
152
|
+
*
|
|
153
|
+
* :param event: {lock, kind, where, reason} from the lock.
|
|
154
|
+
* :return: true once the notice is on the page.
|
|
155
|
+
*/
|
|
156
|
+
export function showLockNotice({ lock = 1, kind, where, reason = "" }) {
|
|
157
|
+
const tone = TONE.bad;
|
|
158
|
+
const ink = `color-mix(in oklab, ${tone} 72%, currentColor)`;
|
|
159
|
+
const box = el("section", "", `margin:10px 0;padding:12px 14px 12px 16px;border-radius:14px;border:1px solid color-mix(in oklab, ${tone} 45%, transparent);border-left:4px solid ${tone};background:color-mix(in oklab, ${tone} 9%, transparent);font-family:inherit;font-size:14px;line-height:1.5;max-width:680px;overflow-wrap:anywhere`);
|
|
160
|
+
box.className = "customs-notice";
|
|
161
|
+
box.dataset.lock = kind;
|
|
162
|
+
box.setAttribute("role", "status");
|
|
163
|
+
const isReplyBlock = lock === 2;
|
|
164
|
+
const isCanaryTrip = lock === 3;
|
|
165
|
+
box.setAttribute("aria-label", isCanaryTrip ? `Agent Customs tripped a ${kind}` : isReplyBlock ? `Agent Customs blocked an ${kind}` : `Agent Customs kept a ${kind} back`);
|
|
166
|
+
const head = el("div", "", "display:flex;align-items:center;justify-content:space-between;gap:10px");
|
|
167
|
+
head.append(el("span", "Agent Customs", `font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:${ink}`),
|
|
168
|
+
el("span", isCanaryTrip ? "Canary tripped" : isReplyBlock ? "Blocked" : "Kept safe", `flex:none;font:700 11px/1 ui-monospace,"Geist Mono",Menlo,Consolas,monospace;letter-spacing:.08em;text-transform:uppercase;color:${ink};border:2px double ${tone};border-radius:6px;padding:4px 7px;transform:rotate(-3deg)`));
|
|
169
|
+
const titleText = isCanaryTrip ? `Tripped ${kind} in ${where}` : isReplyBlock ? `Blocked ${kind} in ${where}` : `Kept a ${kind} out of ${where}`;
|
|
170
|
+
const detailText = isCanaryTrip
|
|
171
|
+
? `${reason ? `${reason}. ` : ""}Protected host context tried to leave its boundary, so execution stopped and involved partner approvals were removed.`
|
|
172
|
+
: isReplyBlock
|
|
173
|
+
? `${reason ? `${reason}. ` : ""}Nothing from that reply reached the assistant or the page.`
|
|
174
|
+
: "Card numbers, bank account numbers, keys and passwords never go to a partner's assistant, an outside tool or a website action a partner could have prompted. Nothing was sent.";
|
|
175
|
+
box.append(head, el("p", titleText, "margin:6px 0 4px;font-size:15px;font-weight:600"),
|
|
176
|
+
el("p", detailText, "margin:0 0 4px;opacity:.88"),
|
|
177
|
+
el("div", "", "display:flex;flex-wrap:wrap;gap:6px 16px;margin-top:4px"));
|
|
178
|
+
place(box);
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function itemRow(item) {
|
|
183
|
+
const sev = SEVERITY[item.severity] || SEVERITY.info;
|
|
184
|
+
const row = el("li", "", "display:flex;gap:8px;align-items:baseline");
|
|
185
|
+
row.append(el("span", sev.label, `flex:none;box-sizing:border-box;width:74px;text-align:center;font-size:10.5px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;padding:1px 6px;border-radius:999px;color:color-mix(in oklab, ${sev.color} 72%, currentColor);border:1px solid color-mix(in oklab, ${sev.color} 50%, transparent)`),
|
|
186
|
+
el("span", item.count > 1 ? `${item.title} (${item.count})` : item.title));
|
|
187
|
+
return row;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// In the runtime's chat, right after the consent card the visitor just answered for this
|
|
191
|
+
// partner. With no card in this turn (say, after "Always allow"), at the end of the chat.
|
|
192
|
+
// Without a chat, in a corner of the page.
|
|
193
|
+
function place(box) {
|
|
194
|
+
const msgs = document.querySelector("#ns-msgs");
|
|
195
|
+
if (msgs) {
|
|
196
|
+
const inChat = (node) => { while (node && node.parentElement !== msgs) node = node.parentElement; return node; };
|
|
197
|
+
const last = (selector) => { const all = msgs.querySelectorAll(selector); return inChat(all[all.length - 1]); };
|
|
198
|
+
const card = last(".ns-consent"), asked = last(".ns-msg.user");
|
|
199
|
+
const thisTurn = card && (!asked || (asked.compareDocumentPosition(card) & Node.DOCUMENT_POSITION_FOLLOWING));
|
|
200
|
+
if (thisTurn) card.after(box); else msgs.append(box);
|
|
201
|
+
msgs.scrollTop = msgs.scrollHeight;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
let corner = document.getElementById("customs-notices");
|
|
205
|
+
if (!corner) {
|
|
206
|
+
corner = el("div", "", "position:fixed;right:16px;bottom:16px;z-index:2147483000;width:min(440px,calc(100vw - 32px));max-height:calc(100vh - 32px);overflow:auto;display:grid;gap:10px");
|
|
207
|
+
corner.id = "customs-notices";
|
|
208
|
+
document.body.append(corner);
|
|
209
|
+
}
|
|
210
|
+
box.style.margin = "0";
|
|
211
|
+
box.style.background = "#10161f";
|
|
212
|
+
box.style.color = "#eef2f8";
|
|
213
|
+
box.style.boxShadow = "0 18px 50px rgba(0,0,0,.45)";
|
|
214
|
+
const close = el("button", "Close", "margin-left:auto;font:inherit;font-size:13px;padding:4px 10px;border-radius:8px;border:1px solid rgba(255,255,255,.25);background:transparent;color:inherit;cursor:pointer");
|
|
215
|
+
close.type = "button";
|
|
216
|
+
close.addEventListener("click", () => box.remove());
|
|
217
|
+
box.lastElementChild.append(close);
|
|
218
|
+
corner.append(box);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function el(tag, text, css) {
|
|
222
|
+
const node = document.createElement(tag);
|
|
223
|
+
if (text) node.textContent = text;
|
|
224
|
+
if (css) node.style.cssText = css;
|
|
225
|
+
return node;
|
|
226
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// guard-ui.js: the visitor's dialogs. One asks whether a network Agent Customs held may
|
|
2
|
+
// run; the other asks any yes-or-no question in the same style.
|
|
3
|
+
//
|
|
4
|
+
// Self-contained (inline styles), so any site can use it without our stylesheet.
|
|
5
|
+
// Everything from the inspected network is shown with textContent, never as HTML.
|
|
6
|
+
|
|
7
|
+
const SEVERITY_COLORS = { critical: "#ff5f6d", high: "#ff9a4d", medium: "#ffc65c", low: "#9aa6bd", info: "#9aa6bd" };
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Ask the visitor whether to let a held network run.
|
|
11
|
+
*
|
|
12
|
+
* :param report: The inspection report.
|
|
13
|
+
* :return: Promise<boolean>, true when the visitor lets it in.
|
|
14
|
+
*/
|
|
15
|
+
export function confirmEntryDialog(report) {
|
|
16
|
+
const body = el("div");
|
|
17
|
+
body.append(el("p", report.drift?.changed
|
|
18
|
+
? "It changed since you approved it. Review what is different before it runs on this page with your AI key."
|
|
19
|
+
: "Inspection found issues to review before it runs on this page with your AI key.", "margin:0 0 10px"));
|
|
20
|
+
const list = el("ul", "", "margin:0 0 10px;padding-left:18px");
|
|
21
|
+
for (const f of report.findings.filter((x) => ["critical", "high", "medium"].includes(x.severity)).slice(0, 6)) {
|
|
22
|
+
const li = el("li", "", "margin:0 0 6px");
|
|
23
|
+
const sev = el("strong", f.severity.toUpperCase() + " ", `color:${SEVERITY_COLORS[f.severity]};font-size:12px`);
|
|
24
|
+
li.append(sev, document.createTextNode(f.title));
|
|
25
|
+
if (f.detail) li.append(el("div", f.detail, "color:#8d99ad;font-size:13px"));
|
|
26
|
+
list.append(li);
|
|
27
|
+
}
|
|
28
|
+
body.append(list);
|
|
29
|
+
if (report.drift?.changed) {
|
|
30
|
+
const changes = el("details", "", "margin:0 0 8px");
|
|
31
|
+
changes.append(el("summary", `What changed (${report.drift.changes.length})`, "cursor:pointer;font-weight:600"));
|
|
32
|
+
for (const c of report.drift.changes.slice(0, 8)) {
|
|
33
|
+
const block = el("div", "", "margin:8px 0");
|
|
34
|
+
block.append(el("div", c.title, "font-weight:600;font-size:13px"));
|
|
35
|
+
for (const line of (c.added || []).slice(0, 6)) block.append(el("pre", "+ " + line, "margin:2px 0;white-space:pre-wrap;font-size:12px;background:rgba(61,220,151,.1);color:#7fefbf;padding:2px 6px;border-radius:4px"));
|
|
36
|
+
for (const line of (c.removed || []).slice(0, 4)) block.append(el("pre", "− " + line, "margin:2px 0;white-space:pre-wrap;font-size:12px;background:rgba(255,95,109,.1);color:#ff9aa3;padding:2px 6px;border-radius:4px"));
|
|
37
|
+
changes.append(block);
|
|
38
|
+
}
|
|
39
|
+
body.append(changes);
|
|
40
|
+
}
|
|
41
|
+
body.append(el("p", `Fingerprint ${report.identity.short}. Letting it in pins this version for this browser.`, "margin:8px 0 0;color:#8d99ad;font-size:12px"));
|
|
42
|
+
return askDialog({
|
|
43
|
+
kicker: "Agent Customs · secondary inspection",
|
|
44
|
+
title: `Let "${report.target.network}" from ${report.target.host} run?`,
|
|
45
|
+
body, yesLabel: "Let it in this time", noLabel: "Turn it away",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Ask the visitor a yes-or-no question in the same style.
|
|
51
|
+
*
|
|
52
|
+
* :param options.kicker: The small line above the title.
|
|
53
|
+
* :param options.title: The question.
|
|
54
|
+
* :param options.paragraphs: Lines of explanation.
|
|
55
|
+
* :param options.confirmLabel: The button that says yes.
|
|
56
|
+
* :param options.cancelLabel: The button that says no.
|
|
57
|
+
* :return: Promise<boolean>, true when the visitor says yes.
|
|
58
|
+
*/
|
|
59
|
+
export function confirmChoice({ kicker = "Agent Customs", title, paragraphs = [], confirmLabel = "Confirm", cancelLabel = "Cancel" }) {
|
|
60
|
+
const body = el("div");
|
|
61
|
+
for (const text of paragraphs) body.append(el("p", text, "margin:0 0 10px"));
|
|
62
|
+
return askDialog({ kicker, title, body, yesLabel: confirmLabel, noLabel: cancelLabel });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// The dialog both questions use. The safe answer is the filled button, and closing the
|
|
66
|
+
// dialog or pressing Escape also counts as no.
|
|
67
|
+
let dialogCount = 0;
|
|
68
|
+
function askDialog({ kicker, title, body, yesLabel, noLabel }) {
|
|
69
|
+
return new Promise((resolve) => {
|
|
70
|
+
const titleId = `customs-dialog-title-${++dialogCount}`;
|
|
71
|
+
const dialog = document.createElement("dialog");
|
|
72
|
+
dialog.className = "customs-review";
|
|
73
|
+
dialog.setAttribute("aria-labelledby", titleId);
|
|
74
|
+
dialog.style.cssText = "max-width:560px;width:calc(100% - 32px);border:1px solid rgba(255,255,255,.14);border-radius:18px;padding:0;color:var(--c2,#eef2f8);background:color-mix(in oklab,var(--c1,#0d1422) 94%,var(--c2,#fff));box-shadow:0 30px 80px rgba(0,0,0,.6);font:15px/1.5 Geist,system-ui,-apple-system,Segoe UI,Roboto,sans-serif";
|
|
75
|
+
const head = el("div", "", "padding:20px 22px 14px;border-bottom:1px solid rgba(255,255,255,.1)");
|
|
76
|
+
const heading = el("h2", title, "margin:0;font-size:19px;line-height:1.3");
|
|
77
|
+
heading.id = titleId;
|
|
78
|
+
heading.tabIndex = -1;
|
|
79
|
+
head.append(el("p", kicker, "margin:0 0 4px;font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:var(--c3,#ffb84d);font-weight:700"), heading);
|
|
80
|
+
body.style.cssText = "padding:14px 22px;max-height:52vh;overflow:auto";
|
|
81
|
+
const foot = el("div", "", "display:flex;gap:10px;justify-content:flex-end;padding:14px 22px 18px;border-top:1px solid rgba(255,255,255,.1);flex-wrap:wrap");
|
|
82
|
+
const no = el("button", noLabel, "font:inherit;font-weight:600;padding:10px 16px;border-radius:10px;border:0;background:var(--c3,#eef2f8);color:var(--on-c3,#061019);cursor:pointer");
|
|
83
|
+
const yes = el("button", yesLabel, "font:inherit;padding:10px 16px;border-radius:10px;border:1px solid rgba(255,255,255,.2);background:transparent;color:#eef2f8;cursor:pointer");
|
|
84
|
+
no.type = "button";
|
|
85
|
+
yes.type = "button";
|
|
86
|
+
no.addEventListener("click", () => dialog.close("no"));
|
|
87
|
+
yes.addEventListener("click", () => dialog.close("yes"));
|
|
88
|
+
foot.append(yes, no);
|
|
89
|
+
dialog.append(head, body, foot);
|
|
90
|
+
dialog.addEventListener("close", () => {
|
|
91
|
+
dialog.remove();
|
|
92
|
+
resolve(dialog.returnValue === "yes");
|
|
93
|
+
});
|
|
94
|
+
document.body.append(dialog);
|
|
95
|
+
dialog.showModal();
|
|
96
|
+
heading.focus();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function el(tag, text, css) {
|
|
101
|
+
const node = document.createElement(tag);
|
|
102
|
+
if (text) node.textContent = text;
|
|
103
|
+
if (css) node.style.cssText = css;
|
|
104
|
+
return node;
|
|
105
|
+
}
|