refactor: replace authentication field with envVars in TPMJS specification
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 <noreply@anthropic.com>
This commit is contained in:
parent
a6ec7df800
commit
cd3dee8133
5 changed files with 61 additions and 52 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -44,16 +44,16 @@ export const TpmjsReturnsSchema = z.object({
|
|||
export type TpmjsReturns = z.infer<typeof TpmjsReturnsSchema>;
|
||||
|
||||
/**
|
||||
* 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<typeof TpmjsAuthenticationSchema>;
|
||||
export type TpmjsEnvVar = z.infer<typeof TpmjsEnvVarSchema>;
|
||||
|
||||
/**
|
||||
* External links schema
|
||||
|
|
@ -99,7 +99,7 @@ export type TpmjsMinimal = z.infer<typeof TpmjsMinimalSchema>;
|
|||
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 ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue