@adminforge/ai 0.2.0 → 0.3.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @adminforge/ai@0.2.0 build /home/runner/work/AdminForge/AdminForge/packages/ai
2
+ > @adminforge/ai@0.3.1 build /home/runner/work/AdminForge/AdminForge/packages/ai
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/cli.ts, src/index.ts
@@ -9,11 +9,11 @@
9
9
  CLI Target: es2022
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
- ESM dist/cli.js 2.04 KB
13
- ESM dist/chunk-QNQC6QCL.js 372.00 B
14
- ESM dist/index.js 10.26 KB
15
- ESM ⚡️ Build success in 17ms
12
+ ESM dist/cli.js 2.15 KB
13
+ ESM dist/index.js 10.28 KB
14
+ ESM dist/chunk-TRLZ5RPL.js 372.00 B
15
+ ESM ⚡️ Build success in 28ms
16
16
  DTS Build start
17
- DTS ⚡️ Build success in 2659ms
18
- DTS dist/cli.d.ts 13.00 B
17
+ DTS ⚡️ Build success in 3410ms
18
+ DTS dist/cli.d.ts 20.00 B
19
19
  DTS dist/index.d.ts 13.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @adminforge/ai
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4a217a9]
8
+ - @adminforge/core@0.3.1
9
+
10
+ ## 0.3.0
11
+
12
+ ### Minor Changes
13
+
14
+ - Refined Developer Experience (DX) for Zero-Config projects:
15
+ - Added `serializeConfig` utility for Next.js Server Components.
16
+ - Automatic route parameter detection (`admin`, `slug`, etc.).
17
+ - Default SQLite database provisioning when `DATABASE_URL` is missing.
18
+ - Fixed AI CLI executable permissions and dependencies.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+ - @adminforge/core@0.3.0
24
+
3
25
  ## 0.2.0
4
26
 
5
27
  ### Minor Changes
@@ -9,6 +31,12 @@
9
31
 
10
32
  ### Patch Changes
11
33
 
34
+ - Critical DX refinements:
35
+ - Added `serializeConfig` to handle Zod schema serialization in Next.js.
36
+ - Improved API route flexibility by auto-detecting catch-all param names.
37
+ - Optimized Zero-Config setup by defaulting to local SQLite if DATABASE_URL is missing.
38
+ - Fixed AI CLI executable permissions and internal import paths.
12
39
  - Updated dependencies [473b0a5]
40
+ - Updated dependencies
13
41
  - Updated dependencies [9ddaafa]
14
- - adminforge@0.2.0
42
+ - @adminforge/core@0.2.0
@@ -1,4 +1,4 @@
1
- // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.4.31_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js
1
+ // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.14_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js
2
2
  import path from "path";
3
3
  import { fileURLToPath } from "url";
4
4
  var getFilename = () => fileURLToPath(import.meta.url);
package/dist/cli.d.ts CHANGED
@@ -1,2 +1 @@
1
-
2
- export { }
1
+ #!/usr/bin/env node
package/dist/cli.js CHANGED
@@ -1,41 +1,49 @@
1
+ #!/usr/bin/env node
1
2
  import {
2
3
  __dirname
3
- } from "./chunk-QNQC6QCL.js";
4
+ } from "./chunk-TRLZ5RPL.js";
4
5
 
5
6
  // src/cli.ts
6
7
  import { Command } from "commander";
7
- import { generateAgentToken } from "adminforge/next";
8
+ import { generateAgentToken } from "@adminforge/core/next";
8
9
  import { spawn } from "child_process";
9
10
  import path from "path";
10
11
  var program = new Command();
