@nebulaos/cli 0.1.1 → 0.1.3
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/LICENSE.txt +21 -0
- package/README.md +310 -298
- package/dist/bin/nebulaos.js +133 -17
- package/dist/bin/nebulaos.js.map +1 -1
- package/dist/index.js +135 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/program.ts
|
|
2
|
-
import { Command as
|
|
2
|
+
import { Command as Command68 } from "commander";
|
|
3
3
|
|
|
4
4
|
// src/lib/flags.ts
|
|
5
5
|
import { Option } from "commander";
|
|
@@ -1096,11 +1096,12 @@ import { Command as Command23 } from "commander";
|
|
|
1096
1096
|
import ora from "ora";
|
|
1097
1097
|
import chalk11 from "chalk";
|
|
1098
1098
|
function createExecutionRunCommand() {
|
|
1099
|
-
const cmd = new Command23("run").description("Trigger execution of an agent or workflow by resource ID").argument("<resourceId>", "Resource ID to execute").option("-i, --input <json>", "Input data as JSON string").addHelpText("after", `
|
|
1099
|
+
const cmd = new Command23("run").description("Trigger execution of an agent or workflow by resource ID").argument("<resourceId>", "Resource ID to execute").option("-i, --input <json>", "Input data as JSON string").option("-m, --memory-key <key>", "Memory partition key for conversation context").addHelpText("after", `
|
|
1100
1100
|
Examples:
|
|
1101
1101
|
$ nebulaos exec run 550e8400-e29b... Run a resource
|
|
1102
1102
|
$ nebulaos exec run my-agent -i '{"prompt":"Hello"}' Run with JSON input
|
|
1103
1103
|
$ nebulaos exec run my-workflow -i '{"data":[1,2,3]}' -o json Run and output as JSON
|
|
1104
|
+
$ nebulaos exec run my-agent -i '"Oi"' -m user-123 Run with memory context
|
|
1104
1105
|
`).action(async (resourceId, options, command) => {
|
|
1105
1106
|
try {
|
|
1106
1107
|
const globalOpts = command.optsWithGlobals();
|
|
@@ -1118,9 +1119,11 @@ Examples:
|
|
|
1118
1119
|
}
|
|
1119
1120
|
}
|
|
1120
1121
|
const spinner = ora("Starting execution...").start();
|
|
1122
|
+
const executionOptions = options.memoryKey ? { memoryKey: options.memoryKey } : void 0;
|
|
1121
1123
|
const { data: execution } = await api.post("/execution", {
|
|
1122
1124
|
resourceId,
|
|
1123
|
-
input: input4
|
|
1125
|
+
input: input4,
|
|
1126
|
+
options: executionOptions
|
|
1124
1127
|
});
|
|
1125
1128
|
spinner.succeed("Execution started.");
|
|
1126
1129
|
if (format === "table") {
|
|
@@ -1337,7 +1340,7 @@ Examples:
|
|
|
1337
1340
|
const params = {};
|
|
1338
1341
|
if (globalOpts.page) params.page = globalOpts.page;
|
|
1339
1342
|
if (globalOpts.pageSize) params.pageSize = globalOpts.pageSize;
|
|
1340
|
-
const { data } = await api.get("/rag/
|
|
1343
|
+
const { data } = await api.get("/rag-openai/connections", { params });
|
|
1341
1344
|
const connections = Array.isArray(data) ? data : data.data || [];
|
|
1342
1345
|
output(format, {
|
|
1343
1346
|
table: {
|
|
@@ -1374,7 +1377,7 @@ Examples:
|
|
|
1374
1377
|
const globalOpts = command.optsWithGlobals();
|
|
1375
1378
|
const format = resolveFormat(globalOpts.output);
|
|
1376
1379
|
const api = getApiClient();
|
|
1377
|
-
const { data } = await api.get(`/rag/
|
|
1380
|
+
const { data } = await api.get(`/rag-openai/connections/${id}`);
|
|
1378
1381
|
if (format === "table") {
|
|
1379
1382
|
console.log(chalk14.bold("RAG Connection\n"));
|
|
1380
1383
|
printDetail("ID", data.id);
|
|
@@ -1422,7 +1425,7 @@ Examples:
|
|
|
1422
1425
|
if (options.apiKey) body.apiKey = options.apiKey;
|
|
1423
1426
|
if (options.model) body.model = options.model;
|
|
1424
1427
|
if (options.dimensions) body.dimensions = options.dimensions;
|
|
1425
|
-
const { data } = await api.post("/rag/
|
|
1428
|
+
const { data } = await api.post("/rag-openai/connections", body);
|
|
1426
1429
|
if (format === "table") {
|
|
1427
1430
|
printSuccess("RAG connection created successfully.");
|
|
1428
1431
|
printDetail("ID", data.id);
|
|
@@ -1460,7 +1463,7 @@ Examples:
|
|
|
1460
1463
|
if (options.apiKey) body.apiKey = options.apiKey;
|
|
1461
1464
|
if (options.model) body.model = options.model;
|
|
1462
1465
|
if (options.dimensions) body.dimensions = options.dimensions;
|
|
1463
|
-
const { data } = await api.patch(`/rag/
|
|
1466
|
+
const { data } = await api.patch(`/rag-openai/connections/${id}`, body);
|
|
1464
1467
|
if (format === "table") {
|
|
1465
1468
|
printSuccess("RAG connection updated successfully.");
|
|
1466
1469
|
printDetail("ID", data.id);
|
|
@@ -1500,7 +1503,7 @@ Examples:
|
|
|
1500
1503
|
}
|
|
1501
1504
|
}
|
|
1502
1505
|
const api = getApiClient();
|
|
1503
|
-
await api.delete(`/rag/
|
|
1506
|
+
await api.delete(`/rag-openai/connections/${id}`);
|
|
1504
1507
|
printSuccess(`RAG connection '${id}' deleted.`);
|
|
1505
1508
|
} catch (error) {
|
|
1506
1509
|
handleError(error);
|
|
@@ -1523,7 +1526,7 @@ Examples:
|
|
|
1523
1526
|
const format = resolveFormat(globalOpts.output);
|
|
1524
1527
|
const api = getApiClient();
|
|
1525
1528
|
console.log("Testing connection...");
|
|
1526
|
-
const { data } = await api.post(`/rag/
|
|
1529
|
+
const { data } = await api.post(`/rag-openai/connections/${id}/test`);
|
|
1527
1530
|
if (format === "table") {
|
|
1528
1531
|
if (data.success) {
|
|
1529
1532
|
console.log(chalk15.green("Connection test passed."));
|
|
@@ -1618,7 +1621,7 @@ Examples:
|
|
|
1618
1621
|
const globalOpts = command.optsWithGlobals();
|
|
1619
1622
|
const format = resolveFormat(globalOpts.output);
|
|
1620
1623
|
const api = getApiClient();
|
|
1621
|
-
const { data } = await api.get("/features/catalog");
|
|
1624
|
+
const { data } = await api.get("/ai-features/catalog");
|
|
1622
1625
|
const features = Array.isArray(data) ? data : data.data || [];
|
|
1623
1626
|
output(format, {
|
|
1624
1627
|
table: {
|
|
@@ -1652,7 +1655,7 @@ Examples:
|
|
|
1652
1655
|
const globalOpts = command.optsWithGlobals();
|
|
1653
1656
|
const format = resolveFormat(globalOpts.output);
|
|
1654
1657
|
const api = getApiClient();
|
|
1655
|
-
const { data } = await api.get("/features");
|
|
1658
|
+
const { data } = await api.get("/ai-features");
|
|
1656
1659
|
const features = Array.isArray(data) ? data : data.data || [];
|
|
1657
1660
|
output(format, {
|
|
1658
1661
|
table: {
|
|
@@ -1687,7 +1690,7 @@ Examples:
|
|
|
1687
1690
|
const globalOpts = command.optsWithGlobals();
|
|
1688
1691
|
const format = resolveFormat(globalOpts.output);
|
|
1689
1692
|
const api = getApiClient();
|
|
1690
|
-
const { data } = await api.get(`/features/${key}`);
|
|
1693
|
+
const { data } = await api.get(`/ai-features/${key}`);
|
|
1691
1694
|
if (format === "table") {
|
|
1692
1695
|
console.log(chalk16.bold("Feature\n"));
|
|
1693
1696
|
printDetail("Key", data.key);
|
|
@@ -1722,7 +1725,7 @@ Examples:
|
|
|
1722
1725
|
`).action(async (key) => {
|
|
1723
1726
|
try {
|
|
1724
1727
|
const api = getApiClient();
|
|
1725
|
-
await api.post(`/features/${key}/enable`);
|
|
1728
|
+
await api.post(`/ai-features/${key}/enable`);
|
|
1726
1729
|
printSuccess(`Feature '${key}' enabled.`);
|
|
1727
1730
|
} catch (error) {
|
|
1728
1731
|
handleError(error);
|
|
@@ -1741,7 +1744,7 @@ Examples:
|
|
|
1741
1744
|
`).action(async (key) => {
|
|
1742
1745
|
try {
|
|
1743
1746
|
const api = getApiClient();
|
|
1744
|
-
await api.post(`/features/${key}/disable`);
|
|
1747
|
+
await api.post(`/ai-features/${key}/disable`);
|
|
1745
1748
|
printSuccess(`Feature '${key}' disabled.`);
|
|
1746
1749
|
} catch (error) {
|
|
1747
1750
|
handleError(error);
|
|
@@ -1779,10 +1782,10 @@ Examples:
|
|
|
1779
1782
|
const v = entry.slice(eqIndex + 1);
|
|
1780
1783
|
configValues[k] = v;
|
|
1781
1784
|
}
|
|
1782
|
-
await api.patch(`/features/${key}/config`, configValues);
|
|
1785
|
+
await api.patch(`/ai-features/${key}/config`, configValues);
|
|
1783
1786
|
printSuccess(`Feature '${key}' configuration updated.`);
|
|
1784
1787
|
} else {
|
|
1785
|
-
const { data } = await api.get(`/features/${key}`);
|
|
1788
|
+
const { data } = await api.get(`/ai-features/${key}`);
|
|
1786
1789
|
const featureConfig = data.config || {};
|
|
1787
1790
|
if (format === "table") {
|
|
1788
1791
|
console.log(chalk17.bold(`Feature '${key}' Configuration
|
|
@@ -2607,9 +2610,121 @@ function createLlmGatewayCommand() {
|
|
|
2607
2610
|
return llmGateway;
|
|
2608
2611
|
}
|
|
2609
2612
|
|
|
2613
|
+
// src/commands/init/index.ts
|
|
2614
|
+
import { Command as Command67 } from "commander";
|
|
2615
|
+
import { execSync } from "child_process";
|
|
2616
|
+
import { existsSync, cpSync, readFileSync, writeFileSync } from "fs";
|
|
2617
|
+
import { join, resolve } from "path";
|
|
2618
|
+
import chalk22 from "chalk";
|
|
2619
|
+
import ora2 from "ora";
|
|
2620
|
+
var TEMPLATE_REPO = "nebulaos/template";
|
|
2621
|
+
var TEMPLATE_REPO_URL = `https://github.com/${TEMPLATE_REPO}`;
|
|
2622
|
+
function createInitCommand() {
|
|
2623
|
+
const cmd = new Command67("init").description("Create a new NebulaOS project from template").argument("<name>", "Project name (will create a directory with this name)").option("-t, --template <template>", "Template to use", "default").option("--from <path>", "Use local template path instead of remote").option("--skip-install", "Skip installing dependencies").addHelpText(
|
|
2624
|
+
"after",
|
|
2625
|
+
`
|
|
2626
|
+
Examples:
|
|
2627
|
+
$ nebulaos init my-project Create a new project
|
|
2628
|
+
$ nebulaos init my-project --skip-install Create without installing deps
|
|
2629
|
+
|
|
2630
|
+
After creating your project:
|
|
2631
|
+
$ cd my-project
|
|
2632
|
+
$ cp .env.example .env
|
|
2633
|
+
$ # Edit .env with your API keys
|
|
2634
|
+
$ pnpm dev
|
|
2635
|
+
`
|
|
2636
|
+
).action(async (name, options) => {
|
|
2637
|
+
try {
|
|
2638
|
+
const targetDir = resolve(process.cwd(), name);
|
|
2639
|
+
if (existsSync(targetDir)) {
|
|
2640
|
+
throw new CLIError(
|
|
2641
|
+
`Directory '${name}' already exists. Choose a different name or delete the existing directory.`,
|
|
2642
|
+
6 /* ConflictError */
|
|
2643
|
+
);
|
|
2644
|
+
}
|
|
2645
|
+
console.log();
|
|
2646
|
+
console.log(chalk22.bold("Creating NebulaOS project..."));
|
|
2647
|
+
console.log();
|
|
2648
|
+
const spinner = ora2(options.from ? "Copying template..." : "Downloading template...").start();
|
|
2649
|
+
try {
|
|
2650
|
+
if (options.from) {
|
|
2651
|
+
const sourcePath = resolve(process.cwd(), options.from);
|
|
2652
|
+
if (!existsSync(sourcePath)) {
|
|
2653
|
+
throw new Error(`Template path not found: ${sourcePath}`);
|
|
2654
|
+
}
|
|
2655
|
+
cpSync(sourcePath, targetDir, { recursive: true });
|
|
2656
|
+
const gitDir = join(targetDir, ".git");
|
|
2657
|
+
if (existsSync(gitDir)) {
|
|
2658
|
+
execSync(`rm -rf "${gitDir}"`, { stdio: "pipe" });
|
|
2659
|
+
}
|
|
2660
|
+
} else {
|
|
2661
|
+
execSync(`npx degit ${TEMPLATE_REPO} ${name}`, {
|
|
2662
|
+
stdio: "pipe",
|
|
2663
|
+
cwd: process.cwd()
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2666
|
+
spinner.succeed(options.from ? "Template copied" : "Template downloaded");
|
|
2667
|
+
} catch (error) {
|
|
2668
|
+
spinner.fail(options.from ? "Failed to copy template" : "Failed to download template");
|
|
2669
|
+
if (options.from) {
|
|
2670
|
+
throw new CLIError(
|
|
2671
|
+
`Failed to copy template from ${options.from}. Make sure the path exists.`,
|
|
2672
|
+
5 /* NotFound */
|
|
2673
|
+
);
|
|
2674
|
+
}
|
|
2675
|
+
throw new CLIError(
|
|
2676
|
+
`Failed to download template from ${TEMPLATE_REPO}. Make sure you have internet access.`,
|
|
2677
|
+
8 /* NetworkError */
|
|
2678
|
+
);
|
|
2679
|
+
}
|
|
2680
|
+
const packageJsonPath = join(targetDir, "package.json");
|
|
2681
|
+
if (existsSync(packageJsonPath)) {
|
|
2682
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
2683
|
+
packageJson.name = name;
|
|
2684
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
|
|
2685
|
+
}
|
|
2686
|
+
if (!options.skipInstall) {
|
|
2687
|
+
const installSpinner = ora2("Installing dependencies...").start();
|
|
2688
|
+
try {
|
|
2689
|
+
const usesPnpm = existsSync(join(targetDir, "pnpm-lock.yaml"));
|
|
2690
|
+
const usesYarn = existsSync(join(targetDir, "yarn.lock"));
|
|
2691
|
+
const pm = usesPnpm ? "pnpm" : usesYarn ? "yarn" : "npm";
|
|
2692
|
+
execSync(`${pm} install`, {
|
|
2693
|
+
stdio: "pipe",
|
|
2694
|
+
cwd: targetDir
|
|
2695
|
+
});
|
|
2696
|
+
installSpinner.succeed("Dependencies installed");
|
|
2697
|
+
} catch {
|
|
2698
|
+
installSpinner.warn("Failed to install dependencies. Run 'pnpm install' manually.");
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
console.log();
|
|
2702
|
+
console.log(chalk22.green("\u2713 Project created successfully!"));
|
|
2703
|
+
console.log();
|
|
2704
|
+
console.log("Next steps:");
|
|
2705
|
+
console.log();
|
|
2706
|
+
console.log(chalk22.cyan(` cd ${name}`));
|
|
2707
|
+
console.log(chalk22.cyan(" cp .env.example .env"));
|
|
2708
|
+
console.log(chalk22.dim(" # Edit .env with your API keys"));
|
|
2709
|
+
console.log(chalk22.cyan(" pnpm dev"));
|
|
2710
|
+
console.log();
|
|
2711
|
+
console.log("Get your API keys:");
|
|
2712
|
+
console.log(chalk22.dim(" nebulaos clients api-keys create <client-id>"));
|
|
2713
|
+
console.log(chalk22.dim(" nebulaos llm keys create --name my-key --type personal"));
|
|
2714
|
+
console.log();
|
|
2715
|
+
console.log("Documentation:");
|
|
2716
|
+
console.log(chalk22.dim(" https://docs.nebulaos.dev"));
|
|
2717
|
+
console.log();
|
|
2718
|
+
} catch (error) {
|
|
2719
|
+
handleError(error);
|
|
2720
|
+
}
|
|
2721
|
+
});
|
|
2722
|
+
return cmd;
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2610
2725
|
// src/program.ts
|
|
2611
2726
|
function createProgram() {
|
|
2612
|
-
const program = new
|
|
2727
|
+
const program = new Command68();
|
|
2613
2728
|
program.name("nebulaos").description("NebulaOS CLI - Manage your AI agents, workflows, and resources").version("0.1.0").configureHelp({
|
|
2614
2729
|
sortSubcommands: true,
|
|
2615
2730
|
sortOptions: true
|
|
@@ -2625,6 +2740,7 @@ function createProgram() {
|
|
|
2625
2740
|
process.env.NEBULAOS_VERBOSE = "1";
|
|
2626
2741
|
}
|
|
2627
2742
|
});
|
|
2743
|
+
program.addCommand(createInitCommand());
|
|
2628
2744
|
program.addCommand(createAuthCommand());
|
|
2629
2745
|
program.addCommand(createOrgsCommand());
|
|
2630
2746
|
program.addCommand(createClientsCommand());
|
|
@@ -2641,11 +2757,11 @@ function createProgram() {
|
|
|
2641
2757
|
}
|
|
2642
2758
|
|
|
2643
2759
|
// src/lib/pagination.ts
|
|
2644
|
-
import
|
|
2760
|
+
import chalk23 from "chalk";
|
|
2645
2761
|
function printPaginationInfo(meta) {
|
|
2646
2762
|
if (meta.totalPages <= 1) return;
|
|
2647
2763
|
console.log(
|
|
2648
|
-
|
|
2764
|
+
chalk23.dim(
|
|
2649
2765
|
`
|
|
2650
2766
|
Page ${meta.page}/${meta.totalPages} (${meta.total} total). Use --page and --page-size to navigate.`
|
|
2651
2767
|
)
|