Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix(harness): preserve manifest usage errors
jkomyno7a77217d33f4
diff --git a/harness/errors.mjs b/harness/errors.mjsnew file mode 100644index 000000000..1aa833bd2--- /dev/null+++ b/harness/errors.mjs@@ -0,0 +1,6 @@+export class HarnessError extends Error {+ constructor(message, exitCode = 2) {+ super(message);+ this.exitCode = exitCode;+ }+}diff --git a/harness/manifest.mjs b/harness/manifest.mjsindex 169743952..7f16a48c1 100644--- a/harness/manifest.mjs+++ b/harness/manifest.mjs@@ -1,6 +1,7 @@import { readFileSync } from 'node:fs';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';+import { HarnessError } from './errors.mjs';const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');@@ -43,22 +44,26 @@ export const entryToolkits = entry => {return [...toolkits];};-export const loadManifest = () => {- const manifest = JSON.parse(readFileSync(join(ROOT, 'examples-manifest.json'), 'utf8'));- for (const entry of manifest.entries) {+export const validateManifestEntries = entries => {+ for (const entry of entries) {if (!entry.id || !entry.lang || !entry.file || !entry.tier) {- throw new Error(`manifest entry missing required fields: ${JSON.stringify(entry)}`);+ throw new HarnessError(`manifest entry missing required fields: ${JSON.stringify(entry)}`);}if (entry.lang === 'ts' && entry.tier !== 'X' && !entry.pkg) {- throw new Error(`ts entry ${entry.id} missing pkg`);+ throw new HarnessError(`ts entry ${entry.id} missing pkg`);}if (entry.tier === '3' && !entry.readiness) {- throw new Error(`tier-3 entry ${entry.id} missing readiness regex`);+ throw new HarnessError(`tier-3 entry ${entry.id} missing readiness regex`);}}- return manifest.entries;+ return entries;};+export const loadManifest = () =>+ validateManifestEntries(+ JSON.parse(readFileSync(join(ROOT, 'examples-manifest.json'), 'utf8')).entries+ );+export const selectManifestEntries = (entries,{ lang, ids, tiers = '1,2,3', excludeToolkits } = {}diff --git a/harness/run.mjs b/harness/run.mjsindex 2e0636134..b94b721db 100755--- a/harness/run.mjs+++ b/harness/run.mjs@@ -18,8 +18,10 @@ import {requiredBrowserGrantToolkits,requiresDemoToolkit,selectManifestEntries,+ validateManifestEntries,} from './manifest.mjs';import { resolveBackendBaseUrl, STAGING_BASE_URL } from './backend-url.mjs';+import { HarnessError } from './errors.mjs';const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');const ARTIFACTS = join(ROOT, '.artifacts', 'examples-parity');@@ -37,13 +39,6 @@ const opt = (name, fallback) => {return i >= 0 && args[i + 1] !== undefined ? args[i + 1] : fallback;};-class HarnessError extends Error {- constructor(message, exitCode = 2) {- super(message);- this.exitCode = exitCode;- }-}-const fail = (msg, code = 2) => {throw new HarnessError(msg, code);};@@ -605,6 +600,14 @@ const cmdSelftest = async () => {}check('python candidate swap accepts a wheel reporting the pinned version', sameVersionPyCandidateAccepted);+ let invalidManifestIsUsageError = false;+ try {+ validateManifestEntries([{ id: 'missing-required-fields' }]);+ } catch (error) {+ invalidManifestIsUsageError = error instanceof HarnessError && error.exitCode === 2;+ }+ check('invalid manifest entries are usage errors', invalidManifestIsUsageError);+const manifest = loadManifest();const withoutGoogleDrive = selectManifestEntries(manifest, {excludeToolkits: 'googledrive',