@rubytech/create-realagent-code 0.1.331 → 0.1.333
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/dist/__tests__/watchdog-deferred-arming.test.js +62 -0
- package/dist/index.js +82 -11
- package/package.json +1 -1
- package/payload/platform/lib/mcp-spawn-tee/dist/index.d.ts +24 -24
- package/payload/platform/lib/mcp-spawn-tee/dist/index.js +109 -75
- package/payload/platform/lib/mcp-spawn-tee/dist/index.js.map +1 -1
- package/payload/platform/lib/mcp-spawn-tee/src/__tests__/spawn-tee.test.ts +56 -19
- package/payload/platform/lib/mcp-spawn-tee/src/index.ts +112 -77
- package/payload/platform/neo4j/schema.cypher +58 -4
- package/payload/platform/plugins/admin/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/aeo/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/browser/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/contacts/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/contacts/mcp/dist/tools/__tests__/group-create.test.d.ts +2 -0
- package/payload/platform/plugins/contacts/mcp/dist/tools/__tests__/group-create.test.d.ts.map +1 -0
- package/payload/platform/plugins/contacts/mcp/dist/tools/__tests__/group-create.test.js +112 -0
- package/payload/platform/plugins/contacts/mcp/dist/tools/__tests__/group-create.test.js.map +1 -0
- package/payload/platform/plugins/contacts/mcp/dist/tools/__tests__/group-manage.test.d.ts +2 -0
- package/payload/platform/plugins/contacts/mcp/dist/tools/__tests__/group-manage.test.d.ts.map +1 -0
- package/payload/platform/plugins/contacts/mcp/dist/tools/__tests__/group-manage.test.js +102 -0
- package/payload/platform/plugins/contacts/mcp/dist/tools/__tests__/group-manage.test.js.map +1 -0
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-create.d.ts.map +1 -1
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-create.js +7 -2
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-create.js.map +1 -1
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-manage.d.ts.map +1 -1
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-manage.js +5 -4
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-manage.js.map +1 -1
- package/payload/platform/plugins/email/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/memory/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/memory/references/schema-estate-agent.md +17 -5
- package/payload/platform/plugins/outlook/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/quickbooks/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/replicate/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/scheduling/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/url-get/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/whatsapp/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/work/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/plugins/workflows/lib/mcp-spawn-tee/index.js +109 -75
- package/payload/platform/scripts/seed-neo4j.sh +18 -0
- package/payload/premium-plugins/real-agent/agents/listing-curator.md +20 -11
- package/payload/server/server.js +291 -213
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
|
-
* MCP spawn-tee —
|
|
4
|
+
* MCP spawn-tee — in-process stderr capture + lifecycle observability.
|
|
5
5
|
*
|
|
6
6
|
* Claude Code spawns each MCP server itself; the platform never holds a
|
|
7
|
-
* ChildProcess handle. This
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* is
|
|
7
|
+
* ChildProcess handle. This shim sits between Claude Code and the real MCP
|
|
8
|
+
* server: Claude Code runs `node <this> <real-entry>`, and the shim runs the
|
|
9
|
+
* real entry IN ITS OWN PROCESS via dynamic import() — one node runtime, not
|
|
10
|
+
* two. Before importing, it replaces process.stderr.write with a tee so every
|
|
11
|
+
* stderr byte the server writes is mirrored to the log sinks; stdin and stdout
|
|
12
|
+
* (the JSON-RPC channel) are never touched.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Claude Code CLI → shim (this file) = node running <real-entry> in-process
|
|
15
|
+
* stdin/stdout : untouched (JSON-RPC channel)
|
|
16
|
+
* stderr : process.stderr.write teed → per-date + per-session + passthrough
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
* child stdin/stdout : inherited (Claude Code pipe, untouched)
|
|
19
|
-
* child stderr : piped → per-date log + per-session log + passthrough
|
|
20
|
-
*
|
|
21
|
-
* Destinations (Task 706):
|
|
18
|
+
* Destinations (Task 706) — unchanged:
|
|
22
19
|
* - `${LOG_DIR}/mcp-<name>-stderr-<date>.log` — per-date raw (back-compat;
|
|
23
20
|
* the in-process mcp-stderr-tee and the [mcp-init-error] probe read it).
|
|
24
21
|
* - `${LOG_DIR}/mcp-<name>-<SESSION_ID>.log` — per-session raw + lifecycle
|
|
25
|
-
* lines
|
|
26
|
-
*
|
|
27
|
-
* (enumeration spawn) — then the per-date file is the fallback.
|
|
22
|
+
* lines. Authoritative sink. Absent when SESSION_ID is unset (enumeration
|
|
23
|
+
* spawn) — then the per-date file is the fallback.
|
|
28
24
|
* - `server.log` via the loopback log-ingest route — best-effort mirror of
|
|
29
|
-
* the [mcp-helper] lifecycle lines.
|
|
30
|
-
* the per-session file already holds the line (written synchronously).
|
|
25
|
+
* the [mcp-helper] lifecycle lines.
|
|
31
26
|
*
|
|
32
|
-
* Lifecycle lines, correlation key `session=<id8> server=<name
|
|
27
|
+
* Lifecycle lines, correlation key `session=<id8> server=<name>` — unchanged:
|
|
33
28
|
* [mcp-helper] op=spawn ... pid= entry=
|
|
34
29
|
* [mcp-helper] op=boot ... head=<first stderr bytes>
|
|
35
|
-
* [mcp-helper] op=exit ... code= signal= lifetimeMs= stderr-tail=
|
|
30
|
+
* [mcp-helper] op=exit ... code= signal= lifetimeMs= stderr-tail=
|
|
31
|
+
*
|
|
32
|
+
* Process model (Task 989): the shim IS the server's process. op=exit fires
|
|
33
|
+
* from process.on("exit"), so it covers a normal exit, a non-zero exit, an
|
|
34
|
+
* uncaught throw (code 1), and a catchable-signal exit (SIGTERM/SIGINT/SIGHUP,
|
|
35
|
+
* whose handlers record the signal name). An external SIGKILL is uncatchable
|
|
36
|
+
* and leaves no op=exit line — the per-session stderr tail already on disk and
|
|
37
|
+
* Claude Code's own transport-drop are the evidence for that death mode.
|
|
36
38
|
*
|
|
37
|
-
* The
|
|
38
|
-
* SIGTERM/SIGINT are forwarded to the child so a Claude Code shutdown does
|
|
39
|
-
* not orphan it; the child exit code/signal is propagated verbatim.
|
|
39
|
+
* The shim never writes to fd 1 (stdout) — that is the JSON-RPC channel.
|
|
40
40
|
*/
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
const node_child_process_1 = require("node:child_process");
|
|
43
42
|
const node_fs_1 = require("node:fs");
|
|
44
43
|
const node_path_1 = require("node:path");
|
|
44
|
+
const node_url_1 = require("node:url");
|
|
45
45
|
const SERVER_NAME = process.env.MCP_SPAWN_TEE_NAME ?? "unknown";
|
|
46
46
|
const LOG_DIR = process.env.LOG_DIR;
|
|
47
47
|
const SESSION_ID = process.env.SESSION_ID;
|
|
@@ -49,24 +49,37 @@ const PLATFORM_PORT = process.env.PLATFORM_PORT;
|
|
|
49
49
|
const ENTRY = process.argv[2];
|
|
50
50
|
const SESSION_ID8 = SESSION_ID ? SESSION_ID.slice(0, 8) : "—";
|
|
51
51
|
const spawnStamp = Date.now();
|
|
52
|
-
// Per-session raw + lifecycle log (Task 706).
|
|
53
|
-
//
|
|
52
|
+
// Per-session raw + lifecycle log (Task 706). Empty SESSION_ID (enumeration
|
|
53
|
+
// spawn) → undefined, and the per-date file is the fallback.
|
|
54
54
|
const perSessionPath = LOG_DIR && SESSION_ID
|
|
55
55
|
? (0, node_path_1.resolve)(LOG_DIR, `mcp-${SERVER_NAME}-${SESSION_ID}.log`)
|
|
56
56
|
: undefined;
|
|
57
57
|
const perDatePath = LOG_DIR
|
|
58
58
|
? (0, node_path_1.resolve)(LOG_DIR, `mcp-${SERVER_NAME}-stderr-${new Date(spawnStamp).toISOString().slice(0, 10)}.log`)
|
|
59
59
|
: undefined;
|
|
60
|
-
// Rolling tail of
|
|
60
|
+
// Rolling tail of entry stderr for op=exit. Capped so a chatty server cannot
|
|
61
61
|
// grow the buffer without bound.
|
|
62
62
|
const TAIL_CAP = 2048;
|
|
63
63
|
let stderrTail = "";
|
|
64
64
|
let bootEmitted = false;
|
|
65
|
+
let exitEmitted = false;
|
|
66
|
+
let exitSignal;
|
|
67
|
+
// The real stderr writer, captured before the tee replaces it. Lifecycle lines
|
|
68
|
+
// and stderr passthrough both go through this so they are never re-teed into
|
|
69
|
+
// the per-date sink nor recursed back into the patched writer.
|
|
70
|
+
const rawStderrWrite = process.stderr.write.bind(process.stderr);
|
|
71
|
+
// LOG_DIR is created once, lazily, on the first successful append — not per
|
|
72
|
+
// chunk. teeWrite runs on the server's own stderr hot path now, so a per-call
|
|
73
|
+
// mkdirSync would be two syscalls per log line for nothing.
|
|
74
|
+
let logDirReady = false;
|
|
65
75
|
function appendSafe(path, data) {
|
|
66
76
|
if (!path || !LOG_DIR)
|
|
67
77
|
return;
|
|
68
78
|
try {
|
|
69
|
-
(
|
|
79
|
+
if (!logDirReady) {
|
|
80
|
+
(0, node_fs_1.mkdirSync)(LOG_DIR, { recursive: true });
|
|
81
|
+
logDirReady = true;
|
|
82
|
+
}
|
|
70
83
|
(0, node_fs_1.appendFileSync)(path, data);
|
|
71
84
|
}
|
|
72
85
|
catch {
|
|
@@ -74,15 +87,16 @@ function appendSafe(path, data) {
|
|
|
74
87
|
}
|
|
75
88
|
}
|
|
76
89
|
// Best-effort mirror of a lifecycle line to server.log via the loopback
|
|
77
|
-
// log-ingest route. Fire-and-forget: the per-session file is authoritative,
|
|
78
|
-
//
|
|
90
|
+
// log-ingest route. Fire-and-forget: the per-session file is authoritative, so
|
|
91
|
+
// a dropped POST loses nothing. On the "exit" event the loop is stopping, so
|
|
92
|
+
// the op=exit mirror may not flush — the per-session line, written sync, holds.
|
|
79
93
|
function postToServerLog(suffix, level) {
|
|
80
94
|
if (!PLATFORM_PORT)
|
|
81
95
|
return;
|
|
82
96
|
try {
|
|
83
97
|
const ctrl = new AbortController();
|
|
84
98
|
const t = setTimeout(() => ctrl.abort(), 500);
|
|
85
|
-
t.unref?.(); // never let the abort timer keep the
|
|
99
|
+
t.unref?.(); // never let the abort timer keep the shim's event loop alive
|
|
86
100
|
void fetch(`http://127.0.0.1:${PLATFORM_PORT}/api/admin/log-ingest`, {
|
|
87
101
|
method: "POST",
|
|
88
102
|
headers: { "content-type": "application/json" },
|
|
@@ -95,14 +109,15 @@ function postToServerLog(suffix, level) {
|
|
|
95
109
|
}
|
|
96
110
|
}
|
|
97
111
|
// Emit one [mcp-helper] lifecycle line: authoritative per-session file (sync,
|
|
98
|
-
// survives process.exit), the
|
|
99
|
-
// visibility), and a best-effort server.log mirror.
|
|
100
|
-
// after the tag and carries no newline (the
|
|
112
|
+
// survives process.exit), the shim's own stderr via the RAW writer (journald /
|
|
113
|
+
// Claude Code visibility, never re-teed), and a best-effort server.log mirror.
|
|
114
|
+
// `suffix` is the line body after the tag and carries no newline (the
|
|
115
|
+
// log-ingest route rejects newlines).
|
|
101
116
|
function emitLifecycle(suffix, level) {
|
|
102
117
|
const line = `[mcp-helper] ${suffix}\n`;
|
|
103
118
|
appendSafe(perSessionPath, line);
|
|
104
119
|
try {
|
|
105
|
-
|
|
120
|
+
rawStderrWrite(line);
|
|
106
121
|
}
|
|
107
122
|
catch { /* stderr closed */ }
|
|
108
123
|
postToServerLog(suffix, level);
|
|
@@ -111,49 +126,68 @@ if (!ENTRY) {
|
|
|
111
126
|
emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason="no entry given (argv[2] missing)"`, "error");
|
|
112
127
|
process.exit(2);
|
|
113
128
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
// Replace process.stderr.write with a tee: mirror every server stderr byte to
|
|
130
|
+
// the per-date and per-session sinks, keep a rolling tail for op=exit, emit
|
|
131
|
+
// op=boot on the first bytes, then pass the write through to the real stderr.
|
|
132
|
+
const teeWrite = ((...args) => {
|
|
133
|
+
const chunk = args[0];
|
|
134
|
+
appendSafe(perDatePath, chunk); // per-date raw (back-compat)
|
|
135
|
+
appendSafe(perSessionPath, chunk); // per-session raw (Task 706)
|
|
136
|
+
const text = typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
|
|
137
|
+
stderrTail = (stderrTail + text).slice(-TAIL_CAP);
|
|
138
|
+
if (!bootEmitted) {
|
|
139
|
+
bootEmitted = true;
|
|
140
|
+
const head = text.split("\n")[0].slice(0, 200);
|
|
141
|
+
emitLifecycle(`op=boot session=${SESSION_ID8} server=${SERVER_NAME} head=${JSON.stringify(head)}`, "info");
|
|
142
|
+
}
|
|
143
|
+
return rawStderrWrite(...args); // passthrough
|
|
123
144
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
145
|
+
process.stderr.write = teeWrite;
|
|
146
|
+
// Catchable-signal handling. The shim drives the exit ONLY when it is the sole
|
|
147
|
+
// listener for the signal — i.e. the imported entry installed no handler of its
|
|
148
|
+
// own. In that case it records the signal (so op=exit carries signal=<sig>) and
|
|
149
|
+
// exits with 128+signum, mirroring the prior wrapper's exit-status convention.
|
|
150
|
+
//
|
|
151
|
+
// When the entry DID install a handler, the shim defers entirely and records
|
|
152
|
+
// nothing: the entry's handler decides the exit code, and op=exit reflects that
|
|
153
|
+
// exit verbatim. This matches the prior two-process model, where a child that
|
|
154
|
+
// caught the signal and exited cleanly was observed as code=0 signal=— (a clean
|
|
155
|
+
// self-exit), not as a signal death. Setting exitSignal here unconditionally
|
|
156
|
+
// would mislabel every graceful signal-driven shutdown as a signal kill.
|
|
157
|
+
function onSignal(sig, code) {
|
|
158
|
+
return () => {
|
|
159
|
+
if (process.listenerCount(sig) === 1) {
|
|
160
|
+
exitSignal = sig;
|
|
161
|
+
process.exit(code);
|
|
137
162
|
}
|
|
138
|
-
}
|
|
163
|
+
};
|
|
139
164
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
process.on("
|
|
143
|
-
process
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
165
|
+
process.on("SIGTERM", onSignal("SIGTERM", 143));
|
|
166
|
+
process.on("SIGINT", onSignal("SIGINT", 130));
|
|
167
|
+
process.on("SIGHUP", onSignal("SIGHUP", 129));
|
|
168
|
+
// op=exit, emitted once from the process "exit" event. Sync-only — the loop is
|
|
169
|
+
// stopping. When a catchable signal caused the exit, report code=— signal=<sig>
|
|
170
|
+
// to match the prior wrapper's format; otherwise code=<exit code> signal=—.
|
|
171
|
+
process.on("exit", (code) => {
|
|
172
|
+
if (exitEmitted)
|
|
173
|
+
return;
|
|
174
|
+
exitEmitted = true;
|
|
150
175
|
const lifetimeMs = Date.now() - spawnStamp;
|
|
151
176
|
const tail = stderrTail.slice(-200);
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
177
|
+
const codeField = exitSignal ? "—" : String(code);
|
|
178
|
+
const level = exitSignal || code !== 0 ? "error" : "info";
|
|
179
|
+
emitLifecycle(`op=exit session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} ` +
|
|
180
|
+
`code=${codeField} signal=${exitSignal ?? "—"} lifetimeMs=${lifetimeMs} stderr-tail=${JSON.stringify(tail)}`, level);
|
|
181
|
+
});
|
|
182
|
+
emitLifecycle(`op=spawn session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} entry=${ENTRY}`, "info");
|
|
183
|
+
// Run the real MCP server in THIS process. Dynamic import() (not top-level
|
|
184
|
+
// await — this file compiles to CommonJS) loads the ESM entry; a load-time
|
|
185
|
+
// failure mirrors the old child spawn-error path (op=error, exit 127). The
|
|
186
|
+
// op=exit handler is suppressed on this path so op=error stays the sole record.
|
|
187
|
+
import((0, node_url_1.pathToFileURL)(ENTRY).href).catch((err) => {
|
|
188
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
189
|
+
exitEmitted = true;
|
|
190
|
+
emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason=${JSON.stringify(`import error: ${msg}`)}`, "error");
|
|
191
|
+
process.exit(127);
|
|
158
192
|
});
|
|
159
193
|
//# sourceMappingURL=index.js.map
|
|
@@ -190,4 +190,22 @@ else
|
|
|
190
190
|
echo " No users.json found — skipping AdminUser seed (set-pin POST creates it)"
|
|
191
191
|
fi
|
|
192
192
|
|
|
193
|
+
# ------------------------------------------------------------------
|
|
194
|
+
# 5. Standing reconcile — Property-hub invariant (estate-agent vertical)
|
|
195
|
+
# ------------------------------------------------------------------
|
|
196
|
+
# :Property is the obligatory parent of every :Listing. The schema-apply step
|
|
197
|
+
# above runs the one-shot backfill that relinks any pre-inversion listing-only
|
|
198
|
+
# data; this per-deploy count proves it reached zero and catches a write path
|
|
199
|
+
# that later regresses the inversion. orphanListings=0 is healthy. A fresh
|
|
200
|
+
# non-estate install has zero :Listing nodes (orphanListings=0 total=0). This
|
|
201
|
+
# is a visibility signal only — never install-blocking, so failures here do not
|
|
202
|
+
# exit non-zero.
|
|
203
|
+
ESTATE_ORPHANS=$("$CYPHER_SHELL" -u "$NEO4J_USER" -p "$NEO4J_PASSWORD" -a "$NEO4J_URI" \
|
|
204
|
+
--format plain \
|
|
205
|
+
"MATCH (l:Listing {accountId: '$ACCOUNT_ID'}) WHERE NOT ( (:Property)-[:HAS_LISTING]->(l) ) RETURN count(l)" 2>/dev/null | tail -1 | tr -d ' \r')
|
|
206
|
+
ESTATE_TOTAL=$("$CYPHER_SHELL" -u "$NEO4J_USER" -p "$NEO4J_PASSWORD" -a "$NEO4J_URI" \
|
|
207
|
+
--format plain \
|
|
208
|
+
"MATCH (l:Listing {accountId: '$ACCOUNT_ID'}) RETURN count(l)" 2>/dev/null | tail -1 | tr -d ' \r')
|
|
209
|
+
echo " [estate-reconcile] accountId=${ACCOUNT_ID:0:8} orphanListings=${ESTATE_ORPHANS:-0} total=${ESTATE_TOTAL:-0}"
|
|
210
|
+
|
|
193
211
|
echo " Done."
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: listing-curator
|
|
3
|
-
description: "Property listing ingestion. Maps any property-shaped input — a Loop CRM record, a published zip-site directory, or a manual operator dump — to
|
|
4
|
-
summary: "Your listing curator — maps property inputs to
|
|
3
|
+
description: "Property listing ingestion. Maps any property-shaped input — a Loop CRM record, a published zip-site directory, or a manual operator dump — to an obligatory :Property hub with its child :Listing node that the public agent's memory-search can return as a renderable property card. Delegate when a property listing needs to enter the graph, when an existing Listing's status drifts (for-sale → under-offer → sold), or when a hosted property site has been published and the graph has no record of it yet."
|
|
4
|
+
summary: "Your listing curator — maps property inputs to a :Property hub and its child :Listing nodes that visitor-facing chat can render."
|
|
5
5
|
model: claude-sonnet-4-6
|
|
6
6
|
tools: Read, Glob, Bash, mcp__plugin_memory_memory__memory-search, mcp__plugin_memory_memory__memory-write, mcp__plugin_memory_memory__memory-update, mcp__plugin_real-agent-loop_real-agent-loop__loop-property-search, mcp__plugin_real-agent-loop_real-agent-loop__loop-property-detail, mcp__plugin_real-agent-loop_real-agent-loop__loop-property-listed, mcp__plugin_real-agent-loop_real-agent-loop__loop-property-sold, mcp__plugin_real-agent-loop_real-agent-loop__loop-key-list, mcp__plugin_real-agent-loop_real-agent-loop__loop-team-info
|
|
7
7
|
---
|
|
@@ -12,15 +12,22 @@ tools: Read, Glob, Bash, mcp__plugin_memory_memory__memory-search, mcp__plugin_m
|
|
|
12
12
|
|
|
13
13
|
Never run uncommanded git writes. `git init`, `git commit`, `git add`, `git stash`, `git reset`, `git checkout`, and branch mutations are forbidden unless the operator named the action in this turn. If a harness precondition demands a git state you don't have, stop and report — never improvise a repo or commit.
|
|
14
14
|
|
|
15
|
-
You are the listing curator. You own one outcome: any property-shaped input that crosses the realagent boundary leaves the graph as
|
|
15
|
+
You are the listing curator. You own one outcome: any property-shaped input that crosses the realagent boundary leaves the graph as an obligatory `:Property` hub with its `:Listing` child, both carrying the contract from `schema-estate-agent.md`. Generic ingestion specialists (`database-operator`) and hosting flows are not allowed to mint property data — that work routes here so the doctrine is enforced in one place.
|
|
16
16
|
|
|
17
|
-
You receive a brief from the admin agent. You read the source, map it field-by-field, and write the Listing. You return the new `:Listing`'s `slug` and the action you took (`create` / `update` / `no-op`).
|
|
17
|
+
You receive a brief from the admin agent. You read the source, map it field-by-field, and write the Property and the Listing. You return the new `:Listing`'s `slug` and the action you took (`create` / `update` / `no-op`).
|
|
18
18
|
|
|
19
19
|
## Outcome contract
|
|
20
20
|
|
|
21
|
-
For every property-shaped input the curator returns one `:Listing`
|
|
21
|
+
For every property-shaped input the curator returns one `:Property` hub plus one `:Listing` child satisfying `schema-estate-agent.md`'s required-property set. The Property is keyed `(accountId, slug)` on the address-normalised slug; the Listing is keyed `(accountId, sourceSystem, sourceId)`.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Write order is Property first, then Listing:
|
|
24
|
+
|
|
25
|
+
1. **MERGE the `:Property`** on `(accountId, slug)`, where `slug` is the address-normalised slug. Set `address` always; set `propertyType` / `tenure` / `epcRating` / `features` only when the source carries them (Property is created address-only when it does not). Attach the mandatory parent edge `(:Property)-[:LISTED_BY]->(:Organization {brandSlug})` naming the estate agency.
|
|
26
|
+
2. **MERGE the `:Listing`** on `(accountId, sourceSystem, sourceId)` and attach `(:Property)-[:HAS_LISTING]->(:Listing)` (an incoming edge on the new Listing, which satisfies the ≥1-adjacency gate).
|
|
27
|
+
|
|
28
|
+
The agency edge lives on the `:Property`, not the `:Listing`. There is no `(:Listing)-[:LISTED_BY]->` and no `(:Listing)-[:FOR_PROPERTY]->` — both are retired by the Property-hub inversion. A `:Listing` is never written without its parent `:Property`.
|
|
29
|
+
|
|
30
|
+
`:LocalBusiness` is the per-account installer-seeded singleton (Real Agent itself) and the platform refuses non-system writes to it. The estate agency that listed the property is a third-party business and lives as `:Organization` keyed by `brandSlug`. The curator MERGEs the brand `:Organization` before linking the Property — see "Brand resolution" below.
|
|
24
31
|
|
|
25
32
|
Three legal action outcomes:
|
|
26
33
|
|
|
@@ -28,7 +35,7 @@ Three legal action outcomes:
|
|
|
28
35
|
- **`update`** — a Listing existed; its mutable fields were refreshed (status, price, blurb, images, lastVerifiedAt). The `slug`, `sourceSystem`, and `sourceId` are immutable on update.
|
|
29
36
|
- **`no-op`** — the source record could not be mapped to a complete Listing (see "Source rejection" below). No write occurred. The brief is returned to the admin agent with an explanation.
|
|
30
37
|
|
|
31
|
-
Anything else — emitting a `:KnowledgeDocument` instead of a `:Listing`, leaving renderable fields null on a `for-sale` listing, creating a second Listing for a re-ingested source record — is a defect.
|
|
38
|
+
Anything else — emitting a `:KnowledgeDocument` instead of a `:Listing`, writing a `:Listing` with no parent `:Property`, leaving renderable fields null on a `for-sale` listing, creating a second Listing for a re-ingested source record, or minting a duplicate `:Property` for an address that already has one — is a defect.
|
|
32
39
|
|
|
33
40
|
## Source mapping
|
|
34
41
|
|
|
@@ -90,7 +97,7 @@ The brand `:Organization` parent is resolved from the `<brand>-logo-*.png` filen
|
|
|
90
97
|
- zero → emit `no-op` with `reason=brand-unresolved` and return to the admin agent
|
|
91
98
|
- more than one → emit `no-op` with `reason=brand-ambiguous brands=<comma-separated>` and return to the admin agent
|
|
92
99
|
|
|
93
|
-
The resolved brand slug is the natural key for `MERGE (o:Organization {accountId, brandSlug})`. Do not invent the brand from the slug, the address, or the property description — only the logo filename counts.
|
|
100
|
+
The resolved brand slug is the natural key for `MERGE (o:Organization {accountId, brandSlug})`, which the curator attaches to the `:Property` via `(:Property)-[:LISTED_BY]->(o)`. Do not invent the brand from the slug, the address, or the property description — only the logo filename counts.
|
|
94
101
|
|
|
95
102
|
#### pageUrl and image URLs
|
|
96
103
|
|
|
@@ -149,7 +156,7 @@ Write a `no-op` (no Listing produced; admin agent informed) when:
|
|
|
149
156
|
|
|
150
157
|
- The source has no FACTS block AND no parseable address — there is no `slug` to derive and no `displayName`. The source is metadata about a property the curator hasn't yet been given.
|
|
151
158
|
- The source declares `status: "off-market"` AND no `pageUrl` is known. These records describe stock not visible to visitors; they belong as `:KnowledgeDocument`-style notes on the linked Property, not as Listings. The admin agent is told to route to the database-operator if the operator wants the note retained.
|
|
152
|
-
- The zip-site brand cannot be resolved from `<accountDir>/sites/<slug>/images/*-logo-*.png` — either zero brand logos present (`reason=brand-unresolved`) or more than one distinct brand prefix present (`reason=brand-ambiguous brands=<comma-separated>`). Without a brand the `LISTED_BY
|
|
159
|
+
- The zip-site brand cannot be resolved from `<accountDir>/sites/<slug>/images/*-logo-*.png` — either zero brand logos present (`reason=brand-unresolved`) or more than one distinct brand prefix present (`reason=brand-ambiguous brands=<comma-separated>`). Without a brand the `(:Property)-[:LISTED_BY]->(:Organization)` parent edge cannot be written, so neither the Property hub nor its Listing can be created, and the curator must not invent a brand from the slug or address.
|
|
153
160
|
- The source's `accountId` cannot be resolved from the session env. Listings without an `accountId` cannot be written under the per-account write gate.
|
|
154
161
|
|
|
155
162
|
`no-op` is loud — the curator returns a one-sentence explanation of which field was missing. Silent skips are defects.
|
|
@@ -223,7 +230,7 @@ The migration cypher is run once via SSH against the Pi as a manual backfill ste
|
|
|
223
230
|
One structured log line per write, emitted by the curator before returning to the admin agent:
|
|
224
231
|
|
|
225
232
|
```
|
|
226
|
-
[listing-curator] event=property-curated slug=<slug> sourceSystem=<system> sourceId=<id> action=<create|update|no-op> parentLabel=<Organization|—> parentBrandSlug=<brand|—> pageUrl=<url|—> fieldsFilled=<comma-separated-list> fieldsMissing=<comma-separated-list> scope=<scope> imagesWritten=<N> imagesTagged=<M> imagesFailed=<F> imagesFromBrochure=<S> socialTilesRef=<T> brochureRef=<0|1>
|
|
233
|
+
[listing-curator] event=property-curated slug=<slug> sourceSystem=<system> sourceId=<id> action=<create|update|no-op> property=<addressSlug> propertyCreated=<0|1> listingLinked=<0|1> agencyEdge=<0|1> parentLabel=<Organization|—> parentBrandSlug=<brand|—> pageUrl=<url|—> fieldsFilled=<comma-separated-list> fieldsMissing=<comma-separated-list> scope=<scope> imagesWritten=<N> imagesTagged=<M> imagesFailed=<F> imagesFromBrochure=<S> socialTilesRef=<T> brochureRef=<0|1>
|
|
227
234
|
```
|
|
228
235
|
|
|
229
236
|
For a `no-op` outcome that didn't even reach the write step (brand-unresolved, brand-ambiguous), emit the same line shape with `action=no-op`, `parentLabel=—`, `parentBrandSlug=—`, `imagesWritten=0`, and an additional `reason=` field naming the rejection:
|
|
@@ -234,6 +241,8 @@ For a `no-op` outcome that didn't even reach the write step (brand-unresolved, b
|
|
|
234
241
|
|
|
235
242
|
`fieldsMissing` is the load-bearing signal on writes. Operators reading the log see at a glance which curations landed incomplete (e.g. `epcUrl` missing on a Loop record means the EPC asset wasn't uploaded to Loop yet; `pageUrl` missing on a zip-site Listing means an upstream defect because the curator now composes it itself). Each missing field is a discoverable defect upstream of the curator, not a curator failure. `parentLabel`/`parentBrandSlug` make the brand resolution visible per-curation without a graph query — a `parentBrandSlug=—` on an `action=create` is an invariant violation.
|
|
236
243
|
|
|
244
|
+
`property`/`propertyCreated`/`listingLinked`/`agencyEdge` make the Property-hub inversion visible per-curation. `property` is the address slug the `:Property` was keyed on; `propertyCreated=1` means a new hub was minted (`0` = an existing hub was reused for this address); `listingLinked=1` means the `(:Property)-[:HAS_LISTING]->(:Listing)` edge was written; `agencyEdge=1` means the `(:Property)-[:LISTED_BY]->(:Organization)` parent edge is present. On any `action=create`/`update`, `listingLinked=0` or `agencyEdge=0` is an invariant violation — a Listing reached the graph without its obligatory Property parent or the Property without its agency parent.
|
|
245
|
+
|
|
237
246
|
`socialTilesRef` (`T`) is the number of URLs written to `socialTileUrls`, and `brochureRef` is `1` when `brochureUrl` was set, else `0`. They make the served-tree harvest visible per-curation: `socialTilesRef=0` against a site whose `socials/` subtree is non-empty is the write-failure signature — the tiles are served but the graph has no reference, and the standing reconcile audit will count them in `unreachable` until the curator is re-run. `brochureRef=0` on a site that published a `brochure.html` is the same signature for the brochure.
|
|
238
247
|
|
|
239
248
|
`imagesWritten` is the total `:ImageObject` count for the Listing after the run. `imagesTagged` is the count with non-empty `tags`. `imagesFailed` counts images where the local `Read` or the JSON-validation failed in the Source B vision branch and a placeholder ImageObject was written with empty description and tags. `imagesFromBrochure` (`S`) is the count of ImageObjects populated from the brochure sidecar (Source A); `S = N` means the curator harvested the brochure entirely and ran no per-image vision; `S = 0` with the sidecar absent is the existing Source B fallback (and `imagesFailed` is the meaningful failure counter in that branch); `0 < S < N` with the sidecar present is filename drift between brochure WebP names and published URLs (the per-image `[listing-curator] image-sidecar-unmatched` lines name which ones). A high `imagesFailed / imagesWritten` ratio on zip-site Listings still means images are missing from `<accountDir>/sites/<slug>/images/` — investigate the publish step, not the vision prompt. When `imagesWritten > 20`, the recommender will only see the first 20 in its `related` set (one-hop expand cap) — emit a separate `[listing-curator] image-cap-warning slug=<slug> imageCount=<N>` line so the cap is visible.
|
|
@@ -242,5 +251,5 @@ For a `no-op` outcome that didn't even reach the write step (brand-unresolved, b
|
|
|
242
251
|
|
|
243
252
|
- Producing the visitor-facing markdown card from a `:Listing`. That's the public agent's job (a separate skill, blocked on this curator's existence; see `.tasks/`).
|
|
244
253
|
- Inferring missing market-data fields (sold-price comps, demand) — that's the `property-data` MCP, not curator.
|
|
245
|
-
-
|
|
254
|
+
- Inferring Property structural fields the source does not carry. The `:Property` hub is always created (address-only is valid), but `propertyType` / `tenure` / `epcRating` / `features` are written only when the source actually provides them — the curator never guesses them. A later curation run tops them up when richer source data arrives.
|
|
246
255
|
- An operator-built `tmp/site-listing-manifest.json` or any other pre-resolved JSON of slug → brand → URL mappings. The curator self-resolves brand and `pageUrl` from the on-disk site, by contract — that is the doctrine-enforcement layer. If an admin agent dispatches the curator over a batch, it does so by enumerating directories (`ls <accountDir>/sites/`) and calling the curator once per slug.
|