@agenticmail/enterprise 0.5.52 → 0.5.53

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 (40) hide show
  1. package/dist/chunk-4ZVC4XJY.js +3563 -0
  2. package/dist/chunk-G54QH5PZ.js +9085 -0
  3. package/dist/chunk-GI5RMYH6.js +37 -0
  4. package/dist/chunk-HAN6MNXJ.js +374 -0
  5. package/dist/chunk-L447KLHG.js +13099 -0
  6. package/dist/chunk-ORN3ILZD.js +48 -0
  7. package/dist/chunk-QIBEF5G3.js +898 -0
  8. package/dist/chunk-WA6WJN3D.js +2115 -0
  9. package/dist/cidr-MQSAKEA6.js +17 -0
  10. package/dist/cli-build-skill-ZD5FURGY.js +235 -0
  11. package/dist/cli-recover-XKHGIGGR.js +97 -0
  12. package/dist/cli-submit-skill-R7HUAMYR.js +162 -0
  13. package/dist/cli-validate-BDWKT6KH.js +148 -0
  14. package/dist/cli-verify-RTYVUWD7.js +98 -0
  15. package/dist/config-store-44Y6KOVX.js +58 -0
  16. package/dist/db-adapter-FJZ5BESQ.js +7 -0
  17. package/dist/domain-lock-7EMDJXFQ.js +7 -0
  18. package/dist/dynamodb-CDDPVEXF.js +424 -0
  19. package/dist/factory-2SRP3B3U.js +9 -0
  20. package/dist/firewall-RTIDM4NY.js +10 -0
  21. package/dist/imap-flow-QTNT4Y75.js +44953 -0
  22. package/dist/index.js +322 -1
  23. package/dist/managed-2CZ3CSGR.js +17 -0
  24. package/dist/mongodb-UEHZUXYD.js +320 -0
  25. package/dist/mysql-4BBS773W.js +575 -0
  26. package/dist/nodemailer-JCKCTRMI.js +11711 -0
  27. package/dist/postgres-BCVODZLS.js +597 -0
  28. package/dist/providers-VPFJNW4H.js +17 -0
  29. package/dist/resolve-driver-ZLJYEK72.js +27 -0
  30. package/dist/routes-M5J73UQY.js +5783 -0
  31. package/dist/runtime-KQFFAIFR.js +47 -0
  32. package/dist/server-4FHO44MK.js +12 -0
  33. package/dist/setup-ZWEA6MUM.js +20 -0
  34. package/dist/skills-WMCZVXBK.js +14 -0
  35. package/dist/sqlite-K6HN7XRU.js +491 -0
  36. package/dist/turso-BBUTZACL.js +496 -0
  37. package/package.json +2 -2
  38. package/src/agenticmail/index.ts +2 -0
  39. package/src/agenticmail/providers/imap.ts +454 -0
  40. package/src/agenticmail/providers/index.ts +4 -2
