opentool 0.8.1 → 0.8.4
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 +1 -1
- package/dist/adapters/hyperliquid/index.d.ts +77 -68
- package/dist/adapters/hyperliquid/index.js +282 -180
- package/dist/adapters/hyperliquid/index.js.map +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +83 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +322 -6
- package/dist/index.js +1210 -207
- package/dist/index.js.map +1 -1
- package/dist/store/index.d.ts +35 -1
- package/dist/store/index.js +61 -1
- package/dist/store/index.js.map +1 -1
- package/dist/{validate-uetwG5jo.d.ts → validate-BJ5-5n8h.d.ts} +1 -0
- package/dist/wallet/index.js +25 -15
- package/dist/wallet/index.js.map +1 -1
- package/package.json +7 -2
- package/templates/base/README.md +10 -0
- package/templates/base/metadata.ts +12 -0
- package/templates/base/package.json +23 -0
- package/templates/base/tools/aave-stake.ts +96 -0
- package/templates/base/tsconfig.json +14 -0
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { program } from 'commander';
|
|
3
3
|
import * as fs4 from 'fs';
|
|
4
|
+
import { promises } from 'fs';
|
|
4
5
|
import * as path5 from 'path';
|
|
6
|
+
import path5__default from 'path';
|
|
5
7
|
import { tmpdir } from 'os';
|
|
6
8
|
import { build } from 'esbuild';
|
|
7
9
|
import { z } from 'zod';
|
|
@@ -1096,6 +1098,9 @@ async function loadAndValidateTools(toolsDir, options = {}) {
|
|
|
1096
1098
|
if (typeof schedule.enabled === "boolean") {
|
|
1097
1099
|
normalizedSchedule.authoredEnabled = schedule.enabled;
|
|
1098
1100
|
}
|
|
1101
|
+
if (typeof schedule.notifyEmail === "boolean") {
|
|
1102
|
+
normalizedSchedule.notifyEmail = schedule.notifyEmail;
|
|
1103
|
+
}
|
|
1099
1104
|
}
|
|
1100
1105
|
if (hasPOST) {
|
|
1101
1106
|
if (!schema) {
|
|
@@ -1627,6 +1632,7 @@ function writeCronManifest(options) {
|
|
|
1627
1632
|
scheduleExpression: schedule.expression,
|
|
1628
1633
|
enabledDefault: false,
|
|
1629
1634
|
...schedule.authoredEnabled !== void 0 ? { authoredEnabled: schedule.authoredEnabled } : {},
|
|
1635
|
+
...schedule.notifyEmail !== void 0 ? { notifyEmail: schedule.notifyEmail } : {},
|
|
1630
1636
|
payload: {
|
|
1631
1637
|
toolPath: payloadPath,
|
|
1632
1638
|
httpMethod: "GET"
|
|
@@ -2263,6 +2269,74 @@ async function generateMetadata(options) {
|
|
|
2263
2269
|
function timestamp2() {
|
|
2264
2270
|
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
|
|
2265
2271
|
}
|
|
2272
|
+
function resolveTemplateDir() {
|
|
2273
|
+
const here = path5__default.dirname(fileURLToPath(import.meta.url));
|
|
2274
|
+
return path5__default.resolve(here, "../../templates/base");
|
|
2275
|
+
}
|
|
2276
|
+
async function directoryIsEmpty(targetDir) {
|
|
2277
|
+
try {
|
|
2278
|
+
const entries = await promises.readdir(targetDir);
|
|
2279
|
+
return entries.length === 0;
|
|
2280
|
+
} catch (error) {
|
|
2281
|
+
if (error.code === "ENOENT") {
|
|
2282
|
+
return true;
|
|
2283
|
+
}
|
|
2284
|
+
throw error;
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
async function copyDir(src, dest) {
|
|
2288
|
+
await promises.mkdir(dest, { recursive: true });
|
|
2289
|
+
const entries = await promises.readdir(src, { withFileTypes: true });
|
|
2290
|
+
for (const entry of entries) {
|
|
2291
|
+
const srcPath = path5__default.join(src, entry.name);
|
|
2292
|
+
const destPath = path5__default.join(dest, entry.name);
|
|
2293
|
+
if (entry.isDirectory()) {
|
|
2294
|
+
await copyDir(srcPath, destPath);
|
|
2295
|
+
} else if (entry.isFile()) {
|
|
2296
|
+
await promises.copyFile(srcPath, destPath);
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
function toPackageName(value) {
|
|
2301
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "opentool-project";
|
|
2302
|
+
}
|
|
2303
|
+
function toDisplayName(value) {
|
|
2304
|
+
return value.trim().replace(/[-_]+/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase()) || "OpenTool Project";
|
|
2305
|
+
}
|
|
2306
|
+
async function updatePackageJson(targetDir, name, description) {
|
|
2307
|
+
const filePath = path5__default.join(targetDir, "package.json");
|
|
2308
|
+
const raw = await promises.readFile(filePath, "utf-8");
|
|
2309
|
+
const pkg = JSON.parse(raw);
|
|
2310
|
+
pkg.name = toPackageName(name);
|
|
2311
|
+
if (description) {
|
|
2312
|
+
pkg.description = description;
|
|
2313
|
+
}
|
|
2314
|
+
await promises.writeFile(filePath, `${JSON.stringify(pkg, null, 2)}
|
|
2315
|
+
`, "utf-8");
|
|
2316
|
+
}
|
|
2317
|
+
async function updateMetadata(targetDir, name, description) {
|
|
2318
|
+
const filePath = path5__default.join(targetDir, "metadata.ts");
|
|
2319
|
+
const raw = await promises.readFile(filePath, "utf-8");
|
|
2320
|
+
const displayName = toDisplayName(name);
|
|
2321
|
+
const resolvedDescription = description || "OpenTool project";
|
|
2322
|
+
const updated = raw.replace(/name:\s*\".*?\"/, `name: "${toPackageName(name)}"`).replace(/displayName:\s*\".*?\"/, `displayName: "${displayName}"`).replace(/description:\s*\".*?\"/, `description: "${resolvedDescription}"`);
|
|
2323
|
+
await promises.writeFile(filePath, updated, "utf-8");
|
|
2324
|
+
}
|
|
2325
|
+
async function initCommand(options) {
|
|
2326
|
+
const targetDir = path5__default.resolve(process.cwd(), options.dir || ".");
|
|
2327
|
+
const templateDir = resolveTemplateDir();
|
|
2328
|
+
const empty = await directoryIsEmpty(targetDir);
|
|
2329
|
+
if (!empty && !options.force) {
|
|
2330
|
+
throw new Error(
|
|
2331
|
+
`Directory not empty: ${targetDir}. Use --force to overwrite.`
|
|
2332
|
+
);
|
|
2333
|
+
}
|
|
2334
|
+
await copyDir(templateDir, targetDir);
|
|
2335
|
+
const projectName = options.name || path5__default.basename(targetDir);
|
|
2336
|
+
const description = options.description;
|
|
2337
|
+
await updatePackageJson(targetDir, projectName, description);
|
|
2338
|
+
await updateMetadata(targetDir, projectName, description);
|
|
2339
|
+
}
|
|
2266
2340
|
|
|
2267
2341
|
// src/cli/index.ts
|
|
2268
2342
|
program.name("opentool").description("OpenTool CLI for building and developing serverless MCP tools").version("1.0.0");
|
|
@@ -2282,6 +2356,15 @@ program.command("metadata").description("Generate OpenTool metadata JSON without
|
|
|
2282
2356
|
"Output file path for metadata.json",
|
|
2283
2357
|
"metadata.json"
|
|
2284
2358
|
).option("--name <name>", "Server name", "opentool-server").option("--version <version>", "Server version", "1.0.0").action(generateMetadataCommand);
|
|
2359
|
+
program.command("init").description("Create a new OpenTool project in the target directory").option("-d, --dir <dir>", "Target directory", ".").option("-n, --name <name>", "Project name").option("--description <description>", "Project description").option("--force", "Overwrite existing files", false).action(async (cmdOptions) => {
|
|
2360
|
+
await initCommand({
|
|
2361
|
+
dir: cmdOptions.dir,
|
|
2362
|
+
name: cmdOptions.name,
|
|
2363
|
+
description: cmdOptions.description,
|
|
2364
|
+
force: cmdOptions.force
|
|
2365
|
+
});
|
|
2366
|
+
console.log(`Initialized OpenTool project in ${cmdOptions.dir || "."}`);
|
|
2367
|
+
});
|
|
2285
2368
|
program.parse();
|
|
2286
2369
|
|
|
2287
2370
|
export { buildCommand, buildProject, devCommand, generateMetadata, generateMetadataCommand, loadAndValidateTools, validateCommand, validateFullCommand };
|