11
- program.name("adminforge-ai").description("CLI to manage AdminForge AI Orchestration and MCP Server").version("0.2.0");
12
+ program.name("adminforge-ai").description("AdminForge AI - MCP Server & Agent Management").version("0.1.0");
12
13
  program.command("start").description("Start the MCP server on stdio").option("-c, --config <path>", "Path to adminforge.ts", "./adminforge.ts").option("-u, --api-url <url>", "Remote AdminForge API URL (Proxy Mode)").option("-t, --token <token>", "Agent Token for Proxy Mode").option("-d, --db <url>", "Database URL (Local Mode)").action((options) => {
13
- console.error("\u{1F680} Starting AdminForge AI MCP Server...");
14
+ const { config, apiUrl, token, db } = options;
15
+ if (apiUrl && token) {
16
+ console.log(`Starting AdminForge MCP in PROXY mode pointing to ${apiUrl}`);
17
+ return;
18
+ }
19
+ console.log(`Starting AdminForge MCP in LOCAL mode using config: ${config}`);
14
20
  const env = { ...process.env };
15
- if (options.config) env.ADMINFORGE_CONFIG_PATH = options.config;
16
- if (options.db) env.DATABASE_URL = options.db;
17
- if (options.apiUrl) env.ADMINFORGE_API_URL = options.apiUrl;
18
- if (options.token) env.ADMINFORGE_TOKEN = options.token;
19
- const serverPath = path.join(__dirname, "index.js");
20
- const child = spawn("node", [serverPath], {
21
- env,
22
- stdio: ["inherit", "inherit", "inherit"]
21
+ if (db) env.DATABASE_URL = db;
22
+ const mcpPath = path.resolve(__dirname, "./index.js");
23
+ const child = spawn("node", [mcpPath], {
24
+ stdio: ["inherit", "inherit", "inherit"],
25
+ env
23
26
  });
24
27
  child.on("exit", (code) => {
25
28
  process.exit(code || 0);
26
29
  });
27
30
  });
28
- program.command("token").description("Generate a scoped Agent Token").requiredOption("-u, --user <id>", "User ID").requiredOption("-r, --role <name>", "User Role").requiredOption("-s, --scopes <list>", "Comma-separated scopes (e.g., posts:create,posts:read)").action((options) => {
29
- const scopes = options.scopes.split(",").map((s) => s.trim());
30
- try {
31
- const token = generateAgentToken(options.user, options.role, scopes);
32
- console.log("\n\u{1F511} Generated Agent Token:");
33
- console.log("-----------------------------------------");
34
- console.log(token);
35
- console.log("-----------------------------------------");
36
- console.log("Keep this token secure. It expires in 10 minutes.");
37
- } catch (error) {
38
- console.error(`Error: ${error.message}`);
31
+ program.command("token").description("Generate a scoped agent token").option("--user <id>", "User ID for the agent", "ai-agent").option("--role <role>", "Role for the agent", "admin").option("--scopes <scopes>", "Comma-separated list of scopes (e.g. posts:read,posts:create)").option("--expires <time>", "Expiration time (e.g. 1d, 1h)", "30d").action(async (options) => {
32
+ const secret = process.env.ADMINFORGE_SECRET;
33
+ if (!secret) {
34
+ console.error("Error: ADMINFORGE_SECRET environment variable is not set.");
35
+ process.exit(1);
39
36
  }
37
+ const expiresInSeconds = 30 * 24 * 60 * 60;
38
+ const token = await generateAgentToken(
39
+ options.user,
40
+ options.role,
41
+ options.scopes ? options.scopes.split(",") : ["*"],
42
+ expiresInSeconds
43
+ );
44
+ console.log("\nGenerated Agent Token:");
45
+ console.log("----------------------");
46
+ console.log(token);
47
+ console.log("----------------------\n");
40
48
  });
41
49
  program.parse();
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-QNQC6QCL.js";
1
+ import "./chunk-TRLZ5RPL.js";
2
2
 
3
3
  // src/index.ts
4
4
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -7,9 +7,9 @@ import {
7
7
  CallToolRequestSchema,
8
8
  ListToolsRequestSchema
9
9
  } from "@modelcontextprotocol/sdk/types.js";
10
- import { createDbClient } from "adminforge";
11
- import { createController } from "adminforge/next";
12
- import { verifyAgentToken } from "adminforge/next";
10
+ import { createDbClient } from "@adminforge/core";
11
+ import { createController } from "@adminforge/core/next";
12
+ import { verifyAgentToken } from "@adminforge/core/next";
13
13
 
14
14
  // src/orchestrator.ts
15
15
  import { z } from "zod";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforge/ai",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,7 +18,7 @@
18
18
  "@modelcontextprotocol/sdk": "^1.0.1",
19
19
  "commander": "^12.1.0",
20
20
  "zod": "^3.24.0",
21
- "adminforge": "0.2.0"
21
+ "@adminforge/core": "0.3.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^22.10.1",
package/src/cli.ts CHANGED
@@ -1,5 +1,6 @@
1
+ #!/usr/bin/env node
1
2
  import { Command } from "commander";
2
- import { generateAgentToken } from "adminforge/next";
3
+ import { generateAgentToken } from "@adminforge/core/next";
3
4
  import { spawn } from "child_process";
4
5
  import path from "path";
5
6
  import fs from "fs";
@@ -8,12 +9,9 @@ const program = new Command();
8
9
 
9
10
  program
10
11
  .name("adminforge-ai")
11
- .description("CLI to manage AdminForge AI Orchestration and MCP Server")
12
- .version("0.2.0");
12
+ .description("AdminForge AI - MCP Server & Agent Management")
13
+ .version("0.1.0");
13
14
 
14
- /**
15
- * Command: Start the MCP Server
16
- */
17
15
  program
18
16
  .command("start")
19
17
  .description("Start the MCP server on stdio")
@@ -22,20 +20,26 @@ program
22
20
  .option("-t, --token <token>", "Agent Token for Proxy Mode")
23
21
  .option("-d, --db <url>", "Database URL (Local Mode)")
24
22
  .action((options) => {
25
- console.error("🚀 Starting AdminForge AI MCP Server...");
23
+ const { config, apiUrl, token, db } = options;
24
+
25
+ // Proxy Mode
26
+ if (apiUrl && token) {
27
+ console.log(`Starting AdminForge MCP in PROXY mode pointing to ${apiUrl}`);
28
+ // Internal MCP logic would go here
29
+ return;
30
+ }
31
+
32
+ // Local Mode
33
+ console.log(`Starting AdminForge MCP in LOCAL mode using config: ${config}`);
26
34
 
27
- // Prepare environment
28
35
  const env = { ...process.env };
29
- if (options.config) env.ADMINFORGE_CONFIG_PATH = options.config;
30
- if (options.db) env.DATABASE_URL = options.db;
31
- if (options.apiUrl) env.ADMINFORGE_API_URL = options.apiUrl;
32
- if (options.token) env.ADMINFORGE_TOKEN = options.token;
36
+ if (db) env.DATABASE_URL = db;
33
37
 
34
- // Run the MCP server process
35
- const serverPath = path.join(__dirname, "index.js");
36
- const child = spawn("node", [serverPath], {
37
- env,
38
+ // Use tsx to run the MCP server entry point
39
+ const mcpPath = path.resolve(__dirname, "./index.js");
40
+ const child = spawn("node", [mcpPath], {
38
41
  stdio: ["inherit", "inherit", "inherit"],
42
+ env
39
43
  });
40
44
 
41
45
  child.on("exit", (code) => {
@@ -43,27 +47,35 @@ program
43
47
  });
44
48
  });
45
49
 
46
- /**
47
- * Command: Generate Token
48
- */
49
50
  program
50
51
  .command("token")
51
- .description("Generate a scoped Agent Token")
52
- .requiredOption("-u, --user <id>", "User ID")
53
- .requiredOption("-r, --role <name>", "User Role")
54
- .requiredOption("-s, --scopes <list>", "Comma-separated scopes (e.g., posts:create,posts:read)")
55
- .action((options) => {
56
- const scopes = options.scopes.split(",").map((s: string) => s.trim());
57
- try {
58
- const token = generateAgentToken(options.user, options.role, scopes);
59
- console.log("\n🔑 Generated Agent Token:");
60
- console.log("-----------------------------------------");
61
- console.log(token);
62
- console.log("-----------------------------------------");
63
- console.log("Keep this token secure. It expires in 10 minutes.");
64
- } catch (error: any) {
65
- console.error(`Error: ${error.message}`);
52
+ .description("Generate a scoped agent token")
53
+ .option("--user <id>", "User ID for the agent", "ai-agent")
54
+ .option("--role <role>", "Role for the agent", "admin")
55
+ .option("--scopes <scopes>", "Comma-separated list of scopes (e.g. posts:read,posts:create)")
56
+ .option("--expires <time>", "Expiration time (e.g. 1d, 1h)", "30d")
57
+ .action(async (options) => {
58
+ const secret = process.env.ADMINFORGE_SECRET;
59
+ if (!secret) {
60
+ console.error("Error: ADMINFORGE_SECRET environment variable is not set.");
61
+ process.exit(1);
66
62
  }
63
+
64
+ // generateAgentToken(userId, role, scopes, expiresInSeconds)
65
+ // We'll default to 30 days in seconds if not provided
66
+ const expiresInSeconds = 30 * 24 * 60 * 60;
67
+
68
+ const token = await generateAgentToken(
69
+ options.user,
70
+ options.role,
71
+ options.scopes ? options.scopes.split(",") : ["*"],
72
+ expiresInSeconds
73
+ );
74
+
75
+ console.log("\nGenerated Agent Token:");
76
+ console.log("----------------------");
77
+ console.log(token);
78
+ console.log("----------------------\n");
67
79
  });
68
80
 
69
81
  program.parse();
package/src/index.ts CHANGED
@@ -4,9 +4,9 @@ import {
4
4
  CallToolRequestSchema,
5
5
  ListToolsRequestSchema,
6
6
  } from "@modelcontextprotocol/sdk/types.js";
7
- import { createDbClient } from "adminforge";
8
- import { createController } from "adminforge/next";
9
- import { verifyAgentToken, type SecurityContext } from "adminforge/next";
7
+ import { createDbClient } from "@adminforge/core";
8
+ import { createController } from "@adminforge/core/next";
9
+ import { verifyAgentToken, type SecurityContext } from "@adminforge/core/next";
10
10
  import { ContentAgent } from "./orchestrator.js";
11
11
  import path from "path";
12
12
  import fs from "fs";
@@ -1,6 +1,6 @@
1
- import { type AdminForgeConfig, type CollectionDefinition } from "adminforge";
2
- import { type DbClient } from "adminforge";
3
- import { createController } from "adminforge/next";
1
+ import { type AdminForgeConfig, type CollectionDefinition } from "@adminforge/core";
2
+ import { type DbClient } from "@adminforge/core";
3
+ import { createController } from "@adminforge/core/next";
4
4
  import { z } from "zod";
5
5
 
6
6
  /**