@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.
- package/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +29 -1
- package/dist/{chunk-QNQC6QCL.js → chunk-TRLZ5RPL.js} +1 -1
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +31 -23
- package/dist/index.js +4 -4
- package/package.json +2 -2
- package/src/cli.ts +46 -34
- package/src/index.ts +3 -3
- package/src/orchestrator.ts +3 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @adminforge/ai@0.
|
|
2
|
+
> @adminforge/ai@0.3.1 build /home/runner/work/AdminForge/AdminForge/packages/ai
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/cli.ts, src/index.ts
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
[34mCLI[39m Target: es2022
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/cli.js [22m[32m2.
|
|
13
|
-
[32mESM[39m [1mdist/
|
|
14
|
-
[32mESM[39m [1mdist/
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
12
|
+
[32mESM[39m [1mdist/cli.js [22m[32m2.15 KB[39m
|
|
13
|
+
[32mESM[39m [1mdist/index.js [22m[32m10.28 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/chunk-TRLZ5RPL.js [22m[32m372.00 B[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 28ms
|
|
16
16
|
[34mDTS[39m Build start
|
|
17
|
-
[32mDTS[39m ⚡️ Build success in
|
|
18
|
-
[32mDTS[39m [1mdist/cli.d.ts [22m[
|
|
17
|
+
[32mDTS[39m ⚡️ Build success in 3410ms
|
|
18
|
+
[32mDTS[39m [1mdist/cli.d.ts [22m[32m20.00 B[39m
|
|
19
19
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m13.00 B[39m
|
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.
|
|
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-
|
|
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("
|
|
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
|
-
|
|
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 (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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-
|
|
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.
|
|
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.
|
|
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("
|
|
12
|
-
.version("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
|
-
|
|
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 (
|
|
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
|
-
//
|
|
35
|
-
const
|
|
36
|
-
const child = spawn("node", [
|
|
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
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
console.
|
|
60
|
-
|
|
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";
|
package/src/orchestrator.ts
CHANGED
|
@@ -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
|
/**
|