mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 19:43:19 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
73
openclaw/extensions/webhooks/src/config.ts
Normal file
73
openclaw/extensions/webhooks/src/config.ts
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
import { z } from "zod";
|
||||
import { normalizeWebhookPath } from "../runtime-api.js";
|
||||
|
||||
const secretRefSchema = z
|
||||
.object({
|
||||
source: z.enum(["env", "file", "exec"]),
|
||||
provider: z.string().trim().min(1),
|
||||
id: z.string().trim().min(1),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const secretInputSchema = z.union([z.string().trim().min(1), secretRefSchema]);
|
||||
|
||||
const webhookRouteConfigSchema = z
|
||||
.object({
|
||||
enabled: z.boolean().optional().default(true),
|
||||
path: z.string().trim().min(1).optional(),
|
||||
sessionKey: z.string().trim().min(1),
|
||||
secret: secretInputSchema,
|
||||
controllerId: z.string().trim().min(1).optional(),
|
||||
description: z.string().trim().min(1).optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const webhooksPluginConfigSchema = z
|
||||
.object({
|
||||
routes: z.record(z.string().trim().min(1), webhookRouteConfigSchema).default({}),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type WebhookSecretInput = z.infer<typeof secretInputSchema>;
|
||||
|
||||
export type ConfiguredWebhookRouteConfig = {
|
||||
routeId: string;
|
||||
path: string;
|
||||
sessionKey: string;
|
||||
secret: WebhookSecretInput;
|
||||
controllerId: string;
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export function resolveWebhooksPluginConfig(params: {
|
||||
pluginConfig: unknown;
|
||||
}): ConfiguredWebhookRouteConfig[] {
|
||||
const parsed = webhooksPluginConfigSchema.parse(params.pluginConfig ?? {});
|
||||
const configuredRoutes: ConfiguredWebhookRouteConfig[] = [];
|
||||
const seenPaths = new Map<string, string>();
|
||||
|
||||
for (const [routeId, route] of Object.entries(parsed.routes)) {
|
||||
if (!route.enabled) {
|
||||
continue;
|
||||
}
|
||||
const path = normalizeWebhookPath(route.path ?? `/plugins/webhooks/${routeId}`);
|
||||
const existingRouteId = seenPaths.get(path);
|
||||
if (existingRouteId) {
|
||||
throw new Error(
|
||||
`webhooks.routes.${routeId}.path conflicts with routes.${existingRouteId}.path (${path}).`,
|
||||
);
|
||||
}
|
||||
|
||||
seenPaths.set(path, routeId);
|
||||
configuredRoutes.push({
|
||||
routeId,
|
||||
path,
|
||||
sessionKey: route.sessionKey,
|
||||
secret: route.secret,
|
||||
controllerId: route.controllerId ?? `webhooks/${routeId}`,
|
||||
...(route.description ? { description: route.description } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
return configuredRoutes;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue