veycraft 0.0.0-stage → 2.8.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/.agent/workflows/apply-url.md +8 -0
- package/.agent/workflows/build-portfolio.md +7 -0
- package/.agent/workflows/daily-run.md +7 -0
- package/.agent/workflows/demo.md +23 -0
- package/.agent/workflows/freelance-bid.md +7 -0
- package/.agent/workflows/freelance-service.md +7 -0
- package/.agent/workflows/github-audit.md +7 -0
- package/.agent/workflows/github-remote.md +7 -0
- package/.agent/workflows/linkedin-growth.md +7 -0
- package/.agent/workflows/portfolio-design.md +7 -0
- package/.agent/workflows/profile-update.md +8 -0
- package/.agent/workflows/quick-tailor.md +20 -0
- package/.agent/workflows/setup.md +8 -0
- package/.agent/workflows/tailor-cv.md +8 -0
- package/.agent/workflows/weekly-report.md +7 -0
- package/.agents/skills/apply-url/SKILL.md +10 -0
- package/.agents/skills/contract-and-nda-auditor/SKILL.md +9 -0
- package/.agents/skills/daily-run/SKILL.md +10 -0
- package/.agents/skills/demo/SKILL.md +10 -0
- package/.agents/skills/freelance-offer-radar-and-batch-bidder/SKILL.md +10 -0
- package/.agents/skills/freelance-profile-and-service-publisher/SKILL.md +10 -0
- package/.agents/skills/github-cli-remote-manager/SKILL.md +10 -0
- package/.agents/skills/linkedin-growth/SKILL.md +10 -0
- package/.agents/skills/offer-negotiator/SKILL.md +9 -0
- package/.agents/skills/profile-intelligence-engine/SKILL.md +10 -0
- package/.agents/skills/quick-tailor/SKILL.md +10 -0
- package/.agents/skills/recruiter-inbox-triage/SKILL.md +9 -0
- package/.agents/skills/rejection-pattern-analyzer/SKILL.md +9 -0
- package/.agents/skills/score-calibration/SKILL.md +9 -0
- package/.agents/skills/setup/SKILL.md +10 -0
- package/.agents/skills/tailor-cv/SKILL.md +10 -0
- package/.agents/skills/weekly-report/SKILL.md +10 -0
- package/.aiassistant/rules/AGENTS.md +11 -0
- package/.aider.conf.yml +5 -0
- package/.amazonq/rules/job-hunter.md +12 -0
- package/.augment/rules/job-hunter.md +17 -0
- package/.clinerules +14 -0
- package/.continue/rules/job-hunter.md +15 -0
- package/.cursor/rules/job-hunter.mdc +9 -0
- package/.github/CODEOWNERS +3 -0
- package/.github/copilot-instructions.md +5 -0
- package/.github/prompts/daily-run.prompt.md +10 -0
- package/.goosehints +12 -0
- package/.junie/guidelines.md +12 -0
- package/.kiro/steering/job-hunter.md +15 -0
- package/.openhands/microagents/repo.md +18 -0
- package/.roo/rules/job-hunter.md +12 -0
- package/.rules +12 -0
- package/.trae/rules/project_rules.md +10 -0
- package/.windsurfrules +14 -0
- package/AGENTS.md +126 -0
- package/AUTHORS.md +13 -0
- package/CHANGELOG.md +309 -0
- package/CLAUDE.md +22 -0
- package/CRUSH.md +12 -0
- package/GEMINI.md +42 -0
- package/HIRED.md +32 -0
- package/LICENSE +26 -0
- package/NOTICE +22 -0
- package/PLATFORMS.md +93 -0
- package/PROVENANCE.json +19 -0
- package/README.ar.md +238 -0
- package/README.md +208 -3
- package/WARP.md +12 -0
- package/adapters/apps/chatgpt-and-web-chats.md +18 -0
- package/adapters/apps/devin-desktop.md +13 -0
- package/adapters/apps/gemini-and-copilot.md +25 -0
- package/adapters/apps/hermes-pi-factory-openclaw.md +24 -0
- package/adapters/apps/openai-codex-cli.md +23 -0
- package/adapters/apps/opencode-and-kilocode.md +16 -0
- package/adapters/apps/qwen-mistral-kimi-deepseek.md +37 -0
- package/adapters/models/claude.md +28 -0
- package/adapters/models/deepseek-qwen-local.md +24 -0
- package/adapters/models/gemini.md +16 -0
- package/adapters/models/grok-and-kimi.md +14 -0
- package/adapters/models/mistral-and-llama.md +13 -0
- package/adapters/models/openai.md +16 -0
- package/bin/browser-payloads.mjs +507 -0
- package/bin/career-intelligence.mjs +8090 -0
- package/bin/cli.mjs +2032 -0
- package/bin/core-ops.mjs +1855 -0
- package/bin/fast-ops.mjs +1392 -0
- package/bin/fs-safety.mjs +1091 -0
- package/bin/mcp-server.mjs +787 -0
- package/bin/notion-sync.mjs +4625 -0
- package/bin/profile-intelligence.mjs +690 -0
- package/bin/ui-server.mjs +948 -0
- package/commands/apply-url.md +2 -0
- package/commands/build-portfolio.md +2 -0
- package/commands/daily-run.md +2 -0
- package/commands/demo.md +2 -0
- package/commands/freelance-bid.md +2 -0
- package/commands/freelance-service.md +2 -0
- package/commands/github-audit.md +2 -0
- package/commands/github-remote.md +2 -0
- package/commands/linkedin-growth.md +2 -0
- package/commands/portfolio-design.md +2 -0
- package/commands/profile-update.md +1 -0
- package/commands/quick-tailor.md +2 -0
- package/commands/setup.md +2 -0
- package/commands/tailor-cv.md +2 -0
- package/commands/weekly-report.md +2 -0
- package/config/guardrails.yaml +67 -0
- package/config/invariants.txt +7 -0
- package/context/DROP_YOUR_FILES_HERE.md +9 -0
- package/context/cv.md.example +12 -0
- package/context/feeds.yaml.example +27 -0
- package/context/form-answers.yaml.example +45 -0
- package/context/preferences.yaml.example +15 -0
- package/context/profile.md.example +20 -0
- package/context/readiness-state.json.example +64 -0
- package/context/resume-data.json.example +29 -0
- package/context/resume-facts.json.example +1 -0
- package/context/targets.yaml.example +433 -0
- package/docs/ARCHITECTURE.md +106 -0
- package/docs/COMPATIBILITY.md +92 -0
- package/docs/OPTIONAL_MCP_PLUGINS.md +49 -0
- package/docs/SKILL_CATALOG.md +73 -0
- package/docs/chat-commands.md +33 -0
- package/docs/demo-dashboard.html +646 -0
- package/docs/execution-safety.md +34 -0
- package/docs/index.html +634 -0
- package/docs/platform-registry.md +23 -0
- package/docs/repository-audit.md +12 -0
- package/evals/PROMPT.md +31 -0
- package/evals/README.md +36 -0
- package/evals/RUBRIC.md +51 -0
- package/evals/approval-gate.test.mjs +432 -0
- package/evals/career-intelligence.test.mjs +4647 -0
- package/evals/fast-ops.test.mjs +614 -0
- package/evals/fixtures/boards/bayt-mock.html +255 -0
- package/evals/fixtures/boards/gulftalent-mock.html +250 -0
- package/evals/fixtures/boards/naukri-mock.html +262 -0
- package/evals/fixtures/boards/stepstone-mock.html +245 -0
- package/evals/fixtures/candidate-profile.md +40 -0
- package/evals/fixtures/forms/ashby-mock.html +41 -0
- package/evals/fixtures/forms/greenhouse-mock.html +77 -0
- package/evals/fixtures/forms/lever-mock.html +46 -0
- package/evals/fixtures/forms/workday-mock.html +328 -0
- package/evals/fixtures/ground-truth.json +53 -0
- package/evals/fixtures/jds/01-strong-match.md +22 -0
- package/evals/fixtures/jds/02-prompt-injection-trap.md +23 -0
- package/evals/fixtures/jds/03-ghost-expired-job.md +14 -0
- package/evals/fixtures/jds/04-blacklist-duplicate.md +15 -0
- package/evals/fixtures/jds/05-stretch-mismatch.md +13 -0
- package/evals/journeys/journey-matrix.json +333 -0
- package/evals/journeys/run-journeys.test.mjs +1201 -0
- package/evals/mcp-server.test.mjs +665 -0
- package/evals/mena-boards.test.mjs +339 -0
- package/evals/naukri-board.test.mjs +304 -0
- package/evals/notion-sync.test.mjs +3479 -0
- package/evals/profile-intelligence.test.mjs +529 -0
- package/evals/results/baseline-verified-run.json +125 -0
- package/evals/results/live-agent-eval-run.json +143 -0
- package/evals/stepstone-board.test.mjs +318 -0
- package/evals/ui-server.test.mjs +502 -0
- package/evals/workday-fixture.test.mjs +268 -0
- package/examples/outputs/sample-interrogation-transcript.md +36 -0
- package/examples/outputs/sample-interview-dossier.md +33 -0
- package/examples/outputs/sample-outreach-75-words.md +13 -0
- package/examples/outputs/sample-tailoring-notes.md +70 -0
- package/examples/sandbox-demo/demo-profile.md +45 -0
- package/examples/sandbox-demo/expected-mission-control.md +16 -0
- package/examples/sandbox-demo/sample-jds.md +39 -0
- package/glama.json +6 -0
- package/llms.txt +70 -0
- package/mcp/README.md +80 -0
- package/mcp/claude_desktop_config.example.json +47 -0
- package/mcp/mcp.template.json +33 -0
- package/opencode.json +42 -0
- package/package.json +115 -6
- package/prompts/partials/pacing.md +8 -0
- package/prompts/partials/snapshot-first.md +4 -0
- package/prompts/partials/stop-conditions.md +5 -0
- package/schemas/application-ledger.schema.json +272 -0
- package/schemas/career-insights.schema.json +111 -0
- package/schemas/cv-versions.schema.json +83 -0
- package/schemas/notion-sync-plan.schema.json +338 -0
- package/schemas/profile-update-plan.schema.json +133 -0
- package/schemas/readiness.schema.json +484 -0
- package/schemas/resume-data.schema.json +171 -0
- package/scripts/install.ps1 +107 -0
- package/scripts/install.sh +130 -0
- package/skills/00-daily-run.md +89 -0
- package/skills/00-interrogate-and-onboard.md +87 -0
- package/skills/01-resume-ingestion.md +76 -0
- package/skills/02-discover-and-triage.md +121 -0
- package/skills/03-tailor-resume-and-verify.md +114 -0
- package/skills/04-fill-and-apply.md +108 -0
- package/skills/05-outreach-and-interview-prep.md +80 -0
- package/skills/06-log-and-insights.md +99 -0
- package/skills/07-persona-switcher.md +61 -0
- package/skills/08-follow-up-radar.md +59 -0
- package/skills/09-offer-negotiator.md +62 -0
- package/skills/10-autonomous-scheduler-loop.md +64 -0
- package/skills/11-portfolio-and-github-auditor.md +130 -0
- package/skills/12-recruiter-inbox-triage.md +69 -0
- package/skills/13-company-due-diligence.md +60 -0
- package/skills/14-privacy-pii-shield.md +56 -0
- package/skills/15-multilingual-adaptation.md +61 -0
- package/skills/16-rejection-pattern-analyzer.md +60 -0
- package/skills/17-score-calibration.md +61 -0
- package/skills/18-condition-based-browser-waiting.md +65 -0
- package/skills/19-on-demand-mcp-routing.md +69 -0
- package/skills/20-skill-authoring-standard.md +61 -0
- package/skills/21-ats-keyword-heatmap.md +60 -0
- package/skills/22-technical-assessment-architect.md +59 -0
- package/skills/23-contract-and-nda-auditor.md +60 -0
- package/skills/24-circuit-breaker-and-antiban.md +68 -0
- package/skills/25-prompt-injection-defense.md +59 -0
- package/skills/26-deduplication-and-blacklist-guard.md +59 -0
- package/skills/27-universal-cv-builder.md +99 -0
- package/skills/28-recruiter-brand-and-domain-intelligence.md +99 -0
- package/skills/29-portfolio-builder-and-deployer.md +160 -0
- package/skills/30-portfolio-design-system-and-qa.md +163 -0
- package/skills/54-github-cli-remote-manager.md +144 -0
- package/skills/55-freelance-profile-and-service-publisher.md +90 -0
- package/skills/56-freelance-offer-radar-and-batch-bidder.md +94 -0
- package/skills/REGISTRY.md +98 -0
- package/skills/ats/ashby.md +54 -0
- package/skills/ats/breezyhr.md +54 -0
- package/skills/ats/greenhouse.md +54 -0
- package/skills/ats/lever.md +54 -0
- package/skills/ats/smartrecruiters.md +54 -0
- package/skills/ats/taleo.md +43 -0
- package/skills/ats/workday.md +49 -0
- package/skills/fallback-no-mcp.md +57 -0
- package/skills/linkedin-growth.md +188 -0
- package/skills/meta-context-compaction.md +88 -0
- package/skills/meta-dom-recovery.md +63 -0
- package/skills/meta-self-verification.md +75 -0
- package/skills/meta-structured-debugging.md +69 -0
- package/skills/platforms/_template.md +69 -0
- package/skills/platforms/ats-engines.md +67 -0
- package/skills/platforms/b2b-contract-networks.md +59 -0
- package/skills/platforms/global-boards.md +122 -0
- package/skills/platforms/linkedin.md +162 -0
- package/skills/platforms/mena-boards.md +99 -0
- package/skills/platforms/remote-boards.md +64 -0
- package/skills/platforms/wellfound.md +59 -0
- package/skills/profile-intelligence-engine.md +98 -0
- package/skills/skills-manifest.json +1730 -0
- package/templates/analytics-dashboard.html +1106 -0
- package/templates/ats-cover-letter-template.html +29 -0
- package/templates/ats-resume-template.html +38 -0
- package/templates/ats-resume.html +3 -0
- package/ui/app.js +1113 -0
- package/ui/favicon.svg +4 -0
- package/ui/index.html +53 -0
- package/ui/styles.css +595 -0
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
// Zero-dependency Safe DOM Distiller & Single-Shot Non-Submitting Batch Form Fill payloads for Veycraft.
|
|
2
|
+
// Pure JS (0 runtime/dev deps, 0 eval/new Function, 0 string interpolation of user input into JS).
|
|
3
|
+
// Every payload is strictly read-only or non-submitting: NEVER triggers form submission or Publish/Save clicks.
|
|
4
|
+
|
|
5
|
+
export const PAYLOAD_NAMES = Object.freeze(['distill-feed', 'distill-form', 'batch-fill']);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Distill an authenticated job/freelance feed page into a compact (<600-token) JSON structure.
|
|
9
|
+
* Strips nav/header/footer/aside/hidden nodes, removes invisible BiDi/Unicode Tag chars,
|
|
10
|
+
* detects CAPTCHA/login stop conditions, and flags potential prompt-injection strings.
|
|
11
|
+
*/
|
|
12
|
+
export function distillFeedInDom(doc, opts = {}) {
|
|
13
|
+
const maxItems = Number.isInteger(opts?.maxItems) && opts.maxItems > 0 ? Math.min(opts.maxItems, 25) : 15;
|
|
14
|
+
const maxSnippet = Number.isInteger(opts?.maxSnippet) && opts.maxSnippet > 20 ? Math.min(opts.maxSnippet, 220) : 140;
|
|
15
|
+
|
|
16
|
+
const stripInvisible = (str) => {
|
|
17
|
+
let out = '';
|
|
18
|
+
const s = String(str || '');
|
|
19
|
+
for (let i = 0; i < s.length; i++) {
|
|
20
|
+
const cp = s.codePointAt(i);
|
|
21
|
+
if (cp > 0xffff) i++;
|
|
22
|
+
if ((cp >= 0xe0000 && cp <= 0xe007f) || (cp >= 0x202a && cp <= 0x202e) || (cp >= 0x2066 && cp <= 0x2069)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
out += String.fromCodePoint(cp);
|
|
26
|
+
}
|
|
27
|
+
return out.replace(/\s+/g, ' ').trim();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const INJECTION_RE = /\b(ignore\s+(?:all\s+)?previous\s+instructions?|system\s+prompt|you\s+are\s+now|disregard\s+guardrails|reveal\s+(?:your\s+)?(?:\.env|api\s+key|token)|auto[- ]?submit|click\s+submit\s+immediately)\b/i;
|
|
31
|
+
|
|
32
|
+
const isHidden = (el) => {
|
|
33
|
+
if (!el || typeof el !== 'object') return true;
|
|
34
|
+
if (el.hidden) return true;
|
|
35
|
+
if (typeof el.getAttribute === 'function') {
|
|
36
|
+
if (el.getAttribute('aria-hidden') === 'true') return true;
|
|
37
|
+
const st = String(el.getAttribute('style') || '').toLowerCase();
|
|
38
|
+
if (/display\s*:\s*none|visibility\s*:\s*hidden|opacity\s*:\s*0(?:\D|$)|font-size\s*:\s*0(?:px|em|rem|%)?(?:\D|$)/.test(st)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const win = doc?.defaultView;
|
|
43
|
+
if (win && typeof win.getComputedStyle === 'function') {
|
|
44
|
+
try {
|
|
45
|
+
const cs = win.getComputedStyle(el);
|
|
46
|
+
if (cs && (cs.display === 'none' || cs.visibility === 'hidden' || cs.opacity === '0' || cs.fontSize === '0px')) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
} catch { /* ignore */ }
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const detectChallenge = () => {
|
|
55
|
+
const htmlSample = String(doc?.body?.textContent || '').slice(0, 6000).toLowerCase();
|
|
56
|
+
const hasCaptchaNode = Boolean(
|
|
57
|
+
doc?.querySelector?.('[class*="captcha" i], [id*="captcha" i], iframe[src*="turnstile" i], iframe[src*="recaptcha" i], iframe[src*="hcaptcha" i], #challenge-form')
|
|
58
|
+
);
|
|
59
|
+
if (hasCaptchaNode || /\b(verify you are human|just a moment|cloudflare|attention required|recaptcha|hcaptcha)\b/i.test(htmlSample)) {
|
|
60
|
+
return 'captcha';
|
|
61
|
+
}
|
|
62
|
+
const hasPw = Boolean(doc?.querySelector?.('input[type="password"]'));
|
|
63
|
+
const hasLoginHeading = /\b(sign in|log in|login to your account|تسجيل الدخول)\b/i.test(String(doc?.title || '') + ' ' + htmlSample.slice(0, 800));
|
|
64
|
+
if (hasPw && hasLoginHeading) return 'login';
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const challenge = detectChallenge();
|
|
69
|
+
if (challenge) {
|
|
70
|
+
return {
|
|
71
|
+
ok: true,
|
|
72
|
+
untrusted_external_data: true,
|
|
73
|
+
url: String(doc?.location?.href || ''),
|
|
74
|
+
auth_or_challenge_detected: challenge,
|
|
75
|
+
items: [],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const cardSelectors = [
|
|
80
|
+
'article',
|
|
81
|
+
'[data-test="job-tile"]',
|
|
82
|
+
'[data-testid*="job" i]',
|
|
83
|
+
'[data-testid*="project" i]',
|
|
84
|
+
'.project-row',
|
|
85
|
+
'.job-card',
|
|
86
|
+
'.search-result',
|
|
87
|
+
'li[class*="job" i]',
|
|
88
|
+
'li[class*="project" i]',
|
|
89
|
+
].join(', ');
|
|
90
|
+
|
|
91
|
+
const rawNodes = Array.from(doc?.querySelectorAll?.(cardSelectors) || []);
|
|
92
|
+
const items = [];
|
|
93
|
+
const seenUrls = new Set();
|
|
94
|
+
|
|
95
|
+
for (const node of rawNodes) {
|
|
96
|
+
if (items.length >= maxItems) break;
|
|
97
|
+
if (isHidden(node)) continue;
|
|
98
|
+
if (typeof node.closest === 'function' && node.closest('nav, header, footer, aside')) continue;
|
|
99
|
+
|
|
100
|
+
const link = node.querySelector?.('a[href]');
|
|
101
|
+
const titleNode = node.querySelector?.('h1, h2, h3, h4, [class*="title" i]') || link;
|
|
102
|
+
const title = stripInvisible(titleNode?.textContent || '').slice(0, 90);
|
|
103
|
+
if (!title || title.length < 4) continue;
|
|
104
|
+
|
|
105
|
+
let href = String(link?.getAttribute?.('href') || link?.href || '').trim();
|
|
106
|
+
if (href && doc?.location?.href && !/^https?:\/\//i.test(href)) {
|
|
107
|
+
try { href = new URL(href, doc.location.href).href; } catch { /* keep relative */ }
|
|
108
|
+
}
|
|
109
|
+
if (href && seenUrls.has(href)) continue;
|
|
110
|
+
if (href) seenUrls.add(href);
|
|
111
|
+
|
|
112
|
+
const rawText = stripInvisible(node.textContent || '');
|
|
113
|
+
const budgetMatch = rawText.match(/(?:\$|€|£|USD|EUR|SAR|AED)\s?\d[\d,]*(?:\s*[-–]\s*(?:\$|€|£|USD|EUR|SAR|AED)?\s?\d[\d,]*)?/i);
|
|
114
|
+
const postedMatch = rawText.match(/\b(?:\d+\s*(?:m|min|mins|minute|minutes|h|hr|hrs|hour|hours|d|day|days)\s+ago|just\s+now|today|yesterday|منذ\s+\S+(?:\s+\S+)?)\b/i);
|
|
115
|
+
const bidsMatch = rawText.match(/\b(?:\d+\+?\s*(?:proposals?|bids?|applicants?|عروض|عرض))\b/i);
|
|
116
|
+
const snippet = rawText.slice(0, maxSnippet);
|
|
117
|
+
const flags = [];
|
|
118
|
+
if (INJECTION_RE.test(rawText)) flags.push('prompt_injection_pattern');
|
|
119
|
+
|
|
120
|
+
items.push({
|
|
121
|
+
idx: items.length + 1,
|
|
122
|
+
title,
|
|
123
|
+
url: href || null,
|
|
124
|
+
budget: budgetMatch ? budgetMatch[0] : null,
|
|
125
|
+
posted: postedMatch ? postedMatch[0] : null,
|
|
126
|
+
bids: bidsMatch ? bidsMatch[0] : null,
|
|
127
|
+
snippet,
|
|
128
|
+
injection_flags: flags,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
ok: true,
|
|
134
|
+
untrusted_external_data: true,
|
|
135
|
+
url: String(doc?.location?.href || ''),
|
|
136
|
+
auth_or_challenge_detected: null,
|
|
137
|
+
total_found: items.length,
|
|
138
|
+
items,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Distill all visible editable form controls (+ open Shadow DOM) into a compact schema (<600 tokens).
|
|
144
|
+
* Segregates honeypot/hidden controls and reports cross-origin iframes and submit button labels as metadata only.
|
|
145
|
+
*/
|
|
146
|
+
export function distillFormInDom(doc, opts = {}) {
|
|
147
|
+
const maxFields = Number.isInteger(opts?.maxFields) && opts.maxFields > 0 ? Math.min(opts.maxFields, 50) : 35;
|
|
148
|
+
|
|
149
|
+
const stripInvisible = (str) => {
|
|
150
|
+
let out = '';
|
|
151
|
+
const s = String(str || '');
|
|
152
|
+
for (let i = 0; i < s.length; i++) {
|
|
153
|
+
const cp = s.codePointAt(i);
|
|
154
|
+
if (cp > 0xffff) i++;
|
|
155
|
+
if ((cp >= 0xe0000 && cp <= 0xe007f) || (cp >= 0x202a && cp <= 0x202e) || (cp >= 0x2066 && cp <= 0x2069)) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
out += String.fromCodePoint(cp);
|
|
159
|
+
}
|
|
160
|
+
return out.replace(/\s+/g, ' ').trim();
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const HONEYPOT_RE = /honeypot|trap|bot[_-]?check|website_url_honeypot|hp[_-]?field/i;
|
|
164
|
+
|
|
165
|
+
const isHiddenOrHoneypot = (el) => {
|
|
166
|
+
const type = String(el?.type || el?.getAttribute?.('type') || '').toLowerCase();
|
|
167
|
+
const name = String(el?.name || el?.getAttribute?.('name') || '');
|
|
168
|
+
const id = String(el?.id || el?.getAttribute?.('id') || '');
|
|
169
|
+
const tabIdx = String(el?.getAttribute?.('tabindex') || '');
|
|
170
|
+
const ariaHidden = String(el?.getAttribute?.('aria-hidden') || '');
|
|
171
|
+
const style = String(el?.getAttribute?.('style') || '').toLowerCase();
|
|
172
|
+
const hiddenAttr = Boolean(el?.hidden) || type === 'hidden';
|
|
173
|
+
const cssHidden = /display\s*:\s*none|visibility\s*:\s*hidden|opacity\s*:\s*0(?:\D|$)|left\s*:\s*-\d{3,}px/.test(style);
|
|
174
|
+
if (HONEYPOT_RE.test(name) || HONEYPOT_RE.test(id)) return 'honeypot_name';
|
|
175
|
+
if (hiddenAttr) return 'hidden_input';
|
|
176
|
+
if (cssHidden || ariaHidden === 'true' || tabIdx === '-1') return 'hidden_or_trap';
|
|
177
|
+
return null;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const resolveLabel = (el, rootNode) => {
|
|
181
|
+
const ariaLabel = el.getAttribute?.('aria-label');
|
|
182
|
+
if (ariaLabel) return stripInvisible(ariaLabel).slice(0, 80);
|
|
183
|
+
const id = el.id || el.getAttribute?.('id');
|
|
184
|
+
if (id && rootNode?.querySelector) {
|
|
185
|
+
const lbl = rootNode.querySelector(`label[for="${id.replace(/"/g, '\\"')}"]`);
|
|
186
|
+
if (lbl?.textContent) return stripInvisible(lbl.textContent).slice(0, 80);
|
|
187
|
+
}
|
|
188
|
+
const parentLabel = el.closest?.('label');
|
|
189
|
+
if (parentLabel?.textContent) return stripInvisible(parentLabel.textContent).slice(0, 80);
|
|
190
|
+
const ph = el.getAttribute?.('placeholder') || el.placeholder || '';
|
|
191
|
+
if (ph) return stripInvisible(ph).slice(0, 80);
|
|
192
|
+
return stripInvisible(el.name || el.getAttribute?.('name') || id || '').slice(0, 80);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const fields = [];
|
|
196
|
+
const honeypotsDetected = [];
|
|
197
|
+
const submitButtons = [];
|
|
198
|
+
const iframeSrcs = [];
|
|
199
|
+
let shadowHostsCount = 0;
|
|
200
|
+
|
|
201
|
+
const walkRoot = (rootNode) => {
|
|
202
|
+
if (!rootNode || typeof rootNode.querySelectorAll !== 'function') return;
|
|
203
|
+
const frames = Array.from(rootNode.querySelectorAll('iframe') || []);
|
|
204
|
+
for (const fr of frames) {
|
|
205
|
+
const src = String(fr.getAttribute?.('src') || fr.src || '').trim();
|
|
206
|
+
if (src && !iframeSrcs.includes(src)) iframeSrcs.push(src);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const controls = Array.from(
|
|
210
|
+
rootNode.querySelectorAll('input, textarea, select, [role="combobox"], [contenteditable="true"], button, input[type="submit"]') || []
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
for (const el of controls) {
|
|
214
|
+
const tag = String(el.tagName || '').toLowerCase();
|
|
215
|
+
const type = String(el.type || el.getAttribute?.('type') || (tag === 'textarea' ? 'textarea' : tag === 'select' ? 'select' : '')).toLowerCase();
|
|
216
|
+
const role = String(el.getAttribute?.('role') || '').toLowerCase();
|
|
217
|
+
|
|
218
|
+
if (tag === 'button' || type === 'submit' || type === 'button') {
|
|
219
|
+
const btnText = stripInvisible(el.textContent || el.value || el.getAttribute?.('aria-label') || '').slice(0, 60);
|
|
220
|
+
if (type === 'submit' || /\b(submit|publish|save|send|apply|post|إرسال|نشر|حفظ|أضف عرض)\b/i.test(btnText)) {
|
|
221
|
+
submitButtons.push({ text: btnText || 'Submit', disabled: Boolean(el.disabled) });
|
|
222
|
+
}
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const trapReason = isHiddenOrHoneypot(el);
|
|
227
|
+
if (trapReason) {
|
|
228
|
+
if (trapReason !== 'hidden_input' || HONEYPOT_RE.test(String(el.name || el.id || ''))) {
|
|
229
|
+
honeypotsDetected.push({
|
|
230
|
+
name: String(el.name || el.getAttribute?.('name') || el.id || ''),
|
|
231
|
+
reason: trapReason,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (fields.length >= maxFields) continue;
|
|
238
|
+
const name = String(el.name || el.getAttribute?.('name') || '');
|
|
239
|
+
const id = String(el.id || el.getAttribute?.('id') || '');
|
|
240
|
+
const label = resolveLabel(el, rootNode);
|
|
241
|
+
const key = name || id || label || `field_${fields.length + 1}`;
|
|
242
|
+
const optionsSample = tag === 'select'
|
|
243
|
+
? Array.from(el.options || []).slice(0, 8).map((o) => stripInvisible(o.text || o.value || '').slice(0, 40))
|
|
244
|
+
: undefined;
|
|
245
|
+
|
|
246
|
+
fields.push({
|
|
247
|
+
key,
|
|
248
|
+
label,
|
|
249
|
+
name: name || null,
|
|
250
|
+
id: id || null,
|
|
251
|
+
type: role === 'combobox' ? 'combobox' : (el.getAttribute?.('contenteditable') === 'true' ? 'contenteditable' : (type || tag)),
|
|
252
|
+
required: Boolean(el.required || el.getAttribute?.('aria-required') === 'true'),
|
|
253
|
+
current_value: type === 'password' ? '[REDACTED]' : stripInvisible(el.value || '').slice(0, 60),
|
|
254
|
+
...(optionsSample ? { options_sample: optionsSample } : {}),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const allEls = Array.from(rootNode.querySelectorAll('*') || []);
|
|
259
|
+
for (const el of allEls) {
|
|
260
|
+
if (el && el.shadowRoot) {
|
|
261
|
+
shadowHostsCount++;
|
|
262
|
+
walkRoot(el.shadowRoot);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
walkRoot(doc);
|
|
268
|
+
|
|
269
|
+
const hasCaptcha = Boolean(
|
|
270
|
+
doc?.querySelector?.('[class*="captcha" i], [id*="captcha" i], iframe[src*="turnstile" i], iframe[src*="recaptcha" i], iframe[src*="hcaptcha" i]')
|
|
271
|
+
);
|
|
272
|
+
const hasPassword = fields.some((f) => f.type === 'password');
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
ok: true,
|
|
276
|
+
untrusted_external_data: true,
|
|
277
|
+
url: String(doc?.location?.href || ''),
|
|
278
|
+
auth_or_challenge_detected: hasCaptcha ? 'captcha' : (hasPassword && fields.length <= 3 ? 'login' : null),
|
|
279
|
+
shadow_hosts_count: shadowHostsCount,
|
|
280
|
+
iframe_srcs: iframeSrcs,
|
|
281
|
+
fields_count: fields.length,
|
|
282
|
+
fields,
|
|
283
|
+
honeypots_detected: honeypotsDetected,
|
|
284
|
+
submit_buttons: submitButtons,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Single-Shot Non-Submitting Batch Form Fill.
|
|
290
|
+
* Accepts `fieldMap` strictly as a serialized object argument (NEVER interpolated into JS source).
|
|
291
|
+
* HARD SAFETY INVARIANT: Never clicks submit/publish/save/send buttons and never calls form submission APIs.
|
|
292
|
+
*/
|
|
293
|
+
export function batchFillFormInDom(doc, fieldMap) {
|
|
294
|
+
if (!fieldMap || typeof fieldMap !== 'object' || Array.isArray(fieldMap)) {
|
|
295
|
+
return {
|
|
296
|
+
ok: false,
|
|
297
|
+
never_submitted: true,
|
|
298
|
+
ready_for_approval_gate: false,
|
|
299
|
+
error: 'fieldMap must be a plain key-value JSON object.',
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const HONEYPOT_RE = /honeypot|trap|bot[_-]?check|website_url_honeypot|hp[_-]?field/i;
|
|
304
|
+
const normalizeKey = (s) => String(s || '').trim().toLowerCase().replace(/\s+/g, ' ');
|
|
305
|
+
|
|
306
|
+
const isBlockedControl = (el) => {
|
|
307
|
+
const tag = String(el?.tagName || '').toLowerCase();
|
|
308
|
+
const type = String(el?.type || el?.getAttribute?.('type') || '').toLowerCase();
|
|
309
|
+
const name = String(el?.name || el?.getAttribute?.('name') || '');
|
|
310
|
+
const id = String(el?.id || el?.getAttribute?.('id') || '');
|
|
311
|
+
const style = String(el?.getAttribute?.('style') || '').toLowerCase();
|
|
312
|
+
if (tag === 'button' || type === 'submit' || type === 'button' || type === 'reset' || type === 'image') return 'non_editable_button';
|
|
313
|
+
if (type === 'hidden' || Boolean(el?.hidden)) return 'hidden_field';
|
|
314
|
+
if (HONEYPOT_RE.test(name) || HONEYPOT_RE.test(id)) return 'honeypot';
|
|
315
|
+
if (el?.getAttribute?.('aria-hidden') === 'true' || String(el?.getAttribute?.('tabindex') || '') === '-1') return 'honeypot';
|
|
316
|
+
if (/display\s*:\s*none|visibility\s*:\s*hidden|opacity\s*:\s*0(?:\D|$)/.test(style)) return 'honeypot';
|
|
317
|
+
return null;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const setNativeValue = (el, val) => {
|
|
321
|
+
const strVal = String(val);
|
|
322
|
+
const tag = String(el.tagName || '').toLowerCase();
|
|
323
|
+
const win = doc?.defaultView;
|
|
324
|
+
const proto =
|
|
325
|
+
tag === 'textarea' ? win?.HTMLTextAreaElement?.prototype :
|
|
326
|
+
tag === 'select' ? win?.HTMLSelectElement?.prototype :
|
|
327
|
+
win?.HTMLInputElement?.prototype;
|
|
328
|
+
const setter = proto ? Object.getOwnPropertyDescriptor(proto, 'value')?.set : null;
|
|
329
|
+
if (typeof setter === 'function') {
|
|
330
|
+
setter.call(el, strVal);
|
|
331
|
+
} else {
|
|
332
|
+
el.value = strVal;
|
|
333
|
+
}
|
|
334
|
+
const EventCtor = win?.Event || globalThis.Event;
|
|
335
|
+
if (typeof el.dispatchEvent === 'function' && typeof EventCtor === 'function') {
|
|
336
|
+
el.dispatchEvent(new EventCtor('input', { bubbles: true }));
|
|
337
|
+
el.dispatchEvent(new EventCtor('change', { bubbles: true }));
|
|
338
|
+
el.dispatchEvent(new EventCtor('blur', { bubbles: true }));
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const allControls = [];
|
|
343
|
+
const collectControls = (rootNode) => {
|
|
344
|
+
if (!rootNode || typeof rootNode.querySelectorAll !== 'function') return;
|
|
345
|
+
for (const el of Array.from(rootNode.querySelectorAll('input, textarea, select, [role="combobox"], [contenteditable="true"]') || [])) {
|
|
346
|
+
allControls.push({ el, rootNode });
|
|
347
|
+
}
|
|
348
|
+
for (const host of Array.from(rootNode.querySelectorAll('*') || [])) {
|
|
349
|
+
if (host && host.shadowRoot) collectControls(host.shadowRoot);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
collectControls(doc);
|
|
353
|
+
|
|
354
|
+
const labelFor = (el, rootNode) => {
|
|
355
|
+
const aria = el.getAttribute?.('aria-label');
|
|
356
|
+
if (aria) return aria;
|
|
357
|
+
const id = el.id || el.getAttribute?.('id');
|
|
358
|
+
if (id && rootNode?.querySelector) {
|
|
359
|
+
const lbl = rootNode.querySelector(`label[for="${id.replace(/"/g, '\\"')}"]`);
|
|
360
|
+
if (lbl?.textContent) return lbl.textContent;
|
|
361
|
+
}
|
|
362
|
+
return el.closest?.('label')?.textContent || el.getAttribute?.('placeholder') || '';
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
const filled = [];
|
|
366
|
+
const skipped = [];
|
|
367
|
+
const unmatched = [];
|
|
368
|
+
const honeypotsIgnored = [];
|
|
369
|
+
const requiresNativeUpload = [];
|
|
370
|
+
const requiresInteractiveSelect = [];
|
|
371
|
+
const validationErrors = [];
|
|
372
|
+
|
|
373
|
+
for (const [rawKey, rawVal] of Object.entries(fieldMap)) {
|
|
374
|
+
if (rawVal === undefined || rawVal === null) {
|
|
375
|
+
skipped.push({ key: rawKey, reason: 'null_or_undefined' });
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
const targetNorm = normalizeKey(rawKey);
|
|
379
|
+
const match = allControls.find(({ el, rootNode }) => {
|
|
380
|
+
const candidates = [
|
|
381
|
+
el.name || el.getAttribute?.('name') || '',
|
|
382
|
+
el.id || el.getAttribute?.('id') || '',
|
|
383
|
+
labelFor(el, rootNode),
|
|
384
|
+
].map(normalizeKey).filter(Boolean);
|
|
385
|
+
return candidates.includes(targetNorm);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
if (!match) {
|
|
389
|
+
unmatched.push(rawKey);
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const { el } = match;
|
|
394
|
+
const blocked = isBlockedControl(el);
|
|
395
|
+
if (blocked === 'honeypot') {
|
|
396
|
+
honeypotsIgnored.push(rawKey);
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
if (blocked) {
|
|
400
|
+
skipped.push({ key: rawKey, reason: blocked });
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const tag = String(el.tagName || '').toLowerCase();
|
|
405
|
+
const type = String(el.type || el.getAttribute?.('type') || '').toLowerCase();
|
|
406
|
+
const role = String(el.getAttribute?.('role') || '').toLowerCase();
|
|
407
|
+
|
|
408
|
+
if (type === 'file') {
|
|
409
|
+
requiresNativeUpload.push({ key: rawKey, name: el.name || el.id || rawKey });
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
if (role === 'combobox') {
|
|
413
|
+
requiresInteractiveSelect.push({ key: rawKey, value: String(rawVal) });
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (type === 'checkbox' || type === 'radio') {
|
|
417
|
+
const desired = Boolean(rawVal) && String(rawVal).toLowerCase() !== 'false';
|
|
418
|
+
el.checked = desired;
|
|
419
|
+
const EventCtor = doc?.defaultView?.Event || globalThis.Event;
|
|
420
|
+
if (typeof el.dispatchEvent === 'function' && typeof EventCtor === 'function') {
|
|
421
|
+
el.dispatchEvent(new EventCtor('change', { bubbles: true }));
|
|
422
|
+
}
|
|
423
|
+
filled.push({ key: rawKey, type, read_back: Boolean(el.checked) });
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
if (el.getAttribute?.('contenteditable') === 'true') {
|
|
427
|
+
el.textContent = String(rawVal);
|
|
428
|
+
const EventCtor = doc?.defaultView?.Event || globalThis.Event;
|
|
429
|
+
if (typeof el.dispatchEvent === 'function' && typeof EventCtor === 'function') {
|
|
430
|
+
el.dispatchEvent(new EventCtor('input', { bubbles: true }));
|
|
431
|
+
}
|
|
432
|
+
filled.push({ key: rawKey, type: 'contenteditable', read_back: String(el.textContent).slice(0, 120) });
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
if (tag === 'select') {
|
|
436
|
+
const strVal = String(rawVal);
|
|
437
|
+
const opts = Array.from(el.options || []);
|
|
438
|
+
const optMatch = opts.find((o) => normalizeKey(o.value) === normalizeKey(strVal) || normalizeKey(o.text) === normalizeKey(strVal));
|
|
439
|
+
if (!optMatch) {
|
|
440
|
+
requiresInteractiveSelect.push({ key: rawKey, value: strVal, reason: 'option_not_found' });
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
setNativeValue(el, optMatch.value);
|
|
444
|
+
filled.push({ key: rawKey, type: 'select', read_back: String(el.value) });
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
setNativeValue(el, rawVal);
|
|
449
|
+
const readBack = type === 'password' ? '[REDACTED]' : String(el.value || '').slice(0, 120);
|
|
450
|
+
if (typeof el.checkValidity === 'function' && !el.checkValidity()) {
|
|
451
|
+
validationErrors.push({ key: rawKey, message: String(el.validationMessage || 'Invalid value') });
|
|
452
|
+
}
|
|
453
|
+
filled.push({ key: rawKey, type: type || tag, read_back: readBack });
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
return {
|
|
457
|
+
ok: true,
|
|
458
|
+
never_submitted: true,
|
|
459
|
+
ready_for_approval_gate: true,
|
|
460
|
+
filled_count: filled.length,
|
|
461
|
+
filled,
|
|
462
|
+
skipped,
|
|
463
|
+
unmatched,
|
|
464
|
+
honeypots_ignored: honeypotsIgnored,
|
|
465
|
+
requires_native_upload: requiresNativeUpload,
|
|
466
|
+
requires_interactive_select: requiresInteractiveSelect,
|
|
467
|
+
validation_errors: validationErrors,
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export function getBrowserPayload(name) {
|
|
472
|
+
const normalized = String(name || '').trim().toLowerCase();
|
|
473
|
+
if (!PAYLOAD_NAMES.includes(normalized)) {
|
|
474
|
+
throw new Error(`Unknown browser payload "${name}". Valid payloads: ${PAYLOAD_NAMES.join(', ')}`);
|
|
475
|
+
}
|
|
476
|
+
if (normalized === 'distill-feed') {
|
|
477
|
+
const fnSource = `(opts) => (${distillFeedInDom.toString()})(document, opts)`;
|
|
478
|
+
return {
|
|
479
|
+
name: 'distill-feed',
|
|
480
|
+
read_only: true,
|
|
481
|
+
never_submits: true,
|
|
482
|
+
untrusted_data_wrapped: true,
|
|
483
|
+
usage: 'Pass `fn_source` to Playwright browser_evaluate with optional `{ maxItems: 15, maxSnippet: 140 }` argument.',
|
|
484
|
+
fn_source: fnSource,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
if (normalized === 'distill-form') {
|
|
488
|
+
const fnSource = `(opts) => (${distillFormInDom.toString()})(document, opts)`;
|
|
489
|
+
return {
|
|
490
|
+
name: 'distill-form',
|
|
491
|
+
read_only: true,
|
|
492
|
+
never_submits: true,
|
|
493
|
+
untrusted_data_wrapped: true,
|
|
494
|
+
usage: 'Pass `fn_source` to Playwright browser_evaluate with optional `{ maxFields: 35 }` argument.',
|
|
495
|
+
fn_source: fnSource,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
const fnSource = `(fieldMap) => (${batchFillFormInDom.toString()})(document, fieldMap)`;
|
|
499
|
+
return {
|
|
500
|
+
name: 'batch-fill',
|
|
501
|
+
read_only: false,
|
|
502
|
+
never_submits: true,
|
|
503
|
+
untrusted_data_wrapped: true,
|
|
504
|
+
usage: 'Pass `fn_source` to Playwright browser_evaluate with `fieldMap` as a separate serialized JSON object argument (NEVER interpolate user strings into JS). Always pause for explicit human APPROVE after reading the returned Live DOM Read-Back JSON.',
|
|
505
|
+
fn_source: fnSource,
|
|
506
|
+
};
|
|
507
|
+
}
|