@wootsup/yt-builder-mcp 1.0.0 → 1.1.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/README.md +18 -6
- package/bin/yt-builder-mcp.js +6 -0
- package/dist/auth.d.ts +86 -6
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +141 -8
- package/dist/auth.js.map +1 -1
- package/dist/errors/sanitize.d.ts.map +1 -1
- package/dist/errors/sanitize.js +10 -0
- package/dist/errors/sanitize.js.map +1 -1
- package/dist/gateway/essentials.d.ts +1 -1
- package/dist/gateway/essentials.d.ts.map +1 -1
- package/dist/gateway/essentials.js +15 -2
- package/dist/gateway/essentials.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -16
- package/dist/index.js.map +1 -1
- package/dist/install-skill.d.ts +10 -2
- package/dist/install-skill.d.ts.map +1 -1
- package/dist/install-skill.js +18 -7
- package/dist/install-skill.js.map +1 -1
- package/dist/platform/detect.d.ts +64 -0
- package/dist/platform/detect.d.ts.map +1 -0
- package/dist/platform/detect.js +98 -0
- package/dist/platform/detect.js.map +1 -0
- package/dist/platform/index.d.ts +72 -0
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/index.js +138 -0
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/joomla.d.ts +44 -0
- package/dist/platform/joomla.d.ts.map +1 -0
- package/dist/platform/joomla.js +46 -0
- package/dist/platform/joomla.js.map +1 -0
- package/dist/server.d.ts +61 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +86 -2
- package/dist/server.js.map +1 -1
- package/dist/setup-cli-confirm.d.ts +36 -0
- package/dist/setup-cli-confirm.d.ts.map +1 -0
- package/dist/setup-cli-confirm.js +59 -0
- package/dist/setup-cli-confirm.js.map +1 -0
- package/dist/setup-cli.d.ts +53 -1
- package/dist/setup-cli.d.ts.map +1 -1
- package/dist/setup-cli.js +525 -10
- package/dist/setup-cli.js.map +1 -1
- package/dist/setup-prompts.d.ts.map +1 -1
- package/dist/setup-prompts.js +12 -8
- package/dist/setup-prompts.js.map +1 -1
- package/dist/setup-wizard-types.d.ts +19 -3
- package/dist/setup-wizard-types.d.ts.map +1 -1
- package/dist/setup-wizard.d.ts.map +1 -1
- package/dist/setup-wizard.js +34 -1
- package/dist/setup-wizard.js.map +1 -1
- package/dist/sites/cli/add-site.d.ts +106 -0
- package/dist/sites/cli/add-site.d.ts.map +1 -0
- package/dist/sites/cli/add-site.js +185 -0
- package/dist/sites/cli/add-site.js.map +1 -0
- package/dist/sites/cli/list-sites.d.ts +40 -0
- package/dist/sites/cli/list-sites.d.ts.map +1 -0
- package/dist/sites/cli/list-sites.js +117 -0
- package/dist/sites/cli/list-sites.js.map +1 -0
- package/dist/sites/cli/remove-site.d.ts +60 -0
- package/dist/sites/cli/remove-site.d.ts.map +1 -0
- package/dist/sites/cli/remove-site.js +120 -0
- package/dist/sites/cli/remove-site.js.map +1 -0
- package/dist/sites/cli/set-default.d.ts +47 -0
- package/dist/sites/cli/set-default.d.ts.map +1 -0
- package/dist/sites/cli/set-default.js +69 -0
- package/dist/sites/cli/set-default.js.map +1 -0
- package/dist/sites/cli/test-site.d.ts +77 -0
- package/dist/sites/cli/test-site.d.ts.map +1 -0
- package/dist/sites/cli/test-site.js +146 -0
- package/dist/sites/cli/test-site.js.map +1 -0
- package/dist/sites/client-pool.d.ts +124 -0
- package/dist/sites/client-pool.d.ts.map +1 -0
- package/dist/sites/client-pool.js +172 -0
- package/dist/sites/client-pool.js.map +1 -0
- package/dist/sites/env-bridge.d.ts +55 -0
- package/dist/sites/env-bridge.d.ts.map +1 -0
- package/dist/sites/env-bridge.js +94 -0
- package/dist/sites/env-bridge.js.map +1 -0
- package/dist/sites/paths.d.ts +21 -0
- package/dist/sites/paths.d.ts.map +1 -0
- package/dist/sites/paths.js +37 -0
- package/dist/sites/paths.js.map +1 -0
- package/dist/sites/probe.d.ts +60 -0
- package/dist/sites/probe.d.ts.map +1 -0
- package/dist/sites/probe.js +112 -0
- package/dist/sites/probe.js.map +1 -0
- package/dist/sites/registry.d.ts +142 -0
- package/dist/sites/registry.d.ts.map +1 -0
- package/dist/sites/registry.js +163 -0
- package/dist/sites/registry.js.map +1 -0
- package/dist/sites/schema.d.ts +90 -0
- package/dist/sites/schema.d.ts.map +1 -0
- package/dist/sites/schema.js +71 -0
- package/dist/sites/schema.js.map +1 -0
- package/dist/sites/secret-resolver.d.ts +109 -0
- package/dist/sites/secret-resolver.d.ts.map +1 -0
- package/dist/sites/secret-resolver.js +189 -0
- package/dist/sites/secret-resolver.js.map +1 -0
- package/dist/sites/store.d.ts +82 -0
- package/dist/sites/store.d.ts.map +1 -0
- package/dist/sites/store.js +198 -0
- package/dist/sites/store.js.map +1 -0
- package/dist/sites/tools/index.d.ts +28 -0
- package/dist/sites/tools/index.d.ts.map +1 -0
- package/dist/sites/tools/index.js +30 -0
- package/dist/sites/tools/index.js.map +1 -0
- package/dist/sites/tools/sites-list.d.ts +48 -0
- package/dist/sites/tools/sites-list.d.ts.map +1 -0
- package/dist/sites/tools/sites-list.js +135 -0
- package/dist/sites/tools/sites-list.js.map +1 -0
- package/dist/sites/tools/sites-test.d.ts +47 -0
- package/dist/sites/tools/sites-test.d.ts.map +1 -0
- package/dist/sites/tools/sites-test.js +148 -0
- package/dist/sites/tools/sites-test.js.map +1 -0
- package/dist/skill-loader.d.ts +63 -3
- package/dist/skill-loader.d.ts.map +1 -1
- package/dist/skill-loader.js +123 -10
- package/dist/skill-loader.js.map +1 -1
- package/dist/tools/elements/builders.d.ts +2 -2
- package/dist/tools/elements/builders.d.ts.map +1 -1
- package/dist/tools/elements/builders.js +45 -23
- package/dist/tools/elements/builders.js.map +1 -1
- package/dist/tools/elements/handlers.d.ts +8 -1
- package/dist/tools/elements/handlers.d.ts.map +1 -1
- package/dist/tools/elements/handlers.js +37 -1
- package/dist/tools/elements/handlers.js.map +1 -1
- package/dist/tools/format/health-format.d.ts +12 -6
- package/dist/tools/format/health-format.d.ts.map +1 -1
- package/dist/tools/format/health-format.js +14 -11
- package/dist/tools/format/health-format.js.map +1 -1
- package/dist/tools/format/pages-format.d.ts +7 -1
- package/dist/tools/format/pages-format.d.ts.map +1 -1
- package/dist/tools/format/pages-format.js +25 -1
- package/dist/tools/format/pages-format.js.map +1 -1
- package/dist/tools/health.d.ts +2 -2
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/health.js +120 -47
- package/dist/tools/health.js.map +1 -1
- package/dist/tools/index.d.ts +9 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +21 -7
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/inspection.d.ts +2 -2
- package/dist/tools/inspection.d.ts.map +1 -1
- package/dist/tools/inspection.js +67 -22
- package/dist/tools/inspection.js.map +1 -1
- package/dist/tools/multi-items/builders.d.ts +2 -2
- package/dist/tools/multi-items/builders.d.ts.map +1 -1
- package/dist/tools/multi-items/builders.js +21 -8
- package/dist/tools/multi-items/builders.js.map +1 -1
- package/dist/tools/pages/builders.d.ts +2 -2
- package/dist/tools/pages/builders.d.ts.map +1 -1
- package/dist/tools/pages/builders.js +36 -24
- package/dist/tools/pages/builders.js.map +1 -1
- package/dist/tools/pages/handlers-read.d.ts.map +1 -1
- package/dist/tools/pages/handlers-read.js +10 -0
- package/dist/tools/pages/handlers-read.js.map +1 -1
- package/dist/tools/pages/schemas.d.ts.map +1 -1
- package/dist/tools/pages/schemas.js +18 -0
- package/dist/tools/pages/schemas.js.map +1 -1
- package/dist/tools/pool-resolve-helper.d.ts +83 -0
- package/dist/tools/pool-resolve-helper.d.ts.map +1 -0
- package/dist/tools/pool-resolve-helper.js +148 -0
- package/dist/tools/pool-resolve-helper.js.map +1 -0
- package/dist/tools/shared-schemas.d.ts +10 -0
- package/dist/tools/shared-schemas.d.ts.map +1 -1
- package/dist/tools/shared-schemas.js +20 -2
- package/dist/tools/shared-schemas.js.map +1 -1
- package/dist/tools/sources/builders.d.ts +2 -2
- package/dist/tools/sources/builders.d.ts.map +1 -1
- package/dist/tools/sources/builders.js +27 -15
- package/dist/tools/sources/builders.js.map +1 -1
- package/dist/tools/tool-builder/index.d.ts +1 -1
- package/dist/tools/tool-builder/index.d.ts.map +1 -1
- package/dist/tools/tool-builder/index.js +1 -1
- package/dist/tools/tool-builder/index.js.map +1 -1
- package/dist/tools/tool-builder/results.d.ts +34 -0
- package/dist/tools/tool-builder/results.d.ts.map +1 -1
- package/dist/tools/tool-builder/results.js +86 -0
- package/dist/tools/tool-builder/results.js.map +1 -1
- package/manifest.json +27 -10
- package/package.json +3 -1
- package/skills/yt-builder-mcp/SKILL.md +846 -0
- package/skills/yootheme-builder/SKILL.md +0 -587
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W1 — Sites-Storage Foundation: load/save the sites file.
|
|
3
|
+
*
|
|
4
|
+
* Guarantees:
|
|
5
|
+
* - **Atomic replace.** Writes go to a sibling `*.tmp.<rand>` file, are
|
|
6
|
+
* fsynced, chmod'd to 0600, and then `rename(2)`d over the target.
|
|
7
|
+
* A SIGINT/SIGKILL between any two of these steps leaves either the
|
|
8
|
+
* old file intact or the new file fully written — never a torn write.
|
|
9
|
+
* - **Lock for concurrent writers.** `proper-lockfile` acquires an
|
|
10
|
+
* advisory lockfile (`<file>.lock`) before any read/modify/write
|
|
11
|
+
* cycle. Default `stale: 10000` ms; second concurrent save retries
|
|
12
|
+
* with exponential back-off (`retries: 10, minTimeout: 50`).
|
|
13
|
+
* - **0600 mode on write.** The temp file is opened/chmod'd to 0600
|
|
14
|
+
* BEFORE the rename so the new inode never exists with looser perms,
|
|
15
|
+
* even for one fsync window.
|
|
16
|
+
* - **Schema-version gate.** Refuses to load a file with a version we
|
|
17
|
+
* don't understand — explicit error, never silent migration.
|
|
18
|
+
*
|
|
19
|
+
* @license MIT
|
|
20
|
+
*/
|
|
21
|
+
import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeSync, } from 'node:fs';
|
|
22
|
+
import { dirname } from 'node:path';
|
|
23
|
+
import lockfile from 'proper-lockfile';
|
|
24
|
+
import { SitesFile } from './schema.js';
|
|
25
|
+
/** Base class for any sites-file IO/format failure. */
|
|
26
|
+
export class SitesFileError extends Error {
|
|
27
|
+
cause;
|
|
28
|
+
constructor(message, cause) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.cause = cause;
|
|
31
|
+
this.name = 'SitesFileError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Thrown when the on-disk file declares a `schema_version` we don't know. */
|
|
35
|
+
export class SchemaVersionError extends SitesFileError {
|
|
36
|
+
found;
|
|
37
|
+
constructor(found) {
|
|
38
|
+
super(`Unsupported sites-file schema_version: ${String(found)}. ` +
|
|
39
|
+
`This build supports schema_version: 1. ` +
|
|
40
|
+
`Upgrade @wootsup/yt-builder-mcp or revert the file.`);
|
|
41
|
+
this.found = found;
|
|
42
|
+
this.name = 'SchemaVersionError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class SitesFileLockError extends SitesFileError {
|
|
46
|
+
lockCode;
|
|
47
|
+
lockfilePath;
|
|
48
|
+
constructor(lockCode, lockfilePath, message, cause) {
|
|
49
|
+
super(message, cause);
|
|
50
|
+
this.lockCode = lockCode;
|
|
51
|
+
this.lockfilePath = lockfilePath;
|
|
52
|
+
this.name = 'SitesFileLockError';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the empty seed used when a sites file does not yet exist.
|
|
57
|
+
* Callers (W3 registry) detect "no file → run env-bridge fallback".
|
|
58
|
+
*/
|
|
59
|
+
export function emptySitesFile() {
|
|
60
|
+
return { schema_version: 1, default_site_id: null, sites: [] };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Load + validate a sites file.
|
|
64
|
+
*
|
|
65
|
+
* Returns {@link emptySitesFile} when the path does not exist (no error).
|
|
66
|
+
* Throws {@link SchemaVersionError} for a known-unknown version and
|
|
67
|
+
* {@link SitesFileError} for JSON-parse or Zod-validation failures.
|
|
68
|
+
*/
|
|
69
|
+
export async function loadSitesFile(path) {
|
|
70
|
+
if (!existsSync(path)) {
|
|
71
|
+
return emptySitesFile();
|
|
72
|
+
}
|
|
73
|
+
let raw;
|
|
74
|
+
try {
|
|
75
|
+
raw = readFileSync(path, 'utf-8');
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
throw new SitesFileError(`Failed to read sites file at ${path}`, e);
|
|
79
|
+
}
|
|
80
|
+
let parsed;
|
|
81
|
+
try {
|
|
82
|
+
parsed = JSON.parse(raw);
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
throw new SitesFileError(`Sites file at ${path} is not valid JSON`, e);
|
|
86
|
+
}
|
|
87
|
+
if (typeof parsed === 'object' && parsed !== null
|
|
88
|
+
&& 'schema_version' in parsed
|
|
89
|
+
&& parsed.schema_version !== 1) {
|
|
90
|
+
throw new SchemaVersionError(parsed.schema_version);
|
|
91
|
+
}
|
|
92
|
+
const result = SitesFile.safeParse(parsed);
|
|
93
|
+
if (!result.success) {
|
|
94
|
+
throw new SitesFileError(`Sites file at ${path} failed schema validation: ` +
|
|
95
|
+
result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('; '));
|
|
96
|
+
}
|
|
97
|
+
return result.data;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Persist + validate a sites file atomically with chmod 0600.
|
|
101
|
+
*
|
|
102
|
+
* Pipeline:
|
|
103
|
+
* 1. Acquire `<path>.lock` via proper-lockfile (with retries).
|
|
104
|
+
* 2. Validate `data` through {@link SitesFile} (rejects bad input
|
|
105
|
+
* before touching the filesystem).
|
|
106
|
+
* 3. Ensure parent directory exists.
|
|
107
|
+
* 4. Write JSON to `<path>.tmp.<pid>.<rand>`, fsync, chmod 0600.
|
|
108
|
+
* 5. `renameSync` over `<path>`.
|
|
109
|
+
* 6. Release lock.
|
|
110
|
+
*
|
|
111
|
+
* Tmp-file cleanup on any failure path.
|
|
112
|
+
*/
|
|
113
|
+
export async function saveSitesFile(path, data) {
|
|
114
|
+
const validated = SitesFile.safeParse(data);
|
|
115
|
+
if (!validated.success) {
|
|
116
|
+
throw new SitesFileError(`Refusing to write invalid sites file: ` +
|
|
117
|
+
validated.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('; '));
|
|
118
|
+
}
|
|
119
|
+
const dir = dirname(path);
|
|
120
|
+
// W12-R1.2 (A2-M3): the on-disk sites file ends up chmod 0600, but
|
|
121
|
+
// the parent directory was previously created with the process
|
|
122
|
+
// umask — typically 0o755 on Linux/macOS, which is world-readable.
|
|
123
|
+
// A world-readable parent dir is harmless for the bearers (they
|
|
124
|
+
// live in 0600 files) but DOES leak the existence of a sites.json
|
|
125
|
+
// to any local user. Tighten to 0700 (owner-only rwx) on creation.
|
|
126
|
+
// Existing directories are left as-is — mkdirSync is a no-op when
|
|
127
|
+
// the dir exists, and chmod'ing an existing dir would surprise
|
|
128
|
+
// operators who chose a shared location intentionally.
|
|
129
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
130
|
+
// proper-lockfile defaults to realpath:true, which throws ENOENT for
|
|
131
|
+
// a not-yet-existing target. Disable realpath + steer the lock at an
|
|
132
|
+
// explicit sibling path. The lock dir always exists (mkdirSync above).
|
|
133
|
+
const lockfilePath = `${path}.lock`;
|
|
134
|
+
let release;
|
|
135
|
+
try {
|
|
136
|
+
release = await lockfile.lock(path, {
|
|
137
|
+
lockfilePath,
|
|
138
|
+
realpath: false,
|
|
139
|
+
stale: 10_000,
|
|
140
|
+
retries: { retries: 10, minTimeout: 50, maxTimeout: 500, factor: 2 },
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
// W12-R1.2 (A4-F1): map the underlying error code into a
|
|
145
|
+
// discriminated lock-failure so callers can render the right
|
|
146
|
+
// recovery hint instead of telling the user three possible
|
|
147
|
+
// causes at once.
|
|
148
|
+
const errCode = e !== null && typeof e === 'object' && 'code' in e
|
|
149
|
+
? e.code
|
|
150
|
+
: undefined;
|
|
151
|
+
let lockCode;
|
|
152
|
+
let hint;
|
|
153
|
+
if (errCode === 'ELOCKED') {
|
|
154
|
+
lockCode = 'LOCK_TIMEOUT';
|
|
155
|
+
hint =
|
|
156
|
+
'Another setup process is currently writing — retry in 30s.';
|
|
157
|
+
}
|
|
158
|
+
else if (errCode === 'EACCES' || errCode === 'EPERM') {
|
|
159
|
+
lockCode = 'LOCK_PERMISSION';
|
|
160
|
+
hint = `Cannot write to lock dir. Check permissions on ${dir}.`;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
lockCode = 'LOCK_ORPHAN';
|
|
164
|
+
hint =
|
|
165
|
+
`Stale lock from prior crashed process. Remove with: rm ${lockfilePath}`;
|
|
166
|
+
}
|
|
167
|
+
throw new SitesFileLockError(lockCode, lockfilePath, `Could not acquire lock on ${lockfilePath}. ${hint}`, e);
|
|
168
|
+
}
|
|
169
|
+
const tmpPath = `${path}.tmp.${process.pid}.${Math.random().toString(36).slice(2, 10)}`;
|
|
170
|
+
try {
|
|
171
|
+
const fd = openSync(tmpPath, 'w', 0o600);
|
|
172
|
+
try {
|
|
173
|
+
const payload = JSON.stringify(validated.data, null, 2) + '\n';
|
|
174
|
+
writeSync(fd, payload);
|
|
175
|
+
fsyncSync(fd);
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
closeSync(fd);
|
|
179
|
+
}
|
|
180
|
+
// Belt-and-braces: openSync's mode arg may be umask-clamped on
|
|
181
|
+
// some platforms; the explicit chmod guarantees 0600 regardless.
|
|
182
|
+
chmodSync(tmpPath, 0o600);
|
|
183
|
+
renameSync(tmpPath, path);
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
// Best-effort tmp cleanup; ignore failures.
|
|
187
|
+
try {
|
|
188
|
+
if (existsSync(tmpPath))
|
|
189
|
+
unlinkSync(tmpPath);
|
|
190
|
+
}
|
|
191
|
+
catch { /* swallow */ }
|
|
192
|
+
throw new SitesFileError(`Failed to write sites file at ${path}`, e);
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
await release().catch(() => { });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/sites/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACH,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,GACZ,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAmB,MAAM,aAAa,CAAC;AAEzD,uDAAuD;AACvD,MAAM,OAAO,cAAe,SAAQ,KAAK;IACQ;IAA7C,YAAY,OAAe,EAAkB,KAAe;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QAD0B,UAAK,GAAL,KAAK,CAAU;QAExD,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IACjC,CAAC;CACJ;AAED,8EAA8E;AAC9E,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IACtB;IAA5B,YAA4B,KAAc;QACtC,KAAK,CACD,0CAA0C,MAAM,CAAC,KAAK,CAAC,IAAI;YAC3D,yCAAyC;YACzC,qDAAqD,CACxD,CAAC;QALsB,UAAK,GAAL,KAAK,CAAS;QAMtC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACrC,CAAC;CACJ;AAoBD,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IAE9B;IACA;IAFpB,YACoB,QAA2B,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,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IACxF,IAAI,CAAC;QACD,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;YAC/D,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;YACvB,SAAS,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;gBAAS,CAAC;YACP,SAAS,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QACD,+DAA+D;QAC/D,iEAAiE;QACjE,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1B,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,4CAA4C;QAC5C,IAAI,CAAC;YAAC,IAAI,UAAU,CAAC,OAAO,CAAC;gBAAE,UAAU,CAAC,OAAO,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC;QAC7E,MAAM,IAAI,cAAc,CAAC,iCAAiC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;YAAS,CAAC;QACP,MAAM,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAA4C,CAAC,CAAC,CAAC;IAC9E,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W7 — sites/tools/ aggregator.
|
|
3
|
+
*
|
|
4
|
+
* Returns the two L1 platform-agnostic site-management tools:
|
|
5
|
+
* - `yootheme_builder_sites_list` (registry inspection — no REST)
|
|
6
|
+
* - `yootheme_builder_sites_test` (per-site connectivity probe)
|
|
7
|
+
*
|
|
8
|
+
* Wired into `buildAllTools(pool)` — the aggregator pulls the
|
|
9
|
+
* read-only `SiteRegistry` off the pool internally so callers thread
|
|
10
|
+
* only the pool through, never the registry separately.
|
|
11
|
+
*
|
|
12
|
+
* @license MIT
|
|
13
|
+
*/
|
|
14
|
+
import type { ClientPool } from '../client-pool.js';
|
|
15
|
+
import type { AnyToolDefinition } from '../../tools/tool-builder.js';
|
|
16
|
+
/**
|
|
17
|
+
* Build the W7 sites-management tool pair. The pool's read-only
|
|
18
|
+
* `registry` accessor feeds `buildSitesListTool` (which never resolves
|
|
19
|
+
* a bearer); the pool itself feeds `buildSitesTestTool` (which calls
|
|
20
|
+
* `pool.resolve(site_id)` to obtain a `RestClient`).
|
|
21
|
+
*
|
|
22
|
+
* W12-R1.3 (A1-L-01): single-arg signature — reading the registry off
|
|
23
|
+
* the pool inside this aggregator removes the only call-site that
|
|
24
|
+
* needed the pool's `registry` getter, so the getter can stay
|
|
25
|
+
* `@internal`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildSitesTools(pool: ClientPool): readonly AnyToolDefinition[];
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sites/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAKrE;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC3B,IAAI,EAAE,UAAU,GACjB,SAAS,iBAAiB,EAAE,CAE9B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W7 — sites/tools/ aggregator.
|
|
3
|
+
*
|
|
4
|
+
* Returns the two L1 platform-agnostic site-management tools:
|
|
5
|
+
* - `yootheme_builder_sites_list` (registry inspection — no REST)
|
|
6
|
+
* - `yootheme_builder_sites_test` (per-site connectivity probe)
|
|
7
|
+
*
|
|
8
|
+
* Wired into `buildAllTools(pool)` — the aggregator pulls the
|
|
9
|
+
* read-only `SiteRegistry` off the pool internally so callers thread
|
|
10
|
+
* only the pool through, never the registry separately.
|
|
11
|
+
*
|
|
12
|
+
* @license MIT
|
|
13
|
+
*/
|
|
14
|
+
import { buildSitesListTool } from './sites-list.js';
|
|
15
|
+
import { buildSitesTestTool } from './sites-test.js';
|
|
16
|
+
/**
|
|
17
|
+
* Build the W7 sites-management tool pair. The pool's read-only
|
|
18
|
+
* `registry` accessor feeds `buildSitesListTool` (which never resolves
|
|
19
|
+
* a bearer); the pool itself feeds `buildSitesTestTool` (which calls
|
|
20
|
+
* `pool.resolve(site_id)` to obtain a `RestClient`).
|
|
21
|
+
*
|
|
22
|
+
* W12-R1.3 (A1-L-01): single-arg signature — reading the registry off
|
|
23
|
+
* the pool inside this aggregator removes the only call-site that
|
|
24
|
+
* needed the pool's `registry` getter, so the getter can stay
|
|
25
|
+
* `@internal`.
|
|
26
|
+
*/
|
|
27
|
+
export function buildSitesTools(pool) {
|
|
28
|
+
return [buildSitesListTool(pool.registry), buildSitesTestTool(pool)];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sites/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC3B,IAAgB;IAEhB,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W7 — `yootheme_builder_sites_list` L1 tool.
|
|
3
|
+
*
|
|
4
|
+
* Platform-agnostic registry inspection: lists the in-process
|
|
5
|
+
* {@link SiteRegistry} as a tabular result so an agent (or a Maria-class
|
|
6
|
+
* Claude-Desktop user) can discover which site_ids are wired into this
|
|
7
|
+
* MCP server WITHOUT a network round-trip.
|
|
8
|
+
*
|
|
9
|
+
* Why it does NOT call `pool.resolve()`:
|
|
10
|
+
* - The tool reads the registry verbatim and never touches bearers, the
|
|
11
|
+
* secret-resolver, or any HTTP endpoint. Resolving through the pool
|
|
12
|
+
* would force a default-site requirement that is exactly the
|
|
13
|
+
* bootstrap failure-mode the tool is meant to diagnose ("I added
|
|
14
|
+
* sites but forgot to mark a default"). For the same reason the
|
|
15
|
+
* handler intentionally skips `withSiteMeta` — there is no resolved
|
|
16
|
+
* site to stamp; instead we emit a `structuredContent._meta.tool_kind
|
|
17
|
+
* = 'registry'` marker so MCP hosts can route the result through a
|
|
18
|
+
* registry-aware UI if/when they grow one.
|
|
19
|
+
*
|
|
20
|
+
* Why `site_id` is exposed but unused:
|
|
21
|
+
* - The W5 SITE_ID_SCHEMA pin requires EVERY tool to expose the
|
|
22
|
+
* optional `site_id` field so legacy/scripted callers never trip a
|
|
23
|
+
* Zod parse on an extra-property. The W12-R1.3 DESCRIPTION_SUFFIX_EXEMPT
|
|
24
|
+
* list opts this tool out of the canonical description suffix
|
|
25
|
+
* because "operates on the default site" would imply per-row
|
|
26
|
+
* filtering that the handler does not perform.
|
|
27
|
+
*
|
|
28
|
+
* W12-R1.3 (A2-L4): `bearer_source` was previously projected into the
|
|
29
|
+
* output row + table column. Even though it carried only the literal
|
|
30
|
+
* `'plain'` / `'op'`, the `sites://current` resource already omits
|
|
31
|
+
* this field (see ADR rationale in server.ts) and the tool surface
|
|
32
|
+
* should match for cross-surface consistency. The field is dropped
|
|
33
|
+
* from both the structured row AND the table column.
|
|
34
|
+
*
|
|
35
|
+
* @license MIT
|
|
36
|
+
*/
|
|
37
|
+
import type { SiteRegistry } from '../registry.js';
|
|
38
|
+
import { type AnyToolDefinition } from '../../tools/tool-builder.js';
|
|
39
|
+
/**
|
|
40
|
+
* Build the W7 `yootheme_builder_sites_list` tool.
|
|
41
|
+
*
|
|
42
|
+
* Signature accepts the {@link SiteRegistry} directly — unlike other
|
|
43
|
+
* tool-builders, it does NOT need the {@link ClientPool} because it
|
|
44
|
+
* never resolves a site. Callers wire `buildSitesListTool(pool.registry)`
|
|
45
|
+
* from the W7 aggregator (`src/sites/tools/index.ts`).
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildSitesListTool(registry: SiteRegistry): AnyToolDefinition;
|
|
48
|
+
//# sourceMappingURL=sites-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites-list.d.ts","sourceRoot":"","sources":["../../../src/sites/tools/sites-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAIH,KAAK,iBAAiB,EACzB,MAAM,6BAA6B,CAAC;AA+BrC;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CAmE5E"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W7 — `yootheme_builder_sites_list` L1 tool.
|
|
3
|
+
*
|
|
4
|
+
* Platform-agnostic registry inspection: lists the in-process
|
|
5
|
+
* {@link SiteRegistry} as a tabular result so an agent (or a Maria-class
|
|
6
|
+
* Claude-Desktop user) can discover which site_ids are wired into this
|
|
7
|
+
* MCP server WITHOUT a network round-trip.
|
|
8
|
+
*
|
|
9
|
+
* Why it does NOT call `pool.resolve()`:
|
|
10
|
+
* - The tool reads the registry verbatim and never touches bearers, the
|
|
11
|
+
* secret-resolver, or any HTTP endpoint. Resolving through the pool
|
|
12
|
+
* would force a default-site requirement that is exactly the
|
|
13
|
+
* bootstrap failure-mode the tool is meant to diagnose ("I added
|
|
14
|
+
* sites but forgot to mark a default"). For the same reason the
|
|
15
|
+
* handler intentionally skips `withSiteMeta` — there is no resolved
|
|
16
|
+
* site to stamp; instead we emit a `structuredContent._meta.tool_kind
|
|
17
|
+
* = 'registry'` marker so MCP hosts can route the result through a
|
|
18
|
+
* registry-aware UI if/when they grow one.
|
|
19
|
+
*
|
|
20
|
+
* Why `site_id` is exposed but unused:
|
|
21
|
+
* - The W5 SITE_ID_SCHEMA pin requires EVERY tool to expose the
|
|
22
|
+
* optional `site_id` field so legacy/scripted callers never trip a
|
|
23
|
+
* Zod parse on an extra-property. The W12-R1.3 DESCRIPTION_SUFFIX_EXEMPT
|
|
24
|
+
* list opts this tool out of the canonical description suffix
|
|
25
|
+
* because "operates on the default site" would imply per-row
|
|
26
|
+
* filtering that the handler does not perform.
|
|
27
|
+
*
|
|
28
|
+
* W12-R1.3 (A2-L4): `bearer_source` was previously projected into the
|
|
29
|
+
* output row + table column. Even though it carried only the literal
|
|
30
|
+
* `'plain'` / `'op'`, the `sites://current` resource already omits
|
|
31
|
+
* this field (see ADR rationale in server.ts) and the tool surface
|
|
32
|
+
* should match for cross-surface consistency. The field is dropped
|
|
33
|
+
* from both the structured row AND the table column.
|
|
34
|
+
*
|
|
35
|
+
* @license MIT
|
|
36
|
+
*/
|
|
37
|
+
import { tableResult } from '@getimo/mcp-toolkit';
|
|
38
|
+
import { z } from 'zod';
|
|
39
|
+
import { SITE_ID_SCHEMA } from '../../tools/shared-schemas.js';
|
|
40
|
+
import { defineTool, readOnly, structuredResult, } from '../../tools/tool-builder.js';
|
|
41
|
+
const SITES_LIST_OUTPUT_SCHEMA = z.object({
|
|
42
|
+
items: z.array(z.object({
|
|
43
|
+
site_id: z.string(),
|
|
44
|
+
url: z.string(),
|
|
45
|
+
platform_hint: z.enum(['wordpress', 'joomla', 'auto']),
|
|
46
|
+
platform_resolved: z.enum(['wordpress', 'joomla']).optional(),
|
|
47
|
+
is_default: z.boolean(),
|
|
48
|
+
label: z.string().optional(),
|
|
49
|
+
})),
|
|
50
|
+
total: z.number(),
|
|
51
|
+
default_site_id: z.string().nullable(),
|
|
52
|
+
_meta: z
|
|
53
|
+
.object({
|
|
54
|
+
tool_kind: z.string(),
|
|
55
|
+
})
|
|
56
|
+
.passthrough()
|
|
57
|
+
.optional(),
|
|
58
|
+
});
|
|
59
|
+
const TABLE_COLUMNS = [
|
|
60
|
+
{ key: 'site_id', label: 'SITE_ID', width: 20 },
|
|
61
|
+
{ key: 'url', label: 'URL', width: 36 },
|
|
62
|
+
{ key: 'platform', label: 'PLATFORM', width: 11 },
|
|
63
|
+
{ key: 'is_default', label: 'DEFAULT', width: 9 },
|
|
64
|
+
{ key: 'label', label: 'LABEL', width: 24 },
|
|
65
|
+
];
|
|
66
|
+
/**
|
|
67
|
+
* Build the W7 `yootheme_builder_sites_list` tool.
|
|
68
|
+
*
|
|
69
|
+
* Signature accepts the {@link SiteRegistry} directly — unlike other
|
|
70
|
+
* tool-builders, it does NOT need the {@link ClientPool} because it
|
|
71
|
+
* never resolves a site. Callers wire `buildSitesListTool(pool.registry)`
|
|
72
|
+
* from the W7 aggregator (`src/sites/tools/index.ts`).
|
|
73
|
+
*/
|
|
74
|
+
export function buildSitesListTool(registry) {
|
|
75
|
+
return defineTool({
|
|
76
|
+
name: 'yootheme_builder_sites_list',
|
|
77
|
+
description: 'List sites configured in this MCP server (site_id, URL, ' +
|
|
78
|
+
'platform, default flag). Read-only, no REST calls. ' +
|
|
79
|
+
'Discover site_ids before targeting one. ' +
|
|
80
|
+
'(site_id is accepted for schema-uniformity but ignored ' +
|
|
81
|
+
'by this tool.)',
|
|
82
|
+
inputSchema: {
|
|
83
|
+
site_id: SITE_ID_SCHEMA,
|
|
84
|
+
},
|
|
85
|
+
outputSchema: SITES_LIST_OUTPUT_SCHEMA,
|
|
86
|
+
annotations: readOnly('Sites — List configured'),
|
|
87
|
+
handler: async () => {
|
|
88
|
+
const rows = registry.listForDisplay();
|
|
89
|
+
const defaultSiteId = registry.defaultSiteId();
|
|
90
|
+
// Map the registry row to a structured-content item with
|
|
91
|
+
// safe-to-render primitives ONLY (no bearer leakage). The
|
|
92
|
+
// `platform` projection collapses hint + resolved into a
|
|
93
|
+
// single display string so the table stays readable.
|
|
94
|
+
const items = rows.map((row) => ({
|
|
95
|
+
site_id: row.site_id,
|
|
96
|
+
url: row.url,
|
|
97
|
+
platform_hint: row.platform_hint,
|
|
98
|
+
...(row.platform_resolved !== undefined
|
|
99
|
+
? { platform_resolved: row.platform_resolved }
|
|
100
|
+
: {}),
|
|
101
|
+
is_default: row.is_default,
|
|
102
|
+
...(row.label !== undefined ? { label: row.label } : {}),
|
|
103
|
+
}));
|
|
104
|
+
// Table-side projection: humans see one `platform` column
|
|
105
|
+
// (resolved if known, hint otherwise) and a yes/no on
|
|
106
|
+
// is_default for legibility.
|
|
107
|
+
const tableRows = rows.map((row) => ({
|
|
108
|
+
site_id: row.site_id,
|
|
109
|
+
url: row.url,
|
|
110
|
+
platform: row.platform_resolved ?? row.platform_hint,
|
|
111
|
+
is_default: row.is_default ? 'yes' : 'no',
|
|
112
|
+
label: row.label ?? '',
|
|
113
|
+
}));
|
|
114
|
+
const toolkitResult = tableResult(tableRows, {
|
|
115
|
+
columns: TABLE_COLUMNS,
|
|
116
|
+
header: (count) => `${String(count)} configured site${count === 1 ? '' : 's'}` +
|
|
117
|
+
(defaultSiteId !== null ? ` (default: ${defaultSiteId})` : ' (no default configured)'),
|
|
118
|
+
footer: 'Use yootheme_builder_sites_test <site_id> to verify connectivity. ' +
|
|
119
|
+
'Pass `site_id: "<id>"` on any tool call to target a specific site.',
|
|
120
|
+
});
|
|
121
|
+
// The W6 `withSiteMeta` wrapper is intentionally NOT used —
|
|
122
|
+
// see the file header for rationale. We emit a stable
|
|
123
|
+
// `_meta.tool_kind: "registry"` marker so MCP hosts can
|
|
124
|
+
// distinguish registry tools from site-bound tools without
|
|
125
|
+
// string-matching the tool name.
|
|
126
|
+
return structuredResult(toolkitResult, {
|
|
127
|
+
items,
|
|
128
|
+
total: items.length,
|
|
129
|
+
default_site_id: defaultSiteId,
|
|
130
|
+
_meta: { tool_kind: 'registry' },
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=sites-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites-list.js","sourceRoot":"","sources":["../../../src/sites/tools/sites-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,WAAW,EAAoB,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EACH,UAAU,EACV,QAAQ,EACR,gBAAgB,GAEnB,MAAM,6BAA6B,CAAC;AAErC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,KAAK,EAAE,CAAC,CAAC,KAAK,CACV,CAAC,CAAC,MAAM,CAAC;QACL,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;QACf,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACtD,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE;QAC7D,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE;QACvB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC/B,CAAC,CACL;IACD,KAAK,EAAE,CAAC,CAAC,MA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cAAc,aAAa,GAAG,CAAC,CAAC,CAAC,0BAA0B,CAAC;gBAC1F,MAAM,EACF,oEAAoE;oBACpE,oEAAoE;aAC3E,CAAC,CAAC;YAEH,4DAA4D;YAC5D,sDAAsD;YACtD,wDAAwD;YACxD,2DAA2D;YAC3D,iCAAiC;YACjC,OAAO,gBAAgB,CAAC,aAAa,EAAE;gBACnC,KAAK;gBACL,KAAK,EAAE,KAAK,CAAC,MAAM;gBACnB,eAAe,EAAE,aAAa;gBAC9B,KAAK,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE;aACnC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W7 — `yootheme_builder_sites_test` L1 tool.
|
|
3
|
+
*
|
|
4
|
+
* Targeted connectivity probe for ONE site_id: runs `/health` (no auth
|
|
5
|
+
* required) + `/etag` (auth required) in parallel and returns a
|
|
6
|
+
* structured `{plugin_reachable, bearer_valid, platform, ...}` block.
|
|
7
|
+
*
|
|
8
|
+
* Why `site_id` is REQUIRED here (not optional):
|
|
9
|
+
* - Every other tool in the registry treats `site_id` as an optional
|
|
10
|
+
* selector that falls back to the default. `sites_test` is the
|
|
11
|
+
* exception: its raison d'être is to verify ONE specific id, so the
|
|
12
|
+
* schema upgrades from `.optional()` to required. The W5
|
|
13
|
+
* SITE_ID_SCHEMA pin-test in `tests/tools/site-id-schema.test.ts`
|
|
14
|
+
* explicitly skips this tool from its "every tool's site_id is
|
|
15
|
+
* optional" loop — see the SITES_TEST_EXEMPT_FROM_OPTIONAL set there.
|
|
16
|
+
*
|
|
17
|
+
* Why the result wraps `withSiteMeta`:
|
|
18
|
+
* - Once `pool.resolve(site_id)` succeeds we DO have a resolved-site
|
|
19
|
+
* descriptor, so the text-prefix `[<label> @ <host>] ` is the same
|
|
20
|
+
* site-awareness signal a Maria-class user already sees on every
|
|
21
|
+
* other tool. The W6.2 wrapper handles both green AND red results
|
|
22
|
+
* uniformly (it just stamps; no behaviour difference).
|
|
23
|
+
*
|
|
24
|
+
* Failure modes mapped:
|
|
25
|
+
* - `UnknownSiteError` → structured error `code: 'unknown_site'` with
|
|
26
|
+
* `available[]` hint (via `resolveSiteOrError`).
|
|
27
|
+
* - `NoDefaultSiteError` → cannot fire here because site_id is required
|
|
28
|
+
* and validated by Zod before the handler runs; left in the helper
|
|
29
|
+
* for defense-in-depth.
|
|
30
|
+
* - `/health` rejects → `plugin_reachable: false` + error message.
|
|
31
|
+
* - `/etag` 401/403 → `plugin_reachable: true` + `bearer_valid: false`.
|
|
32
|
+
* - `/etag` other reject → `plugin_reachable: true` + `bearer_valid:
|
|
33
|
+
* false` + raw error.
|
|
34
|
+
*
|
|
35
|
+
* @license MIT
|
|
36
|
+
*/
|
|
37
|
+
import { type AnyToolDefinition } from '../../tools/tool-builder.js';
|
|
38
|
+
import type { ClientPool } from '../client-pool.js';
|
|
39
|
+
/**
|
|
40
|
+
* Build the W7 `yootheme_builder_sites_test` tool.
|
|
41
|
+
*
|
|
42
|
+
* Signature accepts the {@link ClientPool} directly (no separate
|
|
43
|
+
* registry param) — `pool.resolve(site_id)` is the single source of
|
|
44
|
+
* truth and carries the registry inside.
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildSitesTestTool(pool: ClientPool): AnyToolDefinition;
|
|
47
|
+
//# sourceMappingURL=sites-test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites-test.d.ts","sourceRoot":"","sources":["../../../src/sites/tools/sites-test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAQH,OAAO,EAKH,KAAK,iBAAiB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA2BpD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,CA0DtE"}
|