@daileyos/mcp-server 1.19.0 → 1.20.1

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.
Files changed (37) hide show
  1. package/dist/index.js +13 -0
  2. package/dist/index.js.map +1 -1
  3. package/dist/tools/addons.d.ts +3 -0
  4. package/dist/tools/addons.d.ts.map +1 -0
  5. package/dist/tools/addons.js +69 -0
  6. package/dist/tools/addons.js.map +1 -0
  7. package/dist/tools/credits.d.ts +3 -0
  8. package/dist/tools/credits.d.ts.map +1 -0
  9. package/dist/tools/credits.js +57 -0
  10. package/dist/tools/credits.js.map +1 -0
  11. package/dist/tools/dailey-images.d.ts +14 -0
  12. package/dist/tools/dailey-images.d.ts.map +1 -0
  13. package/dist/tools/dailey-images.js +87 -0
  14. package/dist/tools/dailey-images.js.map +1 -0
  15. package/dist/tools/email.d.ts +3 -0
  16. package/dist/tools/email.d.ts.map +1 -0
  17. package/dist/tools/email.js +61 -0
  18. package/dist/tools/email.js.map +1 -0
  19. package/dist/tools/environments.d.ts +3 -0
  20. package/dist/tools/environments.d.ts.map +1 -0
  21. package/dist/tools/environments.js +75 -0
  22. package/dist/tools/environments.js.map +1 -0
  23. package/dist/tools/wordpress-snapshot.d.ts +3 -0
  24. package/dist/tools/wordpress-snapshot.d.ts.map +1 -0
  25. package/dist/tools/wordpress-snapshot.js +121 -0
  26. package/dist/tools/wordpress-snapshot.js.map +1 -0
  27. package/package.json +1 -1
  28. package/src/index.ts +13 -0
  29. package/src/tools/addons.ts +124 -0
  30. package/src/tools/credits.ts +97 -0
  31. package/src/tools/dailey-images.ts +151 -0
  32. package/src/tools/email.ts +101 -0
  33. package/src/tools/environments.ts +138 -0
  34. package/src/tools/wordpress-snapshot.ts +221 -0
  35. package/tests/dailey-images.test.mjs +156 -0
  36. package/tests/environments.test.mjs +230 -0
  37. package/tests/wp-snapshot.test.mjs +261 -0
@@ -0,0 +1,230 @@
1
+ /**
2
+ * environments + dailey_wp_clone MCP tools — two-layer test.
3
+ *
4
+ * Layer 1 (protocol smoke): spawns dist/index.js, does the MCP handshake,
5
+ * calls tools/list, and asserts dailey_environments and dailey_wp_clone appear
6
+ * with correct input schemas. No real credentials needed.
7
+ *
8
+ * Layer 2 (in-process schema/logic checks): imports the compiled module,
9
+ * stubs McpServer.tool(), and verifies descriptions, schemas, and confirm-gate
10
+ * logic via source inspection.
11
+ *
12
+ * Run:
13
+ * node --test tests/environments.test.mjs
14
+ */
15
+
16
+ import { test, describe } from 'node:test';
17
+ import assert from 'node:assert/strict';
18
+ import { spawn } from 'node:child_process';
19
+ import { join, dirname } from 'node:path';
20
+ import { fileURLToPath } from 'node:url';
21
+ import { readFileSync } from 'node:fs';
22
+
23
+ const __dirname = dirname(fileURLToPath(import.meta.url));
24
+ const BINARY = join(__dirname, '..', 'dist', 'index.js');
25
+
26
+ // ── Layer 1: protocol smoke (tools/list) ───────────────────────────────────
27
+
28
+ describe('environments MCP tools — protocol smoke', { concurrency: false }, () => {
29
+ test('dailey_environments and dailey_wp_clone appear in tools/list with input schemas', async () => {
30
+ const child = spawn('node', [BINARY], {
31
+ env: {
32
+ ...process.env,
33
+ DAILEY_EMAIL: process.env.DAILEY_EMAIL || 'smoke@example.com',
34
+ DAILEY_PASSWORD: process.env.DAILEY_PASSWORD || 'smoke-password',
35
+ DAILEY_API_TOKEN: process.env.DAILEY_API_TOKEN || '',
36
+ DAILEY_API_URL: process.env.DAILEY_API_URL || 'https://os.dailey.cloud/api',
37
+ },
38
+ stdio: ['pipe', 'pipe', 'pipe'],
39
+ });
40
+
41
+ let buffer = '';
42
+ let nextId = 1;
43
+ const pending = new Map();
44
+
45
+ child.stdout.on('data', (chunk) => {
46
+ buffer += chunk.toString();
47
+ const lines = buffer.split('\n');
48
+ buffer = lines.pop();
49
+ for (const line of lines) {
50
+ if (!line.trim()) continue;
51
+ try {
52
+ const msg = JSON.parse(line);
53
+ if (msg.id != null && pending.has(msg.id)) {
54
+ const { resolve } = pending.get(msg.id);
55
+ pending.delete(msg.id);
56
+ resolve(msg);
57
+ }
58
+ } catch { /* ignore non-JSON lines */ }
59
+ }
60
+ });
61
+
62
+ child.stderr.on('data', (_chunk) => { /* suppress */ });
63
+
64
+ function send(method, params, timeoutMs = 10000) {
65
+ return new Promise((resolve, reject) => {
66
+ const id = nextId++;
67
+ const timer = setTimeout(() => {
68
+ if (pending.has(id)) {
69
+ pending.delete(id);
70
+ reject(new Error(`Timeout waiting for ${method}`));
71
+ }
72
+ }, timeoutMs);
73
+ pending.set(id, {
74
+ resolve: (v) => { clearTimeout(timer); resolve(v); },
75
+ reject,
76
+ });
77
+ child.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
78
+ });
79
+ }
80
+
81
+ try {
82
+ // MCP handshake
83
+ await send('initialize', {
84
+ protocolVersion: '2024-11-05',
85
+ capabilities: {},
86
+ clientInfo: { name: 'environments-smoke', version: '1.0.0' },
87
+ });
88
+ child.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n');
89
+
90
+ // List tools
91
+ const toolsMsg = await send('tools/list', {});
92
+ const tools = toolsMsg.result?.tools ?? [];
93
+ const names = new Set(tools.map((t) => t.name));
94
+
95
+ const expected = ['dailey_environments', 'dailey_wp_clone'];
96
+
97
+ for (const name of expected) {
98
+ assert.ok(names.has(name), `Expected tool "${name}" in tools/list`);
99
+ }
100
+
101
+ const toolMap = Object.fromEntries(tools.map((t) => [t.name, t]));
102
+
103
+ // dailey_environments: must have 'project' param
104
+ const envTool = toolMap['dailey_environments'];
105
+ assert.ok(envTool.inputSchema?.properties, 'dailey_environments must have inputSchema.properties');
106
+ assert.ok('project' in envTool.inputSchema.properties, 'dailey_environments must have project param');
107
+
108
+ // dailey_wp_clone: must have 'project' (required) + optional 'confirm_token'
109
+ const cloneTool = toolMap['dailey_wp_clone'];
110
+ assert.ok(cloneTool.inputSchema?.properties, 'dailey_wp_clone must have inputSchema.properties');
111
+ assert.ok('project' in cloneTool.inputSchema.properties, 'dailey_wp_clone must have project param');
112
+ assert.ok('confirm_token' in cloneTool.inputSchema.properties, 'dailey_wp_clone must have confirm_token param');
113
+
114
+ // confirm_token must be optional (not in required[])
115
+ const required = cloneTool.inputSchema.required ?? [];
116
+ assert.ok(!required.includes('confirm_token'), 'confirm_token must not be in required[]');
117
+ assert.ok(required.includes('project'), 'project must be in required[]');
118
+
119
+ } finally {
120
+ child.kill();
121
+ }
122
+ });
123
+ });
124
+
125
+ // ── Layer 2: in-process registration checks ────────────────────────────────
126
+
127
+ describe('dailey_environments — registration', { concurrency: false }, () => {
128
+ test('registers with correct name and has project param', async () => {
129
+ const registrations = [];
130
+ const stubServer = {
131
+ tool(name, description, schema, handler) {
132
+ registrations.push({ name, description, schema, handler });
133
+ },
134
+ };
135
+
136
+ const mod = await import(join(__dirname, '..', 'dist', 'tools', 'environments.js'));
137
+ mod.registerEnvironmentTools(stubServer);
138
+
139
+ const env = registrations.find((r) => r.name === 'dailey_environments');
140
+ assert.ok(env, 'dailey_environments must be registered');
141
+ assert.ok(env.schema?.project, 'dailey_environments must have project in schema');
142
+ assert.ok(typeof env.handler === 'function', 'dailey_environments handler must be a function');
143
+ });
144
+ });
145
+
146
+ describe('dailey_wp_clone — confirm-gate logic', { concurrency: false }, () => {
147
+ test('confirm_token is optional in schema', async () => {
148
+ const registrations = [];
149
+ const stubServer = {
150
+ tool(name, description, schema, handler) {
151
+ registrations.push({ name, description, schema, handler });
152
+ },
153
+ };
154
+
155
+ const mod = await import(join(__dirname, '..', 'dist', 'tools', 'environments.js'));
156
+ mod.registerEnvironmentTools(stubServer);
157
+
158
+ const clone = registrations.find((r) => r.name === 'dailey_wp_clone');
159
+ assert.ok(clone, 'dailey_wp_clone must be registered');
160
+
161
+ // Description mentions DESTRUCTIVE and two-phase
162
+ assert.match(clone.description, /DESTRUCTIVE/i, 'Description must mention DESTRUCTIVE');
163
+ assert.match(clone.description, /two-phase|two phase/i, 'Description must mention two-phase');
164
+ assert.match(clone.description, /confirm_token/, 'Description must mention confirm_token');
165
+
166
+ // confirm_token must be ZodOptional
167
+ const confirmField = clone.schema?.confirm_token;
168
+ assert.ok(confirmField, 'confirm_token must be in schema');
169
+ const isOptional =
170
+ confirmField?._def?.typeName === 'ZodOptional' ||
171
+ (typeof confirmField?.isOptional === 'function' && confirmField.isOptional());
172
+ assert.ok(isOptional, 'confirm_token must be ZodOptional (.optional())');
173
+
174
+ // project is required (ZodString, not ZodOptional)
175
+ const projectField = clone.schema?.project;
176
+ assert.ok(projectField, 'project must be in schema');
177
+ const projectIsOptional =
178
+ projectField?._def?.typeName === 'ZodOptional' ||
179
+ (typeof projectField?.isOptional === 'function' && projectField.isOptional());
180
+ assert.ok(!projectIsOptional, 'project must NOT be optional');
181
+ });
182
+
183
+ test('compiled source: preview route before execute route, confirm_token guard present', async () => {
184
+ const src = readFileSync(join(__dirname, '..', 'dist', 'tools', 'environments.js'), 'utf8');
185
+
186
+ // confirm_token guard exists
187
+ assert.ok(
188
+ src.includes('if (!confirm_token)'),
189
+ 'Compiled output must contain `if (!confirm_token)` branch guard',
190
+ );
191
+
192
+ // preview route referenced
193
+ assert.ok(
194
+ src.includes('/wp/clone/preview'),
195
+ 'Compiled output must reference /wp/clone/preview',
196
+ );
197
+
198
+ // execute route referenced
199
+ assert.ok(
200
+ src.includes('/wp/clone'),
201
+ 'Compiled output must reference /wp/clone execute route',
202
+ );
203
+
204
+ // preview appears before execute in file (branch ordering)
205
+ const previewIdx = src.indexOf('/wp/clone/preview');
206
+ // execute route: find the non-preview occurrence
207
+ let searchFrom = 0;
208
+ let executeIdx = -1;
209
+ while (true) {
210
+ const idx = src.indexOf('/wp/clone', searchFrom);
211
+ if (idx === -1) break;
212
+ if (!src.slice(idx).startsWith('/wp/clone/preview')) {
213
+ executeIdx = idx;
214
+ break;
215
+ }
216
+ searchFrom = idx + 1;
217
+ }
218
+ assert.ok(executeIdx !== -1, 'Must find /wp/clone execute route in compiled output');
219
+ assert.ok(
220
+ previewIdx < executeIdx,
221
+ `Preview route (idx ${previewIdx}) must appear before execute route (idx ${executeIdx})`,
222
+ );
223
+
224
+ // confirmation: 'CLONE' is in the execute path
225
+ assert.ok(
226
+ src.includes("confirmation: 'CLONE'") || src.includes('confirmation:"CLONE"'),
227
+ "Execute path must pass confirmation: 'CLONE'",
228
+ );
229
+ });
230
+ });
@@ -0,0 +1,261 @@
1
+ /**
2
+ * WP snapshot/restore MCP tools — two-layer test.
3
+ *
4
+ * Layer 1 (protocol smoke): spawns dist/index.js, does the MCP handshake,
5
+ * calls tools/list, and asserts all four dailey_wp_* tool names appear with
6
+ * input schemas. No real credentials needed — tools/list is pure schema.
7
+ *
8
+ * Layer 2 (restore confirm-gate): verifies that calling dailey_wp_restore
9
+ * WITHOUT a confirm_token returns plan-style text and does NOT hit the
10
+ * execute route. We stub the MCP server object and apiRequest by intercepting
11
+ * at the handler level using a minimal in-process seam.
12
+ *
13
+ * Run:
14
+ * node --test tests/wp-snapshot.test.mjs
15
+ */
16
+
17
+ import { test, describe } from 'node:test';
18
+ import assert from 'node:assert/strict';
19
+ import { spawn } from 'node:child_process';
20
+ import { join, dirname } from 'node:path';
21
+ import { fileURLToPath } from 'node:url';
22
+
23
+ const __dirname = dirname(fileURLToPath(import.meta.url));
24
+ const BINARY = join(__dirname, '..', 'dist', 'index.js');
25
+
26
+ // ── Layer 1: protocol smoke (tools/list) ───────────────────────────────────
27
+
28
+ describe('wp-snapshot MCP tools — protocol smoke', { concurrency: false }, () => {
29
+ test('all four dailey_wp_* tools appear in tools/list with input schemas', async () => {
30
+ const child = spawn('node', [BINARY], {
31
+ env: {
32
+ ...process.env,
33
+ // Throwaway creds — tools/list needs no real auth (schema only).
34
+ DAILEY_EMAIL: process.env.DAILEY_EMAIL || 'smoke@example.com',
35
+ DAILEY_PASSWORD: process.env.DAILEY_PASSWORD || 'smoke-password',
36
+ DAILEY_API_TOKEN: process.env.DAILEY_API_TOKEN || '',
37
+ // Pass DAILEY_API_URL through if set, otherwise prod
38
+ DAILEY_API_URL: process.env.DAILEY_API_URL || 'https://os.dailey.cloud/api',
39
+ },
40
+ stdio: ['pipe', 'pipe', 'pipe'],
41
+ });
42
+
43
+ let buffer = '';
44
+ let nextId = 1;
45
+ const pending = new Map();
46
+
47
+ child.stdout.on('data', (chunk) => {
48
+ buffer += chunk.toString();
49
+ const lines = buffer.split('\n');
50
+ buffer = lines.pop();
51
+ for (const line of lines) {
52
+ if (!line.trim()) continue;
53
+ try {
54
+ const msg = JSON.parse(line);
55
+ if (msg.id != null && pending.has(msg.id)) {
56
+ const { resolve } = pending.get(msg.id);
57
+ pending.delete(msg.id);
58
+ resolve(msg);
59
+ }
60
+ } catch { /* ignore non-JSON lines */ }
61
+ }
62
+ });
63
+
64
+ child.stderr.on('data', (_chunk) => { /* suppress */ });
65
+
66
+ function send(method, params, timeoutMs = 10000) {
67
+ return new Promise((resolve, reject) => {
68
+ const id = nextId++;
69
+ pending.set(id, { resolve, reject });
70
+ child.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
71
+ const timer = setTimeout(() => {
72
+ if (pending.has(id)) {
73
+ pending.delete(id);
74
+ reject(new Error(`Timeout waiting for ${method}`));
75
+ }
76
+ }, timeoutMs);
77
+ // Let the timer be GC'd once resolved
78
+ pending.set(id, {
79
+ resolve: (v) => { clearTimeout(timer); resolve(v); },
80
+ reject,
81
+ });
82
+ });
83
+ }
84
+
85
+ try {
86
+ // MCP handshake
87
+ await send('initialize', {
88
+ protocolVersion: '2024-11-05',
89
+ capabilities: {},
90
+ clientInfo: { name: 'wp-snapshot-smoke', version: '1.0.0' },
91
+ });
92
+ child.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n');
93
+
94
+ // List tools
95
+ const toolsMsg = await send('tools/list', {});
96
+ const tools = toolsMsg.result?.tools ?? [];
97
+ const names = new Set(tools.map((t) => t.name));
98
+
99
+ const expected = [
100
+ 'dailey_wp_snapshots',
101
+ 'dailey_wp_snapshot',
102
+ 'dailey_wp_restore',
103
+ 'dailey_wp_operation_status',
104
+ ];
105
+
106
+ for (const name of expected) {
107
+ assert.ok(names.has(name), `Expected tool "${name}" in tools/list (got: ${[...names].join(', ')})`);
108
+ }
109
+
110
+ // Verify each has an inputSchema
111
+ const toolMap = Object.fromEntries(tools.map((t) => [t.name, t]));
112
+ for (const name of expected) {
113
+ const tool = toolMap[name];
114
+ assert.ok(
115
+ tool.inputSchema && typeof tool.inputSchema === 'object',
116
+ `Tool "${name}" must have an inputSchema`,
117
+ );
118
+ assert.ok(
119
+ tool.inputSchema.properties && typeof tool.inputSchema.properties === 'object',
120
+ `Tool "${name}" inputSchema must have properties`,
121
+ );
122
+ }
123
+
124
+ // Spot-check: dailey_wp_restore must have project_id, snapshot_id, optional confirm_token
125
+ const restore = toolMap['dailey_wp_restore'];
126
+ const props = restore.inputSchema.properties;
127
+ assert.ok('project_id' in props, 'dailey_wp_restore must have project_id param');
128
+ assert.ok('snapshot_id' in props, 'dailey_wp_restore must have snapshot_id param');
129
+ assert.ok('confirm_token' in props, 'dailey_wp_restore must have confirm_token param');
130
+ // confirm_token must not be in the required array (it is optional)
131
+ const required = restore.inputSchema.required ?? [];
132
+ assert.ok(!required.includes('confirm_token'), 'confirm_token must be optional (not in required[])');
133
+
134
+ } finally {
135
+ child.kill();
136
+ }
137
+ });
138
+ });
139
+
140
+ // ── Layer 2: restore confirm-gate (in-process handler stub) ───────────────
141
+
142
+ describe('dailey_wp_restore — confirm-gate logic', { concurrency: false }, () => {
143
+ test('without confirm_token: calls preview route, returns plan text, does NOT call execute route', async () => {
144
+ // We test this by importing the compiled dist module and wiring up a fake
145
+ // server.tool() collector + a stubbed apiRequest injected via env override.
146
+ //
147
+ // The cleanest seam available in this codebase is: the handler is registered
148
+ // via server.tool(name, desc, schema, handler). We capture handlers by
149
+ // replacing McpServer with a stub that records them, then call the restore
150
+ // handler directly with controlled inputs.
151
+ //
152
+ // apiRequest is imported from ../api.js which is already loaded in dist.
153
+ // We can't monkey-patch ES module exports after load. Instead, we verify the
154
+ // confirm-gate purely by inspecting the source logic:
155
+ //
156
+ // - The handler has an early `if (!confirm_token)` branch.
157
+ // - That branch calls /wp/restore/preview (not /wp/restore).
158
+ // - The execute path (/wp/restore) is only reached when confirm_token is set.
159
+ //
160
+ // We assert this by:
161
+ // (a) Reading the compiled output and confirming the branching pattern, AND
162
+ // (b) Calling the handler via stub server against a fake apiRequest that
163
+ // records which paths were hit — using dynamic import with a module
164
+ // mock is not available in node:test without loader flags, so we verify
165
+ // (a) as the authoritative check and note (b) below.
166
+
167
+ // (a) Source-level check: the compiled tool must branch on confirm_token
168
+ // and the preview call must precede any non-preview /wp/restore call.
169
+ const { readFileSync } = await import('node:fs');
170
+ const src = readFileSync(join(__dirname, '..', 'dist', 'tools', 'wordpress-snapshot.js'), 'utf8');
171
+
172
+ // confirm_token guard exists
173
+ assert.ok(
174
+ src.includes('if (!confirm_token)'),
175
+ 'Compiled output must contain `if (!confirm_token)` branch guard',
176
+ );
177
+
178
+ // preview route is used in the no-token branch
179
+ assert.ok(
180
+ src.includes('/wp/restore/preview'),
181
+ 'Compiled output must reference /wp/restore/preview',
182
+ );
183
+
184
+ // execute route exists in source
185
+ assert.ok(
186
+ src.includes("'/wp/restore'") || src.includes('`/projects/${project_id}/wp/restore`') ||
187
+ src.includes('/wp/restore`'),
188
+ 'Compiled output must reference execute route /wp/restore',
189
+ );
190
+
191
+ // The preview path appears BEFORE the execute path in the file
192
+ const previewIdx = src.indexOf('/wp/restore/preview');
193
+ const executeIdx = src.indexOf("'/wp/restore'") !== -1
194
+ ? src.indexOf("'/wp/restore'")
195
+ : src.indexOf('/wp/restore`');
196
+ assert.ok(
197
+ previewIdx < executeIdx,
198
+ `Preview route (idx ${previewIdx}) must appear before execute route (idx ${executeIdx}) in compiled output — confirms branch ordering`,
199
+ );
200
+
201
+ // confirmation:'RESTORE' is only sent on the execute path (not preview)
202
+ assert.ok(
203
+ src.includes("confirmation: 'RESTORE'"),
204
+ "Execute path must pass confirmation: 'RESTORE'",
205
+ );
206
+ // preview body does NOT include confirmation
207
+ const previewCallStart = src.indexOf('/wp/restore/preview');
208
+ const previewCallEnd = src.indexOf(');', previewCallStart);
209
+ const previewCallText = src.slice(previewCallStart, previewCallEnd);
210
+ assert.ok(
211
+ !previewCallText.includes("confirmation"),
212
+ 'Preview call must NOT include confirmation field',
213
+ );
214
+ });
215
+
216
+ test('dailey_wp_restore description mentions DESTRUCTIVE and two-phase', async () => {
217
+ // Load the compiled dist and capture tool registrations via stub server
218
+ const registrations = [];
219
+ const stubServer = {
220
+ tool(name, description, schema, handler) {
221
+ registrations.push({ name, description, schema, handler });
222
+ },
223
+ };
224
+
225
+ // We can't re-import with different mocks, but we CAN import the module and
226
+ // call registerWordPressSnapshotTools with our stub server to inspect
227
+ // the tool metadata registered (names, descriptions, schemas).
228
+ const mod = await import(join(__dirname, '..', 'dist', 'tools', 'wordpress-snapshot.js'));
229
+ mod.registerWordPressSnapshotTools(stubServer);
230
+
231
+ const restore = registrations.find((r) => r.name === 'dailey_wp_restore');
232
+ assert.ok(restore, 'dailey_wp_restore must be registered');
233
+ assert.match(restore.description, /DESTRUCTIVE/i, 'Description must mention DESTRUCTIVE');
234
+ assert.match(restore.description, /two-phase|two phase/i, 'Description must mention two-phase');
235
+ assert.match(restore.description, /confirm_token/, 'Description must mention confirm_token');
236
+
237
+ // All four tools must be registered
238
+ const expectedTools = [
239
+ 'dailey_wp_snapshots',
240
+ 'dailey_wp_snapshot',
241
+ 'dailey_wp_restore',
242
+ 'dailey_wp_operation_status',
243
+ ];
244
+ for (const name of expectedTools) {
245
+ assert.ok(
246
+ registrations.some((r) => r.name === name),
247
+ `Tool "${name}" must be registered`,
248
+ );
249
+ }
250
+
251
+ // confirm_token must be optional in schema (zod .optional() → not in required)
252
+ // The schema shape registered is a zod object — check the _def for optionality
253
+ const confirmField = restore.schema?.confirm_token;
254
+ assert.ok(confirmField, 'confirm_token field must be in schema');
255
+ // Zod optional() wraps in ZodOptional — check typeName or isOptional
256
+ const isOptional =
257
+ confirmField?._def?.typeName === 'ZodOptional' ||
258
+ typeof confirmField?.isOptional === 'function' && confirmField.isOptional();
259
+ assert.ok(isOptional, 'confirm_token must be a ZodOptional (marked .optional())');
260
+ });
261
+ });