@ghostpaw/email 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -287,8 +287,8 @@ async function authenticate(dispatcher, capabilities, config) {
287
287
  }
288
288
  if ("mechanism" in config) {
289
289
  const { mechanism, credentials } = config;
290
- const payload = encodeBase64(Buffer.from(JSON.stringify(credentials), "utf8"));
291
- const res = await dispatcher.execute("AUTHENTICATE", [mechanism, payload]);
290
+ const payload2 = encodeBase64(Buffer.from(JSON.stringify(credentials), "utf8"));
291
+ const res = await dispatcher.execute("AUTHENTICATE", [mechanism, payload2]);
292
292
  if (res.tagged.status !== "OK") {
293
293
  throw new EmailAuthError(`${mechanism} authentication failed`, mechanism);
294
294
  }
@@ -1209,23 +1209,23 @@ function decodeBodyStructure(data, maxDepth = DEFAULT_MAX_NESTING_DEPTH) {
1209
1209
 
1210
1210
  // src/mime/decode_encoded_words.ts
1211
1211
  var encodedWord = /=\?([\w*.-]+)\?([BbQq])\?([^?]*)\?=/g;
1212
- function decodeQPayload(payload) {
1212
+ function decodeQPayload(payload2) {
1213
1213
  const bytes = [];
1214
- for (let i = 0; i < payload.length; i++) {
1215
- const c = payload[i];
1214
+ for (let i = 0; i < payload2.length; i++) {
1215
+ const c = payload2[i];
1216
1216
  if (c === "_") {
1217
1217
  bytes.push(32);
1218
1218
  continue;
1219
1219
  }
1220
- if (c === "=" && i + 2 < payload.length) {
1221
- const h = payload.slice(i + 1, i + 3);
1220
+ if (c === "=" && i + 2 < payload2.length) {
1221
+ const h = payload2.slice(i + 1, i + 3);
1222
1222
  if (/^[0-9A-Fa-f]{2}$/.test(h)) {
1223
1223
  bytes.push(Number.parseInt(h, 16));
1224
1224
  i += 2;
1225
1225
  continue;
1226
1226
  }
1227
1227
  }
1228
- bytes.push(payload.charCodeAt(i) & 255);
1228
+ bytes.push(payload2.charCodeAt(i) & 255);
1229
1229
  }
1230
1230
  return Buffer.from(bytes);
1231
1231
  }
@@ -1290,9 +1290,9 @@ function parseAddressList(items) {
1290
1290
  const mailbox = s2(addrArr[2]);
1291
1291
  const host = s2(addrArr[3]);
1292
1292
  if (!mailbox || !host) continue;
1293
- const address = `${mailbox}@${host}`;
1293
+ const address2 = `${mailbox}@${host}`;
1294
1294
  const name = nameRaw ? decodeEncodedWords(nameRaw) : void 0;
1295
- out.push(name ? { name, address } : { address });
1295
+ out.push(name ? { name, address: address2 } : { address: address2 });
1296
1296
  }
1297
1297
  return out;
1298
1298
  }
@@ -3221,11 +3221,11 @@ function populateFts(db, messageId, textPlain, textHtml) {
3221
3221
  if (!row) return;
3222
3222
  const subject = row.subject != null ? String(row.subject) : "";
3223
3223
  const sender = row.from != null ? String(row.from) : "";
3224
- const recipients = row.to != null ? String(row.to) : "";
3224
+ const recipients2 = row.to != null ? String(row.to) : "";
3225
3225
  db.exec(`DELETE FROM messages_fts WHERE rowid = ${messageId}`);
3226
3226
  db.prepare(
3227
3227
  "INSERT INTO messages_fts(rowid, subject, body_text, sender, recipients) VALUES (?, ?, ?, ?, ?)"
3228
- ).run(messageId, subject, bodyText, sender, recipients);
3228
+ ).run(messageId, subject, bodyText, sender, recipients2);
3229
3229
  }
3230
3230
 
3231
3231
  // src/sync/fetch_body.ts
@@ -5177,6 +5177,192 @@ __export(aligned_exports, {
5177
5177
  listEmailToolDefinitions: () => listEmailToolDefinitions
5178
5178
  });
5179
5179
 
5180
+ // src/surfaces/schema_example.ts
5181
+ function schemaExample(schema, seed = {}) {
5182
+ if (schema.oneOf) {
5183
+ const branch = schema.oneOf.find(
5184
+ (candidate) => Object.entries(seed).every(([key, value]) => {
5185
+ const values = candidate.properties?.[key]?.enum;
5186
+ return !values || values.includes(value);
5187
+ })
5188
+ );
5189
+ return schemaExample({ ...schema, ...branch, oneOf: void 0 }, seed);
5190
+ }
5191
+ if (schema.enum) return schema.enum[0];
5192
+ if (schema.type === "object") {
5193
+ const result = { ...seed };
5194
+ for (const key of schema.required ?? [])
5195
+ if (!(key in result)) {
5196
+ const property = schema.properties?.[key] ?? {};
5197
+ const placeholders = {
5198
+ folder: "INBOX",
5199
+ destination: "Archive",
5200
+ query: "invoice",
5201
+ subject: "Hello",
5202
+ path: "Projects",
5203
+ oldPath: "Projects",
5204
+ newPath: "Archive/Projects"
5205
+ };
5206
+ result[key] = property.type === "string" && !property.enum && placeholders[key] ? placeholders[key] : schemaExample(property);
5207
+ }
5208
+ return result;
5209
+ }
5210
+ if (schema.type === "array") return [schemaExample(schema.items ?? {})];
5211
+ if (schema.type === "integer" || schema.type === "number") return 1;
5212
+ if (schema.type === "boolean") return false;
5213
+ return schema.description?.includes("address") ? "reader@example.com" : "example";
5214
+ }
5215
+
5216
+ // src/surfaces/validate_input.ts
5217
+ function validateInput(schema, input, path = "$") {
5218
+ const errors = validate(schema, input, path);
5219
+ if (path !== "$" || !errors.length) return errors;
5220
+ const seed = {};
5221
+ if (input && typeof input === "object") {
5222
+ for (const key of ["action", "view"])
5223
+ if (schema.properties?.[key]?.enum?.includes(input[key]))
5224
+ seed[key] = input[key];
5225
+ }
5226
+ return errors.map((error) => `${error}; pass ${JSON.stringify(schemaExample(schema, seed))}`);
5227
+ }
5228
+ function validate(schema, input, path) {
5229
+ const errors = [];
5230
+ const matchesType = (type) => {
5231
+ switch (type) {
5232
+ case "object":
5233
+ return typeof input === "object" && input !== null && !Array.isArray(input);
5234
+ case "array":
5235
+ return Array.isArray(input);
5236
+ case "integer":
5237
+ return typeof input === "number" && Number.isInteger(input);
5238
+ case "number":
5239
+ return typeof input === "number" && Number.isFinite(input);
5240
+ case "null":
5241
+ return input === null;
5242
+ default:
5243
+ return typeof input === type;
5244
+ }
5245
+ };
5246
+ if (schema.type && !(Array.isArray(schema.type) ? schema.type : [schema.type]).some(matchesType)) {
5247
+ return [`${path}: expected ${String(schema.type)}`];
5248
+ }
5249
+ if (schema.enum && !schema.enum.some((value) => JSON.stringify(value) === JSON.stringify(input)))
5250
+ errors.push(`${path}: expected one of ${JSON.stringify(schema.enum)}`);
5251
+ if (schema.oneOf) {
5252
+ const branches = schema.oneOf.map((branch) => validate(branch, input, path));
5253
+ if (!branches.some((errors2) => errors2.length === 0)) {
5254
+ const record = input && typeof input === "object" ? input : {};
5255
+ const selected = schema.oneOf.findIndex(
5256
+ (branch) => ["action", "view"].some((key) => branch.properties?.[key]?.enum?.includes(record[key]))
5257
+ );
5258
+ errors.push(...branches[selected >= 0 ? selected : 0] ?? []);
5259
+ }
5260
+ }
5261
+ if (typeof input === "object" && input !== null && !Array.isArray(input)) {
5262
+ const record = input;
5263
+ for (const name of schema.required ?? [])
5264
+ if (!Object.hasOwn(record, name)) errors.push(`${path}.${name}: required`);
5265
+ for (const [name, property] of Object.entries(schema.properties ?? {}))
5266
+ if (Object.hasOwn(record, name))
5267
+ errors.push(...validate(property, record[name], `${path}.${name}`));
5268
+ }
5269
+ if (Array.isArray(input) && schema.items)
5270
+ input.forEach((value, index) => {
5271
+ errors.push(...validate(schema.items, value, `${path}[${index}]`));
5272
+ });
5273
+ return errors;
5274
+ }
5275
+
5276
+ // src/tools/input_schema.ts
5277
+ var address = {
5278
+ type: "object",
5279
+ required: ["address"],
5280
+ properties: {
5281
+ address: { type: "string", description: "Email address." },
5282
+ name: { type: "string", description: "Display name." }
5283
+ }
5284
+ };
5285
+ var recipients = {
5286
+ type: "array",
5287
+ items: address,
5288
+ description: "Recipient addresses."
5289
+ };
5290
+ var payload = {
5291
+ type: "object",
5292
+ properties: {
5293
+ from: address,
5294
+ sender: address,
5295
+ envelopeFrom: address,
5296
+ replyTo: address,
5297
+ to: recipients,
5298
+ cc: recipients,
5299
+ bcc: recipients,
5300
+ subject: { type: "string", description: "Message subject." },
5301
+ text: { type: "string", description: "Plain text body." },
5302
+ html: { type: "string", description: "HTML body." },
5303
+ replyAll: { type: "boolean", description: "Reply to all original recipients." },
5304
+ mode: { type: "string", enum: ["inline", "attachment"] },
5305
+ attachments: {
5306
+ type: "array",
5307
+ description: "Message attachments.",
5308
+ items: {
5309
+ type: "object",
5310
+ required: ["filename", "content"],
5311
+ properties: {
5312
+ filename: { type: "string" },
5313
+ content: { description: "Attachment bytes (Buffer in library calls)." },
5314
+ mimeType: { type: "string" },
5315
+ inline: { type: "boolean" },
5316
+ contentId: { type: "string" }
5317
+ }
5318
+ }
5319
+ },
5320
+ inReplyTo: { type: "string" },
5321
+ references: { type: "array", items: { type: "string" } },
5322
+ headers: { type: "object" }
5323
+ }
5324
+ };
5325
+ function emailInputSchema(name, schema) {
5326
+ const discriminator = name === "mail_read" ? "view" : "action";
5327
+ const actions = schema.properties?.[discriminator]?.enum;
5328
+ if (!actions || name === "mail_sync") return schema;
5329
+ return {
5330
+ ...schema,
5331
+ oneOf: actions.map((value) => {
5332
+ const action = String(value);
5333
+ let required = [];
5334
+ let input;
5335
+ if (name === "mail_read") {
5336
+ if (action === "thread") required = ["threadId"];
5337
+ if (["message", "attachment", "eml"].includes(action)) required = ["folder", "uid"];
5338
+ } else if (name === "mail_compose") {
5339
+ if (action !== "send_draft") {
5340
+ required.push("input");
5341
+ input = {
5342
+ ...payload,
5343
+ required: ["send", "save_draft", "update_draft"].includes(action) ? ["to", "subject"] : action === "forward" ? ["to"] : []
5344
+ };
5345
+ }
5346
+ if (["reply", "forward"].includes(action)) required.push("folder", "uid");
5347
+ if (["update_draft", "send_draft"].includes(action)) required.push("uid");
5348
+ } else if (name === "mail_organize") {
5349
+ required = action === "rename_folder" ? ["oldPath", "newPath"] : action.endsWith("_folder") ? ["path"] : ["folder", "uids"];
5350
+ if (["copy", "move"].includes(action)) required.push("destination");
5351
+ if (action.endsWith("_labels")) required.push("labels");
5352
+ }
5353
+ return {
5354
+ type: "object",
5355
+ required: [...schema.required ?? [], ...required],
5356
+ properties: {
5357
+ ...schema.properties,
5358
+ [discriminator]: { ...schema.properties?.[discriminator], enum: [value] },
5359
+ ...input ? { input } : {}
5360
+ }
5361
+ };
5362
+ })
5363
+ };
5364
+ }
5365
+
5180
5366
  // src/tools/email_tools.ts
5181
5367
  var emailTools = [
5182
5368
  {
@@ -5897,6 +6083,21 @@ var emailTools = [
5897
6083
  }
5898
6084
  }
5899
6085
  ];
6086
+ for (const tool of emailTools) {
6087
+ Object.assign(tool.inputSchema, emailInputSchema(tool.name, tool.inputSchema));
6088
+ const handler = tool.handler;
6089
+ tool.handler = async (ctx, input) => {
6090
+ const errors = validateInput(tool.inputSchema, input);
6091
+ if (errors.length)
6092
+ return {
6093
+ outcome: "error",
6094
+ summary: errors.join("; "),
6095
+ entities: [],
6096
+ nextSteps: errors
6097
+ };
6098
+ return handler(ctx, input);
6099
+ };
6100
+ }
5900
6101
 
5901
6102
  // src/tools/aligned.ts
5902
6103
  var usage = {
package/dist/index.js CHANGED
@@ -263,8 +263,8 @@ async function authenticate(dispatcher, capabilities, config) {
263
263
  }
264
264
  if ("mechanism" in config) {
265
265
  const { mechanism, credentials } = config;
266
- const payload = encodeBase64(Buffer.from(JSON.stringify(credentials), "utf8"));
267
- const res = await dispatcher.execute("AUTHENTICATE", [mechanism, payload]);
266
+ const payload2 = encodeBase64(Buffer.from(JSON.stringify(credentials), "utf8"));
267
+ const res = await dispatcher.execute("AUTHENTICATE", [mechanism, payload2]);
268
268
  if (res.tagged.status !== "OK") {
269
269
  throw new EmailAuthError(`${mechanism} authentication failed`, mechanism);
270
270
  }
@@ -1185,23 +1185,23 @@ function decodeBodyStructure(data, maxDepth = DEFAULT_MAX_NESTING_DEPTH) {
1185
1185
 
1186
1186
  // src/mime/decode_encoded_words.ts
1187
1187
  var encodedWord = /=\?([\w*.-]+)\?([BbQq])\?([^?]*)\?=/g;
1188
- function decodeQPayload(payload) {
1188
+ function decodeQPayload(payload2) {
1189
1189
  const bytes = [];
1190
- for (let i = 0; i < payload.length; i++) {
1191
- const c = payload[i];
1190
+ for (let i = 0; i < payload2.length; i++) {
1191
+ const c = payload2[i];
1192
1192
  if (c === "_") {
1193
1193
  bytes.push(32);
1194
1194
  continue;
1195
1195
  }
1196
- if (c === "=" && i + 2 < payload.length) {
1197
- const h = payload.slice(i + 1, i + 3);
1196
+ if (c === "=" && i + 2 < payload2.length) {
1197
+ const h = payload2.slice(i + 1, i + 3);
1198
1198
  if (/^[0-9A-Fa-f]{2}$/.test(h)) {
1199
1199
  bytes.push(Number.parseInt(h, 16));
1200
1200
  i += 2;
1201
1201
  continue;
1202
1202
  }
1203
1203
  }
1204
- bytes.push(payload.charCodeAt(i) & 255);
1204
+ bytes.push(payload2.charCodeAt(i) & 255);
1205
1205
  }
1206
1206
  return Buffer.from(bytes);
1207
1207
  }
@@ -1266,9 +1266,9 @@ function parseAddressList(items) {
1266
1266
  const mailbox = s2(addrArr[2]);
1267
1267
  const host = s2(addrArr[3]);
1268
1268
  if (!mailbox || !host) continue;
1269
- const address = `${mailbox}@${host}`;
1269
+ const address2 = `${mailbox}@${host}`;
1270
1270
  const name = nameRaw ? decodeEncodedWords(nameRaw) : void 0;
1271
- out.push(name ? { name, address } : { address });
1271
+ out.push(name ? { name, address: address2 } : { address: address2 });
1272
1272
  }
1273
1273
  return out;
1274
1274
  }
@@ -3197,11 +3197,11 @@ function populateFts(db, messageId, textPlain, textHtml) {
3197
3197
  if (!row) return;
3198
3198
  const subject = row.subject != null ? String(row.subject) : "";
3199
3199
  const sender = row.from != null ? String(row.from) : "";
3200
- const recipients = row.to != null ? String(row.to) : "";
3200
+ const recipients2 = row.to != null ? String(row.to) : "";
3201
3201
  db.exec(`DELETE FROM messages_fts WHERE rowid = ${messageId}`);
3202
3202
  db.prepare(
3203
3203
  "INSERT INTO messages_fts(rowid, subject, body_text, sender, recipients) VALUES (?, ?, ?, ?, ?)"
3204
- ).run(messageId, subject, bodyText, sender, recipients);
3204
+ ).run(messageId, subject, bodyText, sender, recipients2);
3205
3205
  }
3206
3206
 
3207
3207
  // src/sync/fetch_body.ts
@@ -5153,6 +5153,192 @@ __export(aligned_exports, {
5153
5153
  listEmailToolDefinitions: () => listEmailToolDefinitions
5154
5154
  });
5155
5155
 
5156
+ // src/surfaces/schema_example.ts
5157
+ function schemaExample(schema, seed = {}) {
5158
+ if (schema.oneOf) {
5159
+ const branch = schema.oneOf.find(
5160
+ (candidate) => Object.entries(seed).every(([key, value]) => {
5161
+ const values = candidate.properties?.[key]?.enum;
5162
+ return !values || values.includes(value);
5163
+ })
5164
+ );
5165
+ return schemaExample({ ...schema, ...branch, oneOf: void 0 }, seed);
5166
+ }
5167
+ if (schema.enum) return schema.enum[0];
5168
+ if (schema.type === "object") {
5169
+ const result = { ...seed };
5170
+ for (const key of schema.required ?? [])
5171
+ if (!(key in result)) {
5172
+ const property = schema.properties?.[key] ?? {};
5173
+ const placeholders = {
5174
+ folder: "INBOX",
5175
+ destination: "Archive",
5176
+ query: "invoice",
5177
+ subject: "Hello",
5178
+ path: "Projects",
5179
+ oldPath: "Projects",
5180
+ newPath: "Archive/Projects"
5181
+ };
5182
+ result[key] = property.type === "string" && !property.enum && placeholders[key] ? placeholders[key] : schemaExample(property);
5183
+ }
5184
+ return result;
5185
+ }
5186
+ if (schema.type === "array") return [schemaExample(schema.items ?? {})];
5187
+ if (schema.type === "integer" || schema.type === "number") return 1;
5188
+ if (schema.type === "boolean") return false;
5189
+ return schema.description?.includes("address") ? "reader@example.com" : "example";
5190
+ }
5191
+
5192
+ // src/surfaces/validate_input.ts
5193
+ function validateInput(schema, input, path = "$") {
5194
+ const errors = validate(schema, input, path);
5195
+ if (path !== "$" || !errors.length) return errors;
5196
+ const seed = {};
5197
+ if (input && typeof input === "object") {
5198
+ for (const key of ["action", "view"])
5199
+ if (schema.properties?.[key]?.enum?.includes(input[key]))
5200
+ seed[key] = input[key];
5201
+ }
5202
+ return errors.map((error) => `${error}; pass ${JSON.stringify(schemaExample(schema, seed))}`);
5203
+ }
5204
+ function validate(schema, input, path) {
5205
+ const errors = [];
5206
+ const matchesType = (type) => {
5207
+ switch (type) {
5208
+ case "object":
5209
+ return typeof input === "object" && input !== null && !Array.isArray(input);
5210
+ case "array":
5211
+ return Array.isArray(input);
5212
+ case "integer":
5213
+ return typeof input === "number" && Number.isInteger(input);
5214
+ case "number":
5215
+ return typeof input === "number" && Number.isFinite(input);
5216
+ case "null":
5217
+ return input === null;
5218
+ default:
5219
+ return typeof input === type;
5220
+ }
5221
+ };
5222
+ if (schema.type && !(Array.isArray(schema.type) ? schema.type : [schema.type]).some(matchesType)) {
5223
+ return [`${path}: expected ${String(schema.type)}`];
5224
+ }
5225
+ if (schema.enum && !schema.enum.some((value) => JSON.stringify(value) === JSON.stringify(input)))
5226
+ errors.push(`${path}: expected one of ${JSON.stringify(schema.enum)}`);
5227
+ if (schema.oneOf) {
5228
+ const branches = schema.oneOf.map((branch) => validate(branch, input, path));
5229
+ if (!branches.some((errors2) => errors2.length === 0)) {
5230
+ const record = input && typeof input === "object" ? input : {};
5231
+ const selected = schema.oneOf.findIndex(
5232
+ (branch) => ["action", "view"].some((key) => branch.properties?.[key]?.enum?.includes(record[key]))
5233
+ );
5234
+ errors.push(...branches[selected >= 0 ? selected : 0] ?? []);
5235
+ }
5236
+ }
5237
+ if (typeof input === "object" && input !== null && !Array.isArray(input)) {
5238
+ const record = input;
5239
+ for (const name of schema.required ?? [])
5240
+ if (!Object.hasOwn(record, name)) errors.push(`${path}.${name}: required`);
5241
+ for (const [name, property] of Object.entries(schema.properties ?? {}))
5242
+ if (Object.hasOwn(record, name))
5243
+ errors.push(...validate(property, record[name], `${path}.${name}`));
5244
+ }
5245
+ if (Array.isArray(input) && schema.items)
5246
+ input.forEach((value, index) => {
5247
+ errors.push(...validate(schema.items, value, `${path}[${index}]`));
5248
+ });
5249
+ return errors;
5250
+ }
5251
+
5252
+ // src/tools/input_schema.ts
5253
+ var address = {
5254
+ type: "object",
5255
+ required: ["address"],
5256
+ properties: {
5257
+ address: { type: "string", description: "Email address." },
5258
+ name: { type: "string", description: "Display name." }
5259
+ }
5260
+ };
5261
+ var recipients = {
5262
+ type: "array",
5263
+ items: address,
5264
+ description: "Recipient addresses."
5265
+ };
5266
+ var payload = {
5267
+ type: "object",
5268
+ properties: {
5269
+ from: address,
5270
+ sender: address,
5271
+ envelopeFrom: address,
5272
+ replyTo: address,
5273
+ to: recipients,
5274
+ cc: recipients,
5275
+ bcc: recipients,
5276
+ subject: { type: "string", description: "Message subject." },
5277
+ text: { type: "string", description: "Plain text body." },
5278
+ html: { type: "string", description: "HTML body." },
5279
+ replyAll: { type: "boolean", description: "Reply to all original recipients." },
5280
+ mode: { type: "string", enum: ["inline", "attachment"] },
5281
+ attachments: {
5282
+ type: "array",
5283
+ description: "Message attachments.",
5284
+ items: {
5285
+ type: "object",
5286
+ required: ["filename", "content"],
5287
+ properties: {
5288
+ filename: { type: "string" },
5289
+ content: { description: "Attachment bytes (Buffer in library calls)." },
5290
+ mimeType: { type: "string" },
5291
+ inline: { type: "boolean" },
5292
+ contentId: { type: "string" }
5293
+ }
5294
+ }
5295
+ },
5296
+ inReplyTo: { type: "string" },
5297
+ references: { type: "array", items: { type: "string" } },
5298
+ headers: { type: "object" }
5299
+ }
5300
+ };
5301
+ function emailInputSchema(name, schema) {
5302
+ const discriminator = name === "mail_read" ? "view" : "action";
5303
+ const actions = schema.properties?.[discriminator]?.enum;
5304
+ if (!actions || name === "mail_sync") return schema;
5305
+ return {
5306
+ ...schema,
5307
+ oneOf: actions.map((value) => {
5308
+ const action = String(value);
5309
+ let required = [];
5310
+ let input;
5311
+ if (name === "mail_read") {
5312
+ if (action === "thread") required = ["threadId"];
5313
+ if (["message", "attachment", "eml"].includes(action)) required = ["folder", "uid"];
5314
+ } else if (name === "mail_compose") {
5315
+ if (action !== "send_draft") {
5316
+ required.push("input");
5317
+ input = {
5318
+ ...payload,
5319
+ required: ["send", "save_draft", "update_draft"].includes(action) ? ["to", "subject"] : action === "forward" ? ["to"] : []
5320
+ };
5321
+ }
5322
+ if (["reply", "forward"].includes(action)) required.push("folder", "uid");
5323
+ if (["update_draft", "send_draft"].includes(action)) required.push("uid");
5324
+ } else if (name === "mail_organize") {
5325
+ required = action === "rename_folder" ? ["oldPath", "newPath"] : action.endsWith("_folder") ? ["path"] : ["folder", "uids"];
5326
+ if (["copy", "move"].includes(action)) required.push("destination");
5327
+ if (action.endsWith("_labels")) required.push("labels");
5328
+ }
5329
+ return {
5330
+ type: "object",
5331
+ required: [...schema.required ?? [], ...required],
5332
+ properties: {
5333
+ ...schema.properties,
5334
+ [discriminator]: { ...schema.properties?.[discriminator], enum: [value] },
5335
+ ...input ? { input } : {}
5336
+ }
5337
+ };
5338
+ })
5339
+ };
5340
+ }
5341
+
5156
5342
  // src/tools/email_tools.ts
5157
5343
  var emailTools = [
5158
5344
  {
@@ -5873,6 +6059,21 @@ var emailTools = [
5873
6059
  }
5874
6060
  }
5875
6061
  ];
6062
+ for (const tool of emailTools) {
6063
+ Object.assign(tool.inputSchema, emailInputSchema(tool.name, tool.inputSchema));
6064
+ const handler = tool.handler;
6065
+ tool.handler = async (ctx, input) => {
6066
+ const errors = validateInput(tool.inputSchema, input);
6067
+ if (errors.length)
6068
+ return {
6069
+ outcome: "error",
6070
+ summary: errors.join("; "),
6071
+ entities: [],
6072
+ nextSteps: errors
6073
+ };
6074
+ return handler(ctx, input);
6075
+ };
6076
+ }
5876
6077
 
5877
6078
  // src/tools/aligned.ts
5878
6079
  var usage = {