@ninemind/agentgem 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/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/cli.js +55 -0
- package/dist/gem/agentcorePublish.js +91 -0
- package/dist/gem/agentcoreRun.js +85 -0
- package/dist/gem/archive.js +185 -0
- package/dist/gem/archiveFs.js +28 -0
- package/dist/gem/archiveTar.js +66 -0
- package/dist/gem/buildGem.js +88 -0
- package/dist/gem/checks.js +28 -0
- package/dist/gem/credentials.js +34 -0
- package/dist/gem/deploy.js +35 -0
- package/dist/gem/deployRecord.js +24 -0
- package/dist/gem/introspect.js +247 -0
- package/dist/gem/mcpProxy.js +53 -0
- package/dist/gem/publish.js +58 -0
- package/dist/gem/recents.js +39 -0
- package/dist/gem/redact.js +42 -0
- package/dist/gem/registry.js +233 -0
- package/dist/gem/registryGithub.js +74 -0
- package/dist/gem/run.js +322 -0
- package/dist/gem/targets.js +578 -0
- package/dist/gem/testbed.js +103 -0
- package/dist/gem/testbedFlavors.js +287 -0
- package/dist/gem/toml.js +120 -0
- package/dist/gem/types.js +1 -0
- package/dist/gem/workspaces.js +93 -0
- package/dist/gem.controller.js +518 -0
- package/dist/gem.tools.js +103 -0
- package/dist/index.js +59 -0
- package/dist/pickFolder.js +36 -0
- package/dist/public/index.html +1465 -0
- package/dist/publish.js +130 -0
- package/dist/resolveDir.js +26 -0
- package/dist/schemas.js +407 -0
- package/package.json +72 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { config as loadEnv } from "dotenv";
|
|
3
|
+
import { credentialsEnvPath } from "./gem/credentials.js";
|
|
4
|
+
// Load env before anything reads it: cwd .env (a dev override) layered over the
|
|
5
|
+
// persisted server credentials in ~/.agentgem/.env. `override` defaults to false,
|
|
6
|
+
// so a value already set in the cwd .env wins. `quiet` silences dotenv's banner/
|
|
7
|
+
// tips so the `agentgem` CLI output stays clean.
|
|
8
|
+
loadEnv({ quiet: true });
|
|
9
|
+
loadEnv({ path: credentialsEnvPath(), quiet: true });
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
import { dirname, join } from "node:path";
|
|
13
|
+
import { isMain } from "@agentback/core";
|
|
14
|
+
import { RestApplication } from "@agentback/rest";
|
|
15
|
+
import { installExplorer } from "@agentback/rest-explorer";
|
|
16
|
+
import { MCPComponent } from "@agentback/mcp";
|
|
17
|
+
import { installMcpHttp } from "@agentback/mcp-http";
|
|
18
|
+
import { GemController } from "./gem.controller.js";
|
|
19
|
+
import { GemTools } from "./gem.tools.js";
|
|
20
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
function pageHtml() {
|
|
22
|
+
for (const p of [join(here, "public", "index.html"), join(here, "..", "src", "public", "index.html")]) {
|
|
23
|
+
try {
|
|
24
|
+
return readFileSync(p, "utf8");
|
|
25
|
+
}
|
|
26
|
+
catch { /* try next */ }
|
|
27
|
+
}
|
|
28
|
+
return "<!doctype html><p>index.html not found</p>";
|
|
29
|
+
}
|
|
30
|
+
export async function createApp(port) {
|
|
31
|
+
const app = new RestApplication({});
|
|
32
|
+
app.configure("servers.RestServer").to({ port, host: "127.0.0.1" });
|
|
33
|
+
app.component(MCPComponent);
|
|
34
|
+
app.configure("servers.MCPServer").to({ name: "agentgem", version: "0.1.0", transports: { stdio: false } });
|
|
35
|
+
app.restController(GemController);
|
|
36
|
+
app.service(GemTools);
|
|
37
|
+
await installExplorer(app, { title: "agentgem API" });
|
|
38
|
+
await installMcpHttp(app);
|
|
39
|
+
const server = await app.restServer;
|
|
40
|
+
const html = pageHtml();
|
|
41
|
+
server.expressApp.get("/", (_req, res) => res.type("html").send(html));
|
|
42
|
+
return app;
|
|
43
|
+
}
|
|
44
|
+
// Start the server and print where its surfaces live. Shared by the default
|
|
45
|
+
// entry point (below) and the `agentgem` CLI (src/cli.ts).
|
|
46
|
+
export async function run(port = Number(process.env.PORT ?? 4317)) {
|
|
47
|
+
const app = await createApp(port);
|
|
48
|
+
await app.start();
|
|
49
|
+
const server = await app.restServer;
|
|
50
|
+
console.log(`agentgem listening at ${server.url}`);
|
|
51
|
+
console.log(` UI: ${server.url}/`);
|
|
52
|
+
console.log(` API: ${server.url}/api/inventory · POST ${server.url}/api/gem`);
|
|
53
|
+
console.log(` Explorer: ${server.url}/explorer/`);
|
|
54
|
+
console.log(` MCP: ${server.url}/mcp`);
|
|
55
|
+
return app;
|
|
56
|
+
}
|
|
57
|
+
if (isMain(import.meta)) {
|
|
58
|
+
run().catch((err) => { console.error(err); process.exit(1); });
|
|
59
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/pickFolder.ts
|
|
2
|
+
// Pop the OS-native folder chooser (agentgem runs locally, so the dialog appears on the
|
|
3
|
+
// user's own screen) and return the chosen absolute path. The user explicitly selects the
|
|
4
|
+
// folder — there is no server-side directory enumeration to scope or harden.
|
|
5
|
+
import { execFile } from "node:child_process";
|
|
6
|
+
import { platform } from "node:os";
|
|
7
|
+
// Separated from the exec so it can be unit-tested without popping a dialog.
|
|
8
|
+
export function pickFolderCommand(plat) {
|
|
9
|
+
if (plat === "darwin")
|
|
10
|
+
return { cmd: "osascript", args: ["-e", 'POSIX path of (choose folder with prompt "Choose project root")'] };
|
|
11
|
+
if (plat === "linux")
|
|
12
|
+
return { cmd: "zenity", args: ["--file-selection", "--directory", "--title=Choose project root"] };
|
|
13
|
+
if (plat === "win32")
|
|
14
|
+
return {
|
|
15
|
+
cmd: "powershell",
|
|
16
|
+
args: [
|
|
17
|
+
"-NoProfile",
|
|
18
|
+
"-Command",
|
|
19
|
+
"Add-Type -AssemblyName System.Windows.Forms; $f=New-Object System.Windows.Forms.FolderBrowserDialog; if($f.ShowDialog() -eq 'OK'){ $f.SelectedPath }",
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
export function pickFolder() {
|
|
25
|
+
const spec = pickFolderCommand(platform());
|
|
26
|
+
if (!spec)
|
|
27
|
+
return Promise.resolve(null);
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
execFile(spec.cmd, spec.args, { timeout: 180000 }, (err, stdout) => {
|
|
30
|
+
if (err)
|
|
31
|
+
return resolve(null); // cancelled, or the dialog tool is unavailable
|
|
32
|
+
const p = (stdout || "").trim();
|
|
33
|
+
resolve(p || null);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|