@xapp/arachne-web-service 1.31.0 → 1.32.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/lib/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export * from "./utils/agenticProvider";
9
9
  export * from "./llm/LLMProvider";
10
10
  export type { ResourceType } from "puppeteer-core";
11
11
  export type { RequestHeaderRule } from "@xapp/arachne";
12
+ export * from "./taxonomy/ServiceTaxonomy";
package/lib/index.js CHANGED
@@ -23,4 +23,5 @@ __exportStar(require("./utils/pageAgenticSignals"), exports);
23
23
  __exportStar(require("./utils/checkMcpServer"), exports);
24
24
  __exportStar(require("./utils/agenticProvider"), exports);
25
25
  __exportStar(require("./llm/LLMProvider"), exports);
26
+ __exportStar(require("./taxonomy/ServiceTaxonomy"), exports);
26
27
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kCAAkC;AAClC,sDAAoC;AACpC,2CAAyB;AACzB,gDAA8B;AAC9B,8DAA4C;AAC5C,6DAA2C;AAC3C,yDAAuC;AACvC,0DAAwC;AACxC,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kCAAkC;AAClC,sDAAoC;AACpC,2CAAyB;AACzB,gDAA8B;AAC9B,8DAA4C;AAC5C,6DAA2C;AAC3C,yDAAuC;AACvC,0DAAwC;AACxC,oDAAkC;AAMlC,6DAA2C"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * A job a homeowner asks for and a business may advertise, e.g. `plumbing.water_heater.tankless_install`.
3
+ */
4
+ export interface TaxonomyJob {
5
+ /**
6
+ * Canonical slug, `trade.family.job` or `trade.job` for trades without families. Stable once published.
7
+ */
8
+ slug: string;
9
+ /**
10
+ * A symptom or situation homeowners state that no website advertises. The extractor never emits these.
11
+ */
12
+ homeowner_only: boolean;
13
+ /**
14
+ * Family, trade or advertised job a homeowner-only job is scored against.
15
+ */
16
+ rolls_up_to?: string;
17
+ /**
18
+ * Appears rarely, but is a capability a business either has or does not.
19
+ */
20
+ rare?: boolean;
21
+ /**
22
+ * Approximate frequency in the labeled lead samples. Shows where demand concentrates; not a target.
23
+ */
24
+ count?: number;
25
+ /**
26
+ * Words homeowners and websites use for the job.
27
+ */
28
+ synonyms?: string[];
29
+ /**
30
+ * Slug that replaces this one. Slugs are never renamed, only deprecated.
31
+ */
32
+ deprecated_by?: string;
33
+ }
34
+ export interface TaxonomyFamily {
35
+ slug: string;
36
+ /**
37
+ * What websites call the family, e.g. "AC repair".
38
+ */
39
+ website_terms?: string[];
40
+ jobs: TaxonomyJob[];
41
+ }
42
+ export interface TaxonomyTrade {
43
+ slug: string;
44
+ rare?: boolean;
45
+ families?: TaxonomyFamily[];
46
+ /**
47
+ * Jobs that sit directly under the trade.
48
+ */
49
+ jobs?: TaxonomyJob[];
50
+ /**
51
+ * Qualifiers that shape a job without being one, e.g. roofing structure type.
52
+ */
53
+ modifiers?: Record<string, string[]>;
54
+ }
55
+ export interface TaxonomyDefinition {
56
+ slug: string;
57
+ definition: string;
58
+ }
59
+ export interface Taxonomy {
60
+ version: string;
61
+ trades: TaxonomyTrade[];
62
+ /**
63
+ * Non-canonical slug to canonical slug.
64
+ */
65
+ aliases: Record<string, string>;
66
+ /**
67
+ * Slug prefix to canonical prefix, for trades folded into another.
68
+ */
69
+ alias_prefixes: Record<string, string>;
70
+ /**
71
+ * Tri-state business flags.
72
+ */
73
+ capability_flags: TaxonomyDefinition[];
74
+ /**
75
+ * Business attributes that are lists of values.
76
+ */
77
+ capability_lists: TaxonomyDefinition[];
78
+ certifications: string[];
79
+ equipment_types: string[];
80
+ specialty_materials: string[];
81
+ gear: string[];
82
+ sub_trades: string[];
83
+ /**
84
+ * What the homeowner side captures about a request.
85
+ */
86
+ qualifiers: Record<string, string[]>;
87
+ }
88
+ /**
89
+ * A job with the trade and family it sits in.
90
+ */
91
+ export interface TaxonomyJobEntry extends TaxonomyJob {
92
+ trade: string;
93
+ /**
94
+ * Undefined when the job sits directly under the trade.
95
+ */
96
+ family?: string;
97
+ }
98
+ /**
99
+ * Service Taxonomy v1, the vocabulary shared by website extraction and homeowner lead labeling.
100
+ */
101
+ export declare const SERVICE_TAXONOMY_V1: Taxonomy;
102
+ /**
103
+ * Lookups over a taxonomy: canonical slugs, aliases and the family a job is scored in.
104
+ */
105
+ export declare class ServiceTaxonomy {
106
+ private readonly taxonomy;
107
+ readonly version: string;
108
+ readonly jobs: TaxonomyJobEntry[];
109
+ private readonly bySlug;
110
+ private readonly families;
111
+ private readonly trades;
112
+ constructor(taxonomy?: Taxonomy);
113
+ job(slug: string): TaxonomyJobEntry | undefined;
114
+ isFamily(slug: string): boolean;
115
+ isTrade(slug: string): boolean;
116
+ /**
117
+ * Jobs a business website can be tagged with: not homeowner-only, not deprecated.
118
+ *
119
+ * @param trades Limit to these trades
120
+ */
121
+ extractableJobs(trades?: string[]): TaxonomyJobEntry[];
122
+ /**
123
+ * Maps a slug, alias or deprecated slug to the current canonical slug.
124
+ *
125
+ * @returns The canonical slug, or undefined when the slug is not in the taxonomy
126
+ */
127
+ resolve(slug: string): string | undefined;
128
+ /**
129
+ * The family a job is scored in, or its trade when the trade has no families.
130
+ *
131
+ * @returns The family or trade slug, or undefined when the slug is not in the taxonomy
132
+ */
133
+ familyOf(slug: string): string | undefined;
134
+ }
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ServiceTaxonomy = exports.SERVICE_TAXONOMY_V1 = void 0;
7
+ /*! Copyright (c) 2026, XAPP AI */
8
+ const v1_json_1 = __importDefault(require("./v1.json"));
9
+ /**
10
+ * Service Taxonomy v1, the vocabulary shared by website extraction and homeowner lead labeling.
11
+ */
12
+ exports.SERVICE_TAXONOMY_V1 = v1_json_1.default;
13
+ /**
14
+ * Lookups over a taxonomy: canonical slugs, aliases and the family a job is scored in.
15
+ */
16
+ class ServiceTaxonomy {
17
+ constructor(taxonomy = exports.SERVICE_TAXONOMY_V1) {
18
+ var _a, _b;
19
+ this.taxonomy = taxonomy;
20
+ this.version = taxonomy.version;
21
+ this.jobs = [];
22
+ this.families = new Set();
23
+ this.trades = new Set();
24
+ for (const trade of taxonomy.trades) {
25
+ this.trades.add(trade.slug);
26
+ for (const job of (_a = trade.jobs) !== null && _a !== void 0 ? _a : []) {
27
+ this.jobs.push(Object.assign(Object.assign({}, job), { trade: trade.slug }));
28
+ }
29
+ for (const family of (_b = trade.families) !== null && _b !== void 0 ? _b : []) {
30
+ this.families.add(family.slug);
31
+ for (const job of family.jobs) {
32
+ this.jobs.push(Object.assign(Object.assign({}, job), { trade: trade.slug, family: family.slug }));
33
+ }
34
+ }
35
+ }
36
+ this.bySlug = new Map(this.jobs.map((job) => [job.slug, job]));
37
+ }
38
+ job(slug) {
39
+ return this.bySlug.get(slug);
40
+ }
41
+ isFamily(slug) {
42
+ return this.families.has(slug);
43
+ }
44
+ isTrade(slug) {
45
+ return this.trades.has(slug);
46
+ }
47
+ /**
48
+ * Jobs a business website can be tagged with: not homeowner-only, not deprecated.
49
+ *
50
+ * @param trades Limit to these trades
51
+ */
52
+ extractableJobs(trades) {
53
+ return this.jobs.filter((job) => !job.homeowner_only && !job.deprecated_by && (!trades || trades.includes(job.trade)));
54
+ }
55
+ /**
56
+ * Maps a slug, alias or deprecated slug to the current canonical slug.
57
+ *
58
+ * @returns The canonical slug, or undefined when the slug is not in the taxonomy
59
+ */
60
+ resolve(slug) {
61
+ var _a;
62
+ let candidate = slug === null || slug === void 0 ? void 0 : slug.trim().toLowerCase();
63
+ if (!candidate) {
64
+ return undefined;
65
+ }
66
+ candidate = (_a = this.taxonomy.aliases[candidate]) !== null && _a !== void 0 ? _a : candidate;
67
+ if (!this.bySlug.has(candidate)) {
68
+ const prefix = Object.keys(this.taxonomy.alias_prefixes).find((p) => candidate.startsWith(p));
69
+ if (prefix) {
70
+ candidate = this.taxonomy.alias_prefixes[prefix] + candidate.slice(prefix.length);
71
+ }
72
+ }
73
+ // Follow deprecations, guarding against a cycle
74
+ const seen = new Set();
75
+ let job = this.bySlug.get(candidate);
76
+ while ((job === null || job === void 0 ? void 0 : job.deprecated_by) && !seen.has(job.slug)) {
77
+ seen.add(job.slug);
78
+ job = this.bySlug.get(job.deprecated_by);
79
+ }
80
+ return job === null || job === void 0 ? void 0 : job.slug;
81
+ }
82
+ /**
83
+ * The family a job is scored in, or its trade when the trade has no families.
84
+ *
85
+ * @returns The family or trade slug, or undefined when the slug is not in the taxonomy
86
+ */
87
+ familyOf(slug) {
88
+ var _a;
89
+ const canonical = this.resolve(slug);
90
+ const job = canonical ? this.bySlug.get(canonical) : undefined;
91
+ return job ? (_a = job.family) !== null && _a !== void 0 ? _a : job.trade : undefined;
92
+ }
93
+ }
94
+ exports.ServiceTaxonomy = ServiceTaxonomy;
95
+ //# sourceMappingURL=ServiceTaxonomy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceTaxonomy.js","sourceRoot":"","sources":["../../src/taxonomy/ServiceTaxonomy.ts"],"names":[],"mappings":";;;;;;AAAA,kCAAkC;AAClC,wDAA2B;AAyG3B;;GAEG;AACU,QAAA,mBAAmB,GAAa,iBAAE,CAAC;AAEhD;;GAEG;AACH,MAAa,eAAe;IAWxB,YAA6B,WAAqB,2BAAmB;;QAAxC,aAAQ,GAAR,QAAQ,CAAgC;QACjE,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,GA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