@donkeylabs/server 0.1.0
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/README.md +15 -0
- package/cli/commands/generate.ts +461 -0
- package/cli/commands/init.ts +287 -0
- package/cli/commands/interactive.ts +223 -0
- package/cli/commands/plugin.ts +192 -0
- package/cli/donkeylabs +100 -0
- package/cli/index.ts +100 -0
- package/mcp/donkeylabs-mcp +3238 -0
- package/mcp/server.ts +3238 -0
- package/package.json +74 -0
- package/src/client/base.ts +481 -0
- package/src/client/index.ts +150 -0
- package/src/core/cache.ts +183 -0
- package/src/core/cron.ts +255 -0
- package/src/core/errors.ts +320 -0
- package/src/core/events.ts +163 -0
- package/src/core/index.ts +94 -0
- package/src/core/jobs.ts +334 -0
- package/src/core/logger.ts +131 -0
- package/src/core/rate-limiter.ts +193 -0
- package/src/core/sse.ts +210 -0
- package/src/core.ts +428 -0
- package/src/handlers.ts +87 -0
- package/src/harness.ts +70 -0
- package/src/index.ts +38 -0
- package/src/middleware.ts +34 -0
- package/src/registry.ts +13 -0
- package/src/router.ts +155 -0
- package/src/server.ts +233 -0
- package/templates/init/donkeylabs.config.ts.template +14 -0
- package/templates/init/index.ts.template +41 -0
- package/templates/plugin/index.ts.template +25 -0
package/cli/donkeylabs
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* @donkeylabs/server CLI
|
|
4
|
+
*
|
|
5
|
+
* Commands:
|
|
6
|
+
* init Initialize a new project
|
|
7
|
+
* generate Generate types (registry, context, client)
|
|
8
|
+
* plugin Plugin management (create, list)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { parseArgs } from "node:util";
|
|
12
|
+
import pc from "picocolors";
|
|
13
|
+
|
|
14
|
+
const { positionals, values } = parseArgs({
|
|
15
|
+
args: process.argv.slice(2),
|
|
16
|
+
options: {
|
|
17
|
+
help: { type: "boolean", short: "h" },
|
|
18
|
+
version: { type: "boolean", short: "v" },
|
|
19
|
+
},
|
|
20
|
+
allowPositionals: true,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const command = positionals[0];
|
|
24
|
+
|
|
25
|
+
function printHelp() {
|
|
26
|
+
console.log(`
|
|
27
|
+
${pc.bold("@donkeylabs/server")} - Type-safe plugin system for Bun
|
|
28
|
+
|
|
29
|
+
${pc.bold("Usage:")}
|
|
30
|
+
donkeylabs Interactive menu
|
|
31
|
+
donkeylabs <command> [options]
|
|
32
|
+
|
|
33
|
+
${pc.bold("Commands:")}
|
|
34
|
+
${pc.cyan("init")} Initialize a new project
|
|
35
|
+
${pc.cyan("generate")} Generate types (registry, context, client)
|
|
36
|
+
${pc.cyan("plugin")} Plugin management
|
|
37
|
+
|
|
38
|
+
${pc.bold("Options:")}
|
|
39
|
+
-h, --help Show this help message
|
|
40
|
+
-v, --version Show version number
|
|
41
|
+
|
|
42
|
+
${pc.bold("Examples:")}
|
|
43
|
+
donkeylabs # Interactive menu
|
|
44
|
+
donkeylabs init
|
|
45
|
+
donkeylabs generate
|
|
46
|
+
donkeylabs plugin create myPlugin
|
|
47
|
+
`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function printVersion() {
|
|
51
|
+
// Read from package.json
|
|
52
|
+
console.log("0.1.0");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function main() {
|
|
56
|
+
if (values.help) {
|
|
57
|
+
printHelp();
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (values.version) {
|
|
62
|
+
printVersion();
|
|
63
|
+
process.exit(0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// No command provided - launch interactive mode
|
|
67
|
+
if (!command) {
|
|
68
|
+
const { interactiveCommand } = await import("./commands/interactive");
|
|
69
|
+
await interactiveCommand();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
switch (command) {
|
|
74
|
+
case "init":
|
|
75
|
+
const { initCommand } = await import("./commands/init");
|
|
76
|
+
await initCommand(positionals.slice(1));
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
case "generate":
|
|
80
|
+
case "gen":
|
|
81
|
+
const { generateCommand } = await import("./commands/generate");
|
|
82
|
+
await generateCommand(positionals.slice(1));
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
case "plugin":
|
|
86
|
+
const { pluginCommand } = await import("./commands/plugin");
|
|
87
|
+
await pluginCommand(positionals.slice(1));
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
default:
|
|
91
|
+
console.error(pc.red(`Unknown command: ${command}`));
|
|
92
|
+
console.log(`Run ${pc.cyan("donkeylabs --help")} for available commands.`);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
main().catch((error) => {
|
|
98
|
+
console.error(pc.red("Error:"), error.message);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
});
|
package/cli/index.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* @donkeylabs/server CLI
|
|
4
|
+
*
|
|
5
|
+
* Commands:
|
|
6
|
+
* init Initialize a new project
|
|
7
|
+
* generate Generate types (registry, context, client)
|
|
8
|
+
* plugin Plugin management (create, list)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { parseArgs } from "node:util";
|
|
12
|
+
import pc from "picocolors";
|
|
13
|
+
|
|
14
|
+
const { positionals, values } = parseArgs({
|
|
15
|
+
args: process.argv.slice(2),
|
|
16
|
+
options: {
|
|
17
|
+
help: { type: "boolean", short: "h" },
|
|
18
|
+
version: { type: "boolean", short: "v" },
|
|
19
|
+
},
|
|
20
|
+
allowPositionals: true,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const command = positionals[0];
|
|
24
|
+
|
|
25
|
+
function printHelp() {
|
|
26
|
+
console.log(`
|
|
27
|
+
${pc.bold("@donkeylabs/server")} - Type-safe plugin system for Bun
|
|
28
|
+
|
|
29
|
+
${pc.bold("Usage:")}
|
|
30
|
+
donkeylabs Interactive menu
|
|
31
|
+
donkeylabs <command> [options]
|
|
32
|
+
|
|
33
|
+
${pc.bold("Commands:")}
|
|
34
|
+
${pc.cyan("init")} Initialize a new project
|
|
35
|
+
${pc.cyan("generate")} Generate types (registry, context, client)
|
|
36
|
+
${pc.cyan("plugin")} Plugin management
|
|
37
|
+
|
|
38
|
+
${pc.bold("Options:")}
|
|
39
|
+
-h, --help Show this help message
|
|
40
|
+
-v, --version Show version number
|
|
41
|
+
|
|
42
|
+
${pc.bold("Examples:")}
|
|
43
|
+
donkeylabs # Interactive menu
|
|
44
|
+
donkeylabs init
|
|
45
|
+
donkeylabs generate
|
|
46
|
+
donkeylabs plugin create myPlugin
|
|
47
|
+
`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function printVersion() {
|
|
51
|
+
// Read from package.json
|
|
52
|
+
console.log("0.1.0");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function main() {
|
|
56
|
+
if (values.help) {
|
|
57
|
+
printHelp();
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (values.version) {
|
|
62
|
+
printVersion();
|
|
63
|
+
process.exit(0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// No command provided - launch interactive mode
|
|
67
|
+
if (!command) {
|
|
68
|
+
const { interactiveCommand } = await import("./commands/interactive");
|
|
69
|
+
await interactiveCommand();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
switch (command) {
|
|
74
|
+
case "init":
|
|
75
|
+
const { initCommand } = await import("./commands/init");
|
|
76
|
+
await initCommand(positionals.slice(1));
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
case "generate":
|
|
80
|
+
case "gen":
|
|
81
|
+
const { generateCommand } = await import("./commands/generate");
|
|
82
|
+
await generateCommand(positionals.slice(1));
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
case "plugin":
|
|
86
|
+
const { pluginCommand } = await import("./commands/plugin");
|
|
87
|
+
await pluginCommand(positionals.slice(1));
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
default:
|
|
91
|
+
console.error(pc.red(`Unknown command: ${command}`));
|
|
92
|
+
console.log(`Run ${pc.cyan("donkeylabs --help")} for available commands.`);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
main().catch((error) => {
|
|
98
|
+
console.error(pc.red("Error:"), error.message);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
});
|