@rubytech/create-maxy-code 0.1.58 → 0.1.60
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/package.json +1 -1
- package/payload/platform/plugins/admin/hooks/__tests__/turn-completed-graph-write.test.sh +30 -19
- package/payload/platform/plugins/admin/hooks/turn-completed-graph-write.sh +35 -90
- package/payload/platform/plugins/docs/references/admin-session.md +17 -16
- package/payload/platform/plugins/docs/references/platform.md +3 -3
- package/payload/platform/plugins/docs/references/plugins-guide.md +1 -1
- package/payload/platform/plugins/loop/PLUGIN.md +13 -1
- package/payload/platform/plugins/loop/mcp/dist/index.js +8 -7
- package/payload/platform/plugins/loop/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.d.ts +3 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.d.ts.map +1 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.js +48 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.js.map +1 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/key-store.d.ts +22 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/key-store.d.ts.map +1 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/key-store.js +165 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/key-store.js.map +1 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.d.ts +1 -1
- package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.d.ts.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.js +4 -39
- package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.js.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/tools/key-deregister.d.ts.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/tools/key-deregister.js +5 -15
- package/payload/platform/plugins/loop/mcp/dist/tools/key-deregister.js.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/tools/key-register.d.ts.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/tools/key-register.js +11 -28
- package/payload/platform/plugins/loop/mcp/dist/tools/key-register.js.map +1 -1
- package/payload/platform/plugins/loop/mcp/src/index.ts +10 -7
- package/payload/platform/plugins/loop/mcp/src/lib/file-crypto.ts +54 -0
- package/payload/platform/plugins/loop/mcp/src/lib/key-store.ts +221 -0
- package/payload/platform/plugins/loop/mcp/src/lib/loop-api.ts +5 -42
- package/payload/platform/plugins/loop/mcp/src/tools/key-deregister.ts +5 -20
- package/payload/platform/plugins/loop/mcp/src/tools/key-register.ts +14 -39
- package/payload/platform/plugins/preval/.claude-plugin/plugin.json +8 -0
- package/payload/platform/plugins/preval/PLUGIN.md +39 -0
- package/payload/platform/plugins/preval/skills/property-preval/SKILL.md +78 -0
- package/payload/platform/plugins/preval/skills/property-preval/references/render.py +265 -0
- package/payload/platform/plugins/preval/skills/property-preval/references/template-inputs.schema.json +143 -0
- package/payload/platform/plugins/preval/skills/property-preval/references/template.html +253 -0
- package/payload/platform/plugins/property-data/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/property-data/PLUGIN.md +60 -2
- package/payload/platform/plugins/property-data/mcp/dist/index.js +95 -12
- package/payload/platform/plugins/property-data/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.d.ts +3 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.d.ts.map +1 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.js +49 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.js.map +1 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.d.ts +15 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.d.ts.map +1 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.js +135 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.js.map +1 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts +0 -1
- package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.js +11 -22
- package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.js.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.d.ts +10 -0
- package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.d.ts.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.js +15 -2
- package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.js.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-deregister.d.ts.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-deregister.js +5 -15
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-deregister.js.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-register.d.ts.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-register.js +30 -23
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-register.js.map +1 -1
- package/payload/platform/plugins/property-data/mcp/src/__tests__/endpoints.test.ts +252 -0
- package/payload/platform/plugins/property-data/mcp/src/__tests__/schema-parity.test.ts +16 -2
- package/payload/platform/plugins/property-data/mcp/src/index.ts +171 -11
- package/payload/platform/plugins/property-data/mcp/src/lib/file-crypto.ts +55 -0
- package/payload/platform/plugins/property-data/mcp/src/lib/key-store.ts +181 -0
- package/payload/platform/plugins/property-data/mcp/src/lib/propertydata-api.ts +9 -24
- package/payload/platform/plugins/property-data/mcp/src/tools/endpoints.ts +22 -2
- package/payload/platform/plugins/property-data/mcp/src/tools/key-deregister.ts +5 -17
- package/payload/platform/plugins/property-data/mcp/src/tools/key-register.ts +29 -33
- package/payload/platform/plugins/property-data/skills/property-data/SKILL.md +19 -0
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +25 -260
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.d.ts +3 -7
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.js +6 -32
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts +6 -24
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +18 -91
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/reaper.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/reaper.js +0 -11
- package/payload/platform/services/claude-session-manager/dist/reaper.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/session-store.d.ts +0 -21
- package/payload/platform/services/claude-session-manager/dist/session-store.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/session-store.js.map +1 -1
- package/payload/platform/templates/agents/admin/IDENTITY.md +1 -1
- package/payload/platform/templates/agents/admin/SOUL.md +1 -1
- package/payload/premium-plugins/real-agent/BUNDLE.md +5 -3
- package/payload/premium-plugins/real-agent/agents/negotiator.md +1 -1
- package/payload/premium-plugins/real-agent/agents/valuer.md +1 -1
- package/payload/premium-plugins/real-agent/plugins/.claude-plugin/marketplace.json +5 -0
- package/payload/premium-plugins/real-agent/plugins/loop/PLUGIN.md +13 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/index.js +8 -7
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/index.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.d.ts +3 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.d.ts.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.js +48 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.js.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.d.ts +22 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.d.ts.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.js +165 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.js.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.d.ts +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.js +4 -39
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-deregister.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-deregister.js +5 -15
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-deregister.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-register.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-register.js +11 -28
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-register.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/index.ts +10 -7
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/file-crypto.ts +54 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/key-store.ts +221 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/loop-api.ts +5 -42
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/key-deregister.ts +5 -20
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/key-register.ts +14 -39
- package/payload/premium-plugins/real-agent/plugins/preval/.claude-plugin/plugin.json +8 -0
- package/payload/premium-plugins/real-agent/plugins/preval/PLUGIN.md +39 -0
- package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/SKILL.md +78 -0
- package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/references/render.py +265 -0
- package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/references/template-inputs.schema.json +143 -0
- package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/references/template.html +253 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/.claude-plugin/plugin.json +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/PLUGIN.md +60 -2
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/index.js +95 -12
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/index.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.d.ts +3 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.d.ts.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.js +49 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.js.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.d.ts +15 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.d.ts.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.js +135 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.js.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts +0 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.js +11 -22
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.d.ts +10 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.js +15 -2
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-deregister.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-deregister.js +5 -15
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-deregister.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-register.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-register.js +30 -23
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-register.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/__tests__/endpoints.test.ts +252 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/__tests__/schema-parity.test.ts +16 -2
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/index.ts +171 -11
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/lib/file-crypto.ts +55 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/lib/key-store.ts +181 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/lib/propertydata-api.ts +9 -24
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/tools/endpoints.ts +22 -2
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/tools/key-deregister.ts +5 -17
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/tools/key-register.ts +29 -33
- package/payload/premium-plugins/real-agent/plugins/property-data/skills/property-data/SKILL.md +19 -0
- package/payload/server/public/assets/{admin-2ZJmzJ_g.js → admin-Bp-BjBCX.js} +51 -51
- package/payload/server/public/assets/{data-DlmoKxmN.js → data-BGUAGVkV.js} +1 -1
- package/payload/server/public/assets/{graph-BVvcFSEQ.js → graph-MvYxZOBF.js} +1 -1
- package/payload/server/public/assets/{graph-labels-cCvgu38Y.js → graph-labels-D865qb3K.js} +1 -1
- package/payload/server/public/assets/{page-BnAxPkmg.js → page--hOVRrgN.js} +1 -1
- package/payload/server/public/assets/{page-BnaN3u86.js → page-C2b1nlOc.js} +1 -1
- package/payload/server/public/data.html +3 -3
- package/payload/server/public/graph.html +3 -3
- package/payload/server/public/index.html +4 -4
- package/payload/server/server.js +18 -83
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.d.ts +0 -51
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.d.ts.map +0 -1
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.js +0 -196
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.js.map +0 -1
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/package.json +0 -7
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { encrypt } from "../lib/crypto.js";
|
|
1
|
+
import { selectLoopKeyStore } from "../lib/key-store.js";
|
|
3
2
|
import { loopGet, LoopApiError } from "../lib/loop-api.js";
|
|
4
3
|
const ALL_PERMISSIONS = ["properties", "people", "viewings", "feedback", "team", "marketing", "customer", "supplier"];
|
|
5
4
|
export async function keyRegister(params) {
|
|
6
5
|
const { teamName, apiKey, accountId } = params;
|
|
7
6
|
const permissions = params.permissions ?? ALL_PERMISSIONS;
|
|
8
|
-
// Validate key against Loop API — try /team endpoint
|
|
7
|
+
// Validate key against Loop API — try /team endpoint.
|
|
9
8
|
let teamAddress = "";
|
|
10
9
|
let agentId = "";
|
|
11
10
|
let warning;
|
|
12
11
|
try {
|
|
13
12
|
const teamData = await loopGet(apiKey, "/team", "loop-key-register", teamName);
|
|
14
13
|
if (Array.isArray(teamData) && teamData.length === 0) {
|
|
15
|
-
// 204 was converted to empty array — ambiguous scope
|
|
16
14
|
warning =
|
|
17
15
|
"Key accepted but Loop returned no team data (204). " +
|
|
18
16
|
"Verify the key's scope in Loop's dashboard.";
|
|
@@ -27,32 +25,17 @@ export async function keyRegister(params) {
|
|
|
27
25
|
throw new Error(`Loop API rejected the key for team "${teamName}" (HTTP 401). ` +
|
|
28
26
|
`Check that the key is valid and not expired.`);
|
|
29
27
|
}
|
|
30
|
-
// Network/timeout errors — still reject, key is unverified
|
|
31
28
|
throw new Error(`Could not validate key against Loop API: ${err instanceof Error ? err.message : String(err)}`);
|
|
32
29
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
k.encryptedKey = $encryptedKey,
|
|
43
|
-
k.teamAddress = $teamAddress,
|
|
44
|
-
k.agentId = $agentId,
|
|
45
|
-
k.permissions = $permissions,
|
|
46
|
-
k.createdAt = $now,
|
|
47
|
-
k.updatedAt = $now
|
|
48
|
-
RETURN k.createdAt = $now AS created`, { teamName, encryptedKey, teamAddress, agentId, accountId, permissions, now });
|
|
49
|
-
const created = mergeResult.records[0]?.get("created");
|
|
50
|
-
if (!created) {
|
|
51
|
-
throw new Error(`Team "${teamName}" is already registered for this account.`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
finally {
|
|
55
|
-
await writeSession.close();
|
|
30
|
+
const { created } = await selectLoopKeyStore().save(accountId, {
|
|
31
|
+
teamName,
|
|
32
|
+
apiKey,
|
|
33
|
+
teamAddress,
|
|
34
|
+
agentId,
|
|
35
|
+
permissions,
|
|
36
|
+
});
|
|
37
|
+
if (!created) {
|
|
38
|
+
throw new Error(`Team "${teamName}" is already registered for this account.`);
|
|
56
39
|
}
|
|
57
40
|
console.error(`[loop] key-register team=${teamName} account=${accountId}`);
|
|
58
41
|
return { warning };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-register.js","sourceRoot":"","sources":["../../src/tools/key-register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"key-register.js","sourceRoot":"","sources":["../../src/tools/key-register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAU3D,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAEtH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAKjC;IACC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAC/C,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,eAAe,CAAC;IAE1D,sDAAsD;IACtD,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,OAA2B,CAAC;IAEhC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAC5B,MAAM,EACN,OAAO,EACP,mBAAmB,EACnB,QAAQ,CACT,CAAC;QAEF,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrD,OAAO;gBACL,qDAAqD;oBACrD,6CAA6C,CAAC;QAClD,CAAC;aAAM,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACpD,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YAC7C,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,YAAY,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CACb,uCAAuC,QAAQ,gBAAgB;gBAC7D,8CAA8C,CACjD,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,KAAK,CACb,4CAA4C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC/F,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,kBAAkB,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE;QAC7D,QAAQ;QACR,MAAM;QACN,WAAW;QACX,OAAO;QACP,WAAW;KACZ,CAAC,CAAC;IAEH,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,2CAA2C,CAAC,CAAC;IAChF,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,4BAA4B,QAAQ,YAAY,SAAS,EAAE,CAAC,CAAC;IAC3E,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Logging-tee was a platform-wrapper concern; the host owns the stderr pipe
|
|
2
|
+
// in both platform and standalone (Claude Code native) spawn paths.
|
|
3
3
|
|
|
4
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -29,11 +29,11 @@ import { autoResponder } from "./tools/auto-responder.js";
|
|
|
29
29
|
import { customerPreferences } from "./tools/customer-preferences.js";
|
|
30
30
|
import { supplier } from "./tools/supplier.js";
|
|
31
31
|
import { closeDriver } from "./lib/neo4j.js";
|
|
32
|
+
import { selectLoopKeyStore } from "./lib/key-store.js";
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
34
|
+
// ACCOUNT_ID is the platform's tenant id; "local" is the single-tenant
|
|
35
|
+
// standalone stand-in when spawned natively by Claude Code.
|
|
36
|
+
const accountId = process.env.ACCOUNT_ID ?? "local";
|
|
37
37
|
|
|
38
38
|
const server = new McpServer({
|
|
39
39
|
name: "maxy-loop",
|
|
@@ -45,7 +45,10 @@ const ALL_PERMISSIONS = z.enum([
|
|
|
45
45
|
"marketing", "customer", "supplier",
|
|
46
46
|
]);
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
const store = selectLoopKeyStore();
|
|
49
|
+
console.error(
|
|
50
|
+
`[loop] server started, account=${accountId} backend=${store.backendName} path=${store.backendPath}`,
|
|
51
|
+
);
|
|
49
52
|
|
|
50
53
|
// Helper: wrap a tool function in standard error handling
|
|
51
54
|
function toolHandler(fn: (p: Record<string, unknown>) => Promise<string>) {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { randomBytes, createCipheriv, createDecipheriv } from "node:crypto";
|
|
2
|
+
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
// Standalone-mode crypto — see property-data's file-crypto.ts for the
|
|
5
|
+
// shape and rationale. The two are duplicated rather than shared because
|
|
6
|
+
// the MCPs are independent npm workspaces with no shared lib.
|
|
7
|
+
|
|
8
|
+
const ALGORITHM = "aes-256-gcm";
|
|
9
|
+
const KEY_LENGTH = 32;
|
|
10
|
+
const IV_LENGTH = 12;
|
|
11
|
+
const AUTH_TAG_LENGTH = 16;
|
|
12
|
+
|
|
13
|
+
function loadOrGenerateKey(keyFilePath: string, label: string): Buffer {
|
|
14
|
+
if (existsSync(keyFilePath)) {
|
|
15
|
+
const hex = readFileSync(keyFilePath, "utf-8").trim();
|
|
16
|
+
const buf = Buffer.from(hex, "hex");
|
|
17
|
+
if (buf.length !== KEY_LENGTH) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`[${label}] encryption key at ${keyFilePath} is ${buf.length} bytes, expected ${KEY_LENGTH}.`,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return buf;
|
|
23
|
+
}
|
|
24
|
+
const key = randomBytes(KEY_LENGTH);
|
|
25
|
+
writeFileSync(keyFilePath, key.toString("hex"), { mode: 0o600 });
|
|
26
|
+
console.error(`[${label}] encryption key generated at ${keyFilePath}`);
|
|
27
|
+
return key;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function encryptWith(plaintext: string, keyFilePath: string, label: string): string {
|
|
31
|
+
const key = loadOrGenerateKey(keyFilePath, label);
|
|
32
|
+
const iv = randomBytes(IV_LENGTH);
|
|
33
|
+
const cipher = createCipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
34
|
+
let encrypted = cipher.update(plaintext, "utf-8", "hex");
|
|
35
|
+
encrypted += cipher.final("hex");
|
|
36
|
+
const authTag = cipher.getAuthTag().toString("hex");
|
|
37
|
+
return `${iv.toString("hex")}:${encrypted}:${authTag}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function decryptWith(encryptedValue: string, keyFilePath: string, label: string): string {
|
|
41
|
+
const parts = encryptedValue.split(":");
|
|
42
|
+
if (parts.length !== 3) {
|
|
43
|
+
throw new Error(`[${label}] bad encrypted envelope (expected iv:ct:tag)`);
|
|
44
|
+
}
|
|
45
|
+
const key = loadOrGenerateKey(keyFilePath, label);
|
|
46
|
+
const iv = Buffer.from(parts[0], "hex");
|
|
47
|
+
const ciphertext = parts[1];
|
|
48
|
+
const authTag = Buffer.from(parts[2], "hex");
|
|
49
|
+
const decipher = createDecipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
50
|
+
decipher.setAuthTag(authTag);
|
|
51
|
+
let plaintext = decipher.update(ciphertext, "hex", "utf-8");
|
|
52
|
+
plaintext += decipher.final("utf-8");
|
|
53
|
+
return plaintext;
|
|
54
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { resolve, dirname } from "node:path";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { getSession } from "./neo4j.js";
|
|
5
|
+
import { encrypt, decrypt } from "./crypto.js";
|
|
6
|
+
import { encryptWith, decryptWith } from "./file-crypto.js";
|
|
7
|
+
|
|
8
|
+
// Storage abstraction so the same MCP body runs against Neo4j (platform mode)
|
|
9
|
+
// or an on-disk encrypted file (standalone mode, spawned by Claude Code from
|
|
10
|
+
// ~/.claude/). Selected by LOOP_STANDALONE at boot. Loop is multi-team — each
|
|
11
|
+
// account can register many team keys — so the file backend stores a nested
|
|
12
|
+
// map and the store API mirrors that.
|
|
13
|
+
|
|
14
|
+
export interface LoopStoredKey {
|
|
15
|
+
teamName: string;
|
|
16
|
+
apiKey: string;
|
|
17
|
+
teamAddress: string;
|
|
18
|
+
agentId: string;
|
|
19
|
+
permissions: string[];
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type LoopKeyInput = Omit<LoopStoredKey, "createdAt" | "updatedAt">;
|
|
25
|
+
|
|
26
|
+
export interface LoopKeyStore {
|
|
27
|
+
readonly backendName: string;
|
|
28
|
+
readonly backendPath: string;
|
|
29
|
+
loadAll(accountId: string): Promise<LoopStoredKey[]>;
|
|
30
|
+
save(accountId: string, key: LoopKeyInput): Promise<{ created: boolean }>;
|
|
31
|
+
delete(accountId: string, teamName: string): Promise<boolean>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class Neo4jLoopKeyStore implements LoopKeyStore {
|
|
35
|
+
readonly backendName = "neo4j";
|
|
36
|
+
readonly backendPath = process.env.NEO4J_URI ?? "<unset>";
|
|
37
|
+
|
|
38
|
+
async loadAll(accountId: string): Promise<LoopStoredKey[]> {
|
|
39
|
+
const session = getSession();
|
|
40
|
+
try {
|
|
41
|
+
const result = await session.run(
|
|
42
|
+
`MATCH (k:LoopTeamKey {accountId: $accountId})
|
|
43
|
+
RETURN k.teamName AS teamName, k.encryptedKey AS encryptedKey,
|
|
44
|
+
k.teamAddress AS teamAddress, k.agentId AS agentId,
|
|
45
|
+
k.permissions AS permissions, k.createdAt AS createdAt,
|
|
46
|
+
k.updatedAt AS updatedAt
|
|
47
|
+
ORDER BY k.teamName`,
|
|
48
|
+
{ accountId },
|
|
49
|
+
);
|
|
50
|
+
return result.records.map((r) => ({
|
|
51
|
+
teamName: r.get("teamName"),
|
|
52
|
+
apiKey: decrypt(r.get("encryptedKey")),
|
|
53
|
+
teamAddress: r.get("teamAddress") ?? "",
|
|
54
|
+
agentId: r.get("agentId") ?? "",
|
|
55
|
+
permissions: r.get("permissions") ?? [],
|
|
56
|
+
createdAt: r.get("createdAt") ?? "",
|
|
57
|
+
updatedAt: r.get("updatedAt") ?? "",
|
|
58
|
+
}));
|
|
59
|
+
} finally {
|
|
60
|
+
await session.close();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async save(accountId: string, key: LoopKeyInput): Promise<{ created: boolean }> {
|
|
65
|
+
const encryptedKey = encrypt(key.apiKey);
|
|
66
|
+
const now = new Date().toISOString();
|
|
67
|
+
const session = getSession();
|
|
68
|
+
try {
|
|
69
|
+
await session.run(
|
|
70
|
+
`CREATE INDEX loop_team_key_account_team IF NOT EXISTS
|
|
71
|
+
FOR (k:LoopTeamKey) ON (k.accountId, k.teamName)`,
|
|
72
|
+
{},
|
|
73
|
+
);
|
|
74
|
+
const result = await session.run(
|
|
75
|
+
`MERGE (k:LoopTeamKey {teamName: $teamName, accountId: $accountId})
|
|
76
|
+
ON CREATE SET
|
|
77
|
+
k.encryptedKey = $encryptedKey,
|
|
78
|
+
k.teamAddress = $teamAddress,
|
|
79
|
+
k.agentId = $agentId,
|
|
80
|
+
k.permissions = $permissions,
|
|
81
|
+
k.createdAt = $now,
|
|
82
|
+
k.updatedAt = $now
|
|
83
|
+
RETURN k.createdAt = $now AS created`,
|
|
84
|
+
{
|
|
85
|
+
teamName: key.teamName,
|
|
86
|
+
encryptedKey,
|
|
87
|
+
teamAddress: key.teamAddress,
|
|
88
|
+
agentId: key.agentId,
|
|
89
|
+
accountId,
|
|
90
|
+
permissions: key.permissions,
|
|
91
|
+
now,
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
return { created: Boolean(result.records[0]?.get("created")) };
|
|
95
|
+
} finally {
|
|
96
|
+
await session.close();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async delete(accountId: string, teamName: string): Promise<boolean> {
|
|
101
|
+
const session = getSession();
|
|
102
|
+
try {
|
|
103
|
+
const result = await session.run(
|
|
104
|
+
`MATCH (k:LoopTeamKey {teamName: $teamName, accountId: $accountId})
|
|
105
|
+
DELETE k
|
|
106
|
+
RETURN count(k) AS deleted`,
|
|
107
|
+
{ teamName, accountId },
|
|
108
|
+
);
|
|
109
|
+
const deleted = result.records[0]?.get("deleted")?.toNumber?.() ?? 0;
|
|
110
|
+
return deleted > 0;
|
|
111
|
+
} finally {
|
|
112
|
+
await session.close();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const LABEL = "loop";
|
|
118
|
+
|
|
119
|
+
interface FileEnvelope {
|
|
120
|
+
[accountId: string]: {
|
|
121
|
+
[teamName: string]: {
|
|
122
|
+
encryptedKey: string;
|
|
123
|
+
teamAddress: string;
|
|
124
|
+
agentId: string;
|
|
125
|
+
permissions: string[];
|
|
126
|
+
createdAt: string;
|
|
127
|
+
updatedAt: string;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
class FileLoopKeyStore implements LoopKeyStore {
|
|
133
|
+
readonly backendName = "file";
|
|
134
|
+
readonly backendPath: string;
|
|
135
|
+
private readonly storePath: string;
|
|
136
|
+
private readonly keyFilePath: string;
|
|
137
|
+
|
|
138
|
+
constructor() {
|
|
139
|
+
const home = homedir();
|
|
140
|
+
this.storePath = resolve(home, ".claude/.realagent-loop-key.enc");
|
|
141
|
+
this.keyFilePath = resolve(home, ".claude/.realagent-loop-encryption-key");
|
|
142
|
+
this.backendPath = this.storePath;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private ensureDir(): void {
|
|
146
|
+
mkdirSync(dirname(this.storePath), { recursive: true });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private readAll(): FileEnvelope {
|
|
150
|
+
if (!existsSync(this.storePath)) return {};
|
|
151
|
+
const blob = readFileSync(this.storePath, "utf-8").trim();
|
|
152
|
+
if (!blob) return {};
|
|
153
|
+
const json = decryptWith(blob, this.keyFilePath, LABEL);
|
|
154
|
+
return JSON.parse(json) as FileEnvelope;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private writeAll(env: FileEnvelope): void {
|
|
158
|
+
this.ensureDir();
|
|
159
|
+
const blob = encryptWith(JSON.stringify(env), this.keyFilePath, LABEL);
|
|
160
|
+
writeFileSync(this.storePath, blob, { mode: 0o600 });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async loadAll(accountId: string): Promise<LoopStoredKey[]> {
|
|
164
|
+
const env = this.readAll();
|
|
165
|
+
const account = env[accountId];
|
|
166
|
+
if (!account) return [];
|
|
167
|
+
return Object.entries(account)
|
|
168
|
+
.map(([teamName, entry]) => ({
|
|
169
|
+
teamName,
|
|
170
|
+
apiKey: decryptWith(entry.encryptedKey, this.keyFilePath, LABEL),
|
|
171
|
+
teamAddress: entry.teamAddress,
|
|
172
|
+
agentId: entry.agentId,
|
|
173
|
+
permissions: entry.permissions,
|
|
174
|
+
createdAt: entry.createdAt,
|
|
175
|
+
updatedAt: entry.updatedAt,
|
|
176
|
+
}))
|
|
177
|
+
.sort((a, b) => a.teamName.localeCompare(b.teamName));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async save(accountId: string, key: LoopKeyInput): Promise<{ created: boolean }> {
|
|
181
|
+
const env = this.readAll();
|
|
182
|
+
const account = env[accountId] ?? {};
|
|
183
|
+
const prev = account[key.teamName];
|
|
184
|
+
const now = new Date().toISOString();
|
|
185
|
+
const encryptedKey = encryptWith(key.apiKey, this.keyFilePath, LABEL);
|
|
186
|
+
account[key.teamName] = {
|
|
187
|
+
encryptedKey,
|
|
188
|
+
teamAddress: key.teamAddress,
|
|
189
|
+
agentId: key.agentId,
|
|
190
|
+
permissions: key.permissions,
|
|
191
|
+
createdAt: prev?.createdAt ?? now,
|
|
192
|
+
updatedAt: now,
|
|
193
|
+
};
|
|
194
|
+
env[accountId] = account;
|
|
195
|
+
this.writeAll(env);
|
|
196
|
+
return { created: !prev };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async delete(accountId: string, teamName: string): Promise<boolean> {
|
|
200
|
+
const env = this.readAll();
|
|
201
|
+
const account = env[accountId];
|
|
202
|
+
if (!account || !(teamName in account)) return false;
|
|
203
|
+
delete account[teamName];
|
|
204
|
+
if (Object.keys(account).length === 0) delete env[accountId];
|
|
205
|
+
else env[accountId] = account;
|
|
206
|
+
this.writeAll(env);
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let cached: LoopKeyStore | null = null;
|
|
212
|
+
|
|
213
|
+
export function selectLoopKeyStore(): LoopKeyStore {
|
|
214
|
+
if (cached) return cached;
|
|
215
|
+
cached = process.env.LOOP_STANDALONE === "1" ? new FileLoopKeyStore() : new Neo4jLoopKeyStore();
|
|
216
|
+
return cached;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function _resetKeyStoreForTests(): void {
|
|
220
|
+
cached = null;
|
|
221
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { decrypt } from "./crypto.js";
|
|
1
|
+
import { selectLoopKeyStore } from "./key-store.js";
|
|
3
2
|
|
|
4
3
|
// ─────────────────────────────────────────────────────────────────
|
|
5
4
|
// Loop API V2 HTTP Client + Cross-Team Aggregation Engine
|
|
@@ -90,7 +89,7 @@ function unwrapEnvelope<T>(parsed: unknown, toolName: string, teamName: string):
|
|
|
90
89
|
|
|
91
90
|
export interface LoopTeamKey {
|
|
92
91
|
teamName: string;
|
|
93
|
-
|
|
92
|
+
apiKey: string;
|
|
94
93
|
teamAddress: string;
|
|
95
94
|
agentId: string;
|
|
96
95
|
permissions: string[];
|
|
@@ -120,29 +119,7 @@ export interface AggregationResult<T> {
|
|
|
120
119
|
* Load all LoopTeamKey nodes for an account from Neo4j.
|
|
121
120
|
*/
|
|
122
121
|
export async function loadTeamKeys(accountId: string): Promise<LoopTeamKey[]> {
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
const result = await session.run(
|
|
126
|
-
`MATCH (k:LoopTeamKey {accountId: $accountId})
|
|
127
|
-
RETURN k.teamName AS teamName, k.encryptedKey AS encryptedKey,
|
|
128
|
-
k.teamAddress AS teamAddress, k.agentId AS agentId,
|
|
129
|
-
k.permissions AS permissions, k.createdAt AS createdAt,
|
|
130
|
-
k.updatedAt AS updatedAt
|
|
131
|
-
ORDER BY k.teamName`,
|
|
132
|
-
{ accountId }
|
|
133
|
-
);
|
|
134
|
-
return result.records.map((r) => ({
|
|
135
|
-
teamName: r.get("teamName"),
|
|
136
|
-
encryptedKey: r.get("encryptedKey"),
|
|
137
|
-
teamAddress: r.get("teamAddress") ?? "",
|
|
138
|
-
agentId: r.get("agentId") ?? "",
|
|
139
|
-
permissions: r.get("permissions") ?? [],
|
|
140
|
-
createdAt: r.get("createdAt") ?? "",
|
|
141
|
-
updatedAt: r.get("updatedAt") ?? "",
|
|
142
|
-
}));
|
|
143
|
-
} finally {
|
|
144
|
-
await session.close();
|
|
145
|
-
}
|
|
122
|
+
return selectLoopKeyStore().loadAll(accountId);
|
|
146
123
|
}
|
|
147
124
|
|
|
148
125
|
// Truncate to 200 chars, escape newlines, single line — `[loop] <tool> team=<t>
|
|
@@ -396,20 +373,7 @@ export async function aggregateAcrossTeams<T>(
|
|
|
396
373
|
continue;
|
|
397
374
|
}
|
|
398
375
|
|
|
399
|
-
|
|
400
|
-
try {
|
|
401
|
-
apiKey = decrypt(key.encryptedKey);
|
|
402
|
-
} catch (err) {
|
|
403
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
404
|
-
console.error(`[loop] decrypt failed for team=${key.teamName}: ${msg}`);
|
|
405
|
-
failures.push({
|
|
406
|
-
teamName: key.teamName,
|
|
407
|
-
reason: "Decryption failed",
|
|
408
|
-
kind: "other",
|
|
409
|
-
});
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
|
|
376
|
+
const apiKey = key.apiKey;
|
|
413
377
|
const teamName = key.teamName;
|
|
414
378
|
tasks.push({
|
|
415
379
|
key,
|
|
@@ -512,8 +476,7 @@ export async function withTeamKey<T>(
|
|
|
512
476
|
);
|
|
513
477
|
}
|
|
514
478
|
|
|
515
|
-
|
|
516
|
-
return execute(apiKey);
|
|
479
|
+
return execute(key.apiKey);
|
|
517
480
|
}
|
|
518
481
|
|
|
519
482
|
/**
|
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { selectLoopKeyStore } from "../lib/key-store.js";
|
|
2
2
|
|
|
3
3
|
export async function keyDeregister(params: {
|
|
4
4
|
teamName: string;
|
|
5
5
|
accountId: string;
|
|
6
6
|
}): Promise<void> {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
const result = await session.run(
|
|
12
|
-
`MATCH (k:LoopTeamKey {teamName: $teamName, accountId: $accountId})
|
|
13
|
-
DELETE k
|
|
14
|
-
RETURN count(k) AS deleted`,
|
|
15
|
-
{ teamName, accountId }
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const deleted = result.records[0]?.get("deleted")?.toNumber?.() ?? 0;
|
|
19
|
-
if (deleted === 0) {
|
|
20
|
-
throw new Error(`Team "${teamName}" not found.`);
|
|
21
|
-
}
|
|
22
|
-
} finally {
|
|
23
|
-
await session.close();
|
|
7
|
+
const deleted = await selectLoopKeyStore().delete(params.accountId, params.teamName);
|
|
8
|
+
if (!deleted) {
|
|
9
|
+
throw new Error(`Team "${params.teamName}" not found.`);
|
|
24
10
|
}
|
|
25
|
-
|
|
26
|
-
console.error(`[loop] key-deregister team=${teamName} account=${accountId}`);
|
|
11
|
+
console.error(`[loop] key-deregister team=${params.teamName} account=${params.accountId}`);
|
|
27
12
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { encrypt } from "../lib/crypto.js";
|
|
1
|
+
import { selectLoopKeyStore } from "../lib/key-store.js";
|
|
3
2
|
import { loopGet, LoopApiError } from "../lib/loop-api.js";
|
|
4
3
|
|
|
5
4
|
interface LoopTeamResponse {
|
|
@@ -21,7 +20,7 @@ export async function keyRegister(params: {
|
|
|
21
20
|
const { teamName, apiKey, accountId } = params;
|
|
22
21
|
const permissions = params.permissions ?? ALL_PERMISSIONS;
|
|
23
22
|
|
|
24
|
-
// Validate key against Loop API — try /team endpoint
|
|
23
|
+
// Validate key against Loop API — try /team endpoint.
|
|
25
24
|
let teamAddress = "";
|
|
26
25
|
let agentId = "";
|
|
27
26
|
let warning: string | undefined;
|
|
@@ -31,11 +30,10 @@ export async function keyRegister(params: {
|
|
|
31
30
|
apiKey,
|
|
32
31
|
"/team",
|
|
33
32
|
"loop-key-register",
|
|
34
|
-
teamName
|
|
33
|
+
teamName,
|
|
35
34
|
);
|
|
36
35
|
|
|
37
36
|
if (Array.isArray(teamData) && teamData.length === 0) {
|
|
38
|
-
// 204 was converted to empty array — ambiguous scope
|
|
39
37
|
warning =
|
|
40
38
|
"Key accepted but Loop returned no team data (204). " +
|
|
41
39
|
"Verify the key's scope in Loop's dashboard.";
|
|
@@ -47,49 +45,26 @@ export async function keyRegister(params: {
|
|
|
47
45
|
if (err instanceof LoopApiError && err.status === 401) {
|
|
48
46
|
throw new Error(
|
|
49
47
|
`Loop API rejected the key for team "${teamName}" (HTTP 401). ` +
|
|
50
|
-
|
|
48
|
+
`Check that the key is valid and not expired.`,
|
|
51
49
|
);
|
|
52
50
|
}
|
|
53
|
-
// Network/timeout errors — still reject, key is unverified
|
|
54
51
|
throw new Error(
|
|
55
|
-
`Could not validate key against Loop API: ${err instanceof Error ? err.message : String(err)}
|
|
52
|
+
`Could not validate key against Loop API: ${err instanceof Error ? err.message : String(err)}`,
|
|
56
53
|
);
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const { created } = await selectLoopKeyStore().save(accountId, {
|
|
57
|
+
teamName,
|
|
58
|
+
apiKey,
|
|
59
|
+
teamAddress,
|
|
60
|
+
agentId,
|
|
61
|
+
permissions,
|
|
62
|
+
});
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
await writeSession.run(
|
|
66
|
-
`CREATE INDEX loop_team_key_account_team IF NOT EXISTS
|
|
67
|
-
FOR (k:LoopTeamKey) ON (k.accountId, k.teamName)`,
|
|
68
|
-
{}
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const mergeResult = await writeSession.run(
|
|
72
|
-
`MERGE (k:LoopTeamKey {teamName: $teamName, accountId: $accountId})
|
|
73
|
-
ON CREATE SET
|
|
74
|
-
k.encryptedKey = $encryptedKey,
|
|
75
|
-
k.teamAddress = $teamAddress,
|
|
76
|
-
k.agentId = $agentId,
|
|
77
|
-
k.permissions = $permissions,
|
|
78
|
-
k.createdAt = $now,
|
|
79
|
-
k.updatedAt = $now
|
|
80
|
-
RETURN k.createdAt = $now AS created`,
|
|
81
|
-
{ teamName, encryptedKey, teamAddress, agentId, accountId, permissions, now }
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const created = mergeResult.records[0]?.get("created");
|
|
85
|
-
if (!created) {
|
|
86
|
-
throw new Error(`Team "${teamName}" is already registered for this account.`);
|
|
87
|
-
}
|
|
88
|
-
} finally {
|
|
89
|
-
await writeSession.close();
|
|
64
|
+
if (!created) {
|
|
65
|
+
throw new Error(`Team "${teamName}" is already registered for this account.`);
|
|
90
66
|
}
|
|
91
67
|
|
|
92
68
|
console.error(`[loop] key-register team=${teamName} account=${accountId}`);
|
|
93
|
-
|
|
94
69
|
return { warning };
|
|
95
70
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "real-agent-preval",
|
|
3
|
+
"description": "Single-address pre-valuation pack. One full UK address in, 4-page A4 PDF out (cover · valuation · area · demand+trend+sources). Consumes the real-agent-property-data MCP — no MCP tools of its own.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Rubytech LLC"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: real-agent-preval
|
|
3
|
+
description: "Single-address pre-valuation pack. One full UK address in, 4-page A4 PDF out (cover · valuation · area · demand+trend+sources). Consumes the real-agent-property-data MCP — no MCP tools of its own."
|
|
4
|
+
skills:
|
|
5
|
+
- skills/property-preval/SKILL.md
|
|
6
|
+
always: false
|
|
7
|
+
metadata: {"platform":{"optional":true,"embed":["admin"]}}
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Real Agent — Preval
|
|
11
|
+
|
|
12
|
+
Consumer sub-plugin. No MCP server, no new tools — only a skill (`property-preval`) that takes one full UK address and renders a 4-page A4 pre-valuation PDF by fanning out to 12 of the 22 `real-agent-property-data` MCP tools.
|
|
13
|
+
|
|
14
|
+
## What it produces
|
|
15
|
+
|
|
16
|
+
A 4-page A4 PDF and the source HTML, written to `~/Documents/Maxy/preval/<postcode>-<YYYY-MM-DD>/`:
|
|
17
|
+
|
|
18
|
+
- **Page 1 — Cover.** Full address, postcode chip, generated-date meta strip.
|
|
19
|
+
- **Page 2 — Valuation.** Average asking £, asking £/sqft, sold avg £, sold £/sqft. Nearest-sold comps table. Live asking comps grid.
|
|
20
|
+
- **Page 3 — Area.** Crime rating, flood risk, council-tax band D cost, local area population. Crime breakdown panel + council-tax band table. Headline read.
|
|
21
|
+
- **Page 4 — Demand, trend, sources.** Demand rating, days-on-market, turnover, for-sale count. 7y growth sparkline (£ and £/sqft). Rental-side mini-panel. Property-types doughnut. Sources/methodology block.
|
|
22
|
+
|
|
23
|
+
## How the address routes
|
|
24
|
+
|
|
25
|
+
The skill derives the postcode from the address (UK-postcode regex on the final token group), then fans out to **12** `real-agent-property-data` MCP tools in fixed call order:
|
|
26
|
+
|
|
27
|
+
`prices`, `prices-per-sqf`, `sold-prices`, `sold-prices-per-sqf`, `growth`, `growth-psf`, `demand`, `demand-rent`, `property-types`, `crime`, `flood-risk`, `council-tax`.
|
|
28
|
+
|
|
29
|
+
Two tools from the same MCP are **deliberately not called** by this skill:
|
|
30
|
+
|
|
31
|
+
- `property-data-address-match-uprn` — UPRN is CRM hygiene, not preval data.
|
|
32
|
+
- `property-data-planning-applications` — planning is a separate dev-precedent report.
|
|
33
|
+
|
|
34
|
+
Operators can still reach those tools via the underlying `property-data` skill or directly through the MCP.
|
|
35
|
+
|
|
36
|
+
## Dependencies
|
|
37
|
+
|
|
38
|
+
- Requires `real-agent-property-data` enabled on the account with a registered PropertyData API key (`property-data-key-register`). Without a key every fan-out call returns `Error: key-not-registered` and the renderer raises before producing a PDF.
|
|
39
|
+
- Requires Google Chrome at `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` (mac, headless `--print-to-pdf`). Same Chrome dependency as `property-market-report`.
|