@@ -0,0 +1,17 @@
1
+ import {
2
+ compileIpMatcher,
3
+ hostMatchesPattern,
4
+ ipMatchesCidr,
5
+ ipToNumber,
6
+ isValidIpOrCidr,
7
+ parseCidr
8
+ } from "./chunk-DRXMYYKN.js";
9
+ import "./chunk-GI5RMYH6.js";
10
+ export {
11
+ compileIpMatcher,
12
+ hostMatchesPattern,
13
+ ipMatchesCidr,
14
+ ipToNumber,
15
+ isValidIpOrCidr,
16
+ parseCidr
17
+ };
@@ -0,0 +1,235 @@
1
+ import {
2
+ VALID_CATEGORIES,
3
+ VALID_RISK_LEVELS,
4
+ validateSkillManifest
5
+ } from "./chunk-TY7NVD4U.js";
6
+ import "./chunk-GI5RMYH6.js";
7
+
8
+ // src/engine/cli-build-skill.ts
9
+ async function runBuildSkill(_args) {
10
+ const chalk = (await import("chalk")).default;
11
+ const ora = (await import("ora")).default;
12
+ const inquirer = (await import("inquirer")).default;
13
+ const fs = await import("fs/promises");
14
+ const path = await import("path");
15
+ console.log("");
16
+ console.log(chalk.bold("\u{1F6E0}\uFE0F AgenticMail Community Skill Builder"));
17
+ console.log(chalk.dim(" Generate a valid agenticmail-skill.json for any application"));
18
+ console.log("");
19
+ const answers = await inquirer.prompt([
20
+ {
21
+ type: "input",
22
+ name: "application",
23
+ message: "What application or service should this skill integrate with?",
24
+ validate: (v) => v.trim().length > 0 || "Application name is required"
25
+ },
26
+ {
27
+ type: "input",
28
+ name: "operations",
29
+ message: "What operations should it support? (comma-separated)",
30
+ default: "read, create, update, delete, list"
31
+ },
32
+ {
33
+ type: "list",
34
+ name: "category",
35
+ message: "Category:",
36
+ choices: [...VALID_CATEGORIES],
37
+ default: "productivity"
38
+ },
39
+ {
40
+ type: "list",
41
+ name: "risk",
42
+ message: "Risk level:",
43
+ choices: [...VALID_RISK_LEVELS],
44
+ default: "medium"
45
+ },
46
+ {
47
+ type: "input",
48
+ name: "author",
49
+ message: "Your GitHub username:",
50
+ validate: (v) => /^[a-zA-Z0-9_-]+$/.test(v.trim()) || "Must be a valid GitHub username"
51
+ },
52
+ {
53
+ type: "input",
54
+ name: "outputDir",
55
+ message: "Output directory:",
56
+ default: (a) => `./community-skills/${a.application.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "")}`
57
+ }
58
+ ]);
59
+ const appSlug = answers.application.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
60
+ const toolPrefix = appSlug.replace(/-/g, "_");
61
+ const operations = answers.operations.split(",").map((s) => s.trim()).filter(Boolean);
62
+ let manifest = null;
63
+ const spinner = ora("Generating skill manifest...").start();
64
+ try {
65
+ const res = await fetch("http://localhost:3000/health", { signal: AbortSignal.timeout(2e3) });
66
+ if (res.ok) {
67
+ spinner.text = "Agent runtime detected \u2014 using AI to generate manifest...";
68
+ const aiRes = await fetch("http://localhost:3000/api/chat", {
69
+ method: "POST",
70
+ headers: { "Content-Type": "application/json" },
71
+ body: JSON.stringify({
72
+ message: buildAIPrompt(answers.application, operations, answers.category, answers.risk, answers.author, appSlug, toolPrefix),
73
+ system: "You are a skill manifest generator. Respond with ONLY valid JSON, no markdown, no explanation."
74
+ }),
75
+ signal: AbortSignal.timeout(3e4)
76
+ });
77
+ if (aiRes.ok) {
78
+ const aiData = await aiRes.json();
79
+ const content = aiData.response || aiData.message || "";
80
+ const jsonMatch = content.match(/\{[\s\S]*\}/);
81
+ if (jsonMatch) {
82
+ manifest = JSON.parse(jsonMatch[0]);
83
+ }
84
+ }
85
+ }
86
+ } catch {
87
+ }
88
+ if (!manifest) {
89
+ spinner.text = "Generating from template...";
90
+ manifest = generateFromTemplate(answers.application, operations, answers.category, answers.risk, answers.author, appSlug, toolPrefix);
91
+ }
92
+ spinner.succeed("Manifest generated");
93
+ const validation = validateSkillManifest(manifest);
94
+ if (!validation.valid) {
95
+ console.log(chalk.yellow("\n Validation warnings (auto-fixing)..."));
96
+ if (!manifest.category) manifest.category = answers.category;
97
+ if (!manifest.risk) manifest.risk = answers.risk;
98
+ if (!manifest.license) manifest.license = "MIT";
99
+ if (!manifest.description || manifest.description.length < 20) {
100
+ manifest.description = `Integrates with ${answers.application} to ${operations.slice(0, 3).join(", ")} and more.`;
101
+ }
102
+ }
103
+ const outDir = path.resolve(answers.outputDir);
104
+ await fs.mkdir(outDir, { recursive: true });
105
+ const manifestPath = path.join(outDir, "agenticmail-skill.json");
106
+ await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
107
+ console.log(chalk.green(" \u2714") + ` Written: ${manifestPath}`);
108
+ const readmePath = path.join(outDir, "README.md");
109
+ await fs.writeFile(readmePath, generateReadme(manifest));
110
+ console.log(chalk.green(" \u2714") + ` Written: ${readmePath}`);
111
+ const finalCheck = validateSkillManifest(manifest);
112
+ if (finalCheck.valid) {
113
+ console.log(chalk.green("\n \u2714 Manifest is valid!"));
114
+ } else {
115
+ console.log(chalk.yellow("\n \u26A0 Manifest has issues:"));
116
+ for (const err of finalCheck.errors) console.log(chalk.red(" " + err));
117
+ }
118
+ for (const warn of finalCheck.warnings) console.log(chalk.yellow(" \u26A0 " + warn));
119
+ console.log("");
120
+ const { submit } = await inquirer.prompt([{
121
+ type: "confirm",
122
+ name: "submit",
123
+ message: "Submit this skill as a PR to agenticmail/enterprise?",
124
+ default: false
125
+ }]);
126
+ if (submit) {
127
+ const { runSubmitSkill } = await import("./cli-submit-skill-R7HUAMYR.js");
128
+ await runSubmitSkill([outDir]);
129
+ } else {
130
+ console.log(chalk.dim("\n To submit later: npx @agenticmail/enterprise submit-skill " + answers.outputDir));
131
+ }
132
+ }
133
+ function generateFromTemplate(app, operations, category, risk, author, slug, prefix) {
134
+ const tools = operations.map((op) => {
135
+ const opSlug = op.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
136
+ const isRead = ["read", "get", "list", "search", "fetch", "view", "query"].some((r) => opSlug.includes(r));
137
+ const isDelete = ["delete", "remove", "destroy"].some((r) => opSlug.includes(r));
138
+ const toolCategory = isDelete ? "destroy" : isRead ? "read" : "write";
139
+ const toolRisk = isDelete ? "high" : isRead ? "low" : "medium";
140
+ const sideEffects = [];
141
+ if (!isRead) sideEffects.push("network-request");
142
+ if (isDelete) sideEffects.push("deletes-data");
143
+ return {
144
+ id: `${prefix}_${opSlug}`,
145
+ name: op.charAt(0).toUpperCase() + op.slice(1),
146
+ description: `${op.charAt(0).toUpperCase() + op.slice(1)} in ${app}`,
147
+ category: toolCategory,
148
+ riskLevel: toolRisk,
149
+ sideEffects,
150
+ parameters: {}
151
+ };
152
+ });
153
+ return {
154
+ id: slug,
155
+ name: app,
156
+ description: `Integrates with ${app} to ${operations.slice(0, 3).join(", ")}${operations.length > 3 ? " and more" : ""}. Community-contributed skill for AgenticMail agents.`,
157
+ version: "1.0.0",
158
+ author,
159
+ repository: `https://github.com/${author}/${slug}`,
160
+ license: "MIT",
161
+ category,
162
+ risk,
163
+ tags: [slug, category],
164
+ tools,
165
+ configSchema: {
166
+ apiKey: { type: "secret", label: "API Key", description: `Your ${app} API key`, required: true }
167
+ },
168
+ minEngineVersion: "0.3.0",
169
+ homepage: `https://github.com/${author}/${slug}`
170
+ };
171
+ }
172
+ function buildAIPrompt(app, operations, category, risk, author, slug, prefix) {
173
+ return `Generate a valid agenticmail-skill.json manifest for "${app}".
174
+
175
+ Requirements:
176
+ - id: "${slug}"
177
+ - name: "${app}"
178
+ - Operations: ${operations.join(", ")}
179
+ - category: "${category}"
180
+ - risk: "${risk}"
181
+ - author: "${author}"
182
+ - repository: "https://github.com/${author}/${slug}"
183
+ - license: "MIT"
184
+ - Each tool needs: id (${prefix}_<action>), name, description, category (read/write/execute/communicate/destroy), riskLevel (low/medium/high/critical), sideEffects array
185
+ - Valid sideEffects: sends-email, sends-message, sends-sms, posts-social, runs-code, modifies-files, deletes-data, network-request, controls-device, accesses-secrets, financial
186
+ - Include a configSchema with any API keys or settings needed
187
+ - version: "1.0.0"
188
+ - minEngineVersion: "0.3.0"
189
+ - description must be 20-500 chars
190
+
191
+ Output ONLY the JSON object, no explanation.`;
192
+ }
193
+ function generateReadme(manifest) {
194
+ const tools = (manifest.tools || []).map(
195
+ (t) => `| \`${t.id}\` | ${t.name} | ${t.description} | ${t.riskLevel || "medium"} |`
196
+ ).join("\n");
197
+ return `# ${manifest.name}
198
+
199
+ ${manifest.description}
200
+
201
+ ## Tools
202
+
203
+ | ID | Name | Description | Risk |
204
+ |----|------|-------------|------|
205
+ ${tools}
206
+
207
+ ## Configuration
208
+
209
+ ${manifest.configSchema ? Object.entries(manifest.configSchema).map(
210
+ ([k, v]) => `- **${k}** (${v.type || "string"}): ${v.description || k}${v.required ? " *(required)*" : ""}`
211
+ ).join("\n") : "No configuration required."}
212
+
213
+ ## Installation
214
+
215
+ Install this skill from the AgenticMail Enterprise dashboard:
216
+
217
+ 1. Go to **Community Skills** in the sidebar
218
+ 2. Search for "${manifest.name}"
219
+ 3. Click **Install**
220
+
221
+ Or via the API:
222
+ \`\`\`bash
223
+ curl -X POST /api/engine/community/skills/${manifest.id}/install \\
224
+ -H "Content-Type: application/json" \\
225
+ -d '{"orgId": "your-org-id"}'
226
+ \`\`\`
227
+
228
+ ## License
229
+
230
+ ${manifest.license || "MIT"}
231
+ `;
232
+ }
233
+ export {
234
+ runBuildSkill
235
+ };
@@ -0,0 +1,97 @@
1
+ import {
2
+ DomainLock
3
+ } from "./chunk-UPU23ZRG.js";
4
+ import "./chunk-GI5RMYH6.js";
5
+
6
+ // src/domain-lock/cli-recover.ts
7
+ function getFlag(args, name) {
8
+ const idx = args.indexOf(name);
9
+ if (idx !== -1 && args[idx + 1]) return args[idx + 1];
10
+ return void 0;
11
+ }
12
+ async function runRecover(args) {
13
+ const { default: inquirer } = await import("inquirer");
14
+ const { default: chalk } = await import("chalk");
15
+ const { default: ora } = await import("ora");
16
+ console.log("");
17
+ console.log(chalk.bold(" AgenticMail Enterprise \u2014 Domain Recovery"));
18
+ console.log(chalk.dim(" Recover your domain registration on a new machine."));
19
+ console.log("");
20
+ let domain = getFlag(args, "--domain");
21
+ if (!domain) {
22
+ const answer = await inquirer.prompt([{
23
+ type: "input",
24
+ name: "domain",
25
+ message: "Domain to recover:",
26
+ suffix: chalk.dim(" (e.g. agents.agenticmail.io)"),
27
+ validate: (v) => v.includes(".") || "Enter a valid domain"
28
+ }]);
29
+ domain = answer.domain;
30
+ }
31
+ let key = getFlag(args, "--key");
32
+ if (!key) {
33
+ const answer = await inquirer.prompt([{
34
+ type: "password",
35
+ name: "key",
36
+ message: "Deployment key:",
37
+ mask: "*",
38
+ validate: (v) => {
39
+ if (v.length !== 64) return "Deployment key should be 64 hex characters";
40
+ if (!/^[0-9a-fA-F]+$/.test(v)) return "Deployment key should be hexadecimal";
41
+ return true;
42
+ }
43
+ }]);
44
+ key = answer.key;
45
+ }
46
+ const spinner = ora("Contacting AgenticMail registry...").start();
47
+ const lock = new DomainLock();
48
+ const result = await lock.recover(domain, key);
49
+ if (!result.success) {
50
+ spinner.fail("Recovery failed");
51
+ console.log("");
52
+ console.error(chalk.red(` ${result.error}`));
53
+ console.log("");
54
+ process.exit(1);
55
+ }
56
+ spinner.succeed("Domain recovery initiated");
57
+ const { default: bcrypt } = await import("bcryptjs");
58
+ const keyHash = await bcrypt.hash(key, 12);
59
+ const dbPath = getFlag(args, "--db");
60
+ const dbType = getFlag(args, "--db-type") || "sqlite";
61
+ if (dbPath) {
62
+ try {
63
+ const spinnerDb = ora("Saving to local database...").start();
64
+ const { createAdapter } = await import("./factory-2SRP3B3U.js");
65
+ const db = await createAdapter({ type: dbType, connectionString: dbPath });
66
+ await db.migrate();
67
+ await db.updateSettings({
68
+ domain,
69
+ deploymentKeyHash: keyHash,
70
+ domainRegistrationId: result.registrationId,
71
+ domainDnsChallenge: result.dnsChallenge,
72
+ domainRegisteredAt: (/* @__PURE__ */ new Date()).toISOString(),
73
+ domainStatus: "pending_dns"
74
+ });
75
+ spinnerDb.succeed("Local database updated");
76
+ await db.disconnect();
77
+ } catch (err) {
78
+ console.log(chalk.yellow(`
79
+ Could not update local DB: ${err.message}`));
80
+ console.log(chalk.dim(" You can manually update settings after setup."));
81
+ }
82
+ }
83
+ console.log("");
84
+ console.log(chalk.green.bold(" Domain recovery successful!"));
85
+ console.log("");
86
+ console.log(chalk.bold(" Update your DNS TXT record:"));
87
+ console.log("");
88
+ console.log(` ${chalk.bold("Host:")} ${chalk.cyan(`_agenticmail-verify.${domain}`)}`);
89
+ console.log(` ${chalk.bold("Type:")} ${chalk.cyan("TXT")}`);
90
+ console.log(` ${chalk.bold("Value:")} ${chalk.cyan(result.dnsChallenge)}`);
91
+ console.log("");
92
+ console.log(chalk.dim(" Then run: npx @agenticmail/enterprise verify-domain"));
93
+ console.log("");
94
+ }
95
+ export {
96
+ runRecover
97
+ };
@@ -0,0 +1,162 @@
1
+ import {
2
+ validateSkillManifest
3
+ } from "./chunk-TY7NVD4U.js";
4
+ import "./chunk-GI5RMYH6.js";
5
+
6
+ // src/engine/cli-submit-skill.ts
7
+ var UPSTREAM_REPO = "agenticmail/enterprise";
8
+ async function runSubmitSkill(args) {
9
+ const chalk = (await import("chalk")).default;
10
+ const ora = (await import("ora")).default;
11
+ const { execSync } = await import("child_process");
12
+ const fs = await import("fs/promises");
13
+ const path = await import("path");
14
+ const target = args.filter((a) => !a.startsWith("--"))[0];
15
+ if (!target) {
16
+ console.log(`${chalk.bold("Usage:")} npx @agenticmail/enterprise submit-skill <path-to-skill-dir>`);
17
+ process.exit(1);
18
+ return;
19
+ }
20
+ const skillDir = path.resolve(target);
21
+ console.log("");
22
+ console.log(chalk.bold("\u{1F680} Submit Community Skill"));
23
+ console.log("");
24
+ const spinner = ora("Checking prerequisites...").start();
25
+ try {
26
+ execSync("gh --version", { stdio: "pipe" });
27
+ } catch {
28
+ spinner.fail("GitHub CLI (gh) is not installed");
29
+ console.log("");
30
+ console.log(chalk.dim(" Install it from: https://cli.github.com/"));
31
+ console.log(chalk.dim(" Then run: gh auth login"));
32
+ process.exit(1);
33
+ return;
34
+ }
35
+ try {
36
+ execSync("gh auth status", { stdio: "pipe" });
37
+ } catch {
38
+ spinner.fail("Not authenticated with GitHub CLI");
39
+ console.log(chalk.dim(" Run: gh auth login"));
40
+ process.exit(1);
41
+ return;
42
+ }
43
+ spinner.succeed("GitHub CLI authenticated");
44
+ const validateSpinner = ora("Validating skill manifest...").start();
45
+ const manifestPath = path.join(skillDir, "agenticmail-skill.json");
46
+ let manifest;
47
+ try {
48
+ const raw = await fs.readFile(manifestPath, "utf-8");
49
+ manifest = JSON.parse(raw);
50
+ } catch (err) {
51
+ validateSpinner.fail(`Cannot read manifest: ${err.message}`);
52
+ process.exit(1);
53
+ return;
54
+ }
55
+ const validation = validateSkillManifest(manifest);
56
+ if (!validation.valid) {
57
+ validateSpinner.fail("Manifest validation failed");
58
+ for (const err of validation.errors) {
59
+ console.log(chalk.red(" \u2502 " + err));
60
+ }
61
+ console.log(chalk.dim("\n Fix the errors above and try again."));
62
+ process.exit(1);
63
+ return;
64
+ }
65
+ validateSpinner.succeed(`Manifest valid: ${manifest.name} v${manifest.version}`);
66
+ const skillId = manifest.id;
67
+ const branchName = `community/add-${skillId}`;
68
+ const forkSpinner = ora("Forking repository...").start();
69
+ try {
70
+ execSync(`gh repo fork ${UPSTREAM_REPO} --clone=false 2>&1 || true`, { stdio: "pipe" });
71
+ forkSpinner.succeed("Repository forked (or already exists)");
72
+ } catch {
73
+ forkSpinner.succeed("Fork exists");
74
+ }
75
+ let forkUrl;
76
+ try {
77
+ const ghUser = execSync("gh api user --jq .login", { encoding: "utf-8" }).trim();
78
+ forkUrl = `https://github.com/${ghUser}/enterprise.git`;
79
+ } catch {
80
+ forkSpinner.fail("Cannot determine GitHub username");
81
+ process.exit(1);
82
+ return;
83
+ }
84
+ const tmpDir = path.join(process.env.TMPDIR || "/tmp", `agenticmail-submit-${Date.now()}`);
85
+ const pushSpinner = ora("Cloning fork...").start();
86
+ try {
87
+ execSync(`git clone --depth 1 ${forkUrl} "${tmpDir}"`, { stdio: "pipe" });
88
+ pushSpinner.text = "Creating branch...";
89
+ const run = (cmd) => execSync(cmd, { cwd: tmpDir, stdio: "pipe", encoding: "utf-8" });
90
+ run(`git remote add upstream https://github.com/${UPSTREAM_REPO}.git`);
91
+ run("git fetch upstream main --depth 1");
92
+ run(`git checkout -b ${branchName} upstream/main`);
93
+ pushSpinner.text = "Copying skill files...";
94
+ const destDir = path.join(tmpDir, "community-skills", skillId);
95
+ await fs.mkdir(destDir, { recursive: true });
96
+ const files = await fs.readdir(skillDir);
97
+ for (const file of files) {
98
+ await fs.copyFile(path.join(skillDir, file), path.join(destDir, file));
99
+ }
100
+ pushSpinner.text = "Committing...";
101
+ run(`git add community-skills/${skillId}/`);
102
+ run(`git commit -m "Add community skill: ${manifest.name}"`);
103
+ pushSpinner.text = "Pushing to fork...";
104
+ run(`git push origin ${branchName} --force`);
105
+ pushSpinner.succeed("Pushed to fork");
106
+ } catch (err) {
107
+ pushSpinner.fail(`Git operation failed: ${err.message}`);
108
+ process.exit(1);
109
+ return;
110
+ }
111
+ const prSpinner = ora("Opening pull request...").start();
112
+ const toolsList = (manifest.tools || []).map(
113
+ (t) => `- \`${t.id}\` \u2014 ${t.name}: ${t.description}`
114
+ ).join("\n");
115
+ const prBody = `## Community Skill Submission
116
+
117
+ **Skill ID:** \`${manifest.id}\`
118
+ **Application:** ${manifest.name}
119
+ **Category:** ${manifest.category}
120
+ **Risk Level:** ${manifest.risk}
121
+ **Author:** @${manifest.author}
122
+ **License:** ${manifest.license}
123
+
124
+ ### Description
125
+
126
+ ${manifest.description}
127
+
128
+ ### Tools Provided
129
+
130
+ ${toolsList}
131
+
132
+ ### Validation
133
+
134
+ - [x] Manifest passes \`npx @agenticmail/enterprise validate\`
135
+ - [x] All required fields present
136
+ - [x] No duplicate tool IDs
137
+ ${manifest.tags ? `
138
+ **Tags:** ${manifest.tags.join(", ")}` : ""}`;
139
+ try {
140
+ const prUrl = execSync(
141
+ `gh pr create --repo ${UPSTREAM_REPO} --head ${branchName} --title "Add community skill: ${manifest.name}" --body "${prBody.replace(/"/g, '\\"')}"`,
142
+ { cwd: tmpDir, encoding: "utf-8", stdio: "pipe" }
143
+ ).trim();
144
+ prSpinner.succeed("Pull request opened!");
145
+ console.log(chalk.green(`
146
+ ${prUrl}
147
+ `));
148
+ } catch (err) {
149
+ if (err.stderr?.includes("already exists")) {
150
+ prSpinner.warn("A PR for this skill already exists");
151
+ } else {
152
+ prSpinner.fail(`Could not open PR: ${err.message}`);
153
+ }
154
+ }
155
+ try {
156
+ await fs.rm(tmpDir, { recursive: true, force: true });
157
+ } catch {
158
+ }
159
+ }
160
+ export {
161
+ runSubmitSkill
162
+ };
@@ -0,0 +1,148 @@
1
+ import {
2
+ ALL_TOOLS,
3
+ init_tool_catalog
4
+ } from "./chunk-4ZVC4XJY.js";
5
+ import {
6
+ collectCommunityToolIds,
7
+ validateSkillManifest
8
+ } from "./chunk-TY7NVD4U.js";
9
+ import "./chunk-GI5RMYH6.js";
10
+
11
+ // src/engine/cli-validate.ts
12
+ init_tool_catalog();
13
+ async function runValidate(args) {
14
+ const chalk = (await import("chalk")).default;
15
+ const fs = await import("fs/promises");
16
+ const path = await import("path");
17
+ const jsonMode = args.includes("--json");
18
+ const allMode = args.includes("--all");
19
+ const pathArgs = args.filter((a) => !a.startsWith("--"));
20
+ const builtinIds = new Set(ALL_TOOLS.map((t) => t.id));
21
+ const communityDir = path.resolve(process.cwd(), "community-skills");
22
+ const reports = [];
23
+ if (allMode) {
24
+ let entries;
25
+ try {
26
+ entries = await fs.readdir(communityDir, { withFileTypes: true });
27
+ } catch {
28
+ if (jsonMode) {
29
+ console.log(JSON.stringify({ error: "community-skills/ directory not found" }));
30
+ } else {
31
+ console.error(chalk.red("Error: community-skills/ directory not found"));
32
+ }
33
+ process.exit(1);
34
+ return;
35
+ }
36
+ for (const entry of entries) {
37
+ if (!entry.isDirectory() || entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
38
+ const skillDir = path.join(communityDir, entry.name);
39
+ const report = await validatePath(skillDir, builtinIds, communityDir);
40
+ reports.push(report);
41
+ }
42
+ } else {
43
+ const target = pathArgs[0];
44
+ if (!target) {
45
+ if (jsonMode) {
46
+ console.log(JSON.stringify({ error: "No path specified. Usage: npx @agenticmail/enterprise validate <path> [--all] [--json]" }));
47
+ } else {
48
+ console.log(`${chalk.bold("Usage:")} npx @agenticmail/enterprise validate <path>`);
49
+ console.log("");
50
+ console.log(" <path> Path to a skill directory or agenticmail-skill.json file");
51
+ console.log(" --all Validate all skills in community-skills/");
52
+ console.log(" --json Machine-readable JSON output");
53
+ }
54
+ process.exit(1);
55
+ return;
56
+ }
57
+ const report = await validatePath(path.resolve(target), builtinIds, communityDir);
58
+ reports.push(report);
59
+ }
60
+ if (jsonMode) {
61
+ console.log(JSON.stringify({ results: reports, totalErrors: reports.reduce((s, r) => s + r.errors.length, 0) }, null, 2));
62
+ } else {
63
+ console.log("");
64
+ for (const report of reports) {
65
+ if (report.valid) {
66
+ console.log(chalk.green(" \u2714") + " " + chalk.bold(report.skillId) + chalk.dim(` (${report.path})`));
67
+ } else {
68
+ console.log(chalk.red(" \u2718") + " " + chalk.bold(report.skillId) + chalk.dim(` (${report.path})`));
69
+ for (const err of report.errors) {
70
+ console.log(chalk.red(" \u2502 ") + err);
71
+ }
72
+ }
73
+ for (const warn of report.warnings) {
74
+ console.log(chalk.yellow(" \u26A0 ") + warn);
75
+ }
76
+ }
77
+ console.log("");
78
+ const passed = reports.filter((r) => r.valid).length;
79
+ const failed = reports.filter((r) => !r.valid).length;
80
+ if (failed > 0) {
81
+ console.log(chalk.red(` ${failed} failed`) + chalk.dim(`, ${passed} passed, ${reports.length} total`));
82
+ } else {
83
+ console.log(chalk.green(` ${passed} passed`) + chalk.dim(`, ${reports.length} total`));
84
+ }
85
+ console.log("");
86
+ }
87
+ if (reports.some((r) => !r.valid)) {
88
+ process.exit(1);
89
+ }
90
+ }
91
+ async function validatePath(targetPath, builtinIds, communityDir) {
92
+ const fs = await import("fs/promises");
93
+ const path = await import("path");
94
+ let manifestPath;
95
+ try {
96
+ const stat = await fs.stat(targetPath);
97
+ if (stat.isDirectory()) {
98
+ manifestPath = path.join(targetPath, "agenticmail-skill.json");
99
+ } else {
100
+ manifestPath = targetPath;
101
+ }
102
+ } catch {
103
+ return {
104
+ path: targetPath,
105
+ skillId: path.basename(targetPath),
106
+ valid: false,
107
+ errors: [`Path not found: ${targetPath}`],
108
+ warnings: []
109
+ };
110
+ }
111
+ let raw;
112
+ try {
113
+ raw = await fs.readFile(manifestPath, "utf-8");
114
+ } catch {
115
+ return {
116
+ path: manifestPath,
117
+ skillId: path.basename(path.dirname(manifestPath)),
118
+ valid: false,
119
+ errors: [`Cannot read: ${manifestPath}`],
120
+ warnings: []
121
+ };
122
+ }
123
+ let manifest;
124
+ try {
125
+ manifest = JSON.parse(raw);
126
+ } catch (err) {
127
+ return {
128
+ path: manifestPath,
129
+ skillId: path.basename(path.dirname(manifestPath)),
130
+ valid: false,
131
+ errors: [`Invalid JSON: ${err.message}`],
132
+ warnings: []
133
+ };
134
+ }
135
+ const communityIds = await collectCommunityToolIds(communityDir, manifest.id);
136
+ const allExistingIds = /* @__PURE__ */ new Set([...builtinIds, ...communityIds]);
137
+ const result = validateSkillManifest(manifest, { existingToolIds: allExistingIds });
138
+ return {
139
+ path: manifestPath,
140
+ skillId: manifest.id || path.basename(path.dirname(manifestPath)),
141
+ valid: result.valid,
142
+ errors: result.errors,
143
+ warnings: result.warnings
144
+ };
145
+ }
146
+ export {
147
+ runValidate
148
+ };