agent-well-known-next 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Agent Discovery Protocol Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,227 @@
1
+ # agent-well-known-next
2
+
3
+ Next.js App Router helpers for the [Agent Discovery Protocol](https://github.com/user/agent-discovery-protocol). Serve a `/.well-known/agent` manifest and capability detail endpoints with zero boilerplate.
4
+
5
+ This package generates spec-v1.0 compliant endpoints so any AI agent can discover and use your service at runtime -- no plugins, no installation, no per-service configuration.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install agent-well-known-next
11
+ ```
12
+
13
+ > Requires Next.js 13+ with the App Router.
14
+
15
+ ## Quick Start
16
+
17
+ ### 1. Define your config
18
+
19
+ Create a shared config file (or inline it):
20
+
21
+ ```ts
22
+ // lib/agent-config.ts
23
+ import type { AgentConfig } from 'agent-well-known-next';
24
+
25
+ export const agentConfig: AgentConfig = {
26
+ name: "My API",
27
+ description: "What my API does, in 2-3 sentences. Write for an LLM to understand.",
28
+ base_url: "https://api.example.com",
29
+ auth: {
30
+ type: "api_key",
31
+ header: "Authorization",
32
+ prefix: "Bearer",
33
+ setup_url: "https://example.com/api-keys",
34
+ },
35
+ capabilities: [
36
+ {
37
+ name: "send_email",
38
+ description: "Send an email to one or more recipients.",
39
+ endpoint: "/api/emails",
40
+ method: "POST",
41
+ parameters: [
42
+ { name: "to", type: "string", required: true, description: "Recipient email address.", example: "alice@example.com" },
43
+ { name: "subject", type: "string", required: true, description: "Email subject.", example: "Hello" },
44
+ { name: "body", type: "string", required: true, description: "Email body (plain text or HTML).", example: "<p>Hi!</p>" },
45
+ ],
46
+ response_example: {
47
+ status: 200,
48
+ body: { success: true, data: { message_id: "msg_abc123", status: "sent" } },
49
+ },
50
+ auth_scopes: ["email.send"],
51
+ rate_limits: { requests_per_minute: 60, daily_limit: 1000 },
52
+ },
53
+ ],
54
+ };
55
+ ```
56
+
57
+ ### 2. Create the manifest route
58
+
59
+ ```
60
+ app/.well-known/agent/route.ts
61
+ ```
62
+
63
+ ```ts
64
+ import { createAgentManifest } from 'agent-well-known-next';
65
+ import { agentConfig } from '@/lib/agent-config';
66
+
67
+ export const GET = createAgentManifest(agentConfig);
68
+ ```
69
+
70
+ ### 3. Create the capability detail route
71
+
72
+ ```
73
+ app/.well-known/agent/capabilities/[name]/route.ts
74
+ ```
75
+
76
+ ```ts
77
+ import { createCapabilityDetail } from 'agent-well-known-next';
78
+ import { agentConfig } from '@/lib/agent-config';
79
+
80
+ export const GET = createCapabilityDetail(agentConfig);
81
+ ```
82
+
83
+ That's it. Your Next.js app now serves:
84
+
85
+ - `GET /.well-known/agent` -- the service manifest
86
+ - `GET /.well-known/agent/capabilities/send_email` -- capability detail
87
+
88
+ ### Alternative: single-import convenience
89
+
90
+ ```ts
91
+ import { createAgentRoutes } from 'agent-well-known-next';
92
+ import { agentConfig } from '@/lib/agent-config';
93
+
94
+ export const { manifestHandler, capabilityHandler } = createAgentRoutes(agentConfig);
95
+
96
+ // app/.well-known/agent/route.ts
97
+ export const GET = manifestHandler;
98
+
99
+ // app/.well-known/agent/capabilities/[name]/route.ts
100
+ export const GET = capabilityHandler;
101
+ ```
102
+
103
+ ## What Gets Generated
104
+
105
+ ### Manifest (`/.well-known/agent`)
106
+
107
+ ```json
108
+ {
109
+ "spec_version": "1.0",
110
+ "name": "My API",
111
+ "description": "What my API does.",
112
+ "base_url": "https://api.example.com",
113
+ "auth": { "type": "api_key", "header": "Authorization", "prefix": "Bearer", "setup_url": "https://example.com/api-keys" },
114
+ "capabilities": [
115
+ {
116
+ "name": "send_email",
117
+ "description": "Send an email to one or more recipients.",
118
+ "detail_url": "/.well-known/agent/capabilities/send_email"
119
+ }
120
+ ]
121
+ }
122
+ ```
123
+
124
+ ### Capability Detail (`/.well-known/agent/capabilities/send_email`)
125
+
126
+ ```json
127
+ {
128
+ "name": "send_email",
129
+ "description": "Send an email to one or more recipients.",
130
+ "endpoint": "/api/emails",
131
+ "method": "POST",
132
+ "parameters": [
133
+ { "name": "to", "type": "string", "required": true, "description": "Recipient email address.", "example": "alice@example.com" },
134
+ { "name": "subject", "type": "string", "required": true, "description": "Email subject.", "example": "Hello" },
135
+ { "name": "body", "type": "string", "required": true, "description": "Email body (plain text or HTML).", "example": "<p>Hi!</p>" }
136
+ ],
137
+ "request_example": {
138
+ "method": "POST",
139
+ "url": "https://api.example.com/api/emails",
140
+ "headers": { "Authorization": "Bearer {api_key}", "Content-Type": "application/json" },
141
+ "body": { "to": "alice@example.com", "subject": "Hello", "body": "<p>Hi!</p>" }
142
+ },
143
+ "response_example": {
144
+ "status": 200,
145
+ "body": { "success": true, "data": { "message_id": "msg_abc123", "status": "sent" } }
146
+ },
147
+ "auth_scopes": ["email.send"],
148
+ "rate_limits": { "requests_per_minute": 60, "daily_limit": 1000 }
149
+ }
150
+ ```
151
+
152
+ ## Config Reference
153
+
154
+ ### `AgentConfig`
155
+
156
+ | Field | Type | Required | Description |
157
+ |-------|------|----------|-------------|
158
+ | `name` | `string` | Yes | Human-readable service name. |
159
+ | `description` | `string` | Yes | 2-3 sentences for LLM understanding. |
160
+ | `base_url` | `string` | Yes | Base URL for all API calls. |
161
+ | `auth` | `AuthConfig` | Yes | Authentication configuration. |
162
+ | `pricing` | `PricingConfig` | No | Pricing information. |
163
+ | `capabilities` | `CapabilityConfig[]` | Yes | Service capabilities. |
164
+
165
+ ### `AuthConfig`
166
+
167
+ | Field | Type | Required | Description |
168
+ |-------|------|----------|-------------|
169
+ | `type` | `"oauth2" \| "api_key" \| "none"` | Yes | Auth mechanism. |
170
+ | `authorization_url` | `string` | oauth2 | OAuth2 authorization URL. |
171
+ | `token_url` | `string` | oauth2 | OAuth2 token URL. |
172
+ | `scopes` | `string[]` | No | OAuth2 scopes. |
173
+ | `header` | `string` | No | Header name for API key (default: `Authorization`). |
174
+ | `prefix` | `string` | No | Prefix before the key value (e.g. `Bearer`). |
175
+ | `setup_url` | `string` | No | URL where users manage API keys. |
176
+
177
+ ### `PricingConfig`
178
+
179
+ | Field | Type | Required | Description |
180
+ |-------|------|----------|-------------|
181
+ | `type` | `"free" \| "freemium" \| "paid"` | Yes | Pricing model. |
182
+ | `plans` | `Array<{ name, price, limits }>` | No | Available plans. |
183
+ | `plans_url` | `string` | No | URL to full pricing page. |
184
+
185
+ ### `CapabilityConfig`
186
+
187
+ | Field | Type | Required | Description |
188
+ |-------|------|----------|-------------|
189
+ | `name` | `string` | Yes | Machine-readable identifier (snake_case). |
190
+ | `description` | `string` | Yes | 1-2 sentences for LLM understanding. |
191
+ | `endpoint` | `string` | Yes | API path relative to `base_url`. |
192
+ | `method` | `string` | Yes | HTTP method: GET, POST, PUT, PATCH, DELETE. |
193
+ | `parameters` | `ParameterConfig[]` | Yes | Parameter definitions. |
194
+ | `request_example` | `object` | No | Explicit request example. Auto-generated if omitted. |
195
+ | `response_example` | `object` | No | Example response with status and body. |
196
+ | `auth_scopes` | `string[]` | No | Scopes required for this capability. |
197
+ | `rate_limits` | `object` | No | Rate limiting info. |
198
+
199
+ ### `ParameterConfig`
200
+
201
+ | Field | Type | Required | Description |
202
+ |-------|------|----------|-------------|
203
+ | `name` | `string` | Yes | Parameter name. |
204
+ | `type` | `string` | Yes | Type: string, number, boolean, object, string[], object[]. |
205
+ | `required` | `boolean` | Yes | Whether required. |
206
+ | `description` | `string` | Yes | Human-readable description. |
207
+ | `example` | `any` | No | Example value. Used in auto-generated request examples. |
208
+
209
+ ## Auto-Generation
210
+
211
+ The SDK automatically handles:
212
+
213
+ - **`spec_version`**: Always set to `"1.0"`.
214
+ - **`detail_url`**: Generated as `/.well-known/agent/capabilities/{name}` for each capability.
215
+ - **`request_example`**: If not provided, built from `base_url` + `endpoint` + `method` + required parameters with examples + auth headers.
216
+ - **CORS headers**: `Access-Control-Allow-Origin: *` on all responses.
217
+ - **Cache headers**: `Cache-Control: public, max-age=3600` on all responses.
218
+ - **Validation**: Runs once on first request. Issues are logged via `console.warn` -- the server still starts.
219
+
220
+ ## Spec & Registry
221
+
222
+ - [Agent Discovery Protocol Spec](https://github.com/user/agent-discovery-protocol/tree/main/spec)
223
+ - [Agent Discovery Registry](https://registry.agentdiscovery.dev)
224
+
225
+ ## License
226
+
227
+ MIT
@@ -0,0 +1,175 @@
1
+ /**
2
+ * agent-well-known-next
3
+ *
4
+ * Next.js App Router helpers for the Agent Discovery Protocol.
5
+ * Generates the two route handlers every service needs:
6
+ *
7
+ * GET /.well-known/agent - the service manifest
8
+ * GET /.well-known/agent/capabilities/[name] - capability detail
9
+ *
10
+ * Spec: https://github.com/user/agent-discovery-protocol/tree/main/spec
11
+ */
12
+ /** Parameter definition for a capability. */
13
+ export interface ParameterConfig {
14
+ /** Parameter name. */
15
+ name: string;
16
+ /** Type: string, number, boolean, object, string[], object[]. */
17
+ type: string;
18
+ /** Whether this parameter is required. */
19
+ required: boolean;
20
+ /** Human-readable description. */
21
+ description: string;
22
+ /** Example value used in auto-generated request examples. */
23
+ example?: unknown;
24
+ }
25
+ /** Authentication configuration. */
26
+ export interface AuthConfig {
27
+ /** Auth mechanism: oauth2, api_key, or none. */
28
+ type: "oauth2" | "api_key" | "none";
29
+ /** OAuth2 authorization URL. Required when type is oauth2. */
30
+ authorization_url?: string;
31
+ /** OAuth2 token URL. Required when type is oauth2. */
32
+ token_url?: string;
33
+ /** OAuth2 scopes. */
34
+ scopes?: string[];
35
+ /** Header name for API key auth. Defaults to "Authorization". */
36
+ header?: string;
37
+ /** Prefix before the key value (e.g. "Bearer"). */
38
+ prefix?: string;
39
+ /** URL where users can create/manage their API keys. */
40
+ setup_url?: string;
41
+ }
42
+ /** Pricing plan. */
43
+ export interface PricingPlan {
44
+ name: string;
45
+ price: string;
46
+ limits: string;
47
+ }
48
+ /** Pricing configuration (optional). */
49
+ export interface PricingConfig {
50
+ /** Pricing model: free, freemium, or paid. */
51
+ type: "free" | "freemium" | "paid";
52
+ /** Available plans. */
53
+ plans?: PricingPlan[];
54
+ /** URL to the full pricing page. */
55
+ plans_url?: string;
56
+ }
57
+ /** Rate limit configuration for a capability. */
58
+ export interface RateLimitConfig {
59
+ requests_per_minute?: number;
60
+ daily_limit?: number;
61
+ }
62
+ /** Individual capability configuration. */
63
+ export interface CapabilityConfig {
64
+ /** Machine-readable identifier (snake_case). */
65
+ name: string;
66
+ /** 1-2 sentence description for LLM understanding. */
67
+ description: string;
68
+ /** API path relative to base_url. */
69
+ endpoint: string;
70
+ /** HTTP method: GET, POST, PUT, PATCH, DELETE. */
71
+ method: string;
72
+ /** Parameter definitions. */
73
+ parameters: ParameterConfig[];
74
+ /** Explicit request example. Auto-generated if omitted. */
75
+ request_example?: RequestExample;
76
+ /** Example response. */
77
+ response_example?: ResponseExample;
78
+ /** Auth scopes required for this capability. */
79
+ auth_scopes?: string[];
80
+ /** Rate limits for this capability. */
81
+ rate_limits?: RateLimitConfig;
82
+ }
83
+ /** Shape of an auto-generated or user-provided request example. */
84
+ export interface RequestExample {
85
+ method: string;
86
+ url: string;
87
+ headers: Record<string, string>;
88
+ body?: unknown;
89
+ }
90
+ /** Shape of a response example. */
91
+ export interface ResponseExample {
92
+ status: number;
93
+ body: unknown;
94
+ }
95
+ /** Full service configuration passed by the user. */
96
+ export interface AgentConfig {
97
+ /** Human-readable service name. */
98
+ name: string;
99
+ /** 2-3 sentences describing the service, written for an LLM. */
100
+ description: string;
101
+ /** Base URL for all API calls. */
102
+ base_url: string;
103
+ /** Authentication configuration. */
104
+ auth: AuthConfig;
105
+ /** Pricing information (optional). */
106
+ pricing?: PricingConfig;
107
+ /** List of capabilities the service exposes. */
108
+ capabilities: CapabilityConfig[];
109
+ }
110
+ /**
111
+ * Minimal NextRequest shape. Compatible with next/server NextRequest.
112
+ * We use a minimal type so the library compiles without requiring next
113
+ * to be present at build time (it is a peerDependency, resolved at runtime).
114
+ */
115
+ interface NextRequestLike {
116
+ url: string;
117
+ method: string;
118
+ }
119
+ /**
120
+ * Matches Next.js App Router dynamic route context.
121
+ * Next.js 13 passes params directly; Next.js 15+ wraps them in a Promise.
122
+ */
123
+ interface RouteContext {
124
+ params: {
125
+ name: string;
126
+ } | Promise<{
127
+ name: string;
128
+ }>;
129
+ }
130
+ /**
131
+ * Create a Next.js App Router GET handler that serves the Agent Discovery
132
+ * Protocol manifest at `/.well-known/agent`.
133
+ *
134
+ * Usage in `app/.well-known/agent/route.ts`:
135
+ * ```ts
136
+ * import { createAgentManifest } from 'agent-well-known-next';
137
+ *
138
+ * export const GET = createAgentManifest({ ... });
139
+ * ```
140
+ */
141
+ export declare function createAgentManifest(config: AgentConfig): (request: NextRequestLike) => Promise<Response>;
142
+ /**
143
+ * Create a Next.js App Router GET handler that serves capability detail
144
+ * at `/.well-known/agent/capabilities/[name]`.
145
+ *
146
+ * Usage in `app/.well-known/agent/capabilities/[name]/route.ts`:
147
+ * ```ts
148
+ * import { createCapabilityDetail } from 'agent-well-known-next';
149
+ *
150
+ * export const GET = createCapabilityDetail(config);
151
+ * ```
152
+ */
153
+ export declare function createCapabilityDetail(config: AgentConfig): (request: NextRequestLike, context: RouteContext) => Promise<Response>;
154
+ /**
155
+ * Convenience function that returns both route handlers and the config
156
+ * reference, so you can wire up both routes from a single config object.
157
+ *
158
+ * Usage:
159
+ * ```ts
160
+ * const { manifestHandler, capabilityHandler } = createAgentRoutes({ ... });
161
+ *
162
+ * // app/.well-known/agent/route.ts
163
+ * export const GET = manifestHandler;
164
+ *
165
+ * // app/.well-known/agent/capabilities/[name]/route.ts
166
+ * export const GET = capabilityHandler;
167
+ * ```
168
+ */
169
+ export declare function createAgentRoutes(config: AgentConfig): {
170
+ manifestHandler: (request: NextRequestLike) => Promise<Response>;
171
+ capabilityHandler: (request: NextRequestLike, context: RouteContext) => Promise<Response>;
172
+ config: AgentConfig;
173
+ };
174
+ export {};
175
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,QAAQ,EAAE,OAAO,CAAC;IAClB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,oCAAoC;AACpC,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IACpC,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;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C,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjE,iBAAiB,EAAE,CACjB,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,YAAY,KAClB,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvB,MAAM,EAAE,WAAW,CAAC;CACrB,CAMA"}
package/dist/index.js ADDED
@@ -0,0 +1,323 @@
1
+ "use strict";
2
+ /**
3
+ * agent-well-known-next
4
+ *
5
+ * Next.js App Router helpers for the Agent Discovery Protocol.
6
+ * Generates the two route handlers every service needs:
7
+ *
8
+ * GET /.well-known/agent - the service manifest
9
+ * GET /.well-known/agent/capabilities/[name] - capability detail
10
+ *
11
+ * Spec: https://github.com/user/agent-discovery-protocol/tree/main/spec
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.createAgentManifest = createAgentManifest;
15
+ exports.createCapabilityDetail = createCapabilityDetail;
16
+ exports.createAgentRoutes = createAgentRoutes;
17
+ // ---------------------------------------------------------------------------
18
+ // Validation
19
+ // ---------------------------------------------------------------------------
20
+ const VALID_AUTH_TYPES = ["oauth2", "api_key", "none"];
21
+ const VALID_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
22
+ /**
23
+ * Validate the user config and emit console.warn for each issue found.
24
+ * Returns true if the config is structurally valid enough to serve.
25
+ */
26
+ function validateConfig(config) {
27
+ const warnings = [];
28
+ if (!config) {
29
+ warnings.push("Config is missing or undefined.");
30
+ emitWarnings(warnings);
31
+ return false;
32
+ }
33
+ // Top-level required fields
34
+ if (!config.name || typeof config.name !== "string") {
35
+ warnings.push('Missing or invalid "name" (expected non-empty string).');
36
+ }
37
+ if (!config.description || typeof config.description !== "string") {
38
+ warnings.push('Missing or invalid "description" (expected non-empty string).');
39
+ }
40
+ if (!config.base_url || typeof config.base_url !== "string") {
41
+ warnings.push('Missing or invalid "base_url" (expected non-empty string).');
42
+ }
43
+ // Auth
44
+ if (!config.auth || typeof config.auth !== "object") {
45
+ warnings.push('Missing or invalid "auth" object.');
46
+ }
47
+ else if (!config.auth.type ||
48
+ !VALID_AUTH_TYPES.includes(config.auth.type)) {
49
+ warnings.push(`Invalid "auth.type". Expected one of: ${VALID_AUTH_TYPES.join(", ")}.`);
50
+ }
51
+ // Capabilities
52
+ if (!Array.isArray(config.capabilities) || config.capabilities.length === 0) {
53
+ warnings.push('Missing or empty "capabilities" array.');
54
+ }
55
+ else {
56
+ config.capabilities.forEach((cap, idx) => {
57
+ const prefix = `capabilities[${idx}]`;
58
+ if (!cap.name || typeof cap.name !== "string") {
59
+ warnings.push(`${prefix}: Missing or invalid "name".`);
60
+ }
61
+ if (!cap.description || typeof cap.description !== "string") {
62
+ warnings.push(`${prefix}: Missing or invalid "description".`);
63
+ }
64
+ if (!cap.endpoint || typeof cap.endpoint !== "string") {
65
+ warnings.push(`${prefix}: Missing or invalid "endpoint".`);
66
+ }
67
+ if (!cap.method || typeof cap.method !== "string") {
68
+ warnings.push(`${prefix}: Missing or invalid "method".`);
69
+ }
70
+ else if (!VALID_METHODS.includes(cap.method.toUpperCase())) {
71
+ warnings.push(`${prefix}: Invalid "method" (${cap.method}). Expected one of: ${VALID_METHODS.join(", ")}.`);
72
+ }
73
+ // Parameters
74
+ if (!Array.isArray(cap.parameters)) {
75
+ warnings.push(`${prefix}: "parameters" must be an array.`);
76
+ }
77
+ else {
78
+ cap.parameters.forEach((param, pIdx) => {
79
+ const pPrefix = `${prefix}.parameters[${pIdx}]`;
80
+ if (!param.name || typeof param.name !== "string") {
81
+ warnings.push(`${pPrefix}: Missing or invalid "name".`);
82
+ }
83
+ if (!param.type || typeof param.type !== "string") {
84
+ warnings.push(`${pPrefix}: Missing or invalid "type".`);
85
+ }
86
+ if (typeof param.required !== "boolean") {
87
+ warnings.push(`${pPrefix}: Missing or invalid "required" (expected boolean).`);
88
+ }
89
+ if (!param.description || typeof param.description !== "string") {
90
+ warnings.push(`${pPrefix}: Missing or invalid "description".`);
91
+ }
92
+ });
93
+ }
94
+ });
95
+ }
96
+ emitWarnings(warnings);
97
+ return warnings.length === 0;
98
+ }
99
+ function emitWarnings(warnings) {
100
+ for (const w of warnings) {
101
+ console.warn(`[agent-well-known-next] ${w}`);
102
+ }
103
+ }
104
+ // ---------------------------------------------------------------------------
105
+ // Helpers
106
+ // ---------------------------------------------------------------------------
107
+ /**
108
+ * Build the auth header used in auto-generated request examples.
109
+ */
110
+ function buildAuthHeaders(auth) {
111
+ switch (auth.type) {
112
+ case "oauth2":
113
+ return { Authorization: "Bearer {access_token}" };
114
+ case "api_key": {
115
+ const header = auth.header || "Authorization";
116
+ const prefix = auth.prefix ? `${auth.prefix} ` : "";
117
+ return { [header]: `${prefix}{api_key}` };
118
+ }
119
+ default:
120
+ return {};
121
+ }
122
+ }
123
+ /**
124
+ * Auto-generate a request_example from the capability definition.
125
+ */
126
+ function generateRequestExample(cap, config) {
127
+ const method = cap.method.toUpperCase();
128
+ const url = `${config.base_url.replace(/\/+$/, "")}${cap.endpoint}`;
129
+ const headers = {
130
+ ...buildAuthHeaders(config.auth),
131
+ "Content-Type": "application/json",
132
+ };
133
+ const example = { method, url, headers };
134
+ // Build body from required parameters with example values
135
+ if (["POST", "PUT", "PATCH"].includes(method) &&
136
+ Array.isArray(cap.parameters)) {
137
+ const body = {};
138
+ for (const param of cap.parameters) {
139
+ if (param.required && param.example !== undefined) {
140
+ body[param.name] = param.example;
141
+ }
142
+ }
143
+ if (Object.keys(body).length > 0) {
144
+ example.body = body;
145
+ }
146
+ }
147
+ return example;
148
+ }
149
+ // ---------------------------------------------------------------------------
150
+ // Builders
151
+ // ---------------------------------------------------------------------------
152
+ /**
153
+ * Build the spec v1.0 manifest from user config.
154
+ */
155
+ function buildManifest(config) {
156
+ const manifest = {
157
+ spec_version: "1.0",
158
+ name: config.name,
159
+ description: config.description,
160
+ base_url: config.base_url,
161
+ auth: config.auth,
162
+ capabilities: (config.capabilities || []).map((cap) => ({
163
+ name: cap.name,
164
+ description: cap.description,
165
+ detail_url: `/.well-known/agent/capabilities/${cap.name}`,
166
+ })),
167
+ };
168
+ if (config.pricing) {
169
+ manifest.pricing = config.pricing;
170
+ }
171
+ return manifest;
172
+ }
173
+ /**
174
+ * Build the capability detail JSON for a single capability.
175
+ */
176
+ function buildCapabilityDetail(cap, config) {
177
+ const detail = {
178
+ name: cap.name,
179
+ description: cap.description,
180
+ endpoint: cap.endpoint,
181
+ method: cap.method.toUpperCase(),
182
+ parameters: (cap.parameters || []).map((p) => {
183
+ const param = {
184
+ name: p.name,
185
+ type: p.type,
186
+ description: p.description,
187
+ required: p.required,
188
+ };
189
+ if (p.example !== undefined) {
190
+ param.example = p.example;
191
+ }
192
+ return param;
193
+ }),
194
+ request_example: cap.request_example || generateRequestExample(cap, config),
195
+ };
196
+ if (cap.response_example) {
197
+ detail.response_example = cap.response_example;
198
+ }
199
+ if (cap.auth_scopes) {
200
+ detail.auth_scopes = cap.auth_scopes;
201
+ }
202
+ if (cap.rate_limits) {
203
+ detail.rate_limits = cap.rate_limits;
204
+ }
205
+ return detail;
206
+ }
207
+ // We use the global Response (Web API) which Next.js re-exports.
208
+ // This avoids importing from "next/server" at compile time.
209
+ // ---------------------------------------------------------------------------
210
+ // CORS & cache helpers
211
+ // ---------------------------------------------------------------------------
212
+ const CORS_HEADERS = {
213
+ "Access-Control-Allow-Origin": "*",
214
+ "Access-Control-Allow-Methods": "GET, OPTIONS",
215
+ "Access-Control-Allow-Headers": "Content-Type",
216
+ };
217
+ const CACHE_HEADERS = {
218
+ "Cache-Control": "public, max-age=3600",
219
+ };
220
+ function jsonResponse(data, status = 200, extraHeaders = {}) {
221
+ return new Response(JSON.stringify(data), {
222
+ status,
223
+ headers: {
224
+ "Content-Type": "application/json",
225
+ ...CORS_HEADERS,
226
+ ...CACHE_HEADERS,
227
+ ...extraHeaders,
228
+ },
229
+ });
230
+ }
231
+ function notFoundResponse(message) {
232
+ return new Response(JSON.stringify({ error: message }), {
233
+ status: 404,
234
+ headers: {
235
+ "Content-Type": "application/json",
236
+ ...CORS_HEADERS,
237
+ },
238
+ });
239
+ }
240
+ // ---------------------------------------------------------------------------
241
+ // Public API
242
+ // ---------------------------------------------------------------------------
243
+ /**
244
+ * Create a Next.js App Router GET handler that serves the Agent Discovery
245
+ * Protocol manifest at `/.well-known/agent`.
246
+ *
247
+ * Usage in `app/.well-known/agent/route.ts`:
248
+ * ```ts
249
+ * import { createAgentManifest } from 'agent-well-known-next';
250
+ *
251
+ * export const GET = createAgentManifest({ ... });
252
+ * ```
253
+ */
254
+ function createAgentManifest(config) {
255
+ let validated = false;
256
+ let manifest = null;
257
+ return async function manifestHandler(_request) {
258
+ // Validate once on first request
259
+ if (!validated) {
260
+ validateConfig(config);
261
+ manifest = buildManifest(config);
262
+ validated = true;
263
+ }
264
+ return jsonResponse(manifest);
265
+ };
266
+ }
267
+ /**
268
+ * Create a Next.js App Router GET handler that serves capability detail
269
+ * at `/.well-known/agent/capabilities/[name]`.
270
+ *
271
+ * Usage in `app/.well-known/agent/capabilities/[name]/route.ts`:
272
+ * ```ts
273
+ * import { createCapabilityDetail } from 'agent-well-known-next';
274
+ *
275
+ * export const GET = createCapabilityDetail(config);
276
+ * ```
277
+ */
278
+ function createCapabilityDetail(config) {
279
+ let validated = false;
280
+ let detailMap = null;
281
+ return async function capabilityHandler(_request, context) {
282
+ // Validate once on first request
283
+ if (!validated) {
284
+ validateConfig(config);
285
+ detailMap = {};
286
+ for (const cap of config.capabilities || []) {
287
+ detailMap[cap.name] = buildCapabilityDetail(cap, config);
288
+ }
289
+ validated = true;
290
+ }
291
+ // Resolve params (Next.js 15+ returns a Promise, 13-14 returns plain object)
292
+ const params = await Promise.resolve(context.params);
293
+ const name = params.name;
294
+ const detail = detailMap[name];
295
+ if (!detail) {
296
+ return notFoundResponse(`Capability not found: ${name}`);
297
+ }
298
+ return jsonResponse(detail);
299
+ };
300
+ }
301
+ /**
302
+ * Convenience function that returns both route handlers and the config
303
+ * reference, so you can wire up both routes from a single config object.
304
+ *
305
+ * Usage:
306
+ * ```ts
307
+ * const { manifestHandler, capabilityHandler } = createAgentRoutes({ ... });
308
+ *
309
+ * // app/.well-known/agent/route.ts
310
+ * export const GET = manifestHandler;
311
+ *
312
+ * // app/.well-known/agent/capabilities/[name]/route.ts
313
+ * export const GET = capabilityHandler;
314
+ * ```
315
+ */
316
+ function createAgentRoutes(config) {
317
+ return {
318
+ manifestHandler: createAgentManifest(config),
319
+ capabilityHandler: createCapabilityDetail(config),
320
+ config,
321
+ };
322
+ }
323
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAqdH,kDAkBC;AAaD,wDA+BC;AAiBD,8CAaC;AAtZD,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AACvD,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAEhE;;;GAGG;AACH,SAAS,cAAc,CAAC,MAAmB;IACzC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,QAAQ,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QACjD,YAAY,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,4BAA4B;IAC5B,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpD,QAAQ,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAClE,QAAQ,CAAC,IAAI,CACX,+D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QAEhC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,gBAAgB,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,iBAAiB,CAAC,MAAmB;IAQnD,OAAO;QACL,eAAe,EAAE,mBAAmB,CAAC,MAAM,CAAC;QAC5C,iBAAiB,EAAE,sBAAsB,CAAC,MAAM,CAAC;QACjD,MAAM;KACP,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "agent-well-known-next",
3
+ "version": "1.0.1",
4
+ "description": "Next.js App Router helpers for the Agent Discovery Protocol. Serve a /.well-known/agent manifest and capability detail endpoints with zero boilerplate.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "prepublishOnly": "npm run build"
13
+ },
14
+ "keywords": [
15
+ "agent-discovery",
16
+ "well-known",
17
+ "nextjs",
18
+ "app-router",
19
+ "ai-agent",
20
+ "mcp",
21
+ "service-discovery",
22
+ "agent-discovery-protocol"
23
+ ],
24
+ "author": "",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/user/agent-discovery-protocol",
29
+ "directory": "sdks/nextjs"
30
+ },
31
+ "homepage": "https://github.com/user/agent-discovery-protocol/tree/main/sdks/nextjs",
32
+ "bugs": {
33
+ "url": "https://github.com/user/agent-discovery-protocol/issues"
34
+ },
35
+ "peerDependencies": {
36
+ "next": ">=13.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^20.0.0",
40
+ "next": "^14.0.0",
41
+ "typescript": "^5.0.0"
42
+ },
43
+ "engines": {
44
+ "node": ">=18.0.0"
45
+ }
46
+ }