site-agent-pro 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +689 -0
- package/dist/auth/credentialStore.js +62 -0
- package/dist/auth/inbox.js +193 -0
- package/dist/auth/profile.js +379 -0
- package/dist/auth/runner.js +1124 -0
- package/dist/backend/dashboardData.js +194 -0
- package/dist/backend/runArtifacts.js +48 -0
- package/dist/backend/runRepository.js +93 -0
- package/dist/bin.js +2 -0
- package/dist/cli/backfillSiteChecks.js +143 -0
- package/dist/cli/run.js +309 -0
- package/dist/cli/trade.js +69 -0
- package/dist/config.js +199 -0
- package/dist/core/agentProfiles.js +55 -0
- package/dist/core/aggregateReport.js +382 -0
- package/dist/core/audit.js +30 -0
- package/dist/core/customTaskSuite.js +148 -0
- package/dist/core/evaluator.js +217 -0
- package/dist/core/executor.js +788 -0
- package/dist/core/fallbackReport.js +335 -0
- package/dist/core/formHeuristics.js +411 -0
- package/dist/core/gameplaySummary.js +164 -0
- package/dist/core/interaction.js +202 -0
- package/dist/core/pageState.js +201 -0
- package/dist/core/planner.js +1669 -0
- package/dist/core/processSubmissionBatch.js +204 -0
- package/dist/core/runAuditJob.js +170 -0
- package/dist/core/runner.js +2352 -0
- package/dist/core/siteBrief.js +107 -0
- package/dist/core/siteChecks.js +1526 -0
- package/dist/core/taskDirectives.js +279 -0
- package/dist/core/taskHeuristics.js +263 -0
- package/dist/dashboard/client.js +1256 -0
- package/dist/dashboard/contracts.js +95 -0
- package/dist/dashboard/narrative.js +277 -0
- package/dist/dashboard/server.js +458 -0
- package/dist/dashboard/theme.js +888 -0
- package/dist/index.js +84 -0
- package/dist/llm/client.js +188 -0
- package/dist/paystack/account.js +123 -0
- package/dist/paystack/client.js +100 -0
- package/dist/paystack/index.js +13 -0
- package/dist/paystack/test-paystack.js +83 -0
- package/dist/paystack/transfer.js +138 -0
- package/dist/paystack/types.js +74 -0
- package/dist/paystack/webhook.js +121 -0
- package/dist/prompts/browserAgent.js +124 -0
- package/dist/prompts/reviewer.js +71 -0
- package/dist/reporting/clickReplay.js +290 -0
- package/dist/reporting/html.js +930 -0
- package/dist/reporting/markdown.js +238 -0
- package/dist/reporting/template.js +1141 -0
- package/dist/schemas/types.js +361 -0
- package/dist/submissions/customTasks.js +196 -0
- package/dist/submissions/html.js +770 -0
- package/dist/submissions/model.js +56 -0
- package/dist/submissions/publicUrl.js +76 -0
- package/dist/submissions/service.js +74 -0
- package/dist/submissions/store.js +37 -0
- package/dist/submissions/types.js +65 -0
- package/dist/trade/engine.js +241 -0
- package/dist/trade/evm/erc20.js +44 -0
- package/dist/trade/extractor.js +148 -0
- package/dist/trade/policy.js +35 -0
- package/dist/trade/session.js +31 -0
- package/dist/trade/types.js +107 -0
- package/dist/trade/validator.js +148 -0
- package/dist/utils/files.js +59 -0
- package/dist/utils/log.js +24 -0
- package/dist/utils/playwrightCompat.js +14 -0
- package/dist/utils/time.js +3 -0
- package/dist/wallet/provider.js +345 -0
- package/dist/wallet/relay.js +129 -0
- package/dist/wallet/wallet.js +178 -0
- package/docs/01-installation.md +134 -0
- package/docs/02-running-your-first-audit.md +136 -0
- package/docs/03-configuration.md +233 -0
- package/docs/04-how-the-agent-thinks.md +41 -0
- package/docs/05-extending-personas-and-tasks.md +42 -0
- package/docs/06-hardening-for-production.md +92 -0
- package/package.json +60 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { generateStructured } from "../llm/client.js";
|
|
3
|
+
import { SiteBriefSchema } from "../schemas/types.js";
|
|
4
|
+
const SITE_BRIEF_TIMEOUT_MS = 15000;
|
|
5
|
+
const SITE_BRIEF_MAX_RETRIES = 1;
|
|
6
|
+
const SITE_BRIEF_PROMPT = `You are a product-understanding analyst for live websites.
|
|
7
|
+
|
|
8
|
+
Use only the visible homepage or landing-page evidence provided.
|
|
9
|
+
Do not invent facts.
|
|
10
|
+
Infer what the site appears to be for, what a normal visitor is mainly meant to do on it, and the most obvious visible actions on the page.
|
|
11
|
+
Keep the result plain, practical, and grounded in visible text, headings, and visible controls.
|
|
12
|
+
Do not turn this into a critique.
|
|
13
|
+
Do not add tasks that were not visible on the page.
|
|
14
|
+
|
|
15
|
+
Return strict JSON with this exact shape:
|
|
16
|
+
{
|
|
17
|
+
"sitePurpose": "1-2 sentence plain-English description of what the site appears to do",
|
|
18
|
+
"intendedUserActions": ["short phrases for the most obvious things a visitor seems meant to do here"],
|
|
19
|
+
"summary": "1-2 sentence human explanation of what this site seems built for and what a visitor is visibly guided to do first",
|
|
20
|
+
"evidence": ["short visible clues such as headings, CTA labels, or page copy that support the inference"]
|
|
21
|
+
}`;
|
|
22
|
+
const SiteBriefInputSchema = z.object({
|
|
23
|
+
pageState: z.object({
|
|
24
|
+
title: z.string(),
|
|
25
|
+
url: z.string(),
|
|
26
|
+
visibleText: z.string(),
|
|
27
|
+
headings: z.array(z.string()),
|
|
28
|
+
interactive: z.array(z.object({
|
|
29
|
+
role: z.string(),
|
|
30
|
+
tag: z.string(),
|
|
31
|
+
text: z.string(),
|
|
32
|
+
disabled: z.boolean()
|
|
33
|
+
}))
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
function normalizeText(value) {
|
|
37
|
+
return value.replace(/\s+/g, " ").trim();
|
|
38
|
+
}
|
|
39
|
+
function uniqueItems(items, limit) {
|
|
40
|
+
return [...new Set(items.map((item) => normalizeText(item)).filter(Boolean))].slice(0, limit);
|
|
41
|
+
}
|
|
42
|
+
function cleanErrorMessage(error) {
|
|
43
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
44
|
+
return message.replace(/\u001b\[[0-9;]*m/g, "").replace(/\s+/g, " ").trim() || "Unknown site-brief error";
|
|
45
|
+
}
|
|
46
|
+
function buildFallbackSiteBrief(pageState) {
|
|
47
|
+
const primaryHeading = pageState.headings[0] || pageState.title || pageState.url;
|
|
48
|
+
const actionLabels = uniqueItems(pageState.interactive
|
|
49
|
+
.map((item) => item.text || "")
|
|
50
|
+
.map((item) => normalizeText(item))
|
|
51
|
+
.filter((item) => item.length >= 3 && item.length <= 80), 5);
|
|
52
|
+
const evidence = uniqueItems([
|
|
53
|
+
primaryHeading,
|
|
54
|
+
...pageState.headings.slice(0, 3),
|
|
55
|
+
...actionLabels.slice(0, 3),
|
|
56
|
+
pageState.visibleText.slice(0, 180)
|
|
57
|
+
], 5);
|
|
58
|
+
return SiteBriefSchema.parse({
|
|
59
|
+
sitePurpose: primaryHeading
|
|
60
|
+
? `This site appears to center on "${primaryHeading}" and guide visitors toward the main visible actions on the landing page.`
|
|
61
|
+
: "This site appears to introduce a product or service and guide visitors toward its main visible actions.",
|
|
62
|
+
intendedUserActions: actionLabels.length > 0
|
|
63
|
+
? actionLabels.map((label) => `Use "${label}"`)
|
|
64
|
+
: ["Understand the offering from the landing page", "Follow the main visible CTA"],
|
|
65
|
+
summary: actionLabels.length > 0
|
|
66
|
+
? `The landing page appears to explain "${primaryHeading}" and push visitors toward actions like ${actionLabels
|
|
67
|
+
.slice(0, 3)
|
|
68
|
+
.map((label) => `"${label}"`)
|
|
69
|
+
.join(", ")}.`
|
|
70
|
+
: `The landing page appears to explain "${primaryHeading}" and steer visitors through its primary visible path.`,
|
|
71
|
+
evidence
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export async function deriveSiteBrief(args) {
|
|
75
|
+
const payload = SiteBriefInputSchema.parse({
|
|
76
|
+
pageState: {
|
|
77
|
+
title: args.pageState.title,
|
|
78
|
+
url: args.pageState.url,
|
|
79
|
+
visibleText: args.pageState.visibleText,
|
|
80
|
+
headings: args.pageState.headings,
|
|
81
|
+
interactive: args.pageState.interactive.map((item) => ({
|
|
82
|
+
role: item.role,
|
|
83
|
+
tag: item.tag,
|
|
84
|
+
text: item.text,
|
|
85
|
+
disabled: item.disabled
|
|
86
|
+
}))
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
try {
|
|
90
|
+
const siteBrief = await generateStructured({
|
|
91
|
+
...(args.llm ?? {}),
|
|
92
|
+
systemPrompt: SITE_BRIEF_PROMPT,
|
|
93
|
+
userPayload: payload,
|
|
94
|
+
schemaName: "site_brief",
|
|
95
|
+
schema: SiteBriefSchema,
|
|
96
|
+
timeoutMs: SITE_BRIEF_TIMEOUT_MS,
|
|
97
|
+
maxRetries: SITE_BRIEF_MAX_RETRIES
|
|
98
|
+
});
|
|
99
|
+
return { siteBrief: SiteBriefSchema.parse(siteBrief) };
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
return {
|
|
103
|
+
siteBrief: buildFallbackSiteBrief(args.pageState),
|
|
104
|
+
fallbackReason: cleanErrorMessage(error)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|