mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-19 04:13:18 +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
|
|
@ -0,0 +1,98 @@
|
|||
import * as bundledChannelModule from "../../../src/channels/plugins/bundled.js";
|
||||
import type {
|
||||
ChannelConfigRuntimeSchema,
|
||||
ChannelConfigSchema,
|
||||
} from "../../../src/channels/plugins/types.plugin.js";
|
||||
import { listBundledPluginMetadata } from "../../../src/plugins/bundled-plugin-metadata.js";
|
||||
|
||||
type BundledChannelRuntimeMap = ReadonlyMap<string, ChannelConfigRuntimeSchema>;
|
||||
type BundledChannelConfigSchemaMap = ReadonlyMap<string, ChannelConfigSchema>;
|
||||
type BundledChannelPluginShape = {
|
||||
id: string;
|
||||
configSchema?: ChannelConfigSchema;
|
||||
};
|
||||
type BundledChannelMaps = {
|
||||
runtimeMap: Map<string, ChannelConfigRuntimeSchema>;
|
||||
configSchemaMap: Map<string, ChannelConfigSchema>;
|
||||
};
|
||||
|
||||
let cachedBundledChannelMaps: BundledChannelMaps | undefined;
|
||||
|
||||
function buildBundledChannelMaps(
|
||||
plugins: readonly BundledChannelPluginShape[],
|
||||
): BundledChannelMaps {
|
||||
const runtimeMap = new Map<string, ChannelConfigRuntimeSchema>();
|
||||
const configSchemaMap = new Map<string, ChannelConfigSchema>();
|
||||
|
||||
for (const plugin of plugins) {
|
||||
const channelSchema = plugin.configSchema;
|
||||
if (!channelSchema) {
|
||||
continue;
|
||||
}
|
||||
configSchemaMap.set(plugin.id, channelSchema);
|
||||
if (channelSchema.runtime) {
|
||||
runtimeMap.set(plugin.id, channelSchema.runtime);
|
||||
}
|
||||
}
|
||||
|
||||
for (const entry of listBundledPluginMetadata({ includeChannelConfigs: true })) {
|
||||
const channelConfigs = entry.manifest.channelConfigs;
|
||||
if (!channelConfigs) {
|
||||
continue;
|
||||
}
|
||||
for (const [channelId, channelConfig] of Object.entries(channelConfigs)) {
|
||||
const channelSchema = channelConfig?.schema as Record<string, unknown> | undefined;
|
||||
if (!channelSchema) {
|
||||
continue;
|
||||
}
|
||||
if (!configSchemaMap.has(channelId)) {
|
||||
configSchemaMap.set(channelId, {
|
||||
schema: channelSchema,
|
||||
...(channelConfig.runtime ? { runtime: channelConfig.runtime } : {}),
|
||||
...(channelConfig.uiHints ? { uiHints: channelConfig.uiHints } : {}),
|
||||
});
|
||||
}
|
||||
if (channelConfig.runtime && !runtimeMap.has(channelId)) {
|
||||
runtimeMap.set(channelId, channelConfig.runtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { runtimeMap, configSchemaMap };
|
||||
}
|
||||
|
||||
function readBundledChannelPlugins(): readonly BundledChannelPluginShape[] | undefined {
|
||||
try {
|
||||
if (typeof bundledChannelModule.listBundledChannelPlugins !== "function") {
|
||||
return undefined;
|
||||
}
|
||||
const plugins = bundledChannelModule.listBundledChannelPlugins();
|
||||
return Array.isArray(plugins) ? (plugins as readonly BundledChannelPluginShape[]) : undefined;
|
||||
} catch (error) {
|
||||
if (error instanceof ReferenceError) {
|
||||
return undefined;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function getBundledChannelMaps(): BundledChannelMaps {
|
||||
const plugins = readBundledChannelPlugins();
|
||||
if (plugins && cachedBundledChannelMaps) {
|
||||
return cachedBundledChannelMaps;
|
||||
}
|
||||
|
||||
const maps = buildBundledChannelMaps(plugins ?? []);
|
||||
if (plugins) {
|
||||
cachedBundledChannelMaps = maps;
|
||||
}
|
||||
return maps;
|
||||
}
|
||||
|
||||
export function getBundledChannelRuntimeMap(): BundledChannelRuntimeMap {
|
||||
return getBundledChannelMaps().runtimeMap;
|
||||
}
|
||||
|
||||
export function getBundledChannelConfigSchemaMap(): BundledChannelConfigSchemaMap {
|
||||
return getBundledChannelMaps().configSchemaMap;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue