@vibe-agent-toolkit/resources 0.1.38 → 0.1.39-rc.2
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 +33 -24
- package/dist/frontmatter-link-validator.d.ts +9 -9
- package/dist/frontmatter-link-validator.d.ts.map +1 -1
- package/dist/frontmatter-link-validator.js +28 -27
- package/dist/frontmatter-link-validator.js.map +1 -1
- package/dist/frontmatter-validator.d.ts +3 -2
- package/dist/frontmatter-validator.d.ts.map +1 -1
- package/dist/frontmatter-validator.js +8 -14
- package/dist/frontmatter-validator.js.map +1 -1
- package/dist/html-link-parser.d.ts +47 -0
- package/dist/html-link-parser.d.ts.map +1 -0
- package/dist/html-link-parser.js +111 -0
- package/dist/html-link-parser.js.map +1 -0
- package/dist/html-transform.d.ts +45 -0
- package/dist/html-transform.d.ts.map +1 -0
- package/dist/html-transform.js +116 -0
- package/dist/html-transform.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/link-parser.d.ts +26 -2
- package/dist/link-parser.d.ts.map +1 -1
- package/dist/link-parser.js +40 -6
- package/dist/link-parser.js.map +1 -1
- package/dist/link-validator.d.ts +53 -6
- package/dist/link-validator.d.ts.map +1 -1
- package/dist/link-validator.js +100 -131
- package/dist/link-validator.js.map +1 -1
- package/dist/multi-schema-validator.d.ts.map +1 -1
- package/dist/multi-schema-validator.js +6 -8
- package/dist/multi-schema-validator.js.map +1 -1
- package/dist/resource-registry.d.ts +56 -13
- package/dist/resource-registry.d.ts.map +1 -1
- package/dist/resource-registry.js +165 -66
- package/dist/resource-registry.js.map +1 -1
- package/dist/schemas/link-auth.d.ts +382 -0
- package/dist/schemas/link-auth.d.ts.map +1 -0
- package/dist/schemas/link-auth.js +124 -0
- package/dist/schemas/link-auth.js.map +1 -0
- package/dist/schemas/project-config.d.ts +763 -171
- package/dist/schemas/project-config.d.ts.map +1 -1
- package/dist/schemas/project-config.js +5 -0
- package/dist/schemas/project-config.js.map +1 -1
- package/dist/schemas/resource-metadata.d.ts +46 -10
- package/dist/schemas/resource-metadata.d.ts.map +1 -1
- package/dist/schemas/resource-metadata.js +14 -1
- package/dist/schemas/resource-metadata.js.map +1 -1
- package/dist/schemas/validation-result.d.ts +36 -57
- package/dist/schemas/validation-result.d.ts.map +1 -1
- package/dist/schemas/validation-result.js +5 -27
- package/dist/schemas/validation-result.js.map +1 -1
- package/dist/types/resources.d.ts +1 -1
- package/dist/types/resources.d.ts.map +1 -1
- package/dist/types/resources.js.map +1 -1
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +14 -0
- package/dist/utils.js.map +1 -1
- package/package.json +4 -3
- package/src/frontmatter-link-validator.ts +28 -30
- package/src/frontmatter-validator.ts +19 -16
- package/src/html-link-parser.ts +140 -0
- package/src/html-transform.ts +157 -0
- package/src/index.ts +6 -1
- package/src/link-parser.ts +60 -11
- package/src/link-validator.ts +175 -145
- package/src/multi-schema-validator.ts +10 -8
- package/src/resource-registry.ts +205 -72
- package/src/schemas/link-auth.ts +146 -0
- package/src/schemas/project-config.ts +6 -0
- package/src/schemas/resource-metadata.ts +17 -1
- package/src/schemas/validation-result.ts +5 -29
- package/src/types/resources.ts +2 -1
- package/src/utils.ts +15 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for `resources.linkAuth` config.
|
|
3
|
+
*
|
|
4
|
+
* Validates the shape of an adopter's linkAuth configuration: providers
|
|
5
|
+
* (each either a `use: <macro>` reference or a full inline provider) plus
|
|
6
|
+
* an optional cache config. Strict — typos in provider field names are
|
|
7
|
+
* errors, per Postel's law ("writing our output → conservative").
|
|
8
|
+
*
|
|
9
|
+
* Provider entries accept EITHER:
|
|
10
|
+
* - `{ use: <name>, ...overrides }` — reference a shipped macro by name;
|
|
11
|
+
* override fields are deep-merged on top at expansion time. Overrides
|
|
12
|
+
* are NOT strictly typed at this layer because they must match the
|
|
13
|
+
* macro's shape, which we cannot see until expansion. A typo in an
|
|
14
|
+
* override silently no-ops; the full provider shape is validated
|
|
15
|
+
* after expansion (slice 2 wires that).
|
|
16
|
+
* - A full inline `{ match, rewrite, auth, token, check }` — every field
|
|
17
|
+
* required, every nested object strict.
|
|
18
|
+
*
|
|
19
|
+
* Mirrors the runtime types in `@vibe-agent-toolkit/utils`'s `link-auth/`
|
|
20
|
+
* module. Keep these aligned: a config that parses here must satisfy the
|
|
21
|
+
* `Provider` / `LinkAuthConfig` interfaces over there.
|
|
22
|
+
*
|
|
23
|
+
* Per design issue #113 §4 (vocabulary) and §5 (macros).
|
|
24
|
+
*/
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
export declare const ProviderMatchSchema: z.ZodObject<{
|
|
27
|
+
host: z.ZodString;
|
|
28
|
+
excludeHost: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
29
|
+
}, "strict", z.ZodTypeAny, {
|
|
30
|
+
host: string;
|
|
31
|
+
excludeHost?: string[] | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
host: string;
|
|
34
|
+
excludeHost?: string[] | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const RewriteRuleSchema: z.ZodObject<{
|
|
37
|
+
when: z.ZodString;
|
|
38
|
+
vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
39
|
+
to: z.ZodString;
|
|
40
|
+
}, "strict", z.ZodTypeAny, {
|
|
41
|
+
when: string;
|
|
42
|
+
to: string;
|
|
43
|
+
vars?: Record<string, string> | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
when: string;
|
|
46
|
+
to: string;
|
|
47
|
+
vars?: Record<string, string> | undefined;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const ProviderAuthSchema: z.ZodObject<{
|
|
50
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
51
|
+
}, "strict", z.ZodTypeAny, {
|
|
52
|
+
headers: Record<string, string>;
|
|
53
|
+
}, {
|
|
54
|
+
headers: Record<string, string>;
|
|
55
|
+
}>;
|
|
56
|
+
export declare const TokenSourceSchema: z.ZodUnion<[z.ZodObject<{
|
|
57
|
+
env: z.ZodString;
|
|
58
|
+
}, "strict", z.ZodTypeAny, {
|
|
59
|
+
env: string;
|
|
60
|
+
}, {
|
|
61
|
+
env: string;
|
|
62
|
+
}>, z.ZodObject<{
|
|
63
|
+
command: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
64
|
+
}, "strict", z.ZodTypeAny, {
|
|
65
|
+
command: string | string[];
|
|
66
|
+
}, {
|
|
67
|
+
command: string | string[];
|
|
68
|
+
}>]>;
|
|
69
|
+
export declare const ProviderCheckSchema: z.ZodObject<{
|
|
70
|
+
method: z.ZodEnum<["GET", "HEAD"]>;
|
|
71
|
+
aliveStatus: z.ZodArray<z.ZodNumber, "many">;
|
|
72
|
+
notFoundMeaning: z.ZodEnum<["ambiguous", "dead"]>;
|
|
73
|
+
}, "strict", z.ZodTypeAny, {
|
|
74
|
+
method: "GET" | "HEAD";
|
|
75
|
+
aliveStatus: number[];
|
|
76
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
77
|
+
}, {
|
|
78
|
+
method: "GET" | "HEAD";
|
|
79
|
+
aliveStatus: number[];
|
|
80
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
81
|
+
}>;
|
|
82
|
+
export declare const ProviderEntrySchema: z.ZodUnion<[z.ZodObject<{
|
|
83
|
+
use: z.ZodString;
|
|
84
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
85
|
+
use: z.ZodString;
|
|
86
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
87
|
+
use: z.ZodString;
|
|
88
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
89
|
+
match: z.ZodObject<{
|
|
90
|
+
host: z.ZodString;
|
|
91
|
+
excludeHost: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
92
|
+
}, "strict", z.ZodTypeAny, {
|
|
93
|
+
host: string;
|
|
94
|
+
excludeHost?: string[] | undefined;
|
|
95
|
+
}, {
|
|
96
|
+
host: string;
|
|
97
|
+
excludeHost?: string[] | undefined;
|
|
98
|
+
}>;
|
|
99
|
+
rewrite: z.ZodArray<z.ZodObject<{
|
|
100
|
+
when: z.ZodString;
|
|
101
|
+
vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
102
|
+
to: z.ZodString;
|
|
103
|
+
}, "strict", z.ZodTypeAny, {
|
|
104
|
+
when: string;
|
|
105
|
+
to: string;
|
|
106
|
+
vars?: Record<string, string> | undefined;
|
|
107
|
+
}, {
|
|
108
|
+
when: string;
|
|
109
|
+
to: string;
|
|
110
|
+
vars?: Record<string, string> | undefined;
|
|
111
|
+
}>, "many">;
|
|
112
|
+
auth: z.ZodObject<{
|
|
113
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
114
|
+
}, "strict", z.ZodTypeAny, {
|
|
115
|
+
headers: Record<string, string>;
|
|
116
|
+
}, {
|
|
117
|
+
headers: Record<string, string>;
|
|
118
|
+
}>;
|
|
119
|
+
token: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
120
|
+
env: z.ZodString;
|
|
121
|
+
}, "strict", z.ZodTypeAny, {
|
|
122
|
+
env: string;
|
|
123
|
+
}, {
|
|
124
|
+
env: string;
|
|
125
|
+
}>, z.ZodObject<{
|
|
126
|
+
command: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
127
|
+
}, "strict", z.ZodTypeAny, {
|
|
128
|
+
command: string | string[];
|
|
129
|
+
}, {
|
|
130
|
+
command: string | string[];
|
|
131
|
+
}>]>, "many">;
|
|
132
|
+
check: z.ZodObject<{
|
|
133
|
+
method: z.ZodEnum<["GET", "HEAD"]>;
|
|
134
|
+
aliveStatus: z.ZodArray<z.ZodNumber, "many">;
|
|
135
|
+
notFoundMeaning: z.ZodEnum<["ambiguous", "dead"]>;
|
|
136
|
+
}, "strict", z.ZodTypeAny, {
|
|
137
|
+
method: "GET" | "HEAD";
|
|
138
|
+
aliveStatus: number[];
|
|
139
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
140
|
+
}, {
|
|
141
|
+
method: "GET" | "HEAD";
|
|
142
|
+
aliveStatus: number[];
|
|
143
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
144
|
+
}>;
|
|
145
|
+
}, "strict", z.ZodTypeAny, {
|
|
146
|
+
match: {
|
|
147
|
+
host: string;
|
|
148
|
+
excludeHost?: string[] | undefined;
|
|
149
|
+
};
|
|
150
|
+
rewrite: {
|
|
151
|
+
when: string;
|
|
152
|
+
to: string;
|
|
153
|
+
vars?: Record<string, string> | undefined;
|
|
154
|
+
}[];
|
|
155
|
+
auth: {
|
|
156
|
+
headers: Record<string, string>;
|
|
157
|
+
};
|
|
158
|
+
token: ({
|
|
159
|
+
env: string;
|
|
160
|
+
} | {
|
|
161
|
+
command: string | string[];
|
|
162
|
+
})[];
|
|
163
|
+
check: {
|
|
164
|
+
method: "GET" | "HEAD";
|
|
165
|
+
aliveStatus: number[];
|
|
166
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
167
|
+
};
|
|
168
|
+
}, {
|
|
169
|
+
match: {
|
|
170
|
+
host: string;
|
|
171
|
+
excludeHost?: string[] | undefined;
|
|
172
|
+
};
|
|
173
|
+
rewrite: {
|
|
174
|
+
when: string;
|
|
175
|
+
to: string;
|
|
176
|
+
vars?: Record<string, string> | undefined;
|
|
177
|
+
}[];
|
|
178
|
+
auth: {
|
|
179
|
+
headers: Record<string, string>;
|
|
180
|
+
};
|
|
181
|
+
token: ({
|
|
182
|
+
env: string;
|
|
183
|
+
} | {
|
|
184
|
+
command: string | string[];
|
|
185
|
+
})[];
|
|
186
|
+
check: {
|
|
187
|
+
method: "GET" | "HEAD";
|
|
188
|
+
aliveStatus: number[];
|
|
189
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
190
|
+
};
|
|
191
|
+
}>]>;
|
|
192
|
+
export declare const LinkAuthCacheSchema: z.ZodObject<{
|
|
193
|
+
ttlMinutes: z.ZodOptional<z.ZodNumber>;
|
|
194
|
+
}, "strict", z.ZodTypeAny, {
|
|
195
|
+
ttlMinutes?: number | undefined;
|
|
196
|
+
}, {
|
|
197
|
+
ttlMinutes?: number | undefined;
|
|
198
|
+
}>;
|
|
199
|
+
export declare const LinkAuthConfigSchema: z.ZodObject<{
|
|
200
|
+
cache: z.ZodOptional<z.ZodObject<{
|
|
201
|
+
ttlMinutes: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
}, "strict", z.ZodTypeAny, {
|
|
203
|
+
ttlMinutes?: number | undefined;
|
|
204
|
+
}, {
|
|
205
|
+
ttlMinutes?: number | undefined;
|
|
206
|
+
}>>;
|
|
207
|
+
providers: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
208
|
+
use: z.ZodString;
|
|
209
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
210
|
+
use: z.ZodString;
|
|
211
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
212
|
+
use: z.ZodString;
|
|
213
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
214
|
+
match: z.ZodObject<{
|
|
215
|
+
host: z.ZodString;
|
|
216
|
+
excludeHost: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
217
|
+
}, "strict", z.ZodTypeAny, {
|
|
218
|
+
host: string;
|
|
219
|
+
excludeHost?: string[] | undefined;
|
|
220
|
+
}, {
|
|
221
|
+
host: string;
|
|
222
|
+
excludeHost?: string[] | undefined;
|
|
223
|
+
}>;
|
|
224
|
+
rewrite: z.ZodArray<z.ZodObject<{
|
|
225
|
+
when: z.ZodString;
|
|
226
|
+
vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
227
|
+
to: z.ZodString;
|
|
228
|
+
}, "strict", z.ZodTypeAny, {
|
|
229
|
+
when: string;
|
|
230
|
+
to: string;
|
|
231
|
+
vars?: Record<string, string> | undefined;
|
|
232
|
+
}, {
|
|
233
|
+
when: string;
|
|
234
|
+
to: string;
|
|
235
|
+
vars?: Record<string, string> | undefined;
|
|
236
|
+
}>, "many">;
|
|
237
|
+
auth: z.ZodObject<{
|
|
238
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
239
|
+
}, "strict", z.ZodTypeAny, {
|
|
240
|
+
headers: Record<string, string>;
|
|
241
|
+
}, {
|
|
242
|
+
headers: Record<string, string>;
|
|
243
|
+
}>;
|
|
244
|
+
token: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
245
|
+
env: z.ZodString;
|
|
246
|
+
}, "strict", z.ZodTypeAny, {
|
|
247
|
+
env: string;
|
|
248
|
+
}, {
|
|
249
|
+
env: string;
|
|
250
|
+
}>, z.ZodObject<{
|
|
251
|
+
command: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
252
|
+
}, "strict", z.ZodTypeAny, {
|
|
253
|
+
command: string | string[];
|
|
254
|
+
}, {
|
|
255
|
+
command: string | string[];
|
|
256
|
+
}>]>, "many">;
|
|
257
|
+
check: z.ZodObject<{
|
|
258
|
+
method: z.ZodEnum<["GET", "HEAD"]>;
|
|
259
|
+
aliveStatus: z.ZodArray<z.ZodNumber, "many">;
|
|
260
|
+
notFoundMeaning: z.ZodEnum<["ambiguous", "dead"]>;
|
|
261
|
+
}, "strict", z.ZodTypeAny, {
|
|
262
|
+
method: "GET" | "HEAD";
|
|
263
|
+
aliveStatus: number[];
|
|
264
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
265
|
+
}, {
|
|
266
|
+
method: "GET" | "HEAD";
|
|
267
|
+
aliveStatus: number[];
|
|
268
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
269
|
+
}>;
|
|
270
|
+
}, "strict", z.ZodTypeAny, {
|
|
271
|
+
match: {
|
|
272
|
+
host: string;
|
|
273
|
+
excludeHost?: string[] | undefined;
|
|
274
|
+
};
|
|
275
|
+
rewrite: {
|
|
276
|
+
when: string;
|
|
277
|
+
to: string;
|
|
278
|
+
vars?: Record<string, string> | undefined;
|
|
279
|
+
}[];
|
|
280
|
+
auth: {
|
|
281
|
+
headers: Record<string, string>;
|
|
282
|
+
};
|
|
283
|
+
token: ({
|
|
284
|
+
env: string;
|
|
285
|
+
} | {
|
|
286
|
+
command: string | string[];
|
|
287
|
+
})[];
|
|
288
|
+
check: {
|
|
289
|
+
method: "GET" | "HEAD";
|
|
290
|
+
aliveStatus: number[];
|
|
291
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
292
|
+
};
|
|
293
|
+
}, {
|
|
294
|
+
match: {
|
|
295
|
+
host: string;
|
|
296
|
+
excludeHost?: string[] | undefined;
|
|
297
|
+
};
|
|
298
|
+
rewrite: {
|
|
299
|
+
when: string;
|
|
300
|
+
to: string;
|
|
301
|
+
vars?: Record<string, string> | undefined;
|
|
302
|
+
}[];
|
|
303
|
+
auth: {
|
|
304
|
+
headers: Record<string, string>;
|
|
305
|
+
};
|
|
306
|
+
token: ({
|
|
307
|
+
env: string;
|
|
308
|
+
} | {
|
|
309
|
+
command: string | string[];
|
|
310
|
+
})[];
|
|
311
|
+
check: {
|
|
312
|
+
method: "GET" | "HEAD";
|
|
313
|
+
aliveStatus: number[];
|
|
314
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
315
|
+
};
|
|
316
|
+
}>]>, "many">;
|
|
317
|
+
}, "strict", z.ZodTypeAny, {
|
|
318
|
+
providers: ({
|
|
319
|
+
match: {
|
|
320
|
+
host: string;
|
|
321
|
+
excludeHost?: string[] | undefined;
|
|
322
|
+
};
|
|
323
|
+
rewrite: {
|
|
324
|
+
when: string;
|
|
325
|
+
to: string;
|
|
326
|
+
vars?: Record<string, string> | undefined;
|
|
327
|
+
}[];
|
|
328
|
+
auth: {
|
|
329
|
+
headers: Record<string, string>;
|
|
330
|
+
};
|
|
331
|
+
token: ({
|
|
332
|
+
env: string;
|
|
333
|
+
} | {
|
|
334
|
+
command: string | string[];
|
|
335
|
+
})[];
|
|
336
|
+
check: {
|
|
337
|
+
method: "GET" | "HEAD";
|
|
338
|
+
aliveStatus: number[];
|
|
339
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
340
|
+
};
|
|
341
|
+
} | z.objectOutputType<{
|
|
342
|
+
use: z.ZodString;
|
|
343
|
+
}, z.ZodTypeAny, "passthrough">)[];
|
|
344
|
+
cache?: {
|
|
345
|
+
ttlMinutes?: number | undefined;
|
|
346
|
+
} | undefined;
|
|
347
|
+
}, {
|
|
348
|
+
providers: ({
|
|
349
|
+
match: {
|
|
350
|
+
host: string;
|
|
351
|
+
excludeHost?: string[] | undefined;
|
|
352
|
+
};
|
|
353
|
+
rewrite: {
|
|
354
|
+
when: string;
|
|
355
|
+
to: string;
|
|
356
|
+
vars?: Record<string, string> | undefined;
|
|
357
|
+
}[];
|
|
358
|
+
auth: {
|
|
359
|
+
headers: Record<string, string>;
|
|
360
|
+
};
|
|
361
|
+
token: ({
|
|
362
|
+
env: string;
|
|
363
|
+
} | {
|
|
364
|
+
command: string | string[];
|
|
365
|
+
})[];
|
|
366
|
+
check: {
|
|
367
|
+
method: "GET" | "HEAD";
|
|
368
|
+
aliveStatus: number[];
|
|
369
|
+
notFoundMeaning: "ambiguous" | "dead";
|
|
370
|
+
};
|
|
371
|
+
} | z.objectInputType<{
|
|
372
|
+
use: z.ZodString;
|
|
373
|
+
}, z.ZodTypeAny, "passthrough">)[];
|
|
374
|
+
cache?: {
|
|
375
|
+
ttlMinutes?: number | undefined;
|
|
376
|
+
} | undefined;
|
|
377
|
+
}>;
|
|
378
|
+
export type LinkAuthConfig = z.infer<typeof LinkAuthConfigSchema>;
|
|
379
|
+
export type ProviderEntry = z.infer<typeof ProviderEntrySchema>;
|
|
380
|
+
export type RewriteRule = z.infer<typeof RewriteRuleSchema>;
|
|
381
|
+
export type TokenSource = z.infer<typeof TokenSourceSchema>;
|
|
382
|
+
//# sourceMappingURL=link-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-auth.d.ts","sourceRoot":"","sources":["../../src/schemas/link-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,mBAAmB;;;;;;;;;EAS2C,CAAC;AAE5E,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAUwD,CAAC;AAEvF,eAAO,MAAM,kBAAkB;;;;;;EAOgC,CAAC;AAEhE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;IASoE,CAAC;AAEnG,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAckE,CAAC;AAyBnG,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEiE,CAAC;AAMlG,eAAO,MAAM,mBAAmB;;;;;;EASrB,CAAC;AAEZ,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQkD,CAAC;AAEpF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for `resources.linkAuth` config.
|
|
3
|
+
*
|
|
4
|
+
* Validates the shape of an adopter's linkAuth configuration: providers
|
|
5
|
+
* (each either a `use: <macro>` reference or a full inline provider) plus
|
|
6
|
+
* an optional cache config. Strict — typos in provider field names are
|
|
7
|
+
* errors, per Postel's law ("writing our output → conservative").
|
|
8
|
+
*
|
|
9
|
+
* Provider entries accept EITHER:
|
|
10
|
+
* - `{ use: <name>, ...overrides }` — reference a shipped macro by name;
|
|
11
|
+
* override fields are deep-merged on top at expansion time. Overrides
|
|
12
|
+
* are NOT strictly typed at this layer because they must match the
|
|
13
|
+
* macro's shape, which we cannot see until expansion. A typo in an
|
|
14
|
+
* override silently no-ops; the full provider shape is validated
|
|
15
|
+
* after expansion (slice 2 wires that).
|
|
16
|
+
* - A full inline `{ match, rewrite, auth, token, check }` — every field
|
|
17
|
+
* required, every nested object strict.
|
|
18
|
+
*
|
|
19
|
+
* Mirrors the runtime types in `@vibe-agent-toolkit/utils`'s `link-auth/`
|
|
20
|
+
* module. Keep these aligned: a config that parses here must satisfy the
|
|
21
|
+
* `Provider` / `LinkAuthConfig` interfaces over there.
|
|
22
|
+
*
|
|
23
|
+
* Per design issue #113 §4 (vocabulary) and §5 (macros).
|
|
24
|
+
*/
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Leaf types
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
export const ProviderMatchSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
host: z.string().min(1).describe('Glob matched against URL hostname'),
|
|
32
|
+
excludeHost: z
|
|
33
|
+
.array(z.string().min(1))
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('Globs that, if any match the hostname, exclude this provider'),
|
|
36
|
+
})
|
|
37
|
+
.strict()
|
|
38
|
+
.describe('Provider selection — match.host + optional excludeHost globs');
|
|
39
|
+
export const RewriteRuleSchema = z
|
|
40
|
+
.object({
|
|
41
|
+
when: z.string().min(1).describe('Regex source (RFC-style, JavaScript-compatible) matched against the URL'),
|
|
42
|
+
vars: z
|
|
43
|
+
.record(z.string(), z.string())
|
|
44
|
+
.optional()
|
|
45
|
+
.describe('Computed variables, each a template that references captures from `when`'),
|
|
46
|
+
to: z.string().min(1).describe('URL template — interpolates ${capture} and ${var}'),
|
|
47
|
+
})
|
|
48
|
+
.strict()
|
|
49
|
+
.describe('A single rewrite rule (one entry in a provider\'s ordered rewrite list)');
|
|
50
|
+
export const ProviderAuthSchema = z
|
|
51
|
+
.object({
|
|
52
|
+
headers: z
|
|
53
|
+
.record(z.string(), z.string())
|
|
54
|
+
.describe('Header name → value template. Values interpolate ${token} and any capture/var.'),
|
|
55
|
+
})
|
|
56
|
+
.strict()
|
|
57
|
+
.describe('Auth headers attached to the authenticated fetch');
|
|
58
|
+
export const TokenSourceSchema = z
|
|
59
|
+
.union([
|
|
60
|
+
z.object({ env: z.string().min(1) }).strict(),
|
|
61
|
+
z
|
|
62
|
+
.object({
|
|
63
|
+
command: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]),
|
|
64
|
+
})
|
|
65
|
+
.strict(),
|
|
66
|
+
])
|
|
67
|
+
.describe('A single token source — env var, or argv command (preferred), or convenience string');
|
|
68
|
+
export const ProviderCheckSchema = z
|
|
69
|
+
.object({
|
|
70
|
+
method: z.enum(['GET', 'HEAD']),
|
|
71
|
+
aliveStatus: z
|
|
72
|
+
.array(z.number().int().min(100).max(599))
|
|
73
|
+
.min(1)
|
|
74
|
+
.describe('HTTP status codes meaning the URL is alive (per host semantics)'),
|
|
75
|
+
notFoundMeaning: z
|
|
76
|
+
.enum(['ambiguous', 'dead'])
|
|
77
|
+
.describe('Per-host: does 404 mean "dead" (honest 404 host like Graph) or "ambiguous" (masking host like GitHub)?'),
|
|
78
|
+
})
|
|
79
|
+
.strict()
|
|
80
|
+
.describe('Status-to-outcome classifier (consumed by the resources layer, not the pure engine)');
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
// Provider entry (inline OR macro reference)
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
const InlineProviderSchema = z
|
|
85
|
+
.object({
|
|
86
|
+
match: ProviderMatchSchema,
|
|
87
|
+
rewrite: z.array(RewriteRuleSchema).min(1).describe('Ordered rewrite rules — first matching wins'),
|
|
88
|
+
auth: ProviderAuthSchema,
|
|
89
|
+
token: z.array(TokenSourceSchema).describe('Ordered token sources — first non-empty wins'),
|
|
90
|
+
check: ProviderCheckSchema,
|
|
91
|
+
})
|
|
92
|
+
.strict();
|
|
93
|
+
const MacroProviderSchema = z
|
|
94
|
+
.object({
|
|
95
|
+
use: z.string().min(1).describe('Macro name (e.g. "github", "sharepoint")'),
|
|
96
|
+
})
|
|
97
|
+
.passthrough()
|
|
98
|
+
.describe('Reference a shipped macro by name. Override fields (match/rewrite/auth/token/check) deep-merge on top at expansion time.');
|
|
99
|
+
export const ProviderEntrySchema = z
|
|
100
|
+
.union([MacroProviderSchema, InlineProviderSchema])
|
|
101
|
+
.describe('A provider entry — either { use: <macro>, ...overrides } or a full inline provider');
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
// Top-level linkAuth config
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
export const LinkAuthCacheSchema = z
|
|
106
|
+
.object({
|
|
107
|
+
ttlMinutes: z
|
|
108
|
+
.number()
|
|
109
|
+
.int()
|
|
110
|
+
.positive()
|
|
111
|
+
.optional()
|
|
112
|
+
.describe('Content cache TTL in minutes (default 30 — used by slice 3 content-fetch)'),
|
|
113
|
+
})
|
|
114
|
+
.strict();
|
|
115
|
+
export const LinkAuthConfigSchema = z
|
|
116
|
+
.object({
|
|
117
|
+
cache: LinkAuthCacheSchema.optional(),
|
|
118
|
+
providers: z
|
|
119
|
+
.array(ProviderEntrySchema)
|
|
120
|
+
.describe('Ordered list of providers — first claiming-by-host wins'),
|
|
121
|
+
})
|
|
122
|
+
.strict()
|
|
123
|
+
.describe('`resources.linkAuth` — authenticated external link resolution config');
|
|
124
|
+
//# sourceMappingURL=link-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-auth.js","sourceRoot":"","sources":["../../src/schemas/link-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IACrE,WAAW,EAAE,CAAC;SACX,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACxB,QAAQ,EAAE;SACV,QAAQ,CAAC,8DAA8D,CAAC;CAC5E,CAAC;KACD,MAAM,EAAE;KACR,QAAQ,CAAC,8DAA8D,CAAC,CAAC;AAE5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC/B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yEAAyE,CAAC;IAC3G,IAAI,EAAE,CAAC;SACJ,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;SAC9B,QAAQ,EAAE;SACV,QAAQ,CAAC,0EAA0E,CAAC;IACvF,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG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