veryfront 0.1.514 → 0.1.516
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 +0 -1
- package/esm/cli/commands/build/command.js +2 -2
- package/esm/cli/shared/{ensure-content-transformer.d.ts → ensure-content-processor.d.ts} +3 -3
- package/esm/cli/shared/ensure-content-processor.d.ts.map +1 -0
- package/esm/cli/shared/{ensure-content-transformer.js → ensure-content-processor.js} +5 -5
- package/esm/cli/shared/server-startup.js +4 -4
- package/esm/deno.d.ts +0 -5
- package/esm/deno.js +4 -9
- package/esm/extensions/ext-transform-mdx/src/compiler/markdown-compile.d.ts +2 -2
- package/esm/extensions/ext-transform-mdx/src/compiler/markdown-compile.d.ts.map +1 -1
- package/esm/extensions/ext-transform-mdx/src/compiler/mdx-compile.d.ts +2 -2
- package/esm/extensions/ext-transform-mdx/src/compiler/mdx-compile.d.ts.map +1 -1
- package/esm/extensions/ext-transform-mdx/src/index.d.ts +10 -10
- package/esm/extensions/ext-transform-mdx/src/index.d.ts.map +1 -1
- package/esm/extensions/ext-transform-mdx/src/index.js +11 -11
- package/esm/src/agent/index.d.ts +2 -1
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +1 -0
- package/esm/src/agent/runtime/constants.d.ts.map +1 -1
- package/esm/src/agent/runtime/constants.js +5 -1
- package/esm/src/agent/runtime/model-resolution.d.ts.map +1 -1
- package/esm/src/agent/runtime/model-resolution.js +17 -3
- package/esm/src/agent/runtime-agent-markdown-adapter.d.ts +6 -0
- package/esm/src/agent/runtime-agent-markdown-adapter.d.ts.map +1 -0
- package/esm/src/agent/runtime-agent-markdown-adapter.js +20 -0
- package/esm/src/agent/types.d.ts +22 -10
- package/esm/src/agent/types.d.ts.map +1 -1
- package/esm/src/agent/veryfront-cloud-agent-service.d.ts.map +1 -1
- package/esm/src/agent/veryfront-cloud-agent-service.js +19 -8
- package/esm/src/channels/control-plane.d.ts +30 -54
- package/esm/src/channels/control-plane.d.ts.map +1 -1
- package/esm/src/channels/control-plane.js +13 -15
- package/esm/src/discovery/discovery-engine.d.ts.map +1 -1
- package/esm/src/discovery/discovery-engine.js +2 -0
- package/esm/src/discovery/file-discovery.d.ts +6 -1
- package/esm/src/discovery/file-discovery.d.ts.map +1 -1
- package/esm/src/discovery/file-discovery.js +25 -5
- package/esm/src/discovery/handlers/runtime-agent-markdown-handler.d.ts +3 -0
- package/esm/src/discovery/handlers/runtime-agent-markdown-handler.d.ts.map +1 -0
- package/esm/src/discovery/handlers/runtime-agent-markdown-handler.js +51 -0
- package/esm/src/extensions/builtin-extensions.js +1 -1
- package/esm/src/extensions/recommendations.js +1 -1
- package/esm/src/extensions/transform/{content-transformer.d.ts → content-processor.d.ts} +21 -21
- package/esm/src/extensions/transform/content-processor.d.ts.map +1 -0
- package/esm/src/extensions/transform/{content-transformer.js → content-processor.js} +5 -5
- package/esm/src/extensions/transform/index.d.ts +3 -3
- package/esm/src/extensions/transform/index.d.ts.map +1 -1
- package/esm/src/extensions/transform/index.js +1 -1
- package/esm/src/oauth/handlers/init-handler.d.ts.map +1 -1
- package/esm/src/oauth/handlers/init-handler.js +9 -4
- package/esm/src/transforms/md/compiler/md-compiler.d.ts +2 -2
- package/esm/src/transforms/md/compiler/md-compiler.d.ts.map +1 -1
- package/esm/src/transforms/md/compiler/md-compiler.js +2 -2
- package/esm/src/transforms/mdx/compiler/index.d.ts +3 -3
- package/esm/src/transforms/mdx/compiler/index.d.ts.map +1 -1
- package/esm/src/transforms/mdx/compiler/mdx-compiler.d.ts +2 -2
- package/esm/src/transforms/mdx/compiler/mdx-compiler.d.ts.map +1 -1
- package/esm/src/transforms/mdx/compiler/mdx-compiler.js +2 -2
- package/esm/src/transforms/plugins/plugin-loader.d.ts +2 -2
- package/esm/src/transforms/plugins/plugin-loader.js +6 -6
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +4 -4
- package/src/cli/commands/build/command.ts +2 -2
- package/src/cli/shared/{ensure-content-transformer.ts → ensure-content-processor.ts} +6 -6
- package/src/cli/shared/server-startup.ts +4 -4
- package/src/deno.js +4 -9
- package/src/deps/esm.sh/@types/react-dom@19.2.3/client.d.ts +1 -1
- package/src/deps/esm.sh/@types/{react@19.2.14 → react@19.2.3}/global.d.ts +0 -1
- package/src/deps/esm.sh/@types/{react@19.2.14 → react@19.2.3}/index.d.ts +24 -93
- package/src/deps/esm.sh/react-dom@19.2.4/client.d.ts +1 -1
- package/src/extensions/ext-transform-mdx/src/compiler/markdown-compile.ts +5 -2
- package/src/extensions/ext-transform-mdx/src/compiler/mdx-compile.ts +5 -2
- package/src/extensions/ext-transform-mdx/src/index.ts +15 -15
- package/src/src/agent/index.ts +8 -2
- package/src/src/agent/runtime/constants.ts +6 -1
- package/src/src/agent/runtime/model-resolution.ts +17 -3
- package/src/src/agent/runtime-agent-markdown-adapter.ts +31 -0
- package/src/src/agent/types.ts +23 -10
- package/src/src/agent/veryfront-cloud-agent-service.ts +23 -10
- package/src/src/channels/control-plane.ts +18 -20
- package/src/src/discovery/discovery-engine.ts +2 -0
- package/src/src/discovery/file-discovery.ts +40 -5
- package/src/src/discovery/handlers/runtime-agent-markdown-handler.ts +78 -0
- package/src/src/extensions/builtin-extensions.ts +1 -1
- package/src/src/extensions/recommendations.ts +1 -1
- package/src/src/extensions/transform/{content-transformer.ts → content-processor.ts} +20 -20
- package/src/src/extensions/transform/index.ts +5 -5
- package/src/src/oauth/handlers/init-handler.ts +10 -5
- package/src/src/transforms/md/compiler/md-compiler.ts +6 -6
- package/src/src/transforms/mdx/compiler/index.ts +3 -3
- package/src/src/transforms/mdx/compiler/mdx-compiler.ts +5 -5
- package/src/src/transforms/plugins/plugin-loader.ts +7 -7
- package/src/src/utils/version-constant.ts +1 -1
- package/esm/cli/shared/ensure-content-transformer.d.ts.map +0 -1
- package/esm/src/extensions/transform/content-transformer.d.ts.map +0 -1
|
@@ -47,34 +47,32 @@ export const getRuntimeAgentSkillSchema = defineSchema((v) =>
|
|
|
47
47
|
);
|
|
48
48
|
export const RuntimeAgentSkillSchema = getRuntimeAgentSkillSchema();
|
|
49
49
|
|
|
50
|
-
export const
|
|
51
|
-
v.
|
|
50
|
+
export const getRuntimeSuggestionSchema = defineSchema((v) =>
|
|
51
|
+
v.union([
|
|
52
52
|
v.object({
|
|
53
|
-
id: v.string().min(1),
|
|
54
53
|
type: v.literal("prompt"),
|
|
55
54
|
title: v.string().min(1),
|
|
56
|
-
description: v.string().optional(),
|
|
57
55
|
prompt: v.string().min(1),
|
|
58
|
-
}),
|
|
56
|
+
}).strict(),
|
|
59
57
|
v.object({
|
|
60
58
|
id: v.string().min(1),
|
|
59
|
+
type: v.literal("prompt"),
|
|
60
|
+
}).strict(),
|
|
61
|
+
v.object({
|
|
61
62
|
type: v.literal("task"),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
task: v.string().min(1),
|
|
65
|
-
prompt: v.string().min(1).optional(),
|
|
66
|
-
}),
|
|
63
|
+
id: v.string().min(1),
|
|
64
|
+
}).strict(),
|
|
67
65
|
])
|
|
68
66
|
);
|
|
69
|
-
export const
|
|
67
|
+
export const RuntimeSuggestionSchema = getRuntimeSuggestionSchema();
|
|
70
68
|
|
|
71
|
-
export const
|
|
69
|
+
export const getRuntimeSuggestionsSchema = defineSchema((v) =>
|
|
72
70
|
v.object({
|
|
73
71
|
welcomeMessage: v.string().min(1).optional(),
|
|
74
|
-
suggestions: v.array(
|
|
72
|
+
suggestions: v.array(getRuntimeSuggestionSchema()),
|
|
75
73
|
})
|
|
76
74
|
);
|
|
77
|
-
export const
|
|
75
|
+
export const RuntimeSuggestionsSchema = getRuntimeSuggestionsSchema();
|
|
78
76
|
|
|
79
77
|
export const getRuntimeAgentSchema = defineSchema((v) =>
|
|
80
78
|
v.object({
|
|
@@ -84,7 +82,7 @@ export const getRuntimeAgentSchema = defineSchema((v) =>
|
|
|
84
82
|
model: v.string().nullable().optional(),
|
|
85
83
|
version: v.string().nullable().optional(),
|
|
86
84
|
skills: v.array(getRuntimeAgentSkillSchema()).optional(),
|
|
87
|
-
suggestions:
|
|
85
|
+
suggestions: getRuntimeSuggestionsSchema().optional(),
|
|
88
86
|
})
|
|
89
87
|
);
|
|
90
88
|
export const RuntimeAgentSchema = getRuntimeAgentSchema();
|
|
@@ -129,11 +127,11 @@ export type ControlPlaneAgentsListRequest = InferSchema<
|
|
|
129
127
|
ReturnType<typeof getControlPlaneAgentsListRequestSchema>
|
|
130
128
|
>;
|
|
131
129
|
export type RuntimeAgentSkill = InferSchema<ReturnType<typeof getRuntimeAgentSkillSchema>>;
|
|
132
|
-
export type
|
|
133
|
-
ReturnType<typeof
|
|
130
|
+
export type RuntimeSuggestion = InferSchema<
|
|
131
|
+
ReturnType<typeof getRuntimeSuggestionSchema>
|
|
134
132
|
>;
|
|
135
|
-
export type
|
|
136
|
-
ReturnType<typeof
|
|
133
|
+
export type RuntimeSuggestions = InferSchema<
|
|
134
|
+
ReturnType<typeof getRuntimeSuggestionsSchema>
|
|
137
135
|
>;
|
|
138
136
|
export type RuntimeAgent = InferSchema<ReturnType<typeof getRuntimeAgentSchema>>;
|
|
139
137
|
export type RuntimeAgentListResponse = InferSchema<
|
|
@@ -307,7 +305,7 @@ function getRuntimeAgentMetadata(id: string, agent: Agent): RuntimeAgent {
|
|
|
307
305
|
const rawConfig = agent.config as unknown as Record<string, unknown>;
|
|
308
306
|
const suggestionsParseResult = rawConfig.suggestions === undefined
|
|
309
307
|
? null
|
|
310
|
-
:
|
|
308
|
+
: RuntimeSuggestionsSchema.safeParse(rawConfig.suggestions);
|
|
311
309
|
const suggestions = suggestionsParseResult?.success ? suggestionsParseResult.data : undefined;
|
|
312
310
|
|
|
313
311
|
return RuntimeAgentSchema.parse({
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
toolHandler,
|
|
27
27
|
workflowHandler,
|
|
28
28
|
} from "./handlers/index.js";
|
|
29
|
+
import { discoverRuntimeAgentMarkdownDefinitions } from "./handlers/runtime-agent-markdown-handler.js";
|
|
29
30
|
import { filenameToId } from "./discovery-utils.js";
|
|
30
31
|
import { join } from "../platform/compat/path/index.js";
|
|
31
32
|
|
|
@@ -178,6 +179,7 @@ export async function discoverAll(config: DiscoveryConfig): Promise<DiscoveryRes
|
|
|
178
179
|
// Discover agents
|
|
179
180
|
for (const dir of config.agentDirs ?? ["agents"]) {
|
|
180
181
|
await discoverItems(`${baseDir}/${dir}`, result, context, agentHandler, config.verbose);
|
|
182
|
+
await discoverRuntimeAgentMarkdownDefinitions(`${baseDir}/${dir}`, result, context);
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
// Discover resources
|
|
@@ -9,9 +9,10 @@ import type { FileDiscoveryContext } from "./types.js";
|
|
|
9
9
|
/**
|
|
10
10
|
* Find all TypeScript files in a directory recursively
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
async function findFilesByExtension(
|
|
13
13
|
dir: string,
|
|
14
14
|
context: FileDiscoveryContext,
|
|
15
|
+
extensions: readonly string[],
|
|
15
16
|
): Promise<string[]> {
|
|
16
17
|
const files: string[] = [];
|
|
17
18
|
|
|
@@ -22,13 +23,13 @@ export async function findTypeScriptFiles(
|
|
|
22
23
|
for await (const entry of context.fsAdapter.readDir(dir)) {
|
|
23
24
|
const filePath = `${dir}/${entry.name}`;
|
|
24
25
|
|
|
25
|
-
if (entry.isFile &&
|
|
26
|
+
if (entry.isFile && extensions.some((extension) => entry.name.endsWith(extension))) {
|
|
26
27
|
files.push(`file://${filePath}`);
|
|
27
28
|
continue;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
if (entry.isDirectory) {
|
|
31
|
-
files.push(...(await
|
|
32
|
+
files.push(...(await findFilesByExtension(filePath, context, extensions)));
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -41,13 +42,13 @@ export async function findTypeScriptFiles(
|
|
|
41
42
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
42
43
|
const filePath = path.join(dir, entry.name);
|
|
43
44
|
|
|
44
|
-
if (entry.isFile() &&
|
|
45
|
+
if (entry.isFile() && extensions.some((extension) => entry.name.endsWith(extension))) {
|
|
45
46
|
files.push(`file://${path.resolve(filePath)}`);
|
|
46
47
|
continue;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
if (entry.isDirectory()) {
|
|
50
|
-
files.push(...(await
|
|
51
|
+
files.push(...(await findFilesByExtension(filePath, context, extensions)));
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
} catch (_) {
|
|
@@ -72,3 +73,37 @@ async function getNodeDeps(
|
|
|
72
73
|
context.nodeDeps = { fs: fsModule, path: pathModule };
|
|
73
74
|
return context.nodeDeps;
|
|
74
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Find all TypeScript files in a directory recursively.
|
|
79
|
+
*/
|
|
80
|
+
export function findTypeScriptFiles(
|
|
81
|
+
dir: string,
|
|
82
|
+
context: FileDiscoveryContext,
|
|
83
|
+
): Promise<string[]> {
|
|
84
|
+
return findFilesByExtension(dir, context, [".ts", ".tsx"]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Find all Markdown files in a directory recursively.
|
|
89
|
+
*/
|
|
90
|
+
export function findMarkdownFiles(
|
|
91
|
+
dir: string,
|
|
92
|
+
context: FileDiscoveryContext,
|
|
93
|
+
): Promise<string[]> {
|
|
94
|
+
return findFilesByExtension(dir, context, [".md"]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function readDiscoveryTextFile(
|
|
98
|
+
fileUrl: string,
|
|
99
|
+
context: FileDiscoveryContext,
|
|
100
|
+
): Promise<string> {
|
|
101
|
+
const path = fileUrl.replace(/^file:\/\//, "");
|
|
102
|
+
|
|
103
|
+
if (context.fsAdapter) {
|
|
104
|
+
return await context.fsAdapter.readFile(path);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const { fs } = await getNodeDeps(context);
|
|
108
|
+
return fs.readFileSync(path, "utf-8");
|
|
109
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createRuntimeAgentFromMarkdownDefinition } from "../../agent/runtime-agent-markdown-adapter.js";
|
|
2
|
+
import {
|
|
3
|
+
parseRuntimeAgentMarkdownDefinition,
|
|
4
|
+
type RuntimeAgentMarkdownDefinition,
|
|
5
|
+
} from "../../agent/runtime-agent-definition.js";
|
|
6
|
+
import { agentRegistry, registerAgent } from "../../agent/composition/index.js";
|
|
7
|
+
import { ensureError } from "../../errors/veryfront-error.js";
|
|
8
|
+
import type { DiscoveryResult, FileDiscoveryContext } from "../types.js";
|
|
9
|
+
import { trackAgentPath } from "../discovery-utils.js";
|
|
10
|
+
import { findMarkdownFiles, readDiscoveryTextFile } from "../file-discovery.js";
|
|
11
|
+
|
|
12
|
+
const MARKDOWN_AGENT_FILE_PATTERN = /^[A-Za-z0-9._-]+\.md$/;
|
|
13
|
+
|
|
14
|
+
type MarkdownAgentCandidate = {
|
|
15
|
+
id: string;
|
|
16
|
+
file: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function getFileName(file: string): string {
|
|
20
|
+
return file.split("/").pop() ?? "";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getMarkdownAgentCandidate(file: string): MarkdownAgentCandidate | null {
|
|
24
|
+
const fileName = getFileName(file);
|
|
25
|
+
if (!MARKDOWN_AGENT_FILE_PATTERN.test(fileName)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
id: fileName.slice(0, -".md".length),
|
|
31
|
+
file,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function registerMarkdownAgent(
|
|
36
|
+
definition: RuntimeAgentMarkdownDefinition,
|
|
37
|
+
file: string,
|
|
38
|
+
result: DiscoveryResult,
|
|
39
|
+
): void {
|
|
40
|
+
if (result.agents.has(definition.id)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const runtimeAgent = createRuntimeAgentFromMarkdownDefinition(definition);
|
|
45
|
+
if (runtimeAgent.id !== definition.id) {
|
|
46
|
+
agentRegistry.delete(runtimeAgent.id);
|
|
47
|
+
}
|
|
48
|
+
registerAgent(definition.id, runtimeAgent);
|
|
49
|
+
trackAgentPath(definition.id, file);
|
|
50
|
+
result.agents.set(definition.id, runtimeAgent);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function discoverRuntimeAgentMarkdownDefinitions(
|
|
54
|
+
dir: string,
|
|
55
|
+
result: DiscoveryResult,
|
|
56
|
+
context: FileDiscoveryContext,
|
|
57
|
+
): Promise<void> {
|
|
58
|
+
const files = (await findMarkdownFiles(dir, context)).sort((left, right) =>
|
|
59
|
+
left.localeCompare(right)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
for (const file of files) {
|
|
63
|
+
const candidate = getMarkdownAgentCandidate(file);
|
|
64
|
+
if (!candidate) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const definition = parseRuntimeAgentMarkdownDefinition({
|
|
70
|
+
id: candidate.id,
|
|
71
|
+
content: await readDiscoveryTextFile(candidate.file, context),
|
|
72
|
+
});
|
|
73
|
+
registerMarkdownAgent(definition, candidate.file, result);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
result.errors.push({ file: candidate.file, error: ensureError(error) });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -12,7 +12,7 @@ const recommendations = new Map<string, string>([
|
|
|
12
12
|
["CacheStore", "@veryfront/ext-cache-redis"],
|
|
13
13
|
["TokenCacheStore", "@veryfront/ext-cache-redis"],
|
|
14
14
|
["CSSProcessor", "@veryfront/ext-css-tailwind"],
|
|
15
|
-
["
|
|
15
|
+
["ContentProcessor", "@veryfront/ext-transform-mdx"],
|
|
16
16
|
["DatabaseClient", "@veryfront/ext-postgres"],
|
|
17
17
|
["AuthProvider", "@veryfront/ext-auth-jwt"],
|
|
18
18
|
["TracingExporter", "@veryfront/ext-tracing-opentelemetry"],
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Contract interface for content
|
|
2
|
+
* Contract interface for content processing pipelines.
|
|
3
3
|
*
|
|
4
4
|
* Default implementation: `@veryfront/ext-transform-mdx`
|
|
5
5
|
*
|
|
6
|
-
* Implementations
|
|
7
|
-
* modules. Core's `src/transforms/md/compiler` and
|
|
6
|
+
* Implementations process MDX / Markdown source into renderable JavaScript
|
|
7
|
+
* modules plus extracted metadata. Core's `src/transforms/md/compiler` and
|
|
8
8
|
* `src/transforms/mdx/compiler` delegate to the registered implementation;
|
|
9
9
|
* when none is registered, the compile paths throw an actionable install
|
|
10
10
|
* message pointing at `@veryfront/ext-transform-mdx`.
|
|
@@ -12,21 +12,21 @@
|
|
|
12
12
|
* The two compile methods have the same option shape on purpose so a single
|
|
13
13
|
* dispatcher (see `src/transforms/mdx/compiler/index.ts::compileContent`)
|
|
14
14
|
* can route on file extension. Options match the long-standing
|
|
15
|
-
* `compileMDXRuntime` / `compileMarkdownRuntime` signatures
|
|
15
|
+
* `compileMDXRuntime` / `compileMarkdownRuntime` signatures. Option order
|
|
16
16
|
* and defaults are preserved so the extension boundary is a pure refactor,
|
|
17
17
|
* not a behavior change.
|
|
18
18
|
*
|
|
19
|
-
* @module extensions/transform/content-
|
|
19
|
+
* @module extensions/transform/content-processor
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
/** Compilation mode
|
|
22
|
+
/** Compilation mode. Dev surfaces extra diagnostics. */
|
|
23
23
|
export type CompilationMode = "development" | "production";
|
|
24
24
|
|
|
25
|
-
/** Where the output is destined
|
|
25
|
+
/** Where the output is destined: server-side RSC or browser bundle. */
|
|
26
26
|
export type CompilationTarget = "browser" | "server";
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
export interface
|
|
28
|
+
/** Processing result returned by the content pipeline. */
|
|
29
|
+
export interface ContentProcessingResult {
|
|
30
30
|
/** Compiled ESM source containing the default MDX/MD component export. */
|
|
31
31
|
compiledCode: string;
|
|
32
32
|
/** Front-matter extracted from the source document. */
|
|
@@ -41,9 +41,9 @@ export interface ContentRuntimeBundle {
|
|
|
41
41
|
rawHtml?: string;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/** Options for {@link
|
|
44
|
+
/** Options for {@link ContentProcessor.compileMdx} and {@link ContentProcessor.compileMarkdown}. */
|
|
45
45
|
export interface ContentCompileOptions {
|
|
46
|
-
/** Compilation mode
|
|
46
|
+
/** Compilation mode. Defaults to "production" when omitted. */
|
|
47
47
|
mode?: CompilationMode;
|
|
48
48
|
/** Absolute project root (used for resolving relative import rewrites). */
|
|
49
49
|
projectDir: string;
|
|
@@ -53,7 +53,7 @@ export interface ContentCompileOptions {
|
|
|
53
53
|
frontmatter?: Record<string, unknown>;
|
|
54
54
|
/** Source file path hint (used in error messages + import resolution). */
|
|
55
55
|
filePath?: string;
|
|
56
|
-
/** Compile target
|
|
56
|
+
/** Compile target. Defaults to "server". */
|
|
57
57
|
target?: CompilationTarget;
|
|
58
58
|
/** Base URL used when rewriting bare-specifier imports. */
|
|
59
59
|
baseUrl?: string;
|
|
@@ -64,27 +64,27 @@ export interface ContentCompileOptions {
|
|
|
64
64
|
/**
|
|
65
65
|
* Opaque unified-compatible plugin entry. Kept as `unknown[] | unknown` so
|
|
66
66
|
* the contract surface doesn't require consumers to depend on the `unified`
|
|
67
|
-
* package directly
|
|
67
|
+
* package directly. Callers cast to the plugin-list shape they need.
|
|
68
68
|
*/
|
|
69
69
|
export type ContentPlugin = unknown | [unknown, ...unknown[]];
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* ContentProcessor contract for MDX/Markdown processing.
|
|
73
73
|
*
|
|
74
74
|
* Implementations own the entire pipeline (parser, remark/rehype plugins,
|
|
75
75
|
* MDX compile step, sanitization, HTML wrapping). Core only dispatches by
|
|
76
|
-
* file extension and post-processes the returned
|
|
76
|
+
* file extension and post-processes the returned result.
|
|
77
77
|
*
|
|
78
78
|
* `getRemarkPlugins()` / `getRehypePlugins()` are exposed so build-time MDX
|
|
79
79
|
* compilers (which run their own @mdx-js/mdx invocations) can borrow the
|
|
80
80
|
* canonical plugin list without duplicating it. Runtime compile paths
|
|
81
81
|
* should prefer `compileMdx` / `compileMarkdown`.
|
|
82
82
|
*/
|
|
83
|
-
export interface
|
|
84
|
-
/**
|
|
85
|
-
compileMdx(options: ContentCompileOptions): Promise<
|
|
86
|
-
/**
|
|
87
|
-
compileMarkdown(options: ContentCompileOptions): Promise<
|
|
83
|
+
export interface ContentProcessor {
|
|
84
|
+
/** Process MDX source into compiled code and extracted metadata. */
|
|
85
|
+
compileMdx(options: ContentCompileOptions): Promise<ContentProcessingResult>;
|
|
86
|
+
/** Process plain Markdown into compiled code and extracted metadata. */
|
|
87
|
+
compileMarkdown(options: ContentCompileOptions): Promise<ContentProcessingResult>;
|
|
88
88
|
/** Return the canonical remark plugin list. */
|
|
89
89
|
getRemarkPlugins(): ContentPlugin[];
|
|
90
90
|
/** Return the canonical rehype plugin list. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Content category barrel
|
|
2
|
+
* Content category barrel for the MDX/Markdown content processor contract.
|
|
3
3
|
*
|
|
4
4
|
* @module extensions/transform
|
|
5
5
|
*/
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
// Type aliases (unions / shape aliases)
|
|
8
8
|
import "../../../_dnt.polyfills.js";
|
|
9
9
|
|
|
10
|
-
export type { CompilationMode, CompilationTarget, ContentPlugin } from "./content-
|
|
10
|
+
export type { CompilationMode, CompilationTarget, ContentPlugin } from "./content-processor.js";
|
|
11
11
|
|
|
12
12
|
// Interfaces
|
|
13
13
|
export type {
|
|
14
14
|
ContentCompileOptions,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "./content-
|
|
15
|
+
ContentProcessingResult,
|
|
16
|
+
ContentProcessor,
|
|
17
|
+
} from "./content-processor.js";
|
|
@@ -45,12 +45,17 @@ function resolveAppUrl(baseUrl: string | undefined, env: EnvironmentConfig): str
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function createNotConfiguredResponse(config: OAuthServiceConfig): Response {
|
|
48
|
+
// SEC-009: Do NOT leak internal env var names in the HTTP response body.
|
|
49
|
+
// Operators still need the diagnostic, so log the missing env var names
|
|
50
|
+
// server-side via the existing logger.
|
|
51
|
+
logger.error("OAuth provider not configured", {
|
|
52
|
+
serviceId: config.serviceId,
|
|
53
|
+
displayName: config.displayName,
|
|
54
|
+
missingVars: [config.clientIdEnvVar, config.clientSecretEnvVar],
|
|
55
|
+
});
|
|
48
56
|
return Response.json(
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
details: `Missing ${config.clientIdEnvVar} or ${config.clientSecretEnvVar}`,
|
|
52
|
-
},
|
|
53
|
-
{ status: 500 },
|
|
57
|
+
{ error: `${config.displayName} OAuth not configured` },
|
|
58
|
+
{ status: 503 },
|
|
54
59
|
);
|
|
55
60
|
}
|
|
56
61
|
|
|
@@ -3,8 +3,8 @@ import { resolve as resolveContract } from "../../../extensions/contracts.js";
|
|
|
3
3
|
import type {
|
|
4
4
|
CompilationMode,
|
|
5
5
|
CompilationTarget,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
ContentProcessingResult,
|
|
7
|
+
ContentProcessor,
|
|
8
8
|
} from "../../../extensions/transform/index.js";
|
|
9
9
|
import { createError, toError } from "../../../errors/veryfront-error.js";
|
|
10
10
|
import { withSpan } from "../../../observability/tracing/otlp-setup.js";
|
|
@@ -20,13 +20,13 @@ export function compileMarkdownRuntime(
|
|
|
20
20
|
target: CompilationTarget = "server",
|
|
21
21
|
baseUrl?: string,
|
|
22
22
|
studioEmbed?: boolean,
|
|
23
|
-
): Promise<
|
|
23
|
+
): Promise<ContentProcessingResult> {
|
|
24
24
|
return withSpan(
|
|
25
25
|
"transforms.compileMarkdownRuntime",
|
|
26
|
-
async (): Promise<
|
|
26
|
+
async (): Promise<ContentProcessingResult> => {
|
|
27
27
|
try {
|
|
28
|
-
const
|
|
29
|
-
return await
|
|
28
|
+
const processor = resolveContract<ContentProcessor>("ContentProcessor");
|
|
29
|
+
return await processor.compileMarkdown({
|
|
30
30
|
mode,
|
|
31
31
|
projectDir,
|
|
32
32
|
content,
|
|
@@ -10,7 +10,7 @@ export { rewriteBodyImports, rewriteCompiledImports } from "./import-rewriter.js
|
|
|
10
10
|
export type {
|
|
11
11
|
CompilationMode,
|
|
12
12
|
CompilationTarget,
|
|
13
|
-
|
|
13
|
+
ContentProcessingResult,
|
|
14
14
|
} from "../../../extensions/transform/index.js";
|
|
15
15
|
export type { FrontmatterExtractionResult } from "./frontmatter-extractor.js";
|
|
16
16
|
export type { ImportRewriterConfig } from "./import-rewriter.js";
|
|
@@ -20,7 +20,7 @@ import { compileMarkdownRuntime } from "../../md/compiler/index.js";
|
|
|
20
20
|
import type {
|
|
21
21
|
CompilationMode,
|
|
22
22
|
CompilationTarget,
|
|
23
|
-
|
|
23
|
+
ContentProcessingResult,
|
|
24
24
|
} from "../../../extensions/transform/index.js";
|
|
25
25
|
|
|
26
26
|
function isMarkdownFile(filePath?: string): boolean {
|
|
@@ -36,7 +36,7 @@ export function compileContent(
|
|
|
36
36
|
target: CompilationTarget = "server",
|
|
37
37
|
baseUrl?: string,
|
|
38
38
|
studioEmbed?: boolean,
|
|
39
|
-
): Promise<
|
|
39
|
+
): Promise<ContentProcessingResult> {
|
|
40
40
|
if (isMarkdownFile(filePath)) {
|
|
41
41
|
return compileMarkdownRuntime(
|
|
42
42
|
mode,
|
|
@@ -3,8 +3,8 @@ import { resolve as resolveContract } from "../../../extensions/contracts.js";
|
|
|
3
3
|
import type {
|
|
4
4
|
CompilationMode,
|
|
5
5
|
CompilationTarget,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
ContentProcessingResult,
|
|
7
|
+
ContentProcessor,
|
|
8
8
|
} from "../../../extensions/transform/index.js";
|
|
9
9
|
import { createError, toError } from "../../../errors/veryfront-error.js";
|
|
10
10
|
import { withSpan } from "../../../observability/tracing/otlp-setup.js";
|
|
@@ -20,13 +20,13 @@ export function compileMDXRuntime(
|
|
|
20
20
|
target: CompilationTarget = "server",
|
|
21
21
|
baseUrl?: string,
|
|
22
22
|
studioEmbed?: boolean,
|
|
23
|
-
): Promise<
|
|
23
|
+
): Promise<ContentProcessingResult> {
|
|
24
24
|
return withSpan(
|
|
25
25
|
"transforms.compileMDXRuntime",
|
|
26
26
|
async () => {
|
|
27
27
|
try {
|
|
28
|
-
const
|
|
29
|
-
return await
|
|
28
|
+
const processor = resolveContract<ContentProcessor>("ContentProcessor");
|
|
29
|
+
return await processor.compileMdx({
|
|
30
30
|
mode,
|
|
31
31
|
projectDir,
|
|
32
32
|
content,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shim that routes MDX plugin lookups through the `
|
|
2
|
+
* Shim that routes MDX plugin lookups through the `ContentProcessor`
|
|
3
3
|
* extension contract (default implementation: `@veryfront/ext-transform-mdx`).
|
|
4
4
|
*
|
|
5
5
|
* Build-time MDX compilers (`src/build/compiler/mdx-compiler/mdx-processor.ts`,
|
|
6
6
|
* `src/build/renderer/services/mdx-bundler.ts`, `layout-applicator.ts`)
|
|
7
7
|
* historically imported `getRemarkPlugins` / `getRehypePlugins` directly.
|
|
8
8
|
* Now those callers get the canonical plugin list from whichever
|
|
9
|
-
* `
|
|
9
|
+
* `ContentProcessor` implementation is registered.
|
|
10
10
|
*
|
|
11
11
|
* When no implementation is registered, the lookup throws with an
|
|
12
12
|
* actionable install message pointing at `@veryfront/ext-transform-mdx`.
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
import type { Pluggable } from "unified";
|
|
18
18
|
import { resolve as resolveContract } from "../../extensions/contracts.js";
|
|
19
|
-
import type {
|
|
19
|
+
import type { ContentProcessor } from "../../extensions/transform/index.js";
|
|
20
20
|
|
|
21
21
|
export function getRemarkPlugins(): Pluggable[] {
|
|
22
|
-
const
|
|
23
|
-
return
|
|
22
|
+
const processor = resolveContract<ContentProcessor>("ContentProcessor");
|
|
23
|
+
return processor.getRemarkPlugins() as unknown as Pluggable[];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export function getRehypePlugins(): Pluggable[] {
|
|
27
|
-
const
|
|
28
|
-
return
|
|
27
|
+
const processor = resolveContract<ContentProcessor>("ContentProcessor");
|
|
28
|
+
return processor.getRehypePlugins() as unknown as Pluggable[];
|
|
29
29
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-content-transformer.d.ts","sourceRoot":"","sources":["../../../src/cli/shared/ensure-content-transformer.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAGtD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-transformer.d.ts","sourceRoot":"","sources":["../../../../src/src/extensions/transform/content-transformer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,yDAAyD;AACzD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,YAAY,CAAC;AAE3D,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAErD,2DAA2D;AAC3D,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,YAAY,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,gEAAgE;IAChE,QAAQ,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzD,kEAAkE;IAClE,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wGAAwG;AACxG,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC1E,oDAAoD;IACpD,eAAe,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/E,+CAA+C;IAC/C,gBAAgB,IAAI,aAAa,EAAE,CAAC;IACpC,+CAA+C;IAC/C,gBAAgB,IAAI,aAAa,EAAE,CAAC;CACrC"}
|