From cd3dee81335bd753e9f690b2308ef1449a28e2e5 Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Mon, 1 Dec 2025 05:21:30 +1000 Subject: [PATCH] refactor: replace authentication field with envVars in TPMJS specification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the authentication field with a more general envVars array that allows tools to specify required environment variables: Changes to type definitions: - Remove TpmjsAuthenticationSchema and TpmjsAuthentication type - Add TpmjsEnvVarSchema with fields: name, description, required, default - Replace authentication field with envVars array in TpmjsRichSchema - Update validateTpmjsField to check envVars instead of authentication Changes to documentation: - Update /spec page to document envVars instead of authentication - Update /publish page examples to use envVars - Update HOW_TO_PUBLISH_A_TOOL.md with envVars examples - Update validation errors section - Remove authentication from @tpmjs/createblogpost example The envVars field is more flexible and clearer - it lists all environment variables a tool needs (API keys, endpoints, config values) rather than trying to categorize authentication types. Example: ```json "envVars": [ { "name": "OPENAI_API_KEY", "description": "API key for OpenAI services", "required": true } ] ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- HOW_TO_PUBLISH_A_TOOL.md | 38 ++++++++++++-------- apps/web/src/app/publish/page.tsx | 11 +++--- apps/web/src/app/spec/page.tsx | 42 +++++++++++----------- packages/tools/createBlogPost/package.json | 4 --- packages/types/src/tpmjs.ts | 18 +++++----- 5 files changed, 61 insertions(+), 52 deletions(-) diff --git a/HOW_TO_PUBLISH_A_TOOL.md b/HOW_TO_PUBLISH_A_TOOL.md index e95e758..d7ae0bb 100644 --- a/HOW_TO_PUBLISH_A_TOOL.md +++ b/HOW_TO_PUBLISH_A_TOOL.md @@ -129,10 +129,13 @@ Complete metadata for maximum visibility: "type": "SentimentResult", "description": "Object with score, label, and optional emotions array" }, - "authentication": { - "type": "api-key", - "required": true - }, + "envVars": [ + { + "name": "SENTIMENT_API_KEY", + "description": "API key for sentiment analysis service", + "required": true + } + ], "frameworks": ["vercel-ai", "langchain"], "links": { "documentation": "https://docs.example.com", @@ -308,10 +311,6 @@ Here's the complete `package.json` from the published example: "type": "BlogPost", "description": "A structured blog post object with frontmatter, content, and metadata including slug, wordCount, readingTime, and formattedOutput" }, - "authentication": { - "required": false, - "type": "api-key" - }, "frameworks": ["vercel-ai", "langchain"], "links": { "documentation": "https://tpmjs.com/tools/createblogpost", @@ -354,7 +353,7 @@ Here's the complete `package.json` from the published example: | Field | Type | Description | |-------|------|-------------| -| `authentication` | object | Auth requirements | +| `envVars` | array | Required environment variables | | `frameworks` | array | Compatible frameworks | | `links` | object | Related URLs | | `tags` | array | Additional tags | @@ -374,15 +373,24 @@ Choose one of these for the `category` field: - `integration` - Third-party integrations - `other` - Anything else -### Authentication Types +### Environment Variables -If your tool requires authentication: +If your tool requires environment variables: ```json -"authentication": { - "type": "api-key", // or "oauth", "bearer-token", "basic" - "required": true -} +"envVars": [ + { + "name": "OPENAI_API_KEY", + "description": "API key for OpenAI services", + "required": true + }, + { + "name": "API_ENDPOINT", + "description": "Custom API endpoint URL", + "required": false, + "default": "https://api.example.com" + } +] ``` ## Quality Score diff --git a/apps/web/src/app/publish/page.tsx b/apps/web/src/app/publish/page.tsx index a4bf6ef..9cc7e85 100644 --- a/apps/web/src/app/publish/page.tsx +++ b/apps/web/src/app/publish/page.tsx @@ -165,10 +165,13 @@ export default function PublishPage(): React.ReactElement { "example": "const result = await analyzeSentiment({ text: 'I love this!', includeEmotions: true });", "parameters": [...], "returns": {...}, - "authentication": { - "type": "api-key", - "required": true - }, + "envVars": [ + { + "name": "SENTIMENT_API_KEY", + "description": "API key for sentiment analysis service", + "required": true + } + ], "frameworks": ["vercel-ai", "langchain"], "links": { "documentation": "https://docs.example.com", diff --git a/apps/web/src/app/spec/page.tsx b/apps/web/src/app/spec/page.tsx index 3b928d0..988adc5 100644 --- a/apps/web/src/app/spec/page.tsx +++ b/apps/web/src/app/spec/page.tsx @@ -289,26 +289,27 @@ export default function SpecPage(): React.ReactElement {

- authentication + envVars

- Authentication requirements. Fields: + Array of environment variables required by the tool. Each variable has:

  • - required - Boolean + name - Environment variable name + (e.g., "OPENAI_API_KEY")
  • - type - "api-key", "oauth", - "basic-auth", or "custom" + description - What the variable is + used for
  • - envVar - Environment variable - name (optional) + required - Boolean (defaults to + true)
  • - docsUrl - Auth documentation URL - (optional) + default - Default value if not + provided (optional)
@@ -419,12 +420,13 @@ export default function SpecPage(): React.ReactElement { "example": "const result = await analyzeSentiment({ text: 'I love this!', includeEmotions: true });", "parameters": [...], "returns": {...}, - "authentication": { - "required": true, - "type": "api-key", - "envVar": "SENTIMENT_API_KEY", - "docsUrl": "https://docs.example.com/auth" - }, + "envVars": [ + { + "name": "SENTIMENT_API_KEY", + "description": "API key for sentiment analysis service", + "required": true + } + ], "frameworks": ["vercel-ai", "langchain"], "links": { "documentation": "https://docs.example.com", @@ -540,16 +542,16 @@ export default function SpecPage(): React.ReactElement { - authentication + envVars - object + array Rich No - Auth requirements + Required environment variables @@ -780,8 +782,8 @@ export default function SpecPage(): React.ReactElement { at least 10 characters
  • - Invalid authentication type: Type - must be "api-key", "oauth", "basic-auth", or "custom" + Invalid envVar: Each environment + variable must have a name and description
  • Too many tags: Maximum 10 tags diff --git a/packages/tools/createBlogPost/package.json b/packages/tools/createBlogPost/package.json index b9fb851..b347894 100644 --- a/packages/tools/createBlogPost/package.json +++ b/packages/tools/createBlogPost/package.json @@ -80,10 +80,6 @@ "type": "BlogPost", "description": "A structured blog post object with frontmatter, content, and metadata including slug, wordCount, readingTime, and formattedOutput" }, - "authentication": { - "required": false, - "type": "api-key" - }, "frameworks": ["vercel-ai", "langchain"], "links": { "documentation": "https://tpmjs.com/tools/createblogpost", diff --git a/packages/types/src/tpmjs.ts b/packages/types/src/tpmjs.ts index df3deb3..57d25b0 100644 --- a/packages/types/src/tpmjs.ts +++ b/packages/types/src/tpmjs.ts @@ -44,16 +44,16 @@ export const TpmjsReturnsSchema = z.object({ export type TpmjsReturns = z.infer; /** - * Authentication configuration schema + * Environment variable schema */ -export const TpmjsAuthenticationSchema = z.object({ - required: z.boolean(), - type: z.enum(['api-key', 'oauth', 'basic-auth', 'custom']), - envVar: z.string().optional(), - docsUrl: z.string().url().optional(), +export const TpmjsEnvVarSchema = z.object({ + name: z.string().min(1), + description: z.string().min(1), + required: z.boolean().default(true), + default: z.string().optional(), }); -export type TpmjsAuthentication = z.infer; +export type TpmjsEnvVar = z.infer; /** * External links schema @@ -99,7 +99,7 @@ export type TpmjsMinimal = z.infer; export const TpmjsRichSchema = TpmjsMinimalSchema.extend({ parameters: z.array(TpmjsParameterSchema).optional(), returns: TpmjsReturnsSchema.optional(), - authentication: TpmjsAuthenticationSchema.optional(), + envVars: z.array(TpmjsEnvVarSchema).optional(), frameworks: z .array(z.enum(['vercel-ai', 'langchain', 'llamaindex', 'haystack', 'semantic-kernel'])) .optional(), @@ -138,7 +138,7 @@ export function validateTpmjsField(tpmjs: unknown): ValidationResult { const hasRichFields = data.parameters || data.returns || - data.authentication || + data.envVars || data.frameworks || data.links || data.tags ||