dwelldelta-mcp 0.4.0 → 0.7.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/LICENSE +12 -4
- package/README.md +51 -12
- package/area-rents-tool.mjs +178 -0
- package/contribute-tool.mjs +139 -0
- package/package.json +11 -2
- package/sale-prices-tool.mjs +145 -0
- package/server.mjs +98 -5
- package/tools.mjs +1 -1
- package/vendor/contribute.mjs +109 -0
- package/vendor/indicators.json +229 -20
- package/vendor/nsw-rents.json +7609 -0
- package/vendor/nsw-sales.json +17888 -0
- package/vendor/nsw-suburbs.json +1 -0
- package/vendor/qld-rents.json +5926 -0
- package/vendor/rents-index.json +25 -17
- package/vendor/vic-rents.json +1425 -0
- package/vendor/wa-rents.json +5310 -0
- package/vic-rents-tool.mjs +97 -0
package/LICENSE
CHANGED
|
@@ -20,7 +20,15 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
22
|
|
|
23
|
-
The data files in vendor/ (rents-index.json, indicators.json
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
The data files in vendor/ (rents-index.json, indicators.json, nsw-suburbs.json, vic-rents.json,
|
|
24
|
+
nsw-rents.json, qld-rents.json, wa-rents.json, nsw-sales.json) are
|
|
25
|
+
not covered by this licence. Each figure keeps its source's own licence and
|
|
26
|
+
attribution, which the data files and every answer state (for example, ABS data:
|
|
27
|
+
CC BY 4.0, "Based on Australian Bureau of Statistics data"; the NSW suburb list:
|
|
28
|
+
CC BY 3.0 AU, NSW Spatial Services; Victorian rents: CC BY 4.0, Homes Victoria;
|
|
29
|
+
NSW rents: CC BY 4.0, State of New South Wales (Department of Communities and
|
|
30
|
+
Justice); Queensland rents: CC BY 4.0, The State of Queensland (Residential
|
|
31
|
+
Tenancies Authority); WA rents: based on WA Rental Bonds Data, CC BY 4.0,
|
|
32
|
+
Government of Western Australia, with medians calculated by DwellDelta;
|
|
33
|
+
NSW sale prices: CC BY 4.0, State of New South Wales (Department of
|
|
34
|
+
Communities and Justice)).
|
package/README.md
CHANGED
|
@@ -1,21 +1,47 @@
|
|
|
1
1
|
# dwelldelta-mcp - is an Australian rent fair?
|
|
2
2
|
|
|
3
|
-
An MCP server that lets an AI assistant check a weekly rent against the ABS rents index,
|
|
4
|
-
Australian property and lending indicators. From
|
|
5
|
-
Xcelerent Pty Ltd, built on public data.
|
|
3
|
+
An MCP server that lets an AI assistant check a weekly rent against the ABS rents index, look up median rents
|
|
4
|
+
by area in four states and NSW median sale prices, and quote sourced Australian property and lending indicators. From
|
|
5
|
+
[DwellDelta](https://dwelldelta.com.au/), a service of Xcelerent Pty Ltd, built on public data.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Six read-only tools, and one that adds the user's own rent when they ask:
|
|
8
8
|
|
|
9
9
|
| Tool | What it answers |
|
|
10
10
|
|---|---|
|
|
11
11
|
| `rent_check` | a weekly rent, and any proposed new rent, against the ABS rents index for the capital city since the lease began (the same arithmetic as the rent check at tools.dwelldelta.com.au) |
|
|
12
12
|
| `market_indicators` | the latest RBA cash rate, unemployment, wage growth, rents for all eight capitals, NSW lending, lending standards and arrears, approvals and completions - each with period, source, licence and limits; filter by `geography` |
|
|
13
|
+
| `vic_rents` | Victorian rents by suburb group from Homes Victoria's Rental Report: the median weekly rent of new leases, the lease count and the change on a year before, for 146 suburb groups and 13 regions; filter by `suburb_group` or `region` (from 0.5.0) |
|
|
14
|
+
| `area_rents` | median weekly rent of new bonds, all dwellings together, with the bond count and the change on a year before, for one state per call: NSW by postcode or council (NSW Department of Communities and Justice), Queensland by suburb or council (Residential Tenancies Authority), WA by locality (calculated by DwellDelta from the Government of Western Australia's bond records); each CC BY 4.0 (from 0.6.0) |
|
|
15
|
+
| `nsw_sale_prices` | NSW median sale prices by postcode or council from the NSW Department of Communities and Justice's Rent and Sales Report (CC BY 4.0): the median, the quartiles, the number of sales and the change on a year before, each for all dwellings, houses (non-strata) and units and town houses (strata). Medians of homes sold - never what any one home sold for; a line a few very large sales have set is marked UNUSUAL (from 0.7.0) |
|
|
13
16
|
| `data_sources` | the sources, their licences, and what DwellDelta cannot answer |
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
| `contribute_rent` | adds the user's own rent, anonymously, to DwellDelta's suburb benchmarks - only when the user asks, and only after they have read and agreed to the consent wording (from 0.5.0) |
|
|
18
|
+
|
|
19
|
+
It runs on your own machine over stdio. It records nothing and sends nothing about you unless you choose to add
|
|
20
|
+
your rent. At start it fetches the week's indicators from tools.dwelldelta.com.au - one request for one public
|
|
21
|
+
file; nothing about you or your questions is sent - and otherwise uses the copy it ships with. Set
|
|
22
|
+
`DWELLDELTA_OFFLINE=1` and that fetch is not made. Nothing it says is a forecast, a valuation or advice.
|
|
23
|
+
|
|
24
|
+
## Adding a rent (from 0.5.0)
|
|
25
|
+
|
|
26
|
+
`contribute_rent` is the one tool that can send anything, and it takes two calls. The first stores and sends
|
|
27
|
+
nothing: it returns the consent wording, the [Contributor Terms](https://tools.dwelldelta.com.au/terms/) and
|
|
28
|
+
[Privacy Notice](https://tools.dwelldelta.com.au/privacy/), and a token. Only when the assistant has shown you
|
|
29
|
+
that wording and you have said yes does it call again, with the token. What is then stored, in AWS Sydney, is the
|
|
30
|
+
suburb, home type, bedrooms, rent, lease month and lease kind, and whether it is a rent you pay or the rent of a
|
|
31
|
+
property you own - never an address, name or email. You get a deletion code; email it to lingtao@xcelerent.com
|
|
32
|
+
and the record is deleted. Only your own rent may be added: an assistant must not add a figure it read on a
|
|
33
|
+
website or a listing.
|
|
34
|
+
|
|
35
|
+
## NSW sale prices (from 0.7.0)
|
|
36
|
+
|
|
37
|
+
`nsw_sale_prices` gives DCJ's medians for the dwellings sold in a quarter - not asking prices, not valuations,
|
|
38
|
+
and never the price or value of any one home; no individual sale is in the data. Every answer names the dwelling
|
|
39
|
+
type, because a sale price without it answers nobody's question, and carries the quarter, DCJ's source line and
|
|
40
|
+
its limits. DCJ reports a quarter when about 80% of its sales have been notified, so the counts are incomplete
|
|
41
|
+
and the sales quarter runs behind the rents quarter. DCJ's own table has rows that a few very large sales, or
|
|
42
|
+
many sales at one identical price, have set: the answer marks those lines UNUSUAL and says not to quote them as
|
|
43
|
+
a going price. Prices in the structured result stay in DCJ's unit, thousands of dollars, and `unit` says so.
|
|
44
|
+
The feed is public at <https://tools.dwelldelta.com.au/market/nsw-sales.json>.
|
|
19
45
|
|
|
20
46
|
## Use it
|
|
21
47
|
|
|
@@ -35,8 +61,20 @@ Claude Desktop - add to `claude_desktop_config.json`:
|
|
|
35
61
|
Claude Code: `claude mcp add dwelldelta -- npx -y dwelldelta-mcp`. Any other MCP client: run `npx -y dwelldelta-mcp`
|
|
36
62
|
as a stdio server. Node 18 or later.
|
|
37
63
|
|
|
38
|
-
Then ask: "Is a rise from $700 to $770 a week in Sydney since July 2025 in line with rents?"
|
|
39
|
-
unemployment doing?"
|
|
64
|
+
Then ask: "Is a rise from $700 to $770 a week in Sydney since July 2025 in line with rents?", "What is the
|
|
65
|
+
median rent of new leases in postcode 2148?" or "What is NSW unemployment doing?"
|
|
66
|
+
|
|
67
|
+
## Rents by area (from 0.6.0)
|
|
68
|
+
|
|
69
|
+
`area_rents` answers for one state at a time, because the three publishers measure in their own ways and the WA
|
|
70
|
+
medians are DwellDelta's own calculation from the Government's one-record-per-bond data. They must not be added
|
|
71
|
+
or ranked as one series. Every answer carries that state's quarter, its source line, what DwellDelta selected or
|
|
72
|
+
calculated, and its limits. These are medians of new bonds, all dwellings together - not advertised rents, not
|
|
73
|
+
what sitting tenants pay, and not the rent of a home of a given size. Where a publisher reports nothing for a
|
|
74
|
+
small area the answer says so; it never shows a zero. The feeds are public at
|
|
75
|
+
https://tools.dwelldelta.com.au/market/nsw-rents.json, `qld-rents.json` and `wa-rents.json`; the server reads them
|
|
76
|
+
at start the way it reads the indicators, and `DWELLDELTA_STATE_RENTS_DIR` points it at a folder of copies.
|
|
77
|
+
Victoria, measured differently again, stays in `vic_rents`.
|
|
40
78
|
|
|
41
79
|
It is listed in the MCP registry as `au.com.dwelldelta/dwelldelta`.
|
|
42
80
|
|
|
@@ -61,5 +99,6 @@ answer states - for example ABS data is CC BY 4.0, "Based on Australian Bureau o
|
|
|
61
99
|
|
|
62
100
|
## Development
|
|
63
101
|
|
|
64
|
-
`npm test` here starts the server and calls
|
|
102
|
+
`npm test` here starts the server and calls the six read-only tools, and the first (consent) call of
|
|
103
|
+
`contribute_rent`, over MCP; the repository's root `npm test` holds the
|
|
65
104
|
tool answers themselves and checks that `vendor/` matches its sources. `npm pack` runs `scripts/vendor.mjs` first.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* area_rents (0.6.0, 2026-10-10): rents by area for NSW (postcodes and councils, NSW Department of Communities and
|
|
3
|
+
* Justice), Queensland (suburbs and councils, Residential Tenancies Authority) and Western Australia (localities,
|
|
4
|
+
* calculated by DwellDelta from the Government's bond records), as published at
|
|
5
|
+
* tools.dwelldelta.com.au/market/{nsw,qld,wa}-rents.json - each CC BY 4.0, republishable with attribution.
|
|
6
|
+
*
|
|
7
|
+
* One state per call, never pooled: each publisher measures in its own way, and the WA medians are our own
|
|
8
|
+
* calculation, so every answer carries that state's own source line, what was changed, and its limits.
|
|
9
|
+
*
|
|
10
|
+
* Loaded like vic_rents: DWELLDELTA_STATE_RENTS_DIR (a folder holding the three files), else the owner's live store,
|
|
11
|
+
* else the published file (fetched once at start - one public file each; nothing about the user or their questions is
|
|
12
|
+
* sent - and used if well formed, for the right state, and not older than the bundled copy), else the copy bundled at
|
|
13
|
+
* pack time. DWELLDELTA_OFFLINE=1 never fetches. The data changes once a quarter, so every answer states its quarter.
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync } from "node:fs";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
import { loadJson, envelope, ToolError, FOOTER, FETCH_TIMEOUT_MS } from "./tools.mjs";
|
|
19
|
+
import { quarterKey } from "./vic-rents-tool.mjs";
|
|
20
|
+
|
|
21
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
const LIVE_DIR = join(HERE, "..", "..", "dwelldelta-data", "market");
|
|
23
|
+
export const BUNDLED_DIR = join(HERE, "vendor");
|
|
24
|
+
export const PUBLISHED_BASE = "https://tools.dwelldelta.com.au/market/";
|
|
25
|
+
export const STATES = {
|
|
26
|
+
NSW: { file: "nsw-rents.json", name: "New South Wales",
|
|
27
|
+
hint: "NSW rents are by four-digit postcode (area: \"2148\") or by council (council: \"Blacktown\")." },
|
|
28
|
+
QLD: { file: "qld-rents.json", name: "Queensland",
|
|
29
|
+
hint: "Queensland rents are by suburb, as the RTA names it (area: \"Acacia Ridge\"; part of a name works), " +
|
|
30
|
+
"or by council (council: \"Brisbane\")." },
|
|
31
|
+
WA: { file: "wa-rents.json", name: "Western Australia",
|
|
32
|
+
hint: "WA rents are by locality (area: \"Fremantle\"; part of a name works). There are no councils in the " +
|
|
33
|
+
"bond records." },
|
|
34
|
+
};
|
|
35
|
+
/** Rows shown in one answer; a wider match says how many more there are instead of dropping them silently. */
|
|
36
|
+
export const MAX_ROWS = 25;
|
|
37
|
+
|
|
38
|
+
const wellFormed = (f, state) => f && f.state === state && quarterKey(f.quarter) > 0
|
|
39
|
+
&& Array.isArray(f.areas) && f.areas.length > 0 && Array.isArray(f.councils) && Array.isArray(f.regions)
|
|
40
|
+
&& f.state_total && Array.isArray(f.limits) && f.licence && f.attribution && f.changes_made;
|
|
41
|
+
|
|
42
|
+
/** One state's feed and where it came from ("env", "live", "published" or "bundled"); { feed: null } if none. */
|
|
43
|
+
export async function loadAreaRents(state, { env = process.env, fetchImpl = globalThis.fetch, liveDir = LIVE_DIR,
|
|
44
|
+
bundledDir = BUNDLED_DIR } = {}) {
|
|
45
|
+
const { file } = STATES[state];
|
|
46
|
+
// A copy that is not this state's feed is no copy: the wrong file under the right name must never answer.
|
|
47
|
+
const read = (path) => loadJson(path).then((f) => (wellFormed(f, state) ? f : null)).catch(() => null);
|
|
48
|
+
if (env.DWELLDELTA_STATE_RENTS_DIR) return { feed: await read(join(env.DWELLDELTA_STATE_RENTS_DIR, file)), origin: "env" };
|
|
49
|
+
if (existsSync(join(liveDir, file))) return { feed: await read(join(liveDir, file)), origin: "live" };
|
|
50
|
+
const shipped = await read(join(bundledDir, file));
|
|
51
|
+
if (env.DWELLDELTA_OFFLINE !== "1" && typeof fetchImpl === "function") {
|
|
52
|
+
try {
|
|
53
|
+
const res = await fetchImpl(PUBLISHED_BASE + file, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
54
|
+
const got = res.ok ? await res.json() : null;
|
|
55
|
+
if (wellFormed(got, state) && (!shipped || quarterKey(got.quarter) >= quarterKey(shipped.quarter))) {
|
|
56
|
+
return { feed: got, origin: "published" };
|
|
57
|
+
}
|
|
58
|
+
} catch {
|
|
59
|
+
// Offline, blocked or slow: the bundled copy answers, and its quarter says how current it is.
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return { feed: shipped, origin: shipped ? "bundled" : null };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Every state's feed, loaded together at start: { NSW: feed-with-origin | null, QLD: ..., WA: ... }. */
|
|
66
|
+
export async function loadAllAreaRents(opts) {
|
|
67
|
+
const loaded = await Promise.all(Object.keys(STATES).map((s) => loadAreaRents(s, opts)));
|
|
68
|
+
return Object.fromEntries(Object.keys(STATES).map((s, i) =>
|
|
69
|
+
[s, loaded[i].feed ? { ...loaded[i].feed, origin: loaded[i].origin } : null]));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Exported for sale-prices-tool.mjs (0.7.0), which matches names and words figures the same way.
|
|
73
|
+
export const norm = (s) => String(s).trim().toLowerCase();
|
|
74
|
+
export const dollars = (v) => `$${v.toLocaleString("en-AU")}`;
|
|
75
|
+
export const signed = (v) => `${v >= 0 ? "+" : ""}${v}%`;
|
|
76
|
+
|
|
77
|
+
function line(r, name) {
|
|
78
|
+
if (r.median_weekly_rent_aud == null) {
|
|
79
|
+
const why = r.withheld ?? (r.new_bonds == null ? "too few bonds"
|
|
80
|
+
: `${r.new_bonds} new bond${r.new_bonds === 1 ? "" : "s"} - too few for a median`);
|
|
81
|
+
return `${name}: no median (${why}).`;
|
|
82
|
+
}
|
|
83
|
+
const bonds = r.new_bonds_band ? ` from ${r.new_bonds_band} new bonds (the publisher withholds the count)`
|
|
84
|
+
: r.new_bonds == null ? "" : ` from ${r.new_bonds.toLocaleString("en-AU")} new bonds`;
|
|
85
|
+
const change = r.change_pct == null ? ""
|
|
86
|
+
: r.year_ago_median_aud == null ? `, ${signed(r.change_pct)} on a year before`
|
|
87
|
+
: `, ${signed(r.change_pct)} on ${dollars(r.year_ago_median_aud)} a year before`;
|
|
88
|
+
const spread = r.first_quartile_aud == null || r.third_quartile_aud == null ? ""
|
|
89
|
+
: `; half of new bonds between ${dollars(r.first_quartile_aud)} and ${dollars(r.third_quartile_aud)}`;
|
|
90
|
+
return `${name}: ${dollars(r.median_weekly_rent_aud)} a week${bonds}${change}${spread}` +
|
|
91
|
+
`${r.small_sample ? " (small sample: treat with caution)" : ""}.`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Exact name first, so "Brighton" does not drag in "Brighton East"; otherwise every name containing the words. */
|
|
95
|
+
export function match(rows, key, wanted) {
|
|
96
|
+
const exact = rows.filter((r) => norm(r[key]) === norm(wanted));
|
|
97
|
+
return exact.length ? exact : rows.filter((r) => norm(r[key]).includes(norm(wanted)));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* People ask NSW by suburb, and DCJ reports by postcode. For a name that matched no postcode: the suburbs of that name
|
|
102
|
+
* in the NSW suburb list ("Parramatta (2150)", already shipped for contribute_rent), with the postcodes this feed
|
|
103
|
+
* holds - offered as the next step, never answered silently, because a postcode's median is not a suburb's.
|
|
104
|
+
*/
|
|
105
|
+
export function nswPostcodes(wanted, suburbs, feed) {
|
|
106
|
+
const held = new Set(feed.areas.map((r) => r.area));
|
|
107
|
+
const named = suburbs.map((s) => /^(.*) \((\d{4})\)$/.exec(s)).filter((m) => m && held.has(m[2]));
|
|
108
|
+
const exact = named.filter((m) => norm(m[1]) === norm(wanted));
|
|
109
|
+
const found = exact.length ? exact : named.filter((m) => norm(m[1]).includes(norm(wanted)));
|
|
110
|
+
return found.slice(0, 5).map((m) => `${m[1]} is in postcode ${m[2]}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** area_rents: one state; an area (postcode, suburb or locality), a council, or neither for the state's own row. */
|
|
114
|
+
export function areaRentsResult({ state, area, council } = {}, feeds, now = new Date(), { nswSuburbs = [] } = {}) {
|
|
115
|
+
const info = STATES[state];
|
|
116
|
+
if (!info) {
|
|
117
|
+
throw new ToolError(`No area rents for ${JSON.stringify(state)}.`,
|
|
118
|
+
`Call area_rents with state NSW, QLD or WA. Victoria is in vic_rents; South Australia, Tasmania, the ACT and ` +
|
|
119
|
+
`the Northern Territory are not covered.`);
|
|
120
|
+
}
|
|
121
|
+
const feed = feeds[state];
|
|
122
|
+
if (!feed) {
|
|
123
|
+
throw new ToolError(`The ${info.name} rents feed is not on this machine.`,
|
|
124
|
+
`Point DWELLDELTA_STATE_RENTS_DIR at a folder holding a copy of ${PUBLISHED_BASE}${info.file}.`);
|
|
125
|
+
}
|
|
126
|
+
const kind = feed.area_kind;
|
|
127
|
+
let areas = [], councils = [], regions = [];
|
|
128
|
+
if (area != null && String(area).trim()) {
|
|
129
|
+
areas = match(feed.areas, "area", area);
|
|
130
|
+
if (!areas.length) {
|
|
131
|
+
const named = state === "NSW" ? nswPostcodes(area, nswSuburbs, feed) : [];
|
|
132
|
+
throw new ToolError(`No ${info.name} ${kind} matches ${JSON.stringify(area)}.`,
|
|
133
|
+
`${info.hint} ${feed.areas.length.toLocaleString("en-AU")} ${kind} rows are held.` +
|
|
134
|
+
(named.length ? ` In the NSW suburb list (NSW Spatial Services, CC BY 3.0 AU): ${named.join("; ")}. Call ` +
|
|
135
|
+
"again with that postcode, and say the figure is for the whole postcode, not the suburb alone." : ""));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (council != null && String(council).trim()) {
|
|
139
|
+
councils = match(feed.councils, "council", council);
|
|
140
|
+
if (!councils.length) {
|
|
141
|
+
throw new ToolError(`No ${info.name} council matches ${JSON.stringify(council)}.`,
|
|
142
|
+
feed.councils.length ? `Try part of a council's name; ${feed.councils.length} councils are held. ${info.hint}` : info.hint);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const whole = !areas.length && !councils.length;
|
|
146
|
+
if (whole) regions = feed.regions;
|
|
147
|
+
const dropped = [];
|
|
148
|
+
for (const [label, rows] of [[kind, areas], ["council", councils]]) {
|
|
149
|
+
if (rows.length > MAX_ROWS) dropped.push(`${rows.length - MAX_ROWS} more ${label} rows match: narrow the name.`);
|
|
150
|
+
}
|
|
151
|
+
areas = areas.slice(0, MAX_ROWS);
|
|
152
|
+
councils = councils.slice(0, MAX_ROWS);
|
|
153
|
+
const env = envelope({ sources: [{ source: feed.source, licence: feed.licence, attribution: feed.attribution }],
|
|
154
|
+
dataAsOf: feed.quarter, origin: feed.origin ?? null }, now);
|
|
155
|
+
const text = [
|
|
156
|
+
`${feed.what}. Quarter: ${feed.quarter}, against ${feed.compared_with}.`,
|
|
157
|
+
"",
|
|
158
|
+
...(whole ? [line(feed.state_total, `${info.name} (whole state)`)] : []),
|
|
159
|
+
...regions.map((r) => line(r, `${r.region} (region)`)),
|
|
160
|
+
...councils.map((r) => line(r, `${r.council} (council)`)),
|
|
161
|
+
...areas.map((r) => line(r, `${r.area} (${kind})`)),
|
|
162
|
+
...dropped,
|
|
163
|
+
...(whole ? ["", `${feed.areas.length.toLocaleString("en-AU")} ${kind} rows` +
|
|
164
|
+
`${feed.councils.length ? ` and ${feed.councils.length} councils` : ""} are available: call again with area` +
|
|
165
|
+
`${feed.councils.length ? " or council" : ""}.`] : []),
|
|
166
|
+
"",
|
|
167
|
+
"Limits:",
|
|
168
|
+
...feed.limits.map((l) => "- " + l),
|
|
169
|
+
"",
|
|
170
|
+
`Source: ${feed.attribution}`,
|
|
171
|
+
`What DwellDelta changed: ${feed.changes_made}`,
|
|
172
|
+
FOOTER,
|
|
173
|
+
].join("\n");
|
|
174
|
+
return { text, structured: { ...env, state, state_name: info.name, area_kind: kind, quarter: feed.quarter,
|
|
175
|
+
compared_with: feed.compared_with, derived: feed.derived === true,
|
|
176
|
+
state_total: whole ? feed.state_total : null, regions, councils, areas,
|
|
177
|
+
truncated: dropped.length > 0, limits: feed.limits, changes_made: feed.changes_made } };
|
|
178
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* contribute_rent: the AI-assistant route into the rent contributions the rent check page collects (2026-09-30,
|
|
3
|
+
* control advisory 2026-09-30-ai-agents-contribute-data.md). Same fields, same checks, same endpoint, same terms,
|
|
4
|
+
* same deletion code as the page - vendored from rent/contribute.mjs so the two cannot disagree.
|
|
5
|
+
*
|
|
6
|
+
* CONNECTED since 2026-10-03, on the owner's word (terms in force on the owner's approval; legal/status.json says
|
|
7
|
+
* so). TERMS_URL and PRIVACY_URL name the pages rendered from legal/. With no endpoint - set
|
|
8
|
+
* CONTRIBUTION_ENDPOINT back to null - every call says contributions are not being collected and nothing is
|
|
9
|
+
* stored or sent.
|
|
10
|
+
*
|
|
11
|
+
* Consent takes two calls, because an assistant cannot agree to terms; its user must:
|
|
12
|
+
* 1. Without a consent_token, nothing is stored or sent. The answer is the consent text, the terms' addresses
|
|
13
|
+
* and a one-use token, valid for TOKEN_MINUTES and bound to exactly these details.
|
|
14
|
+
* 2. The assistant shows the text to its user. Only if the user says yes does it call again with the same
|
|
15
|
+
* details, the token and user_agreed: true. The answer carries the deletion code for the user.
|
|
16
|
+
* The server cannot see the conversation, so this proves the text was fetched, not that it was read; the review
|
|
17
|
+
* brief (legal/REVIEW-BRIEF.md, question 6) asks whether that is enough.
|
|
18
|
+
*/
|
|
19
|
+
import { randomBytes as nodeRandomBytes } from "node:crypto";
|
|
20
|
+
import { ToolError, FOOTER } from "./tools.mjs";
|
|
21
|
+
import {
|
|
22
|
+
validateContribution, deletionCode, hashCode, payload, submitContribution, CONTRIBUTION_ENDPOINT, CONSENT, WHOSE,
|
|
23
|
+
TERMS_VERSION,
|
|
24
|
+
} from "./vendor/contribute.mjs";
|
|
25
|
+
|
|
26
|
+
// The published pages (tools/render-legal.mjs renders them from legal/). Set, but the tool still refuses while
|
|
27
|
+
// CONTRIBUTION_ENDPOINT is null - and tests/legal.test.mjs refuses an endpoint while the terms are a draft.
|
|
28
|
+
export const TERMS_URL = "https://tools.dwelldelta.com.au/terms/";
|
|
29
|
+
export const PRIVACY_URL = "https://tools.dwelldelta.com.au/privacy/";
|
|
30
|
+
export const TOKEN_MINUTES = 30;
|
|
31
|
+
export const DELETE_BY = "lingtao@xcelerent.com";
|
|
32
|
+
|
|
33
|
+
export const NOT_COLLECTING = "Contributions are not being collected yet, so nothing was stored or sent.";
|
|
34
|
+
export const WHOSE_REFUSAL = "Only the user's own rent can be added: their own tenancy, or a property they own. " +
|
|
35
|
+
"A figure read on a website, in a listing or from anyone else cannot be added.";
|
|
36
|
+
|
|
37
|
+
// The tool's own instruction to every assistant, repeated in its description (server.mjs).
|
|
38
|
+
export const INSTRUCTION = "Call only when the user has asked to add their rent, or has said yes to the consent " +
|
|
39
|
+
"text. Never add a rent on the user's behalf by default, never batch, and never add a figure found online.";
|
|
40
|
+
|
|
41
|
+
/** The details as the page would record them, from the tool's argument names. */
|
|
42
|
+
function toRecordInput(a) {
|
|
43
|
+
return {
|
|
44
|
+
suburb: a.suburb, homeType: a.home_type, bedrooms: a.bedrooms, currentRent: a.current_rent,
|
|
45
|
+
proposedRent: a.proposed_rent ?? null, leaseStart: a.lease_start, leaseKind: a.lease_kind,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Suburbs whose name contains what was typed, for the next step when a suburb is not recognised. */
|
|
50
|
+
function nearest(typed, suburbs, limit = 5) {
|
|
51
|
+
const t = String(typed ?? "").trim().toLowerCase().replace(/\s*\(\d{4}\)\s*$/, "");
|
|
52
|
+
if (!t) return [];
|
|
53
|
+
return suburbs.filter((s) => s.toLowerCase().startsWith(t)).slice(0, limit)
|
|
54
|
+
.concat(suburbs.filter((s) => !s.toLowerCase().startsWith(t) && s.toLowerCase().includes(t)))
|
|
55
|
+
.slice(0, limit);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Returns contributeRent(args) -> Promise<{ text, structured }>, or rejects with a ToolError naming the next step.
|
|
60
|
+
* deps are injectable so tests run without a network: endpoint, termsUrl, privacyUrl, fetchImpl, now, randomBytes.
|
|
61
|
+
*/
|
|
62
|
+
export function makeContributeTool({
|
|
63
|
+
suburbs, endpoint = CONTRIBUTION_ENDPOINT, termsUrl = TERMS_URL, privacyUrl = PRIVACY_URL,
|
|
64
|
+
fetchImpl = globalThis.fetch, now = () => new Date(), randomBytes = (n) => new Uint8Array(nodeRandomBytes(n)),
|
|
65
|
+
} = {}) {
|
|
66
|
+
const tokens = new Map(); // token -> { key, expires }; in this process's memory only
|
|
67
|
+
|
|
68
|
+
return async function contributeRent(args) {
|
|
69
|
+
if (!endpoint || !termsUrl || !privacyUrl) {
|
|
70
|
+
throw new ToolError(NOT_COLLECTING, "Tell the user, and thank them for offering; there is nothing to retry.");
|
|
71
|
+
}
|
|
72
|
+
if (!WHOSE.includes(args.whose)) {
|
|
73
|
+
throw new ToolError(WHOSE_REFUSAL, `Use whose = ${WHOSE.join(" or ")} only when that is true; otherwise do not add it.`);
|
|
74
|
+
}
|
|
75
|
+
const t = now();
|
|
76
|
+
let record;
|
|
77
|
+
try {
|
|
78
|
+
record = validateContribution(toRecordInput(args), suburbs, t.toISOString().slice(0, 7));
|
|
79
|
+
} catch (err) {
|
|
80
|
+
const near = /suburb/.test(err.message) ? nearest(args.suburb, suburbs) : [];
|
|
81
|
+
throw new ToolError(`Not added: ${err.message}.`, near.length
|
|
82
|
+
? `Ask the user which suburb, then call again with its exact name, e.g. ${near.map((s) => `"${s}"`).join(", ")}.`
|
|
83
|
+
: "Ask the user for the missing or corrected detail, then call again. Nothing was stored.");
|
|
84
|
+
}
|
|
85
|
+
const key = JSON.stringify({ record, whose: args.whose });
|
|
86
|
+
|
|
87
|
+
if (!args.consent_token) {
|
|
88
|
+
for (const [k, v] of tokens) if (v.expires <= t.getTime()) tokens.delete(k);
|
|
89
|
+
const token = [...randomBytes(16)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
90
|
+
tokens.set(token, { key, expires: t.getTime() + TOKEN_MINUTES * 60000 });
|
|
91
|
+
const consent = `${CONSENT.heading} ${CONSENT.body} By adding it you agree to the Contributor Terms ` +
|
|
92
|
+
`(${termsUrl}) and Privacy Notice (${privacyUrl}), version ${TERMS_VERSION}.`;
|
|
93
|
+
const text = [
|
|
94
|
+
"NOTHING HAS BEEN STORED OR SENT. Show the user this text, word for word, and ask whether to add their rent:",
|
|
95
|
+
"",
|
|
96
|
+
consent,
|
|
97
|
+
"",
|
|
98
|
+
`Only if they say yes, call contribute_rent again with the same details, consent_token "${token}" and ` +
|
|
99
|
+
`user_agreed: true, within ${TOKEN_MINUTES} minutes. If they say no, do nothing further.`,
|
|
100
|
+
"",
|
|
101
|
+
FOOTER,
|
|
102
|
+
].join("\n");
|
|
103
|
+
return { text, structured: { stored: false, consent_text: consent, terms_url: termsUrl, privacy_url: privacyUrl,
|
|
104
|
+
terms_version: TERMS_VERSION,
|
|
105
|
+
consent_token: token, expires_in_minutes: TOKEN_MINUTES } };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const entry = tokens.get(args.consent_token);
|
|
109
|
+
const again = "Call contribute_rent without a consent_token to get the consent text, and show it to the user.";
|
|
110
|
+
if (!entry || entry.expires <= t.getTime()) {
|
|
111
|
+
tokens.delete(args.consent_token);
|
|
112
|
+
throw new ToolError("Not added: that consent token is unknown, used or expired.", again);
|
|
113
|
+
}
|
|
114
|
+
if (entry.key !== key) {
|
|
115
|
+
throw new ToolError("Not added: the details differ from the ones the consent was shown for.", again);
|
|
116
|
+
}
|
|
117
|
+
if (args.user_agreed !== true) {
|
|
118
|
+
throw new ToolError("Not added: user_agreed is not true.",
|
|
119
|
+
"Set user_agreed: true only if the user said yes to the consent text; if they did not, do nothing further.");
|
|
120
|
+
}
|
|
121
|
+
tokens.delete(args.consent_token); // one use, whatever happens next
|
|
122
|
+
|
|
123
|
+
const code = deletionCode(randomBytes(12));
|
|
124
|
+
const body = { ...payload(record, await hashCode(code), t.toISOString().slice(0, 10)), whose: args.whose };
|
|
125
|
+
try {
|
|
126
|
+
await submitContribution(body, { endpoint, fetchImpl });
|
|
127
|
+
} catch (err) {
|
|
128
|
+
throw new ToolError(`Not added: ${err.message}.`, "Tell the user it was not added. Do not retry automatically.");
|
|
129
|
+
}
|
|
130
|
+
const text = [
|
|
131
|
+
`Added. The user's deletion code is ${code} - give it to them now; it is shown once and cannot be recovered.`,
|
|
132
|
+
`To have this rent deleted, they email the code to ${DELETE_BY}.`,
|
|
133
|
+
"DwellDelta publishes only medians built from 10 or more rents, so no one rent can be picked out.",
|
|
134
|
+
"",
|
|
135
|
+
FOOTER,
|
|
136
|
+
].join("\n");
|
|
137
|
+
return { text, structured: { stored: true, deletion_code: code, delete_by_emailing: DELETE_BY } };
|
|
138
|
+
};
|
|
139
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dwelldelta-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Is an Australian rent fair? A rent check on the ABS rents index,
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Is an Australian rent fair? A rent check on the ABS rents index, rents by area for four states, NSW median sale prices, and sourced property and lending indicators, for AI agents.",
|
|
5
5
|
"mcpName": "au.com.dwelldelta/dwelldelta",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://dwelldelta.com.au/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/xcelerent/dwelldelta-tools.git",
|
|
11
|
+
"directory": "mcp"
|
|
12
|
+
},
|
|
8
13
|
"author": "DwellDelta, a service of Xcelerent Pty Ltd",
|
|
9
14
|
"type": "module",
|
|
10
15
|
"engines": {
|
|
@@ -16,6 +21,10 @@
|
|
|
16
21
|
"files": [
|
|
17
22
|
"server.mjs",
|
|
18
23
|
"tools.mjs",
|
|
24
|
+
"contribute-tool.mjs",
|
|
25
|
+
"vic-rents-tool.mjs",
|
|
26
|
+
"area-rents-tool.mjs",
|
|
27
|
+
"sale-prices-tool.mjs",
|
|
19
28
|
"vendor/",
|
|
20
29
|
"LICENSE",
|
|
21
30
|
"README.md"
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nsw_sale_prices (0.7.0): NSW median sale prices by postcode and council, from the NSW Department of Communities and
|
|
3
|
+
* Justice's Rent and Sales Report, sales tables, as published at tools.dwelldelta.com.au/market/nsw-sales.json
|
|
4
|
+
* (CC BY 4.0, republishable with attribution; DCJ's licence re-read for the sales tables on 2026-10-10).
|
|
5
|
+
*
|
|
6
|
+
* Medians of the dwellings SOLD in a quarter, by dwelling type - never the price or value of any one home, and never an
|
|
7
|
+
* individual sale. Three things this tool will not let an agent miss:
|
|
8
|
+
* - a sale price without its dwelling type answers nobody's question, so every area is given as all dwellings,
|
|
9
|
+
* non-strata (separate houses) and strata (units, town houses, villas), each labelled;
|
|
10
|
+
* - DCJ's own table has rows that a few unusual sales set (postcode 2034, strata, March 2026: $8.954m, up 478%, from
|
|
11
|
+
* 184 sales). The feed marks them `unusual_prices`; the answer says UNUSUAL in words, on that line, with the reason;
|
|
12
|
+
* - a gap is said with its reason and is never shown as zero.
|
|
13
|
+
*
|
|
14
|
+
* The feed keeps DCJ's unit (thousands of dollars) and so does the structured result, which says so; the text writes
|
|
15
|
+
* the same figure out in dollars, to the thousand DCJ reports.
|
|
16
|
+
*
|
|
17
|
+
* Loaded like the rents feeds: DWELLDELTA_STATE_RENTS_DIR (a folder holding copies of the feeds), else the owner's
|
|
18
|
+
* live store, else the published file (fetched once at start - one public file; nothing about the user or their
|
|
19
|
+
* questions is sent - and used if well formed and not older than the bundled copy), else the copy bundled at pack
|
|
20
|
+
* time. DWELLDELTA_OFFLINE=1 never fetches.
|
|
21
|
+
*/
|
|
22
|
+
import { existsSync } from "node:fs";
|
|
23
|
+
import { fileURLToPath } from "node:url";
|
|
24
|
+
import { dirname, join } from "node:path";
|
|
25
|
+
import { loadJson, envelope, ToolError, FOOTER, FETCH_TIMEOUT_MS } from "./tools.mjs";
|
|
26
|
+
import { quarterKey } from "./vic-rents-tool.mjs";
|
|
27
|
+
import { signed, match, nswPostcodes, MAX_ROWS, BUNDLED_DIR, PUBLISHED_BASE } from "./area-rents-tool.mjs";
|
|
28
|
+
|
|
29
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
30
|
+
const LIVE_DIR = join(HERE, "..", "..", "dwelldelta-data", "market");
|
|
31
|
+
export const SALES_FILE = "nsw-sales.json";
|
|
32
|
+
export const DWELLING_TYPES = ["total", "non_strata", "strata"];
|
|
33
|
+
const LABEL = { total: "all dwellings", non_strata: "houses (non-strata)", strata: "units and town houses (strata)" };
|
|
34
|
+
const HINT = "NSW sale prices are by four-digit postcode (area: \"2148\") or by council (council: \"Blacktown\").";
|
|
35
|
+
|
|
36
|
+
const wellFormed = (f) => f && f.state === "NSW" && f.measure === "sale_price" && quarterKey(f.quarter) > 0
|
|
37
|
+
&& Array.isArray(f.areas) && f.areas.length > 0 && Array.isArray(f.councils) && f.state_total?.total
|
|
38
|
+
&& Array.isArray(f.limits) && f.licence && f.attribution && f.changes_made && f.unit;
|
|
39
|
+
|
|
40
|
+
/** The feed and where it came from ("env", "live", "published" or "bundled"); { feed: null } if none can be read. */
|
|
41
|
+
export async function loadNswSales({ env = process.env, fetchImpl = globalThis.fetch, liveDir = LIVE_DIR,
|
|
42
|
+
bundledDir = BUNDLED_DIR } = {}) {
|
|
43
|
+
// A rents feed saved under this name is no sales feed: `measure` must say sale_price or the copy does not answer.
|
|
44
|
+
const read = (path) => loadJson(path).then((f) => (wellFormed(f) ? f : null)).catch(() => null);
|
|
45
|
+
if (env.DWELLDELTA_STATE_RENTS_DIR) return { feed: await read(join(env.DWELLDELTA_STATE_RENTS_DIR, SALES_FILE)), origin: "env" };
|
|
46
|
+
if (existsSync(join(liveDir, SALES_FILE))) return { feed: await read(join(liveDir, SALES_FILE)), origin: "live" };
|
|
47
|
+
const shipped = await read(join(bundledDir, SALES_FILE));
|
|
48
|
+
if (env.DWELLDELTA_OFFLINE !== "1" && typeof fetchImpl === "function") {
|
|
49
|
+
try {
|
|
50
|
+
const res = await fetchImpl(PUBLISHED_BASE + SALES_FILE, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
51
|
+
const got = res.ok ? await res.json() : null;
|
|
52
|
+
if (wellFormed(got) && (!shipped || quarterKey(got.quarter) >= quarterKey(shipped.quarter))) {
|
|
53
|
+
return { feed: got, origin: "published" };
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
// Offline, blocked or slow: the bundled copy answers, and its quarter says how current it is.
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { feed: shipped, origin: shipped ? "bundled" : null };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** 1033 (thousands, as DCJ reports) -> "$1,033,000". */
|
|
63
|
+
const price = (k) => `$${(k * 1000).toLocaleString("en-AU")}`;
|
|
64
|
+
|
|
65
|
+
function line(r, name, type) {
|
|
66
|
+
const label = `${name}, ${LABEL[type]}`;
|
|
67
|
+
if (r == null) return `${label}: no row in DCJ's table.`;
|
|
68
|
+
if (r.median_price_k_aud == null) return `${label}: no median (${r.withheld ?? "not reported"}).`;
|
|
69
|
+
const sales = r.sales_band ? ` from ${r.sales_band} sales (DCJ withholds the count)`
|
|
70
|
+
: r.sales == null ? "" : ` from ${r.sales.toLocaleString("en-AU")} sales`;
|
|
71
|
+
const change = r.change_pct == null ? "" : `, ${signed(r.change_pct)} on a year before`;
|
|
72
|
+
const spread = r.first_quartile_k_aud == null || r.third_quartile_k_aud == null ? ""
|
|
73
|
+
: `; half of sales between ${price(r.first_quartile_k_aud)} and ${price(r.third_quartile_k_aud)}`;
|
|
74
|
+
return `${label}: median ${price(r.median_price_k_aud)}${sales}${change}${spread}` +
|
|
75
|
+
`${r.small_sample ? " (small sample: treat with caution)" : ""}.` +
|
|
76
|
+
`${r.unusual_prices ? ` UNUSUAL - ${r.unusual_prices}: do not quote this as the going price of a home there.` : ""}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** nsw_sale_prices: a postcode, a council, or neither for the state; optionally one dwelling type. */
|
|
80
|
+
export function salePricesResult({ area, council, dwelling_type } = {}, feed, now = new Date(), { nswSuburbs = [] } = {}) {
|
|
81
|
+
if (!feed) {
|
|
82
|
+
throw new ToolError("The NSW sale prices feed is not on this machine.",
|
|
83
|
+
`Point DWELLDELTA_STATE_RENTS_DIR at a folder holding a copy of ${PUBLISHED_BASE}${SALES_FILE}.`);
|
|
84
|
+
}
|
|
85
|
+
if (dwelling_type != null && !DWELLING_TYPES.includes(dwelling_type)) {
|
|
86
|
+
throw new ToolError(`No dwelling type ${JSON.stringify(dwelling_type)}.`,
|
|
87
|
+
`Use one of ${DWELLING_TYPES.join(", ")} - or leave it out for all three.`);
|
|
88
|
+
}
|
|
89
|
+
const types = dwelling_type ? [dwelling_type] : DWELLING_TYPES;
|
|
90
|
+
let areas = [], councils = [];
|
|
91
|
+
if (area != null && String(area).trim()) {
|
|
92
|
+
areas = match(feed.areas, "area", area);
|
|
93
|
+
if (!areas.length) {
|
|
94
|
+
const named = nswPostcodes(area, nswSuburbs, feed);
|
|
95
|
+
throw new ToolError(`No NSW postcode matches ${JSON.stringify(area)}.`,
|
|
96
|
+
`${HINT} ${feed.areas.length.toLocaleString("en-AU")} postcode rows are held.` +
|
|
97
|
+
(named.length ? ` In the NSW suburb list (NSW Spatial Services, CC BY 3.0 AU): ${named.join("; ")}. Call ` +
|
|
98
|
+
"again with that postcode, and say the figure is for the whole postcode, not the suburb alone." : ""));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (council != null && String(council).trim()) {
|
|
102
|
+
councils = match(feed.councils, "council", council);
|
|
103
|
+
if (!councils.length) {
|
|
104
|
+
throw new ToolError(`No NSW council matches ${JSON.stringify(council)}.`,
|
|
105
|
+
`Try part of a council's name; ${feed.councils.length} councils are held. ${HINT}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const whole = !areas.length && !councils.length;
|
|
109
|
+
const dropped = [];
|
|
110
|
+
for (const [label, rows] of [["postcode", areas], ["council", councils]]) {
|
|
111
|
+
if (rows.length > MAX_ROWS) dropped.push(`${rows.length - MAX_ROWS} more ${label} rows match: narrow the name.`);
|
|
112
|
+
}
|
|
113
|
+
areas = areas.slice(0, MAX_ROWS);
|
|
114
|
+
councils = councils.slice(0, MAX_ROWS);
|
|
115
|
+
const shown = [...(whole ? [["New South Wales (whole state)", feed.state_total]] : []),
|
|
116
|
+
...councils.map((g) => [`${g.council} (council)`, g]), ...areas.map((g) => [`${g.area} (postcode)`, g])];
|
|
117
|
+
const marked = shown.some(([, g]) => types.some((t) => g[t]?.unusual_prices));
|
|
118
|
+
const env = envelope({ sources: [{ source: feed.source, licence: feed.licence, attribution: feed.attribution }],
|
|
119
|
+
dataAsOf: feed.quarter, origin: feed.origin ?? null }, now);
|
|
120
|
+
const text = [
|
|
121
|
+
`${feed.what}. Quarter: ${feed.quarter}, against ${feed.compared_with}. Medians of homes sold - not asking ` +
|
|
122
|
+
"prices, not valuations, and not the price or value of any one home.",
|
|
123
|
+
"",
|
|
124
|
+
...shown.flatMap(([name, g]) => types.map((t) => line(g[t], name, t))),
|
|
125
|
+
...dropped,
|
|
126
|
+
...(whole ? ["", `${feed.areas.length.toLocaleString("en-AU")} postcode rows and ${feed.councils.length} councils ` +
|
|
127
|
+
"are available: call again with area or council."] : []),
|
|
128
|
+
...(marked ? ["", "At least one row above is marked UNUSUAL: its figure is DCJ's own, and a few very large sales " +
|
|
129
|
+
"or many sales at one identical price have set it. Say so if you mention it."] : []),
|
|
130
|
+
"",
|
|
131
|
+
"Limits:",
|
|
132
|
+
...feed.limits.map((l) => "- " + l),
|
|
133
|
+
"",
|
|
134
|
+
`Source: ${feed.attribution}`,
|
|
135
|
+
`What DwellDelta changed: ${feed.changes_made}`,
|
|
136
|
+
FOOTER,
|
|
137
|
+
].join("\n");
|
|
138
|
+
const pick = (g) => Object.fromEntries(Object.entries(g).filter(([k]) => !DWELLING_TYPES.includes(k) || types.includes(k)));
|
|
139
|
+
return { text, structured: { ...env, state: "NSW", measure: "sale_price", unit: feed.unit, area_kind: "postcode",
|
|
140
|
+
quarter: feed.quarter, compared_with: feed.compared_with,
|
|
141
|
+
dwelling_types: feed.dwelling_types ?? null,
|
|
142
|
+
state_total: whole ? pick(feed.state_total) : null,
|
|
143
|
+
councils: councils.map(pick), areas: areas.map(pick), any_unusual: marked,
|
|
144
|
+
truncated: dropped.length > 0, limits: feed.limits, changes_made: feed.changes_made } };
|
|
145
|
+
}
|