opentool 0.8.10 → 0.8.12

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 CHANGED
@@ -82,19 +82,13 @@ GET-only (scheduled default)
82
82
  export const profile = {
83
83
  description: "Stake 100 USDC daily at 12:00 UTC",
84
84
  category: "strategy",
85
- fixedAmount: "100",
86
- tokenSymbol: "USDC",
87
85
  schedule: { cron: "0 12 * * *", enabled: false },
88
- limits: { concurrency: 1, dailyCap: 1 },
89
86
  };
90
87
 
91
88
  export async function GET(_req: Request) {
92
- const amount = profile.fixedAmount;
93
89
  return Response.json({
94
90
  ok: true,
95
91
  action: "stake",
96
- amount,
97
- token: profile.tokenSymbol,
98
92
  });
99
93
  }
100
94
  ```
@@ -131,7 +125,7 @@ export async function POST(req: Request) {
131
125
  ### Cron schedules (`profile.schedule`)
132
126
 
133
127
  - GET-only tools require `profile.schedule` with a standard 5–6 field cron expression (e.g., `0 12 * * *` or `0 0 ? * MON-FRI *`).
134
- - Build validates the cron shape and emits `.well-known/opentool/cron.json` capturing each scheduled tool (`toolName`, `toolPath`, `scheduleExpression`). Enabled defaults to `false` even if authors set it to `true` in code. Deployment targets can translate these cron strings to their provider format (e.g., EventBridge) downstream.
128
+ - Build validates the cron shape and emits `dist/tools.json` with schedule data per tool. Enabled defaults to `false` even if authors set it to `true` in code. Deployment targets can translate these cron strings to their provider format (e.g., EventBridge) downstream.
135
129
  - Use `profile.schedule.notifyEmail = true` to request email delivery on schedule runs.
136
130
 
137
131
  ### Public tools: Add x402 payments (optional)
@@ -417,7 +411,7 @@ npm run examples:metadata # Regenerate metadata.json
417
411
  OpenTool has three levels of metadata config:
418
412
 
419
413
  1. **Default** - pulls from your `package.json` automatically
420
- 2. **Project-level** - add a `metadata.ts` file for branding, payments, etc.
414
+ 2. **Project-level (optional)** - add a `metadata.ts` file for branding, payments, etc.
421
415
  3. **Tool-level** - override metadata per tool
422
416
 
423
417
  See [`METADATA.md`](./METADATA.md) for details on configuring metadata for on-chain registration and payments.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { M as Metadata, I as InternalToolDefinition } from '../validate-CrJVvsV7.js';
3
- export { G as GenerateMetadataOptions, a as GenerateMetadataResult, V as ValidateOptions, b as generateMetadata, g as generateMetadataCommand, l as loadAndValidateTools, v as validateCommand, c as validateFullCommand } from '../validate-CrJVvsV7.js';
2
+ import { M as Metadata, I as InternalToolDefinition } from '../validate-CilU0rkD.js';
3
+ export { G as GenerateMetadataOptions, a as GenerateMetadataResult, V as ValidateOptions, b as generateMetadata, g as generateMetadataCommand, l as loadAndValidateTools, v as validateCommand, c as validateFullCommand } from '../validate-CilU0rkD.js';
4
4
  import 'zod';
5
5
  import '../x402/index.js';
6
6
  import 'viem';
@@ -17,7 +17,7 @@ interface BuildArtifacts {
17
17
  tools: InternalToolDefinition[];
18
18
  compiledTools: CompiledToolArtifact[];
19
19
  workflowBundles: WorkflowBundleArtifact | null;
20
- cronManifestPath: string | null;
20
+ toolsManifestPath: string | null;
21
21
  sharedModules?: SharedModulesInfo | null;
22
22
  }
23
23
  interface CompiledToolArtifact {
package/dist/cli/index.js CHANGED
@@ -229,9 +229,10 @@ var METADATA_ENTRY = "metadata.ts";
229
229
  async function loadMetadata(projectRoot) {
230
230
  const absPath = path6.join(projectRoot, METADATA_ENTRY);
231
231
  if (!fs4.existsSync(absPath)) {
232
- throw new Error(
233
- `metadata.ts not found in ${projectRoot}. Create metadata.ts to describe your agent.`
234
- );
232
+ return {
233
+ metadata: MetadataSchema.parse({}),
234
+ sourcePath: "smart defaults (metadata.ts missing)"
235
+ };
235
236
  }
236
237
  const tempDir = path6.join(projectRoot, ".opentool-temp");
237
238
  if (fs4.existsSync(tempDir)) {
@@ -1189,6 +1190,7 @@ async function loadAndValidateTools(toolsDir, options = {}) {
1189
1190
  handler: async (params) => adapter(params),
1190
1191
  payment: paymentExport ?? null,
1191
1192
  schedule: normalizedSchedule,
1193
+ profile: toolModule?.profile && typeof toolModule.profile === "object" ? toolModule.profile : null,
1192
1194
  ...profileNotifyEmail !== void 0 ? { notifyEmail: profileNotifyEmail } : {},
1193
1195
  profileDescription: typeof toolModule?.profile?.description === "string" ? toolModule.profile?.description ?? null : null,
1194
1196
  ...profileCategoryRaw ? { profileCategory: profileCategoryRaw } : {}
@@ -1417,7 +1419,7 @@ async function buildProject(options) {
1417
1419
  projectRoot,
1418
1420
  outputDir
1419
1421
  });
1420
- const cronManifestPath = await writeCronManifest({
1422
+ const toolsManifestPath = await writeToolsManifest({
1421
1423
  tools,
1422
1424
  compiledTools,
1423
1425
  outputDir
@@ -1445,7 +1447,7 @@ async function buildProject(options) {
1445
1447
  tools,
1446
1448
  compiledTools,
1447
1449
  workflowBundles,
1448
- cronManifestPath,
1450
+ toolsManifestPath,
1449
1451
  sharedModules
1450
1452
  };
1451
1453
  }
@@ -1631,54 +1633,44 @@ async function writeMcpServer(options) {
1631
1633
  fs4.writeFileSync(serverPath, serverCode);
1632
1634
  fs4.chmodSync(serverPath, 493);
1633
1635
  }
1634
- function writeCronManifest(options) {
1635
- const scheduledTools = options.tools.filter((tool) => tool.schedule?.expression);
1636
- const manifestDir = path6.join(options.outputDir, ".well-known", "opentool");
1637
- const manifestPath = path6.join(manifestDir, "cron.json");
1638
- if (scheduledTools.length === 0) {
1639
- if (fs4.existsSync(manifestPath)) {
1640
- fs4.rmSync(manifestPath);
1641
- }
1642
- return null;
1636
+ function writeToolsManifest(options) {
1637
+ const manifestPath = path6.join(options.outputDir, "tools.json");
1638
+ const legacyManifestPath = path6.join(
1639
+ options.outputDir,
1640
+ ".well-known",
1641
+ "opentool",
1642
+ "cron.json"
1643
+ );
1644
+ if (fs4.existsSync(legacyManifestPath)) {
1645
+ fs4.rmSync(legacyManifestPath, { force: true });
1643
1646
  }
1644
- const entries = scheduledTools.map((tool) => {
1645
- const schedule = tool.schedule;
1646
- if (!schedule) {
1647
- throw new Error(`Internal error: missing schedule for tool ${tool.filename}`);
1648
- }
1647
+ const entries = options.tools.map((tool) => {
1649
1648
  const compiled = options.compiledTools.find(
1650
1649
  (artifact) => artifact.filename === tool.filename
1651
1650
  );
1652
1651
  if (!compiled) {
1653
1652
  throw new Error(`Internal error: missing compiled artifact for ${tool.filename}`);
1654
1653
  }
1655
- const toolName = tool.metadata?.name ?? tool.filename;
1656
- const description = tool.metadata?.description ?? tool.profileDescription ?? void 0;
1657
- const payloadPath = compiled.modulePath.replace(/\\/g, "/");
1654
+ const handler = tool.httpHandlers[0];
1655
+ const method = handler ? handler.method.toUpperCase() : "GET";
1656
+ const toolPath = compiled.modulePath.replace(/\\/g, "/");
1658
1657
  const entry = {
1659
- toolName,
1660
- scheduleType: schedule.type,
1661
- scheduleExpression: schedule.expression,
1662
- enabledDefault: false,
1663
- ...schedule.authoredEnabled !== void 0 ? { authoredEnabled: schedule.authoredEnabled } : {},
1664
- ...schedule.notifyEmail !== void 0 ? { notifyEmail: schedule.notifyEmail } : {},
1665
- payload: {
1666
- toolPath: payloadPath,
1667
- httpMethod: "GET"
1668
- }
1658
+ name: tool.metadata?.name ?? tool.filename,
1659
+ method,
1660
+ toolPath
1669
1661
  };
1670
- if (description !== void 0) {
1671
- entry.description = description;
1662
+ if (tool.inputSchema) {
1663
+ entry.inputSchema = tool.inputSchema;
1664
+ }
1665
+ if (tool.profile) {
1666
+ entry.profile = tool.profile;
1667
+ }
1668
+ if (tool.schedule) {
1669
+ entry.schedule = tool.schedule;
1672
1670
  }
1673
1671
  return entry;
1674
1672
  });
1675
- const manifest = {
1676
- version: 1,
1677
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1678
- entries
1679
- };
1680
- fs4.mkdirSync(manifestDir, { recursive: true });
1681
- fs4.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
1673
+ fs4.writeFileSync(manifestPath, JSON.stringify(entries, null, 2));
1682
1674
  return manifestPath;
1683
1675
  }
1684
1676
  function logBuildSummary(artifacts, options) {
@@ -1702,8 +1694,8 @@ function logBuildSummary(artifacts, options) {
1702
1694
  console.log(` - ${tool.name} [${methods}]${walletBadge}`);
1703
1695
  });
1704
1696
  console.log(" \u2022 metadata.json (registry artifact)");
1705
- if (artifacts.cronManifestPath) {
1706
- console.log(" \u2022 .well-known/opentool/cron.json (cron manifest)");
1697
+ if (artifacts.toolsManifestPath) {
1698
+ console.log(" \u2022 tools.json (runtime tool manifest)");
1707
1699
  }
1708
1700
  if (artifacts.workflowBundles) {
1709
1701
  console.log(" \u2022 .well-known/workflow/v1/ (workflow bundles)");