@vibe-lark/larkpal 0.1.85 → 0.1.86
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/dist/account-id-BM1T6029-DYjVxojW.mjs +46 -0
- package/dist/activation-context--5yu1dPF-Bwsn3moT.mjs +172 -0
- package/dist/anthropic-TH8ERTXK.mjs +5962 -0
- package/dist/assistant-visible-text-DuFWokAt-CsbII5KS.mjs +596 -0
- package/dist/azure-openai-responses-Bt_Ag9Er.mjs +166 -0
- package/dist/boundary-file-read-BSd9MXPy--KThL5e6.mjs +594 -0
- package/dist/browser-lifecycle-cleanup-BdNsMhMD-O3tnAM4i.mjs +60 -0
- package/dist/build-DgTrEpge.mjs +3333 -0
- package/dist/bundled-compat-BpaDaAAu-D7oazKjD.mjs +5216 -0
- package/dist/bundled-dir-U738ay4K-DXK0q_TV.mjs +258 -0
- package/dist/call-DimWbpgJ-ColD4W-y.mjs +9993 -0
- package/dist/channel-bootstrap.runtime-BVclcGv1-DJv_Z-Kr.mjs +2 -0
- package/dist/channel-bootstrap.runtime-Cwcr38m2-VRfVCR-i.mjs +33 -0
- package/dist/chunk-D6SyT4dJ.mjs +36 -0
- package/dist/cli.mjs +6 -6
- package/dist/command-format-LSnUCVVF-BQ2SMKka.mjs +685 -0
- package/dist/config-Bim2pi8a-BQUdfiEi.mjs +9 -0
- package/dist/delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs +72 -0
- package/dist/diagnostic-ClMwNnUA-D6nUtLnb.mjs +140 -0
- package/dist/dist-CEGw8-2W.mjs +429 -0
- package/dist/dist-DD2aJ2UL.mjs +125135 -0
- package/dist/env-api-keys-BVvSg7T2.mjs +68 -0
- package/dist/event-stream-xaQWmyas.mjs +15226 -0
- package/dist/facade-loader-DFzIYYt_-CIr4HKtE.mjs +194 -0
- package/dist/from-DF7cl2wz.mjs +3842 -0
- package/dist/gateway-method-policy-C7rf0SeV-CJQMEYIE.mjs +28 -0
- package/dist/github-copilot-headers-DjqWtUoP.mjs +22 -0
- package/dist/google-C2pVrgBZ.mjs +336 -0
- package/dist/google-gemini-cli-BBxgS5Ho.mjs +623 -0
- package/dist/google-shared-BsWgwEk1.mjs +22791 -0
- package/dist/google-vertex-BsVLJrrC.mjs +358 -0
- package/dist/hash-DAFtW_W7.mjs +16 -0
- package/dist/headers-R3HdCbAE.mjs +8 -0
- package/dist/home-dir-C44RaPME-CBRS4HLP.mjs +93 -0
- package/dist/ids-BPsM98Uu-CwuxvUai.mjs +77 -0
- package/dist/image-2w3cApg7-CxpHvoB5.mjs +207 -0
- package/dist/io-CH2g3vsv-BOGlLlB8.mjs +26218 -0
- package/dist/jiti-loader-cache-Bat69wam-D6hCxboy.mjs +5049 -0
- package/dist/json-file-BQRNuxmK-DhJM5NsG.mjs +108 -0
- package/dist/json-parse-v_HIJjjI.mjs +381 -0
- package/dist/jws-GFcTvvVT.mjs +2291 -0
- package/dist/{lark-cli-provider-7LvtOIF_.mjs → lark-cli-provider-BARgbbmo.mjs} +1 -1
- package/dist/{live-smoke-nvTUPtrv.mjs → live-smoke-BhkBOcH9.mjs} +3 -3
- package/dist/load-context-mb7uvLSn-B10MAi3I.mjs +29 -0
- package/dist/loader-708jrx4Y-BOswuvpe.mjs +5053 -0
- package/dist/main.mjs +56550 -205
- package/dist/manifest-registry-_hxKCS2K-CZdeyN0f.mjs +3512 -0
- package/dist/mcp-server.mjs +1 -1
- package/dist/message-channel-Bk_YHfQg-AeNrPPpp.mjs +50 -0
- package/dist/message-channel-core-DTA--Gjh-CY4Tkb7N.mjs +29 -0
- package/dist/message.config.runtime-K-k4XOyq-DZTmXomP.mjs +2 -0
- package/dist/message.gateway.runtime-DqHOHRTQ-DH4ml0YF.mjs +2 -0
- package/dist/mistral-CaR4DiLu.mjs +28657 -0
- package/dist/model-auth-env-oyg2Hexc-DU_rOUU5.mjs +1306 -0
- package/dist/models-config-BmpSQJQF-Gfvh1n3A.mjs +1282 -0
- package/dist/models-config.runtime-BsU_22xk.mjs +2 -0
- package/dist/multipart-parser-DedmaB5g.mjs +294 -0
- package/dist/oauth-DOJeGfcE.mjs +6392 -0
- package/dist/openai-BDtIh3Ja.mjs +6693 -0
- package/dist/openai-codex-responses-C5EORu31.mjs +664 -0
- package/dist/openai-completions-CR_cS6gX.mjs +669 -0
- package/dist/openai-responses-oGxwZyuC.mjs +184 -0
- package/dist/openai-responses-shared-BixMSDZE.mjs +398 -0
- package/dist/paths-D6msg0S1-C2lYuisN.mjs +189 -0
- package/dist/paths-D92DjaZ--CTOESW2b.mjs +192 -0
- package/dist/pi-model-discovery-Bd0TWzo8-BFsJmeMb.mjs +227 -0
- package/dist/pi-model-discovery-runtime-CCCZxkd8.mjs +2 -0
- package/dist/pi-tools.before-tool-call.runtime-Bn7uqKie-C5ewk8kK.mjs +399 -0
- package/dist/plugin-auto-enable-DdH3n9V8-DsA1isaF.mjs +1456 -0
- package/dist/process-scoped-map-B2cWkYET-CXwUZ8CZ.mjs +61 -0
- package/dist/provider-discovery.runtime-BPzz1PFj.mjs +58 -0
- package/dist/provider-model-compat-CFqcq0it-BDDuBI3A.mjs +118 -0
- package/dist/provider-runtime-C8rljsNs-CIT93zoy.mjs +2 -0
- package/dist/provider-runtime-CT50mNIX-BwEV6GyO.mjs +573 -0
- package/dist/provider-stream-COLujAAo-CbJPDngm.mjs +35449 -0
- package/dist/providers.runtime-Ba7tOlq7-CXkhkzU9.mjs +219 -0
- package/dist/public-surface-loader-BVl0NQAE-C0piXtsT.mjs +117 -0
- package/dist/resolve-C33B7eeu-BNvYTl6k.mjs +1041 -0
- package/dist/runtime-Cym-fqI8-DaSDMH-a.mjs +120 -0
- package/dist/runtime-channel-state-CohMybAh-hXR6y5Gx.mjs +19 -0
- package/dist/runtime-snapshot-C54O1-gI-40cbyi7P.mjs +677 -0
- package/dist/runtime-state-IBOIXKOx-Bf9tcLvc.mjs +10 -0
- package/dist/runtime-web-tools-fallback.runtime-Ca-qn1mj-BCVImm7a.mjs +39 -0
- package/dist/runtime-web-tools-manifest.runtime-BgxQTjmq-Cb4nJkRT.mjs +2 -0
- package/dist/runtime-web-tools-public-artifacts.runtime-D9qcoWIX-BrQdXzOQ.mjs +2 -0
- package/dist/session-archive.runtime-B52_5vs4-BG-_IwNJ.mjs +2 -0
- package/dist/session-key-Cn2QoOyX-CuHbJMgR.mjs +82 -0
- package/dist/session-transcript-files.fs-DEeFXruQ-B1PF6nLy.mjs +147 -0
- package/dist/src-BgCX0MLG.mjs +813 -0
- package/dist/src-DYbqlAqf.mjs +1177 -0
- package/dist/subagent-announce-L5WsQatW-CQWI9GMd.mjs +344 -0
- package/dist/subagent-announce.registry.runtime-DiqZyeTs-BKuniyi3.mjs +28 -0
- package/dist/subagent-registry-steer-runtime-DFgZFC0j-BhBz0roy.mjs +211 -0
- package/dist/subagent-system-prompt-C1qnN--K-DpnTFP47.mjs +3061 -0
- package/dist/target-parsing-loaded-DKkb6jJY-BMD4CkpS.mjs +1002 -0
- package/dist/task-registry-delivery-runtime-Dd1CUkZF-C8U40a3O.mjs +2950 -0
- package/dist/task-registry-delivery-runtime-ragbeVx5-CNbFAkjD.mjs +2 -0
- package/dist/thinking-Bh-7MqXz-D3woGbO7.mjs +2 -0
- package/dist/transcript-E_-ISOkD-DWCfZP2p.mjs +2019 -0
- package/dist/transcript.runtime-BqhvZZdl-BPy42vBP.mjs +2 -0
- package/dist/transform-messages-DbhIzTxq.mjs +207 -0
- package/dist/web-provider-public-artifacts-BlpRwIUS-CGPSV4W2.mjs +295 -0
- package/dist/web-search-providers.runtime--0aUtC3b-DyuhC95V.mjs +200 -0
- package/package.json +3 -3
- package/dist/rolldown-runtime-wcPFST8Q.mjs +0 -13
- /package/dist/{interactive-init-B6j8j_Ap.mjs → interactive-init-BXQBalNr.mjs} +0 -0
|
@@ -0,0 +1,1456 @@
|
|
|
1
|
+
import { a as hasNonEmptyString$1, c as normalizeOptionalString, s as normalizeOptionalLowercaseString } from "./home-dir-C44RaPME-CBRS4HLP.mjs";
|
|
2
|
+
import { o as resolveStateDir, s as isBlockedObjectKey } from "./paths-D92DjaZ--CTOESW2b.mjs";
|
|
3
|
+
import { c as resolveConfigDir, l as resolveUserPath, s as isRecord } from "./bundled-dir-U738ay4K-DXK0q_TV.mjs";
|
|
4
|
+
import { i as normalizeChatChannelId } from "./ids-BPsM98Uu-CwuxvUai.mjs";
|
|
5
|
+
import { Ft as getChatChannelMeta, Mt as formatErrorMessage, S as normalizePluginsConfig, St as createSubsystemLogger, a as getBootstrapChannelPlugin, f as loadChannelPluginModule, h as isJavaScriptModulePath, l as normalizeProviderId, m as resolveExistingPluginModulePath, o as listBundledChannelPluginIds, r as withBundledPluginVitestCompat, s as listChannelCatalogEntries, w as resolveEffectivePluginActivationState } from "./bundled-compat-BpaDaAAu-D7oazKjD.mjs";
|
|
6
|
+
import { M as normalizeStringEntries, _ as discoverOpenClawPlugins, c as resolveManifestContractOwnerPluginId, l as resolveManifestContractPluginIds, o as loadPluginManifestRegistry, v as resolvePluginCacheInputs } from "./manifest-registry-_hxKCS2K-CZdeyN0f.mjs";
|
|
7
|
+
import { t as getCachedPluginJitiLoader } from "./jiti-loader-cache-Bat69wam-D6hCxboy.mjs";
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import os from "node:os";
|
|
12
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/persisted-auth-state-Cl6A4BLr.js
|
|
13
|
+
function normalizePluginIdScope(ids) {
|
|
14
|
+
if (ids === void 0) return;
|
|
15
|
+
return Array.from(new Set(ids.filter((id) => typeof id === "string").map((id) => id.trim()).filter(Boolean))).toSorted();
|
|
16
|
+
}
|
|
17
|
+
function hasExplicitPluginIdScope(ids) {
|
|
18
|
+
return ids !== void 0;
|
|
19
|
+
}
|
|
20
|
+
function createPluginIdScopeSet(ids) {
|
|
21
|
+
if (ids === void 0) return null;
|
|
22
|
+
return new Set(ids);
|
|
23
|
+
}
|
|
24
|
+
function serializePluginIdScope(ids) {
|
|
25
|
+
return ids === void 0 ? "__unscoped__" : JSON.stringify(ids);
|
|
26
|
+
}
|
|
27
|
+
const log = createSubsystemLogger("channels");
|
|
28
|
+
const registryCache = /* @__PURE__ */ new Map();
|
|
29
|
+
function resolveChannelPackageStateMetadata(entry, metadataKey) {
|
|
30
|
+
const metadata = entry.channel[metadataKey];
|
|
31
|
+
if (!metadata || typeof metadata !== "object") return null;
|
|
32
|
+
const specifier = normalizeOptionalString(metadata.specifier) ?? "";
|
|
33
|
+
const exportName = normalizeOptionalString(metadata.exportName) ?? "";
|
|
34
|
+
if (!specifier || !exportName) return null;
|
|
35
|
+
return {
|
|
36
|
+
specifier,
|
|
37
|
+
exportName
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function getChannelPackageStateRegistry(metadataKey) {
|
|
41
|
+
const cached = registryCache.get(metadataKey);
|
|
42
|
+
if (cached) return cached;
|
|
43
|
+
const catalog = listChannelCatalogEntries({ origin: "bundled" }).filter((entry) => Boolean(resolveChannelPackageStateMetadata(entry, metadataKey)));
|
|
44
|
+
const registry = {
|
|
45
|
+
catalog,
|
|
46
|
+
entriesById: new Map(catalog.map((entry) => [entry.pluginId, entry])),
|
|
47
|
+
checkerCache: /* @__PURE__ */ new Map()
|
|
48
|
+
};
|
|
49
|
+
registryCache.set(metadataKey, registry);
|
|
50
|
+
return registry;
|
|
51
|
+
}
|
|
52
|
+
function resolveChannelPackageStateChecker(params) {
|
|
53
|
+
const registry = getChannelPackageStateRegistry(params.metadataKey);
|
|
54
|
+
const cached = registry.checkerCache.get(params.entry.pluginId);
|
|
55
|
+
if (cached !== void 0) return cached;
|
|
56
|
+
const metadata = resolveChannelPackageStateMetadata(params.entry, params.metadataKey);
|
|
57
|
+
if (!metadata) {
|
|
58
|
+
registry.checkerCache.set(params.entry.pluginId, null);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const checker = loadChannelPluginModule({
|
|
63
|
+
modulePath: resolveExistingPluginModulePath(params.entry.rootDir, metadata.specifier),
|
|
64
|
+
rootDir: params.entry.rootDir,
|
|
65
|
+
shouldTryNativeRequire: isJavaScriptModulePath
|
|
66
|
+
})[metadata.exportName];
|
|
67
|
+
if (typeof checker !== "function") throw new Error(`missing ${params.metadataKey} export ${metadata.exportName}`);
|
|
68
|
+
registry.checkerCache.set(params.entry.pluginId, checker);
|
|
69
|
+
return checker;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const detail = formatErrorMessage(error);
|
|
72
|
+
log.warn(`[channels] failed to load ${params.metadataKey} checker for ${params.entry.pluginId}: ${detail}`);
|
|
73
|
+
registry.checkerCache.set(params.entry.pluginId, null);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function listBundledChannelIdsForPackageState(metadataKey) {
|
|
78
|
+
return getChannelPackageStateRegistry(metadataKey).catalog.map((entry) => entry.pluginId);
|
|
79
|
+
}
|
|
80
|
+
function hasBundledChannelPackageState(params) {
|
|
81
|
+
const entry = getChannelPackageStateRegistry(params.metadataKey).entriesById.get(params.channelId);
|
|
82
|
+
if (!entry) return false;
|
|
83
|
+
const checker = resolveChannelPackageStateChecker({
|
|
84
|
+
entry,
|
|
85
|
+
metadataKey: params.metadataKey
|
|
86
|
+
});
|
|
87
|
+
return checker ? checker({
|
|
88
|
+
cfg: params.cfg,
|
|
89
|
+
env: params.env
|
|
90
|
+
}) : false;
|
|
91
|
+
}
|
|
92
|
+
function listBundledChannelIdsWithPersistedAuthState() {
|
|
93
|
+
return listBundledChannelIdsForPackageState("persistedAuthState");
|
|
94
|
+
}
|
|
95
|
+
function hasBundledChannelPersistedAuthState(params) {
|
|
96
|
+
return hasBundledChannelPackageState({
|
|
97
|
+
metadataKey: "persistedAuthState",
|
|
98
|
+
channelId: params.channelId,
|
|
99
|
+
cfg: params.cfg,
|
|
100
|
+
env: params.env
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/api-builder-d3jBS7ML.js
|
|
105
|
+
const noopRegisterTool = () => {};
|
|
106
|
+
const noopRegisterHook = () => {};
|
|
107
|
+
const noopRegisterHttpRoute = () => {};
|
|
108
|
+
const noopRegisterChannel = () => {};
|
|
109
|
+
const noopRegisterGatewayMethod = () => {};
|
|
110
|
+
const noopRegisterCli = () => {};
|
|
111
|
+
const noopRegisterReload = () => {};
|
|
112
|
+
const noopRegisterNodeHostCommand = () => {};
|
|
113
|
+
const noopRegisterSecurityAuditCollector = () => {};
|
|
114
|
+
const noopRegisterService = () => {};
|
|
115
|
+
const noopRegisterCliBackend = () => {};
|
|
116
|
+
const noopRegisterTextTransforms = () => {};
|
|
117
|
+
const noopRegisterConfigMigration = () => {};
|
|
118
|
+
const noopRegisterAutoEnableProbe = () => {};
|
|
119
|
+
const noopRegisterProvider = () => {};
|
|
120
|
+
const noopRegisterSpeechProvider = () => {};
|
|
121
|
+
const noopRegisterRealtimeTranscriptionProvider = () => {};
|
|
122
|
+
const noopRegisterRealtimeVoiceProvider = () => {};
|
|
123
|
+
const noopRegisterMediaUnderstandingProvider = () => {};
|
|
124
|
+
const noopRegisterImageGenerationProvider = () => {};
|
|
125
|
+
const noopRegisterVideoGenerationProvider = () => {};
|
|
126
|
+
const noopRegisterMusicGenerationProvider = () => {};
|
|
127
|
+
const noopRegisterWebFetchProvider = () => {};
|
|
128
|
+
const noopRegisterWebSearchProvider = () => {};
|
|
129
|
+
const noopRegisterInteractiveHandler = () => {};
|
|
130
|
+
const noopOnConversationBindingResolved = () => {};
|
|
131
|
+
const noopRegisterCommand = () => {};
|
|
132
|
+
const noopRegisterContextEngine = () => {};
|
|
133
|
+
const noopRegisterCompactionProvider = () => {};
|
|
134
|
+
const noopRegisterAgentHarness = () => {};
|
|
135
|
+
const noopRegisterEmbeddedExtensionFactory = () => {};
|
|
136
|
+
const noopRegisterCodexAppServerExtensionFactory = () => {};
|
|
137
|
+
const noopRegisterDetachedTaskRuntime = () => {};
|
|
138
|
+
const noopRegisterMemoryCapability = () => {};
|
|
139
|
+
const noopRegisterMemoryPromptSection = () => {};
|
|
140
|
+
const noopRegisterMemoryPromptSupplement = () => {};
|
|
141
|
+
const noopRegisterMemoryCorpusSupplement = () => {};
|
|
142
|
+
const noopRegisterMemoryFlushPlan = () => {};
|
|
143
|
+
const noopRegisterMemoryRuntime = () => {};
|
|
144
|
+
const noopRegisterMemoryEmbeddingProvider = () => {};
|
|
145
|
+
const noopOn = () => {};
|
|
146
|
+
function buildPluginApi(params) {
|
|
147
|
+
const handlers = params.handlers ?? {};
|
|
148
|
+
return {
|
|
149
|
+
id: params.id,
|
|
150
|
+
name: params.name,
|
|
151
|
+
version: params.version,
|
|
152
|
+
description: params.description,
|
|
153
|
+
source: params.source,
|
|
154
|
+
rootDir: params.rootDir,
|
|
155
|
+
registrationMode: params.registrationMode,
|
|
156
|
+
config: params.config,
|
|
157
|
+
pluginConfig: params.pluginConfig,
|
|
158
|
+
runtime: params.runtime,
|
|
159
|
+
logger: params.logger,
|
|
160
|
+
registerTool: handlers.registerTool ?? noopRegisterTool,
|
|
161
|
+
registerHook: handlers.registerHook ?? noopRegisterHook,
|
|
162
|
+
registerHttpRoute: handlers.registerHttpRoute ?? noopRegisterHttpRoute,
|
|
163
|
+
registerChannel: handlers.registerChannel ?? noopRegisterChannel,
|
|
164
|
+
registerGatewayMethod: handlers.registerGatewayMethod ?? noopRegisterGatewayMethod,
|
|
165
|
+
registerCli: handlers.registerCli ?? noopRegisterCli,
|
|
166
|
+
registerReload: handlers.registerReload ?? noopRegisterReload,
|
|
167
|
+
registerNodeHostCommand: handlers.registerNodeHostCommand ?? noopRegisterNodeHostCommand,
|
|
168
|
+
registerSecurityAuditCollector: handlers.registerSecurityAuditCollector ?? noopRegisterSecurityAuditCollector,
|
|
169
|
+
registerService: handlers.registerService ?? noopRegisterService,
|
|
170
|
+
registerCliBackend: handlers.registerCliBackend ?? noopRegisterCliBackend,
|
|
171
|
+
registerTextTransforms: handlers.registerTextTransforms ?? noopRegisterTextTransforms,
|
|
172
|
+
registerConfigMigration: handlers.registerConfigMigration ?? noopRegisterConfigMigration,
|
|
173
|
+
registerAutoEnableProbe: handlers.registerAutoEnableProbe ?? noopRegisterAutoEnableProbe,
|
|
174
|
+
registerProvider: handlers.registerProvider ?? noopRegisterProvider,
|
|
175
|
+
registerSpeechProvider: handlers.registerSpeechProvider ?? noopRegisterSpeechProvider,
|
|
176
|
+
registerRealtimeTranscriptionProvider: handlers.registerRealtimeTranscriptionProvider ?? noopRegisterRealtimeTranscriptionProvider,
|
|
177
|
+
registerRealtimeVoiceProvider: handlers.registerRealtimeVoiceProvider ?? noopRegisterRealtimeVoiceProvider,
|
|
178
|
+
registerMediaUnderstandingProvider: handlers.registerMediaUnderstandingProvider ?? noopRegisterMediaUnderstandingProvider,
|
|
179
|
+
registerImageGenerationProvider: handlers.registerImageGenerationProvider ?? noopRegisterImageGenerationProvider,
|
|
180
|
+
registerVideoGenerationProvider: handlers.registerVideoGenerationProvider ?? noopRegisterVideoGenerationProvider,
|
|
181
|
+
registerMusicGenerationProvider: handlers.registerMusicGenerationProvider ?? noopRegisterMusicGenerationProvider,
|
|
182
|
+
registerWebFetchProvider: handlers.registerWebFetchProvider ?? noopRegisterWebFetchProvider,
|
|
183
|
+
registerWebSearchProvider: handlers.registerWebSearchProvider ?? noopRegisterWebSearchProvider,
|
|
184
|
+
registerInteractiveHandler: handlers.registerInteractiveHandler ?? noopRegisterInteractiveHandler,
|
|
185
|
+
onConversationBindingResolved: handlers.onConversationBindingResolved ?? noopOnConversationBindingResolved,
|
|
186
|
+
registerCommand: handlers.registerCommand ?? noopRegisterCommand,
|
|
187
|
+
registerContextEngine: handlers.registerContextEngine ?? noopRegisterContextEngine,
|
|
188
|
+
registerCompactionProvider: handlers.registerCompactionProvider ?? noopRegisterCompactionProvider,
|
|
189
|
+
registerAgentHarness: handlers.registerAgentHarness ?? noopRegisterAgentHarness,
|
|
190
|
+
registerEmbeddedExtensionFactory: handlers.registerEmbeddedExtensionFactory ?? noopRegisterEmbeddedExtensionFactory,
|
|
191
|
+
registerCodexAppServerExtensionFactory: handlers.registerCodexAppServerExtensionFactory ?? noopRegisterCodexAppServerExtensionFactory,
|
|
192
|
+
registerDetachedTaskRuntime: handlers.registerDetachedTaskRuntime ?? noopRegisterDetachedTaskRuntime,
|
|
193
|
+
registerMemoryCapability: handlers.registerMemoryCapability ?? noopRegisterMemoryCapability,
|
|
194
|
+
registerMemoryPromptSection: handlers.registerMemoryPromptSection ?? noopRegisterMemoryPromptSection,
|
|
195
|
+
registerMemoryPromptSupplement: handlers.registerMemoryPromptSupplement ?? noopRegisterMemoryPromptSupplement,
|
|
196
|
+
registerMemoryCorpusSupplement: handlers.registerMemoryCorpusSupplement ?? noopRegisterMemoryCorpusSupplement,
|
|
197
|
+
registerMemoryFlushPlan: handlers.registerMemoryFlushPlan ?? noopRegisterMemoryFlushPlan,
|
|
198
|
+
registerMemoryRuntime: handlers.registerMemoryRuntime ?? noopRegisterMemoryRuntime,
|
|
199
|
+
registerMemoryEmbeddingProvider: handlers.registerMemoryEmbeddingProvider ?? noopRegisterMemoryEmbeddingProvider,
|
|
200
|
+
resolvePath: params.resolvePath,
|
|
201
|
+
on: handlers.on ?? noopOn
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/channel-configured-CdNwff8K.js
|
|
206
|
+
function hasBundledChannelConfiguredState(params) {
|
|
207
|
+
return hasBundledChannelPackageState({
|
|
208
|
+
metadataKey: "configuredState",
|
|
209
|
+
channelId: params.channelId,
|
|
210
|
+
cfg: params.cfg,
|
|
211
|
+
env: params.env
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function resolveChannelConfigRecord(cfg, channelId) {
|
|
215
|
+
const entry = cfg.channels?.[channelId];
|
|
216
|
+
return isRecord(entry) ? entry : null;
|
|
217
|
+
}
|
|
218
|
+
function hasMeaningfulChannelConfigShallow(value) {
|
|
219
|
+
if (!isRecord(value)) return false;
|
|
220
|
+
return Object.keys(value).some((key) => key !== "enabled");
|
|
221
|
+
}
|
|
222
|
+
function isChannelConfigured(cfg, channelId, env = process.env) {
|
|
223
|
+
if (hasMeaningfulChannelConfigShallow(resolveChannelConfigRecord(cfg, channelId))) return true;
|
|
224
|
+
if (hasBundledChannelConfiguredState({
|
|
225
|
+
channelId,
|
|
226
|
+
cfg,
|
|
227
|
+
env
|
|
228
|
+
})) return true;
|
|
229
|
+
if (hasBundledChannelPersistedAuthState({
|
|
230
|
+
channelId,
|
|
231
|
+
cfg,
|
|
232
|
+
env
|
|
233
|
+
})) return true;
|
|
234
|
+
const plugin = getBootstrapChannelPlugin(channelId);
|
|
235
|
+
return Boolean(plugin?.config?.hasConfiguredState?.({
|
|
236
|
+
cfg,
|
|
237
|
+
env
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/setup-descriptors-RCxmI-tF.js
|
|
242
|
+
function listSetupProviderIds(record) {
|
|
243
|
+
return record.setup?.providers?.map((entry) => entry.id) ?? record.providers;
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/channel-target-CCaXUjhc.js
|
|
247
|
+
const hasNonEmptyString = hasNonEmptyString$1;
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/manifest-owner-policy-BHAz5kob.js
|
|
250
|
+
function collectConfiguredAgentHarnessRuntimes(config, env) {
|
|
251
|
+
const runtimes = /* @__PURE__ */ new Set();
|
|
252
|
+
const pushRuntime = (value) => {
|
|
253
|
+
if (typeof value !== "string") return;
|
|
254
|
+
const normalized = normalizeOptionalLowercaseString(value);
|
|
255
|
+
if (!normalized || normalized === "auto" || normalized === "pi") return;
|
|
256
|
+
runtimes.add(normalized);
|
|
257
|
+
};
|
|
258
|
+
pushRuntime(config.agents?.defaults?.embeddedHarness?.runtime);
|
|
259
|
+
if (Array.isArray(config.agents?.list)) for (const agent of config.agents.list) {
|
|
260
|
+
if (!isRecord(agent)) continue;
|
|
261
|
+
pushRuntime(agent.embeddedHarness?.runtime);
|
|
262
|
+
}
|
|
263
|
+
pushRuntime(env.OPENCLAW_AGENT_RUNTIME);
|
|
264
|
+
return [...runtimes].toSorted((left, right) => left.localeCompare(right));
|
|
265
|
+
}
|
|
266
|
+
const IGNORED_CHANNEL_CONFIG_KEYS = new Set(["defaults", "modelByChannel"]);
|
|
267
|
+
function hasMeaningfulChannelConfig(value) {
|
|
268
|
+
if (!isRecord(value)) return false;
|
|
269
|
+
return Object.keys(value).some((key) => key !== "enabled");
|
|
270
|
+
}
|
|
271
|
+
function listChannelEnvPrefixes(channelIds) {
|
|
272
|
+
return channelIds.map((channelId) => [`${channelId.replace(/[^a-z0-9]+/gi, "_").toUpperCase()}_`, channelId]);
|
|
273
|
+
}
|
|
274
|
+
function hasPersistedChannelState(env) {
|
|
275
|
+
return fs.existsSync(resolveStateDir(env, os.homedir));
|
|
276
|
+
}
|
|
277
|
+
let persistedAuthStateChannelIds = null;
|
|
278
|
+
function listPersistedAuthStateChannelIds(options) {
|
|
279
|
+
const override = options.persistedAuthStateProbe?.listChannelIds();
|
|
280
|
+
if (override) return override;
|
|
281
|
+
if (persistedAuthStateChannelIds) return persistedAuthStateChannelIds;
|
|
282
|
+
persistedAuthStateChannelIds = listBundledChannelIdsWithPersistedAuthState();
|
|
283
|
+
return persistedAuthStateChannelIds;
|
|
284
|
+
}
|
|
285
|
+
function hasPersistedAuthState(params) {
|
|
286
|
+
const override = params.options.persistedAuthStateProbe;
|
|
287
|
+
if (override) return override.hasState(params);
|
|
288
|
+
return hasBundledChannelPersistedAuthState(params);
|
|
289
|
+
}
|
|
290
|
+
function listPotentialConfiguredChannelIds(cfg, env = process.env, options = {}) {
|
|
291
|
+
return [...new Set(listPotentialConfiguredChannelPresenceSignals(cfg, env, options).map((signal) => signal.channelId))];
|
|
292
|
+
}
|
|
293
|
+
function listPotentialConfiguredChannelPresenceSignals(cfg, env = process.env, options = {}) {
|
|
294
|
+
const signals = [];
|
|
295
|
+
const seenSignals = /* @__PURE__ */ new Set();
|
|
296
|
+
const addSignal = (channelId, source) => {
|
|
297
|
+
const key = `${source}:${channelId}`;
|
|
298
|
+
if (seenSignals.has(key)) return;
|
|
299
|
+
seenSignals.add(key);
|
|
300
|
+
signals.push({
|
|
301
|
+
channelId,
|
|
302
|
+
source
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
const configuredChannelIds = /* @__PURE__ */ new Set();
|
|
306
|
+
const channelEnvPrefixes = listChannelEnvPrefixes(listBundledChannelPluginIds());
|
|
307
|
+
const channels = isRecord(cfg.channels) ? cfg.channels : null;
|
|
308
|
+
if (channels) for (const [key, value] of Object.entries(channels)) {
|
|
309
|
+
if (IGNORED_CHANNEL_CONFIG_KEYS.has(key)) continue;
|
|
310
|
+
if (hasMeaningfulChannelConfig(value)) {
|
|
311
|
+
configuredChannelIds.add(key);
|
|
312
|
+
addSignal(key, "config");
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
for (const [key, value] of Object.entries(env)) {
|
|
316
|
+
if (!hasNonEmptyString(value)) continue;
|
|
317
|
+
for (const [prefix, channelId] of channelEnvPrefixes) if (key.startsWith(prefix)) {
|
|
318
|
+
configuredChannelIds.add(channelId);
|
|
319
|
+
addSignal(channelId, "env");
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (options.includePersistedAuthState !== false && hasPersistedChannelState(env)) {
|
|
323
|
+
for (const channelId of listPersistedAuthStateChannelIds(options)) if (hasPersistedAuthState({
|
|
324
|
+
channelId,
|
|
325
|
+
cfg,
|
|
326
|
+
env,
|
|
327
|
+
options
|
|
328
|
+
})) {
|
|
329
|
+
configuredChannelIds.add(channelId);
|
|
330
|
+
addSignal(channelId, "persisted-auth");
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return signals.filter((signal) => configuredChannelIds.has(signal.channelId));
|
|
334
|
+
}
|
|
335
|
+
function hasEnvConfiguredChannel(cfg, env, options = {}) {
|
|
336
|
+
const channelEnvPrefixes = listChannelEnvPrefixes(listBundledChannelPluginIds());
|
|
337
|
+
for (const [key, value] of Object.entries(env)) {
|
|
338
|
+
if (!hasNonEmptyString(value)) continue;
|
|
339
|
+
if (channelEnvPrefixes.some(([prefix]) => key.startsWith(prefix))) return true;
|
|
340
|
+
}
|
|
341
|
+
if (options.includePersistedAuthState === false || !hasPersistedChannelState(env)) return false;
|
|
342
|
+
return listPersistedAuthStateChannelIds(options).some((channelId) => hasPersistedAuthState({
|
|
343
|
+
channelId,
|
|
344
|
+
cfg,
|
|
345
|
+
env,
|
|
346
|
+
options
|
|
347
|
+
}));
|
|
348
|
+
}
|
|
349
|
+
function hasPotentialConfiguredChannels(cfg, env = process.env, options = {}) {
|
|
350
|
+
const channels = isRecord(cfg?.channels) ? cfg.channels : null;
|
|
351
|
+
if (channels) for (const [key, value] of Object.entries(channels)) {
|
|
352
|
+
if (IGNORED_CHANNEL_CONFIG_KEYS.has(key)) continue;
|
|
353
|
+
if (hasMeaningfulChannelConfig(value)) return true;
|
|
354
|
+
}
|
|
355
|
+
return hasEnvConfiguredChannel(cfg ?? {}, env, options);
|
|
356
|
+
}
|
|
357
|
+
function passesManifestOwnerBasePolicy(params) {
|
|
358
|
+
if (!params.normalizedConfig.enabled) return false;
|
|
359
|
+
if (params.normalizedConfig.deny.includes(params.plugin.id)) return false;
|
|
360
|
+
if (params.normalizedConfig.entries[params.plugin.id]?.enabled === false && params.allowExplicitlyDisabled !== true) return false;
|
|
361
|
+
if (params.allowRestrictiveAllowlistBypass !== true && params.normalizedConfig.allow.length > 0 && !params.normalizedConfig.allow.includes(params.plugin.id)) return false;
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
function isActivatedManifestOwner(params) {
|
|
365
|
+
return resolveEffectivePluginActivationState({
|
|
366
|
+
id: params.plugin.id,
|
|
367
|
+
origin: params.plugin.origin,
|
|
368
|
+
config: params.normalizedConfig,
|
|
369
|
+
rootConfig: params.rootConfig,
|
|
370
|
+
enabledByDefault: params.plugin.enabledByDefault
|
|
371
|
+
}).activated;
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/setup-registry-ivK2QpZk.js
|
|
375
|
+
const SETUP_API_EXTENSIONS = [
|
|
376
|
+
".js",
|
|
377
|
+
".mjs",
|
|
378
|
+
".cjs",
|
|
379
|
+
".ts",
|
|
380
|
+
".mts",
|
|
381
|
+
".cts"
|
|
382
|
+
];
|
|
383
|
+
const CURRENT_MODULE_PATH = fileURLToPath(import.meta.url);
|
|
384
|
+
const RUNNING_FROM_BUILT_ARTIFACT = CURRENT_MODULE_PATH.includes(`${path.sep}dist${path.sep}`) || CURRENT_MODULE_PATH.includes(`${path.sep}dist-runtime${path.sep}`);
|
|
385
|
+
const EMPTY_RUNTIME = {};
|
|
386
|
+
const NOOP_LOGGER = {
|
|
387
|
+
info() {},
|
|
388
|
+
warn() {},
|
|
389
|
+
error() {}
|
|
390
|
+
};
|
|
391
|
+
const MAX_SETUP_LOOKUP_CACHE_ENTRIES = 128;
|
|
392
|
+
const jitiLoaders = /* @__PURE__ */ new Map();
|
|
393
|
+
const setupRegistryCache = /* @__PURE__ */ new Map();
|
|
394
|
+
const setupProviderCache = /* @__PURE__ */ new Map();
|
|
395
|
+
let setupLookupCacheEntryCap = MAX_SETUP_LOOKUP_CACHE_ENTRIES;
|
|
396
|
+
function getJiti(modulePath) {
|
|
397
|
+
return getCachedPluginJitiLoader({
|
|
398
|
+
cache: jitiLoaders,
|
|
399
|
+
modulePath,
|
|
400
|
+
importerUrl: import.meta.url
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
function getCachedSetupValue(cache, key) {
|
|
404
|
+
if (!cache.has(key)) return { hit: false };
|
|
405
|
+
const cached = cache.get(key);
|
|
406
|
+
cache.delete(key);
|
|
407
|
+
cache.set(key, cached);
|
|
408
|
+
return {
|
|
409
|
+
hit: true,
|
|
410
|
+
value: cached
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function setCachedSetupValue(cache, key, value) {
|
|
414
|
+
if (cache.has(key)) cache.delete(key);
|
|
415
|
+
cache.set(key, value);
|
|
416
|
+
while (cache.size > setupLookupCacheEntryCap) {
|
|
417
|
+
const oldestKey = cache.keys().next().value;
|
|
418
|
+
if (typeof oldestKey !== "string") break;
|
|
419
|
+
cache.delete(oldestKey);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function buildSetupRegistryCacheKey(params) {
|
|
423
|
+
const { roots, loadPaths } = resolvePluginCacheInputs({
|
|
424
|
+
workspaceDir: params.workspaceDir,
|
|
425
|
+
env: params.env
|
|
426
|
+
});
|
|
427
|
+
return JSON.stringify({
|
|
428
|
+
roots,
|
|
429
|
+
loadPaths,
|
|
430
|
+
pluginIds: params.pluginIds ? [...new Set(params.pluginIds)].toSorted() : null
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
function buildSetupProviderCacheKey(params) {
|
|
434
|
+
return JSON.stringify({
|
|
435
|
+
provider: normalizeProviderId(params.provider),
|
|
436
|
+
registry: buildSetupRegistryCacheKey(params)
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
function resolveSetupApiPath(rootDir) {
|
|
440
|
+
const orderedExtensions = RUNNING_FROM_BUILT_ARTIFACT ? SETUP_API_EXTENSIONS : [...SETUP_API_EXTENSIONS.slice(3), ...SETUP_API_EXTENSIONS.slice(0, 3)];
|
|
441
|
+
const findSetupApi = (candidateRootDir) => {
|
|
442
|
+
for (const extension of orderedExtensions) {
|
|
443
|
+
const candidate = path.join(candidateRootDir, `setup-api${extension}`);
|
|
444
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
445
|
+
}
|
|
446
|
+
return null;
|
|
447
|
+
};
|
|
448
|
+
const direct = findSetupApi(rootDir);
|
|
449
|
+
if (direct) return direct;
|
|
450
|
+
const bundledExtensionDir = path.basename(rootDir);
|
|
451
|
+
const repoRootCandidates = [path.resolve(path.dirname(CURRENT_MODULE_PATH), "..", ".."), process.cwd()];
|
|
452
|
+
for (const repoRoot of repoRootCandidates) {
|
|
453
|
+
const sourceExtensionRoot = path.join(repoRoot, "extensions", bundledExtensionDir);
|
|
454
|
+
if (sourceExtensionRoot === rootDir) continue;
|
|
455
|
+
const sourceFallback = findSetupApi(sourceExtensionRoot);
|
|
456
|
+
if (sourceFallback) return sourceFallback;
|
|
457
|
+
}
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
function resolveRegister(mod) {
|
|
461
|
+
if (typeof mod === "function") return { register: mod };
|
|
462
|
+
if (mod && typeof mod === "object" && typeof mod.register === "function") return {
|
|
463
|
+
definition: mod,
|
|
464
|
+
register: mod.register.bind(mod)
|
|
465
|
+
};
|
|
466
|
+
return {};
|
|
467
|
+
}
|
|
468
|
+
function resolveSetupRegistration(record) {
|
|
469
|
+
const setupSource = record.setupSource ?? resolveSetupApiPath(record.rootDir);
|
|
470
|
+
if (!setupSource) return null;
|
|
471
|
+
let mod;
|
|
472
|
+
try {
|
|
473
|
+
mod = getJiti(setupSource)(setupSource);
|
|
474
|
+
} catch {
|
|
475
|
+
return null;
|
|
476
|
+
}
|
|
477
|
+
const resolved = resolveRegister(mod.default ?? mod);
|
|
478
|
+
if (!resolved.register) return null;
|
|
479
|
+
if (resolved.definition?.id && resolved.definition.id !== record.id) return null;
|
|
480
|
+
return {
|
|
481
|
+
setupSource,
|
|
482
|
+
register: resolved.register
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function buildSetupPluginApi(params) {
|
|
486
|
+
return buildPluginApi({
|
|
487
|
+
id: params.record.id,
|
|
488
|
+
name: params.record.name ?? params.record.id,
|
|
489
|
+
version: params.record.version,
|
|
490
|
+
description: params.record.description,
|
|
491
|
+
source: params.setupSource,
|
|
492
|
+
rootDir: params.record.rootDir,
|
|
493
|
+
registrationMode: "setup-only",
|
|
494
|
+
config: {},
|
|
495
|
+
runtime: EMPTY_RUNTIME,
|
|
496
|
+
logger: NOOP_LOGGER,
|
|
497
|
+
resolvePath: (input) => input,
|
|
498
|
+
handlers: params.handlers
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
function ignoreAsyncSetupRegisterResult(result) {
|
|
502
|
+
if (!result || typeof result.then !== "function") return;
|
|
503
|
+
Promise.resolve(result).catch(() => void 0);
|
|
504
|
+
}
|
|
505
|
+
function matchesProvider(provider, providerId) {
|
|
506
|
+
const normalized = normalizeProviderId(providerId);
|
|
507
|
+
if (normalizeProviderId(provider.id) === normalized) return true;
|
|
508
|
+
return [...provider.aliases ?? [], ...provider.hookAliases ?? []].some((alias) => normalizeProviderId(alias) === normalized);
|
|
509
|
+
}
|
|
510
|
+
function loadSetupManifestRegistry(params) {
|
|
511
|
+
const env = params?.env ?? process.env;
|
|
512
|
+
const discovery = discoverOpenClawPlugins({
|
|
513
|
+
workspaceDir: params?.workspaceDir,
|
|
514
|
+
env,
|
|
515
|
+
cache: true
|
|
516
|
+
});
|
|
517
|
+
return loadPluginManifestRegistry({
|
|
518
|
+
workspaceDir: params?.workspaceDir,
|
|
519
|
+
env,
|
|
520
|
+
cache: true,
|
|
521
|
+
candidates: discovery.candidates,
|
|
522
|
+
diagnostics: discovery.diagnostics
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
function findUniqueSetupManifestOwner(params) {
|
|
526
|
+
const matches = params.registry.plugins.filter((entry) => params.listIds(entry).some((id) => normalizeProviderId(id) === params.normalizedId));
|
|
527
|
+
if (matches.length === 0) return;
|
|
528
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
529
|
+
}
|
|
530
|
+
function resolvePluginSetupRegistry(params) {
|
|
531
|
+
const env = params?.env ?? process.env;
|
|
532
|
+
const cacheKey = buildSetupRegistryCacheKey({
|
|
533
|
+
workspaceDir: params?.workspaceDir,
|
|
534
|
+
env,
|
|
535
|
+
pluginIds: params?.pluginIds
|
|
536
|
+
});
|
|
537
|
+
const cached = getCachedSetupValue(setupRegistryCache, cacheKey);
|
|
538
|
+
if (cached.hit) return cached.value;
|
|
539
|
+
const selectedPluginIds = params?.pluginIds ? new Set(params.pluginIds.map((pluginId) => pluginId.trim()).filter(Boolean)) : null;
|
|
540
|
+
if (selectedPluginIds && selectedPluginIds.size === 0) {
|
|
541
|
+
const empty = {
|
|
542
|
+
providers: [],
|
|
543
|
+
cliBackends: [],
|
|
544
|
+
configMigrations: [],
|
|
545
|
+
autoEnableProbes: []
|
|
546
|
+
};
|
|
547
|
+
setCachedSetupValue(setupRegistryCache, cacheKey, empty);
|
|
548
|
+
return empty;
|
|
549
|
+
}
|
|
550
|
+
const providers = [];
|
|
551
|
+
const cliBackends = [];
|
|
552
|
+
const configMigrations = [];
|
|
553
|
+
const autoEnableProbes = [];
|
|
554
|
+
const providerKeys = /* @__PURE__ */ new Set();
|
|
555
|
+
const cliBackendKeys = /* @__PURE__ */ new Set();
|
|
556
|
+
const manifestRegistry = loadSetupManifestRegistry({
|
|
557
|
+
workspaceDir: params?.workspaceDir,
|
|
558
|
+
env
|
|
559
|
+
});
|
|
560
|
+
for (const record of manifestRegistry.plugins) {
|
|
561
|
+
if (selectedPluginIds && !selectedPluginIds.has(record.id)) continue;
|
|
562
|
+
const setupRegistration = resolveSetupRegistration(record);
|
|
563
|
+
if (!setupRegistration) continue;
|
|
564
|
+
const api = buildSetupPluginApi({
|
|
565
|
+
record,
|
|
566
|
+
setupSource: setupRegistration.setupSource,
|
|
567
|
+
handlers: {
|
|
568
|
+
registerProvider(provider) {
|
|
569
|
+
const key = `${record.id}:${normalizeProviderId(provider.id)}`;
|
|
570
|
+
if (providerKeys.has(key)) return;
|
|
571
|
+
providerKeys.add(key);
|
|
572
|
+
providers.push({
|
|
573
|
+
pluginId: record.id,
|
|
574
|
+
provider
|
|
575
|
+
});
|
|
576
|
+
},
|
|
577
|
+
registerCliBackend(backend) {
|
|
578
|
+
const key = `${record.id}:${normalizeProviderId(backend.id)}`;
|
|
579
|
+
if (cliBackendKeys.has(key)) return;
|
|
580
|
+
cliBackendKeys.add(key);
|
|
581
|
+
cliBackends.push({
|
|
582
|
+
pluginId: record.id,
|
|
583
|
+
backend
|
|
584
|
+
});
|
|
585
|
+
},
|
|
586
|
+
registerConfigMigration(migrate) {
|
|
587
|
+
configMigrations.push({
|
|
588
|
+
pluginId: record.id,
|
|
589
|
+
migrate
|
|
590
|
+
});
|
|
591
|
+
},
|
|
592
|
+
registerAutoEnableProbe(probe) {
|
|
593
|
+
autoEnableProbes.push({
|
|
594
|
+
pluginId: record.id,
|
|
595
|
+
probe
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
try {
|
|
601
|
+
const result = setupRegistration.register(api);
|
|
602
|
+
if (result && typeof result.then === "function") ignoreAsyncSetupRegisterResult(result);
|
|
603
|
+
} catch {
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
const registry = {
|
|
608
|
+
providers,
|
|
609
|
+
cliBackends,
|
|
610
|
+
configMigrations,
|
|
611
|
+
autoEnableProbes
|
|
612
|
+
};
|
|
613
|
+
setCachedSetupValue(setupRegistryCache, cacheKey, registry);
|
|
614
|
+
return registry;
|
|
615
|
+
}
|
|
616
|
+
function resolvePluginSetupProvider(params) {
|
|
617
|
+
const cacheKey = buildSetupProviderCacheKey(params);
|
|
618
|
+
const cached = getCachedSetupValue(setupProviderCache, cacheKey);
|
|
619
|
+
if (cached.hit) return cached.value ?? void 0;
|
|
620
|
+
const env = params.env ?? process.env;
|
|
621
|
+
const normalizedProvider = normalizeProviderId(params.provider);
|
|
622
|
+
const record = findUniqueSetupManifestOwner({
|
|
623
|
+
registry: loadSetupManifestRegistry({
|
|
624
|
+
workspaceDir: params.workspaceDir,
|
|
625
|
+
env
|
|
626
|
+
}),
|
|
627
|
+
normalizedId: normalizedProvider,
|
|
628
|
+
listIds: listSetupProviderIds
|
|
629
|
+
});
|
|
630
|
+
if (!record) {
|
|
631
|
+
setCachedSetupValue(setupProviderCache, cacheKey, null);
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
const setupRegistration = resolveSetupRegistration(record);
|
|
635
|
+
if (!setupRegistration) {
|
|
636
|
+
setCachedSetupValue(setupProviderCache, cacheKey, null);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
let matchedProvider;
|
|
640
|
+
const localProviderKeys = /* @__PURE__ */ new Set();
|
|
641
|
+
const api = buildSetupPluginApi({
|
|
642
|
+
record,
|
|
643
|
+
setupSource: setupRegistration.setupSource,
|
|
644
|
+
handlers: {
|
|
645
|
+
registerProvider(provider) {
|
|
646
|
+
const key = normalizeProviderId(provider.id);
|
|
647
|
+
if (localProviderKeys.has(key)) return;
|
|
648
|
+
localProviderKeys.add(key);
|
|
649
|
+
if (matchesProvider(provider, normalizedProvider)) matchedProvider = provider;
|
|
650
|
+
},
|
|
651
|
+
registerConfigMigration() {},
|
|
652
|
+
registerAutoEnableProbe() {}
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
try {
|
|
656
|
+
const result = setupRegistration.register(api);
|
|
657
|
+
if (result && typeof result.then === "function") ignoreAsyncSetupRegisterResult(result);
|
|
658
|
+
} catch {
|
|
659
|
+
setCachedSetupValue(setupProviderCache, cacheKey, null);
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
setCachedSetupValue(setupProviderCache, cacheKey, matchedProvider ?? null);
|
|
663
|
+
return matchedProvider;
|
|
664
|
+
}
|
|
665
|
+
function resolvePluginSetupAutoEnableReasons(params) {
|
|
666
|
+
const env = params.env ?? process.env;
|
|
667
|
+
const reasons = [];
|
|
668
|
+
const seen = /* @__PURE__ */ new Set();
|
|
669
|
+
for (const entry of resolvePluginSetupRegistry({
|
|
670
|
+
workspaceDir: params.workspaceDir,
|
|
671
|
+
env,
|
|
672
|
+
pluginIds: params.pluginIds
|
|
673
|
+
}).autoEnableProbes) {
|
|
674
|
+
const raw = entry.probe({
|
|
675
|
+
config: params.config,
|
|
676
|
+
env
|
|
677
|
+
});
|
|
678
|
+
const values = Array.isArray(raw) ? raw : raw ? [raw] : [];
|
|
679
|
+
for (const reason of values) {
|
|
680
|
+
const normalized = reason.trim();
|
|
681
|
+
if (!normalized) continue;
|
|
682
|
+
const key = `${entry.pluginId}:${normalized}`;
|
|
683
|
+
if (seen.has(key)) continue;
|
|
684
|
+
seen.add(key);
|
|
685
|
+
reasons.push({
|
|
686
|
+
pluginId: entry.pluginId,
|
|
687
|
+
reason: normalized
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return reasons;
|
|
692
|
+
}
|
|
693
|
+
//#endregion
|
|
694
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/plugins-allowlist-Cwto7-rU.js
|
|
695
|
+
function ensurePluginAllowlisted(cfg, pluginId) {
|
|
696
|
+
const allow = cfg.plugins?.allow;
|
|
697
|
+
if (!Array.isArray(allow) || allow.includes(pluginId)) return cfg;
|
|
698
|
+
return {
|
|
699
|
+
...cfg,
|
|
700
|
+
plugins: {
|
|
701
|
+
...cfg.plugins,
|
|
702
|
+
allow: [...allow, pluginId]
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
//#endregion
|
|
707
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/plugin-auto-enable-DdH3n9V8.js
|
|
708
|
+
function loadProviderManifestRegistry(params) {
|
|
709
|
+
return loadPluginManifestRegistry({
|
|
710
|
+
config: params.config,
|
|
711
|
+
workspaceDir: params.workspaceDir,
|
|
712
|
+
env: params.env
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
function loadScopedProviderManifestRegistry(params) {
|
|
716
|
+
return {
|
|
717
|
+
registry: loadProviderManifestRegistry(params),
|
|
718
|
+
onlyPluginIdSet: createPluginIdScopeSet(params.onlyPluginIds)
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
function listManifestPluginIds(registry, predicate) {
|
|
722
|
+
return registry.plugins.filter(predicate).map((plugin) => plugin.id).toSorted((left, right) => left.localeCompare(right));
|
|
723
|
+
}
|
|
724
|
+
function resolveProviderOwnerPluginIds(params) {
|
|
725
|
+
if (params.pluginIds.length === 0) return [];
|
|
726
|
+
const pluginIdSet = new Set(params.pluginIds);
|
|
727
|
+
const registry = loadProviderManifestRegistry(params);
|
|
728
|
+
const normalizedConfig = normalizePluginsConfig(params.config?.plugins);
|
|
729
|
+
return listManifestPluginIds(registry, (plugin) => pluginIdSet.has(plugin.id) && params.isEligible(plugin, normalizedConfig));
|
|
730
|
+
}
|
|
731
|
+
function withBundledProviderVitestCompat(params) {
|
|
732
|
+
return withBundledPluginVitestCompat(params);
|
|
733
|
+
}
|
|
734
|
+
function resolveBundledProviderCompatPluginIds(params) {
|
|
735
|
+
const { registry, onlyPluginIdSet } = loadScopedProviderManifestRegistry(params);
|
|
736
|
+
return listManifestPluginIds(registry, (plugin) => plugin.origin === "bundled" && plugin.providers.length > 0 && (!onlyPluginIdSet || onlyPluginIdSet.has(plugin.id)));
|
|
737
|
+
}
|
|
738
|
+
function resolveEnabledProviderPluginIds(params) {
|
|
739
|
+
const { registry, onlyPluginIdSet } = loadScopedProviderManifestRegistry(params);
|
|
740
|
+
const normalizedConfig = normalizePluginsConfig(params.config?.plugins);
|
|
741
|
+
return listManifestPluginIds(registry, (plugin) => plugin.providers.length > 0 && (!onlyPluginIdSet || onlyPluginIdSet.has(plugin.id)) && resolveEffectivePluginActivationState({
|
|
742
|
+
id: plugin.id,
|
|
743
|
+
origin: plugin.origin,
|
|
744
|
+
config: normalizedConfig,
|
|
745
|
+
rootConfig: params.config,
|
|
746
|
+
enabledByDefault: plugin.enabledByDefault
|
|
747
|
+
}).activated);
|
|
748
|
+
}
|
|
749
|
+
function resolveExternalAuthProfileProviderPluginIds(params) {
|
|
750
|
+
return resolveManifestContractPluginIds({
|
|
751
|
+
contract: "externalAuthProviders",
|
|
752
|
+
config: params.config,
|
|
753
|
+
workspaceDir: params.workspaceDir,
|
|
754
|
+
env: params.env
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
function resolveExternalAuthProfileCompatFallbackPluginIds(params) {
|
|
758
|
+
const declaredPluginIds = params.declaredPluginIds ?? new Set(resolveExternalAuthProfileProviderPluginIds(params));
|
|
759
|
+
const registry = loadProviderManifestRegistry(params);
|
|
760
|
+
const normalizedConfig = normalizePluginsConfig(params.config?.plugins);
|
|
761
|
+
return listManifestPluginIds(registry, (plugin) => plugin.origin !== "bundled" && plugin.providers.length > 0 && !declaredPluginIds.has(plugin.id) && isProviderPluginEligibleForRuntimeOwnerActivation({
|
|
762
|
+
plugin,
|
|
763
|
+
normalizedConfig,
|
|
764
|
+
rootConfig: params.config
|
|
765
|
+
}));
|
|
766
|
+
}
|
|
767
|
+
function resolveDiscoveredProviderPluginIds(params) {
|
|
768
|
+
const { registry, onlyPluginIdSet } = loadScopedProviderManifestRegistry(params);
|
|
769
|
+
const shouldFilterUntrustedWorkspacePlugins = params.includeUntrustedWorkspacePlugins === false;
|
|
770
|
+
const normalizedConfig = normalizePluginsConfig(params.config?.plugins);
|
|
771
|
+
return listManifestPluginIds(registry, (plugin) => {
|
|
772
|
+
if (!(plugin.providers.length > 0 && (!onlyPluginIdSet || onlyPluginIdSet.has(plugin.id)))) return false;
|
|
773
|
+
return isProviderPluginEligibleForSetupDiscovery({
|
|
774
|
+
plugin,
|
|
775
|
+
shouldFilterUntrustedWorkspacePlugins,
|
|
776
|
+
normalizedConfig,
|
|
777
|
+
rootConfig: params.config
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
function isProviderPluginEligibleForSetupDiscovery(params) {
|
|
782
|
+
if (!params.shouldFilterUntrustedWorkspacePlugins || params.plugin.origin !== "workspace") return true;
|
|
783
|
+
if (!passesManifestOwnerBasePolicy({
|
|
784
|
+
plugin: params.plugin,
|
|
785
|
+
normalizedConfig: params.normalizedConfig
|
|
786
|
+
})) return false;
|
|
787
|
+
return isActivatedManifestOwner({
|
|
788
|
+
plugin: params.plugin,
|
|
789
|
+
normalizedConfig: params.normalizedConfig,
|
|
790
|
+
rootConfig: params.rootConfig
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
function resolveDiscoverableProviderOwnerPluginIds(params) {
|
|
794
|
+
const shouldFilterUntrustedWorkspacePlugins = params.includeUntrustedWorkspacePlugins === false;
|
|
795
|
+
return resolveProviderOwnerPluginIds({
|
|
796
|
+
...params,
|
|
797
|
+
isEligible: (plugin, normalizedConfig) => isProviderPluginEligibleForSetupDiscovery({
|
|
798
|
+
plugin,
|
|
799
|
+
shouldFilterUntrustedWorkspacePlugins,
|
|
800
|
+
normalizedConfig,
|
|
801
|
+
rootConfig: params.config
|
|
802
|
+
})
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
function isProviderPluginEligibleForRuntimeOwnerActivation(params) {
|
|
806
|
+
if (!passesManifestOwnerBasePolicy({
|
|
807
|
+
plugin: params.plugin,
|
|
808
|
+
normalizedConfig: params.normalizedConfig
|
|
809
|
+
})) return false;
|
|
810
|
+
if (params.plugin.origin !== "workspace") return true;
|
|
811
|
+
return isActivatedManifestOwner({
|
|
812
|
+
plugin: params.plugin,
|
|
813
|
+
normalizedConfig: params.normalizedConfig,
|
|
814
|
+
rootConfig: params.rootConfig
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
function resolveActivatableProviderOwnerPluginIds(params) {
|
|
818
|
+
return resolveProviderOwnerPluginIds({
|
|
819
|
+
...params,
|
|
820
|
+
isEligible: (plugin, normalizedConfig) => isProviderPluginEligibleForRuntimeOwnerActivation({
|
|
821
|
+
plugin,
|
|
822
|
+
normalizedConfig,
|
|
823
|
+
rootConfig: params.config
|
|
824
|
+
})
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
function resolveManifestRegistry(params) {
|
|
828
|
+
return params.manifestRegistry ?? loadProviderManifestRegistry(params);
|
|
829
|
+
}
|
|
830
|
+
function stripModelProfileSuffix(value) {
|
|
831
|
+
const trimmed = value.trim();
|
|
832
|
+
const at = trimmed.indexOf("@");
|
|
833
|
+
return at <= 0 ? trimmed : trimmed.slice(0, at).trim();
|
|
834
|
+
}
|
|
835
|
+
function splitExplicitModelRef(rawModel) {
|
|
836
|
+
const trimmed = rawModel.trim();
|
|
837
|
+
if (!trimmed) return null;
|
|
838
|
+
const slash = trimmed.indexOf("/");
|
|
839
|
+
if (slash === -1) {
|
|
840
|
+
const modelId = stripModelProfileSuffix(trimmed);
|
|
841
|
+
return modelId ? { modelId } : null;
|
|
842
|
+
}
|
|
843
|
+
const provider = normalizeProviderId(trimmed.slice(0, slash));
|
|
844
|
+
const modelId = stripModelProfileSuffix(trimmed.slice(slash + 1));
|
|
845
|
+
if (!provider || !modelId) return null;
|
|
846
|
+
return {
|
|
847
|
+
provider,
|
|
848
|
+
modelId
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
function resolveModelSupportMatchKind(plugin, modelId) {
|
|
852
|
+
const patterns = plugin.modelSupport?.modelPatterns ?? [];
|
|
853
|
+
for (const patternSource of patterns) try {
|
|
854
|
+
if (new RegExp(patternSource, "u").test(modelId)) return "pattern";
|
|
855
|
+
} catch {
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
const prefixes = plugin.modelSupport?.modelPrefixes ?? [];
|
|
859
|
+
for (const prefix of prefixes) if (modelId.startsWith(prefix)) return "prefix";
|
|
860
|
+
}
|
|
861
|
+
function dedupeSortedPluginIds(values) {
|
|
862
|
+
return [...new Set(values)].toSorted((left, right) => left.localeCompare(right));
|
|
863
|
+
}
|
|
864
|
+
function resolvePreferredManifestPluginIds(registry, matchedPluginIds) {
|
|
865
|
+
if (matchedPluginIds.length === 0) return;
|
|
866
|
+
const uniquePluginIds = dedupeSortedPluginIds(matchedPluginIds);
|
|
867
|
+
if (uniquePluginIds.length <= 1) return uniquePluginIds;
|
|
868
|
+
const nonBundledPluginIds = uniquePluginIds.filter((pluginId) => {
|
|
869
|
+
return registry.plugins.find((entry) => entry.id === pluginId)?.origin !== "bundled";
|
|
870
|
+
});
|
|
871
|
+
if (nonBundledPluginIds.length === 1) return nonBundledPluginIds;
|
|
872
|
+
if (nonBundledPluginIds.length > 1) return;
|
|
873
|
+
}
|
|
874
|
+
function resolveOwningPluginIdsForProvider(params) {
|
|
875
|
+
const normalizedProvider = normalizeProviderId(params.provider);
|
|
876
|
+
if (!normalizedProvider) return;
|
|
877
|
+
const pluginIds = resolveManifestRegistry(params).plugins.filter((plugin) => plugin.providers.some((providerId) => normalizeProviderId(providerId) === normalizedProvider) || plugin.cliBackends.some((backendId) => normalizeProviderId(backendId) === normalizedProvider)).map((plugin) => plugin.id);
|
|
878
|
+
return pluginIds.length > 0 ? pluginIds : void 0;
|
|
879
|
+
}
|
|
880
|
+
function resolveOwningPluginIdsForModelRef(params) {
|
|
881
|
+
const parsed = splitExplicitModelRef(params.model);
|
|
882
|
+
if (!parsed) return;
|
|
883
|
+
if (parsed.provider) return resolveOwningPluginIdsForProvider({
|
|
884
|
+
provider: parsed.provider,
|
|
885
|
+
config: params.config,
|
|
886
|
+
workspaceDir: params.workspaceDir,
|
|
887
|
+
env: params.env,
|
|
888
|
+
manifestRegistry: params.manifestRegistry
|
|
889
|
+
});
|
|
890
|
+
const registry = resolveManifestRegistry(params);
|
|
891
|
+
const preferredPatternPluginIds = resolvePreferredManifestPluginIds(registry, registry.plugins.filter((plugin) => resolveModelSupportMatchKind(plugin, parsed.modelId) === "pattern").map((plugin) => plugin.id));
|
|
892
|
+
if (preferredPatternPluginIds) return preferredPatternPluginIds;
|
|
893
|
+
return resolvePreferredManifestPluginIds(registry, registry.plugins.filter((plugin) => resolveModelSupportMatchKind(plugin, parsed.modelId) === "prefix").map((plugin) => plugin.id));
|
|
894
|
+
}
|
|
895
|
+
function resolveOwningPluginIdsForModelRefs(params) {
|
|
896
|
+
const registry = resolveManifestRegistry(params);
|
|
897
|
+
return dedupeSortedPluginIds(params.models.flatMap((model) => resolveOwningPluginIdsForModelRef({
|
|
898
|
+
model,
|
|
899
|
+
config: params.config,
|
|
900
|
+
workspaceDir: params.workspaceDir,
|
|
901
|
+
env: params.env,
|
|
902
|
+
manifestRegistry: registry
|
|
903
|
+
}) ?? []));
|
|
904
|
+
}
|
|
905
|
+
function resolveCatalogHookProviderPluginIds(params) {
|
|
906
|
+
const registry = loadProviderManifestRegistry(params);
|
|
907
|
+
const normalizedConfig = normalizePluginsConfig(params.config?.plugins);
|
|
908
|
+
const enabledProviderPluginIds = listManifestPluginIds(registry, (plugin) => plugin.providers.length > 0 && resolveEffectivePluginActivationState({
|
|
909
|
+
id: plugin.id,
|
|
910
|
+
origin: plugin.origin,
|
|
911
|
+
config: normalizedConfig,
|
|
912
|
+
rootConfig: params.config,
|
|
913
|
+
enabledByDefault: plugin.enabledByDefault
|
|
914
|
+
}).activated);
|
|
915
|
+
const bundledCompatPluginIds = resolveBundledProviderCompatPluginIds(params);
|
|
916
|
+
return [...new Set([...enabledProviderPluginIds, ...bundledCompatPluginIds])].toSorted((left, right) => left.localeCompare(right));
|
|
917
|
+
}
|
|
918
|
+
const ENV_CATALOG_PATHS = ["OPENCLAW_PLUGIN_CATALOG_PATHS", "OPENCLAW_MPM_CATALOG_PATHS"];
|
|
919
|
+
function splitEnvPaths(value) {
|
|
920
|
+
const trimmed = normalizeOptionalString(value) ?? "";
|
|
921
|
+
if (!trimmed) return [];
|
|
922
|
+
return normalizeStringEntries(trimmed.split(/[;,]/g).flatMap((chunk) => chunk.split(path.delimiter)));
|
|
923
|
+
}
|
|
924
|
+
function resolveExternalCatalogPaths(env) {
|
|
925
|
+
for (const key of ENV_CATALOG_PATHS) {
|
|
926
|
+
const raw = normalizeOptionalString(env[key]);
|
|
927
|
+
if (raw) return splitEnvPaths(raw);
|
|
928
|
+
}
|
|
929
|
+
const configDir = resolveConfigDir(env);
|
|
930
|
+
return [
|
|
931
|
+
path.join(configDir, "mpm", "plugins.json"),
|
|
932
|
+
path.join(configDir, "mpm", "catalog.json"),
|
|
933
|
+
path.join(configDir, "plugins", "catalog.json")
|
|
934
|
+
];
|
|
935
|
+
}
|
|
936
|
+
function parseExternalCatalogChannelEntries(raw) {
|
|
937
|
+
const list = (() => {
|
|
938
|
+
if (Array.isArray(raw)) return raw;
|
|
939
|
+
if (!isRecord(raw)) return [];
|
|
940
|
+
const entries = raw.entries ?? raw.packages ?? raw.plugins;
|
|
941
|
+
return Array.isArray(entries) ? entries : [];
|
|
942
|
+
})();
|
|
943
|
+
const channels = [];
|
|
944
|
+
for (const entry of list) {
|
|
945
|
+
if (!isRecord(entry) || !isRecord(entry.openclaw) || !isRecord(entry.openclaw.channel)) continue;
|
|
946
|
+
const channel = entry.openclaw.channel;
|
|
947
|
+
const id = normalizeOptionalString(channel.id) ?? "";
|
|
948
|
+
if (!id) continue;
|
|
949
|
+
const preferOver = Array.isArray(channel.preferOver) ? channel.preferOver.filter((value) => typeof value === "string") : [];
|
|
950
|
+
channels.push({
|
|
951
|
+
id,
|
|
952
|
+
preferOver
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
return channels;
|
|
956
|
+
}
|
|
957
|
+
function resolveExternalCatalogPreferOver(channelId, env) {
|
|
958
|
+
for (const rawPath of resolveExternalCatalogPaths(env)) {
|
|
959
|
+
const resolved = resolveUserPath(rawPath, env);
|
|
960
|
+
if (!fs.existsSync(resolved)) continue;
|
|
961
|
+
try {
|
|
962
|
+
const channel = parseExternalCatalogChannelEntries(JSON.parse(fs.readFileSync(resolved, "utf-8"))).find((entry) => entry.id === channelId);
|
|
963
|
+
if (channel) return channel.preferOver;
|
|
964
|
+
} catch {}
|
|
965
|
+
}
|
|
966
|
+
return [];
|
|
967
|
+
}
|
|
968
|
+
function resolveBuiltInChannelPreferOver(channelId) {
|
|
969
|
+
const builtInChannelId = normalizeChatChannelId(channelId);
|
|
970
|
+
if (!builtInChannelId) return [];
|
|
971
|
+
return getChatChannelMeta(builtInChannelId)?.preferOver ?? [];
|
|
972
|
+
}
|
|
973
|
+
function resolvePreferredOverIds(candidate, env, registry) {
|
|
974
|
+
const channelId = candidate.kind === "channel-configured" ? candidate.channelId : candidate.pluginId;
|
|
975
|
+
const installedPlugin = registry.plugins.find((record) => record.id === candidate.pluginId);
|
|
976
|
+
const manifestChannelPreferOver = installedPlugin?.channelConfigs?.[channelId]?.preferOver;
|
|
977
|
+
if (manifestChannelPreferOver?.length) return [...manifestChannelPreferOver];
|
|
978
|
+
const installedChannelMeta = installedPlugin?.channelCatalogMeta;
|
|
979
|
+
if (installedChannelMeta?.preferOver?.length) return [...installedChannelMeta.preferOver];
|
|
980
|
+
const builtInChannelPreferOver = resolveBuiltInChannelPreferOver(channelId);
|
|
981
|
+
if (builtInChannelPreferOver.length) return [...builtInChannelPreferOver];
|
|
982
|
+
return resolveExternalCatalogPreferOver(channelId, env);
|
|
983
|
+
}
|
|
984
|
+
function getPluginAutoEnableCandidateCacheKey(candidate) {
|
|
985
|
+
return `${candidate.pluginId}:${candidate.kind === "channel-configured" ? candidate.channelId : candidate.pluginId}`;
|
|
986
|
+
}
|
|
987
|
+
function shouldSkipPreferredPluginAutoEnable(params) {
|
|
988
|
+
const getPreferredOverIds = (candidate) => {
|
|
989
|
+
const cacheKey = getPluginAutoEnableCandidateCacheKey(candidate);
|
|
990
|
+
const cached = params.preferOverCache.get(cacheKey);
|
|
991
|
+
if (cached) return cached;
|
|
992
|
+
const resolved = resolvePreferredOverIds(candidate, params.env, params.registry);
|
|
993
|
+
params.preferOverCache.set(cacheKey, resolved);
|
|
994
|
+
return resolved;
|
|
995
|
+
};
|
|
996
|
+
for (const other of params.configured) {
|
|
997
|
+
if (other.pluginId === params.entry.pluginId) continue;
|
|
998
|
+
if (params.isPluginDenied(params.config, other.pluginId) || params.isPluginExplicitlyDisabled(params.config, other.pluginId)) continue;
|
|
999
|
+
if (getPreferredOverIds(other).includes(params.entry.pluginId)) return true;
|
|
1000
|
+
}
|
|
1001
|
+
return false;
|
|
1002
|
+
}
|
|
1003
|
+
const EMPTY_PLUGIN_MANIFEST_REGISTRY = {
|
|
1004
|
+
plugins: [],
|
|
1005
|
+
diagnostics: []
|
|
1006
|
+
};
|
|
1007
|
+
function resolveAutoEnableProviderPluginIds(registry) {
|
|
1008
|
+
const entries = /* @__PURE__ */ new Map();
|
|
1009
|
+
for (const plugin of registry.plugins) for (const providerId of plugin.autoEnableWhenConfiguredProviders ?? []) if (!entries.has(providerId)) entries.set(providerId, plugin.id);
|
|
1010
|
+
return Object.fromEntries(entries);
|
|
1011
|
+
}
|
|
1012
|
+
function collectModelRefs(cfg) {
|
|
1013
|
+
const refs = [];
|
|
1014
|
+
const pushModelRef = (value) => {
|
|
1015
|
+
if (typeof value === "string" && value.trim()) refs.push(value.trim());
|
|
1016
|
+
};
|
|
1017
|
+
const collectFromAgent = (agent) => {
|
|
1018
|
+
if (!agent) return;
|
|
1019
|
+
const model = agent.model;
|
|
1020
|
+
if (typeof model === "string") pushModelRef(model);
|
|
1021
|
+
else if (isRecord(model)) {
|
|
1022
|
+
pushModelRef(model.primary);
|
|
1023
|
+
const fallbacks = model.fallbacks;
|
|
1024
|
+
if (Array.isArray(fallbacks)) for (const entry of fallbacks) pushModelRef(entry);
|
|
1025
|
+
}
|
|
1026
|
+
const models = agent.models;
|
|
1027
|
+
if (isRecord(models)) for (const key of Object.keys(models)) pushModelRef(key);
|
|
1028
|
+
};
|
|
1029
|
+
collectFromAgent(cfg.agents?.defaults);
|
|
1030
|
+
const list = cfg.agents?.list;
|
|
1031
|
+
if (Array.isArray(list)) {
|
|
1032
|
+
for (const entry of list) if (isRecord(entry)) collectFromAgent(entry);
|
|
1033
|
+
}
|
|
1034
|
+
return refs;
|
|
1035
|
+
}
|
|
1036
|
+
function extractProviderFromModelRef(value) {
|
|
1037
|
+
const trimmed = value.trim();
|
|
1038
|
+
const slash = trimmed.indexOf("/");
|
|
1039
|
+
if (slash <= 0) return null;
|
|
1040
|
+
return normalizeProviderId(trimmed.slice(0, slash));
|
|
1041
|
+
}
|
|
1042
|
+
function hasConfiguredEmbeddedHarnessRuntime(cfg, env) {
|
|
1043
|
+
return collectConfiguredAgentHarnessRuntimes(cfg, env).length > 0;
|
|
1044
|
+
}
|
|
1045
|
+
function resolveAgentHarnessOwnerPluginIds(registry, runtime) {
|
|
1046
|
+
const normalizedRuntime = normalizeOptionalLowercaseString(runtime);
|
|
1047
|
+
if (!normalizedRuntime) return [];
|
|
1048
|
+
return registry.plugins.filter((plugin) => (plugin.activation?.onAgentHarnesses ?? []).some((entry) => normalizeOptionalLowercaseString(entry) === normalizedRuntime)).map((plugin) => plugin.id).toSorted((left, right) => left.localeCompare(right));
|
|
1049
|
+
}
|
|
1050
|
+
function isProviderConfigured(cfg, providerId) {
|
|
1051
|
+
const normalized = normalizeProviderId(providerId);
|
|
1052
|
+
const profiles = cfg.auth?.profiles;
|
|
1053
|
+
if (profiles && typeof profiles === "object") for (const profile of Object.values(profiles)) {
|
|
1054
|
+
if (!isRecord(profile)) continue;
|
|
1055
|
+
if (normalizeProviderId(profile.provider ?? "") === normalized) return true;
|
|
1056
|
+
}
|
|
1057
|
+
const providerConfig = cfg.models?.providers;
|
|
1058
|
+
if (providerConfig && typeof providerConfig === "object") {
|
|
1059
|
+
for (const key of Object.keys(providerConfig)) if (normalizeProviderId(key) === normalized) return true;
|
|
1060
|
+
}
|
|
1061
|
+
for (const ref of collectModelRefs(cfg)) {
|
|
1062
|
+
const provider = extractProviderFromModelRef(ref);
|
|
1063
|
+
if (provider && provider === normalized) return true;
|
|
1064
|
+
}
|
|
1065
|
+
return false;
|
|
1066
|
+
}
|
|
1067
|
+
function hasPluginOwnedWebSearchConfig(cfg, pluginId) {
|
|
1068
|
+
const pluginConfig = cfg.plugins?.entries?.[pluginId]?.config;
|
|
1069
|
+
return isRecord(pluginConfig) && isRecord(pluginConfig.webSearch);
|
|
1070
|
+
}
|
|
1071
|
+
function hasPluginOwnedWebFetchConfig(cfg, pluginId) {
|
|
1072
|
+
const pluginConfig = cfg.plugins?.entries?.[pluginId]?.config;
|
|
1073
|
+
return isRecord(pluginConfig) && isRecord(pluginConfig.webFetch);
|
|
1074
|
+
}
|
|
1075
|
+
function resolvePluginOwnedToolConfigKeys(plugin) {
|
|
1076
|
+
if ((plugin.contracts?.tools?.length ?? 0) === 0) return [];
|
|
1077
|
+
const properties = isRecord(plugin.configSchema) ? plugin.configSchema.properties : void 0;
|
|
1078
|
+
if (!isRecord(properties)) return [];
|
|
1079
|
+
return Object.keys(properties).filter((key) => key !== "webSearch" && key !== "webFetch");
|
|
1080
|
+
}
|
|
1081
|
+
function hasPluginOwnedToolConfig(cfg, plugin) {
|
|
1082
|
+
const pluginConfig = cfg.plugins?.entries?.[plugin.id]?.config;
|
|
1083
|
+
if (!isRecord(pluginConfig)) return false;
|
|
1084
|
+
return resolvePluginOwnedToolConfigKeys(plugin).some((key) => pluginConfig[key] !== void 0);
|
|
1085
|
+
}
|
|
1086
|
+
function resolveProviderPluginsWithOwnedWebSearch(registry) {
|
|
1087
|
+
return registry.plugins.filter((plugin) => (plugin.providers?.length ?? 0) > 0).filter((plugin) => (plugin.contracts?.webSearchProviders?.length ?? 0) > 0);
|
|
1088
|
+
}
|
|
1089
|
+
function resolveProviderPluginsWithOwnedWebFetch(registry) {
|
|
1090
|
+
return registry.plugins.filter((plugin) => (plugin.contracts?.webFetchProviders?.length ?? 0) > 0);
|
|
1091
|
+
}
|
|
1092
|
+
function resolvePluginsWithOwnedToolConfig(registry) {
|
|
1093
|
+
return registry.plugins.filter((plugin) => (plugin.contracts?.tools?.length ?? 0) > 0);
|
|
1094
|
+
}
|
|
1095
|
+
function resolvePluginIdForConfiguredWebFetchProvider(providerId, env) {
|
|
1096
|
+
return resolveManifestContractOwnerPluginId({
|
|
1097
|
+
contract: "webFetchProviders",
|
|
1098
|
+
value: normalizeOptionalLowercaseString(providerId) ?? "",
|
|
1099
|
+
origin: "bundled",
|
|
1100
|
+
env
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
function buildChannelToPluginIdMap(registry) {
|
|
1104
|
+
const map = /* @__PURE__ */ new Map();
|
|
1105
|
+
for (const record of registry.plugins) for (const channelId of record.channels ?? []) if (channelId && !map.has(channelId)) map.set(channelId, record.id);
|
|
1106
|
+
return map;
|
|
1107
|
+
}
|
|
1108
|
+
function resolvePluginIdForChannel(channelId, channelToPluginId) {
|
|
1109
|
+
const builtInId = normalizeChatChannelId(channelId);
|
|
1110
|
+
if (builtInId) return builtInId;
|
|
1111
|
+
return channelToPluginId.get(channelId) ?? channelId;
|
|
1112
|
+
}
|
|
1113
|
+
function collectCandidateChannelIds(cfg, env) {
|
|
1114
|
+
return listPotentialConfiguredChannelIds(cfg, env).map((channelId) => normalizeChatChannelId(channelId) ?? channelId);
|
|
1115
|
+
}
|
|
1116
|
+
function hasConfiguredWebSearchPluginEntry(cfg) {
|
|
1117
|
+
const entries = cfg.plugins?.entries;
|
|
1118
|
+
return !!entries && typeof entries === "object" && Object.values(entries).some((entry) => isRecord(entry) && isRecord(entry.config) && isRecord(entry.config.webSearch));
|
|
1119
|
+
}
|
|
1120
|
+
function hasConfiguredWebFetchPluginEntry(cfg) {
|
|
1121
|
+
const entries = cfg.plugins?.entries;
|
|
1122
|
+
return !!entries && typeof entries === "object" && Object.values(entries).some((entry) => isRecord(entry) && isRecord(entry.config) && isRecord(entry.config.webFetch));
|
|
1123
|
+
}
|
|
1124
|
+
function hasConfiguredPluginConfigEntry(cfg) {
|
|
1125
|
+
const entries = cfg.plugins?.entries;
|
|
1126
|
+
return !!entries && typeof entries === "object" && Object.values(entries).some((entry) => isRecord(entry) && isRecord(entry.config));
|
|
1127
|
+
}
|
|
1128
|
+
function listContainsNormalized(value, expected) {
|
|
1129
|
+
return Array.isArray(value) && value.some((entry) => normalizeOptionalLowercaseString(entry) === expected);
|
|
1130
|
+
}
|
|
1131
|
+
function toolPolicyReferencesBrowser(value) {
|
|
1132
|
+
return isRecord(value) && (listContainsNormalized(value.allow, "browser") || listContainsNormalized(value.alsoAllow, "browser"));
|
|
1133
|
+
}
|
|
1134
|
+
function hasBrowserToolReference(cfg) {
|
|
1135
|
+
if (toolPolicyReferencesBrowser(cfg.tools)) return true;
|
|
1136
|
+
const agentList = cfg.agents?.list;
|
|
1137
|
+
return Array.isArray(agentList) ? agentList.some((entry) => isRecord(entry) && toolPolicyReferencesBrowser(entry.tools)) : false;
|
|
1138
|
+
}
|
|
1139
|
+
function collectConfiguredPluginEntryIds(cfg) {
|
|
1140
|
+
const entries = cfg.plugins?.entries;
|
|
1141
|
+
if (!entries || typeof entries !== "object") return [];
|
|
1142
|
+
return Object.keys(entries).map((pluginId) => pluginId.trim()).filter(Boolean);
|
|
1143
|
+
}
|
|
1144
|
+
function resolveRelevantSetupAutoEnablePluginIds(cfg) {
|
|
1145
|
+
const pluginIds = new Set(collectConfiguredPluginEntryIds(cfg));
|
|
1146
|
+
if (isRecord(cfg.browser) || isRecord(cfg.plugins?.entries?.browser) || hasBrowserToolReference(cfg)) pluginIds.add("browser");
|
|
1147
|
+
if (isRecord(cfg.acp) || isRecord(cfg.plugins?.entries?.acpx)) pluginIds.add("acpx");
|
|
1148
|
+
if (isRecord(cfg.plugins?.entries?.xai) || isRecord(cfg.tools?.web) && isRecord(cfg.tools.web.x_search)) pluginIds.add("xai");
|
|
1149
|
+
return [...pluginIds].toSorted((left, right) => left.localeCompare(right));
|
|
1150
|
+
}
|
|
1151
|
+
function hasSetupAutoEnableRelevantConfig(cfg) {
|
|
1152
|
+
const entries = cfg.plugins?.entries;
|
|
1153
|
+
if (isRecord(cfg.browser) || isRecord(cfg.acp) || hasBrowserToolReference(cfg)) return true;
|
|
1154
|
+
if (isRecord(entries?.browser) || isRecord(entries?.acpx) || isRecord(entries?.xai)) return true;
|
|
1155
|
+
if (isRecord(cfg.tools?.web) && isRecord(cfg.tools.web.x_search)) return true;
|
|
1156
|
+
return hasConfiguredPluginConfigEntry(cfg);
|
|
1157
|
+
}
|
|
1158
|
+
function hasPluginEntries(cfg) {
|
|
1159
|
+
const entries = cfg.plugins?.entries;
|
|
1160
|
+
return !!entries && typeof entries === "object" && Object.keys(entries).length > 0;
|
|
1161
|
+
}
|
|
1162
|
+
function hasPluginAllowlistWithEntries(cfg) {
|
|
1163
|
+
return Array.isArray(cfg.plugins?.allow) && cfg.plugins.allow.length > 0 && hasPluginEntries(cfg);
|
|
1164
|
+
}
|
|
1165
|
+
function hasConfiguredProviderModelOrHarness(cfg, env) {
|
|
1166
|
+
if (cfg.auth?.profiles && Object.keys(cfg.auth.profiles).length > 0) return true;
|
|
1167
|
+
if (cfg.models?.providers && Object.keys(cfg.models.providers).length > 0) return true;
|
|
1168
|
+
if (collectModelRefs(cfg).length > 0) return true;
|
|
1169
|
+
return hasConfiguredEmbeddedHarnessRuntime(cfg, env);
|
|
1170
|
+
}
|
|
1171
|
+
function configMayNeedPluginManifestRegistry(cfg, env) {
|
|
1172
|
+
if (hasPluginAllowlistWithEntries(cfg)) return true;
|
|
1173
|
+
if (hasConfiguredPluginConfigEntry(cfg)) return true;
|
|
1174
|
+
if (hasConfiguredProviderModelOrHarness(cfg, env)) return true;
|
|
1175
|
+
const configuredChannels = cfg.channels;
|
|
1176
|
+
if (!configuredChannels || typeof configuredChannels !== "object") return false;
|
|
1177
|
+
for (const key of Object.keys(configuredChannels)) {
|
|
1178
|
+
if (key === "defaults" || key === "modelByChannel") continue;
|
|
1179
|
+
if (!normalizeChatChannelId(key)) return true;
|
|
1180
|
+
}
|
|
1181
|
+
return false;
|
|
1182
|
+
}
|
|
1183
|
+
function configMayNeedPluginAutoEnable(cfg, env) {
|
|
1184
|
+
if (hasPluginAllowlistWithEntries(cfg)) return true;
|
|
1185
|
+
if (hasConfiguredPluginConfigEntry(cfg)) return true;
|
|
1186
|
+
if (hasPotentialConfiguredChannels(cfg, env)) return true;
|
|
1187
|
+
if (hasConfiguredProviderModelOrHarness(cfg, env)) return true;
|
|
1188
|
+
if (hasConfiguredWebSearchPluginEntry(cfg) || hasConfiguredWebFetchPluginEntry(cfg)) return true;
|
|
1189
|
+
if (!hasSetupAutoEnableRelevantConfig(cfg)) return false;
|
|
1190
|
+
return resolvePluginSetupAutoEnableReasons({
|
|
1191
|
+
config: cfg,
|
|
1192
|
+
env,
|
|
1193
|
+
pluginIds: resolveRelevantSetupAutoEnablePluginIds(cfg)
|
|
1194
|
+
}).length > 0;
|
|
1195
|
+
}
|
|
1196
|
+
function resolvePluginAutoEnableCandidateReason(candidate) {
|
|
1197
|
+
switch (candidate.kind) {
|
|
1198
|
+
case "channel-configured": return `${candidate.channelId} configured`;
|
|
1199
|
+
case "provider-auth-configured": return `${candidate.providerId} auth configured`;
|
|
1200
|
+
case "provider-model-configured": return `${candidate.modelRef} model configured`;
|
|
1201
|
+
case "agent-harness-runtime-configured": return `${candidate.runtime} agent harness runtime configured`;
|
|
1202
|
+
case "web-fetch-provider-selected": return `${candidate.providerId} web fetch provider selected`;
|
|
1203
|
+
case "plugin-web-search-configured": return `${candidate.pluginId} web search configured`;
|
|
1204
|
+
case "plugin-web-fetch-configured": return `${candidate.pluginId} web fetch configured`;
|
|
1205
|
+
case "plugin-tool-configured": return `${candidate.pluginId} tool configured`;
|
|
1206
|
+
case "setup-auto-enable": return candidate.reason;
|
|
1207
|
+
}
|
|
1208
|
+
throw new Error("Unsupported plugin auto-enable candidate");
|
|
1209
|
+
}
|
|
1210
|
+
function resolveConfiguredPluginAutoEnableCandidates(params) {
|
|
1211
|
+
const changes = [];
|
|
1212
|
+
const channelToPluginId = buildChannelToPluginIdMap(params.registry);
|
|
1213
|
+
for (const channelId of collectCandidateChannelIds(params.config, params.env)) {
|
|
1214
|
+
const pluginId = resolvePluginIdForChannel(channelId, channelToPluginId);
|
|
1215
|
+
if (isChannelConfigured(params.config, channelId, params.env)) changes.push({
|
|
1216
|
+
pluginId,
|
|
1217
|
+
kind: "channel-configured",
|
|
1218
|
+
channelId
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
for (const [providerId, pluginId] of Object.entries(resolveAutoEnableProviderPluginIds(params.registry))) if (isProviderConfigured(params.config, providerId)) changes.push({
|
|
1222
|
+
pluginId,
|
|
1223
|
+
kind: "provider-auth-configured",
|
|
1224
|
+
providerId
|
|
1225
|
+
});
|
|
1226
|
+
for (const modelRef of collectModelRefs(params.config)) {
|
|
1227
|
+
const owningPluginIds = resolveOwningPluginIdsForModelRef({
|
|
1228
|
+
model: modelRef,
|
|
1229
|
+
config: params.config,
|
|
1230
|
+
env: params.env,
|
|
1231
|
+
manifestRegistry: params.registry
|
|
1232
|
+
});
|
|
1233
|
+
if (owningPluginIds?.length === 1) changes.push({
|
|
1234
|
+
pluginId: owningPluginIds[0],
|
|
1235
|
+
kind: "provider-model-configured",
|
|
1236
|
+
modelRef
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
for (const runtime of collectConfiguredAgentHarnessRuntimes(params.config, params.env)) {
|
|
1240
|
+
const pluginIds = resolveAgentHarnessOwnerPluginIds(params.registry, runtime);
|
|
1241
|
+
for (const pluginId of pluginIds) changes.push({
|
|
1242
|
+
pluginId,
|
|
1243
|
+
kind: "agent-harness-runtime-configured",
|
|
1244
|
+
runtime
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
const webFetchProvider = typeof params.config.tools?.web?.fetch?.provider === "string" ? params.config.tools.web.fetch.provider : void 0;
|
|
1248
|
+
const webFetchPluginId = resolvePluginIdForConfiguredWebFetchProvider(webFetchProvider, params.env);
|
|
1249
|
+
if (webFetchPluginId) changes.push({
|
|
1250
|
+
pluginId: webFetchPluginId,
|
|
1251
|
+
kind: "web-fetch-provider-selected",
|
|
1252
|
+
providerId: normalizeOptionalLowercaseString(webFetchProvider) ?? ""
|
|
1253
|
+
});
|
|
1254
|
+
for (const plugin of resolveProviderPluginsWithOwnedWebSearch(params.registry)) {
|
|
1255
|
+
const pluginId = plugin.id;
|
|
1256
|
+
if (hasPluginOwnedWebSearchConfig(params.config, pluginId)) changes.push({
|
|
1257
|
+
pluginId,
|
|
1258
|
+
kind: "plugin-web-search-configured"
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
for (const plugin of resolvePluginsWithOwnedToolConfig(params.registry)) {
|
|
1262
|
+
const pluginId = plugin.id;
|
|
1263
|
+
if (hasPluginOwnedToolConfig(params.config, plugin)) changes.push({
|
|
1264
|
+
pluginId,
|
|
1265
|
+
kind: "plugin-tool-configured"
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
for (const plugin of resolveProviderPluginsWithOwnedWebFetch(params.registry)) {
|
|
1269
|
+
const pluginId = plugin.id;
|
|
1270
|
+
if (hasPluginOwnedWebFetchConfig(params.config, pluginId)) changes.push({
|
|
1271
|
+
pluginId,
|
|
1272
|
+
kind: "plugin-web-fetch-configured"
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
if (hasSetupAutoEnableRelevantConfig(params.config)) for (const entry of resolvePluginSetupAutoEnableReasons({
|
|
1276
|
+
config: params.config,
|
|
1277
|
+
env: params.env,
|
|
1278
|
+
pluginIds: resolveRelevantSetupAutoEnablePluginIds(params.config)
|
|
1279
|
+
})) changes.push({
|
|
1280
|
+
pluginId: entry.pluginId,
|
|
1281
|
+
kind: "setup-auto-enable",
|
|
1282
|
+
reason: entry.reason
|
|
1283
|
+
});
|
|
1284
|
+
return changes;
|
|
1285
|
+
}
|
|
1286
|
+
function isPluginExplicitlyDisabled(cfg, pluginId) {
|
|
1287
|
+
const builtInChannelId = normalizeChatChannelId(pluginId);
|
|
1288
|
+
if (builtInChannelId) {
|
|
1289
|
+
const channelConfig = cfg.channels?.[builtInChannelId];
|
|
1290
|
+
if (channelConfig && typeof channelConfig === "object" && !Array.isArray(channelConfig) && channelConfig.enabled === false) return true;
|
|
1291
|
+
}
|
|
1292
|
+
return cfg.plugins?.entries?.[pluginId]?.enabled === false;
|
|
1293
|
+
}
|
|
1294
|
+
function isPluginDenied(cfg, pluginId) {
|
|
1295
|
+
const deny = cfg.plugins?.deny;
|
|
1296
|
+
return Array.isArray(deny) && deny.includes(pluginId);
|
|
1297
|
+
}
|
|
1298
|
+
function isBuiltInChannelAlreadyEnabled(cfg, channelId) {
|
|
1299
|
+
const channelConfig = cfg.channels?.[channelId];
|
|
1300
|
+
return !!channelConfig && typeof channelConfig === "object" && !Array.isArray(channelConfig) && channelConfig.enabled === true;
|
|
1301
|
+
}
|
|
1302
|
+
function registerPluginEntry(cfg, pluginId) {
|
|
1303
|
+
const builtInChannelId = normalizeChatChannelId(pluginId);
|
|
1304
|
+
if (builtInChannelId) {
|
|
1305
|
+
const existing = cfg.channels?.[builtInChannelId];
|
|
1306
|
+
const existingRecord = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
|
|
1307
|
+
return {
|
|
1308
|
+
...cfg,
|
|
1309
|
+
channels: {
|
|
1310
|
+
...cfg.channels,
|
|
1311
|
+
[builtInChannelId]: {
|
|
1312
|
+
...existingRecord,
|
|
1313
|
+
enabled: true
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
return {
|
|
1319
|
+
...cfg,
|
|
1320
|
+
plugins: {
|
|
1321
|
+
...cfg.plugins,
|
|
1322
|
+
entries: {
|
|
1323
|
+
...cfg.plugins?.entries,
|
|
1324
|
+
[pluginId]: {
|
|
1325
|
+
...cfg.plugins?.entries?.[pluginId],
|
|
1326
|
+
enabled: true
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
function hasMaterialPluginEntryConfig(entry) {
|
|
1333
|
+
if (!isRecord(entry)) return false;
|
|
1334
|
+
return entry.enabled === true || isRecord(entry.config) || isRecord(entry.hooks) || isRecord(entry.subagent) || entry.apiKey !== void 0 || entry.env !== void 0;
|
|
1335
|
+
}
|
|
1336
|
+
function isKnownPluginId(pluginId, manifestRegistry) {
|
|
1337
|
+
if (normalizeChatChannelId(pluginId)) return true;
|
|
1338
|
+
return manifestRegistry.plugins.some((plugin) => plugin.id === pluginId);
|
|
1339
|
+
}
|
|
1340
|
+
function materializeConfiguredPluginEntryAllowlist(params) {
|
|
1341
|
+
let next = params.config;
|
|
1342
|
+
const allow = next.plugins?.allow;
|
|
1343
|
+
const entries = next.plugins?.entries;
|
|
1344
|
+
if (!Array.isArray(allow) || allow.length === 0 || !entries || typeof entries !== "object") return next;
|
|
1345
|
+
for (const pluginId of Object.keys(entries).toSorted((left, right) => left.localeCompare(right))) {
|
|
1346
|
+
const entry = entries[pluginId];
|
|
1347
|
+
if (!hasMaterialPluginEntryConfig(entry) || isPluginDenied(next, pluginId) || isPluginExplicitlyDisabled(next, pluginId) || allow.includes(pluginId) || !isKnownPluginId(pluginId, params.manifestRegistry)) continue;
|
|
1348
|
+
next = ensurePluginAllowlisted(next, pluginId);
|
|
1349
|
+
params.changes.push(`${pluginId} plugin config present, added to plugin allowlist.`);
|
|
1350
|
+
}
|
|
1351
|
+
return next;
|
|
1352
|
+
}
|
|
1353
|
+
function resolveChannelAutoEnableDisplayLabel(entry, manifestRegistry) {
|
|
1354
|
+
const builtInChannelId = normalizeChatChannelId(entry.channelId);
|
|
1355
|
+
if (builtInChannelId) return getChatChannelMeta(builtInChannelId)?.label;
|
|
1356
|
+
const plugin = manifestRegistry.plugins.find((record) => record.id === entry.pluginId);
|
|
1357
|
+
return plugin?.channelConfigs?.[entry.channelId]?.label ?? plugin?.channelCatalogMeta?.label;
|
|
1358
|
+
}
|
|
1359
|
+
function formatAutoEnableChange(entry, manifestRegistry) {
|
|
1360
|
+
if (entry.kind === "channel-configured") {
|
|
1361
|
+
const label = resolveChannelAutoEnableDisplayLabel(entry, manifestRegistry);
|
|
1362
|
+
if (label) return `${label} configured, enabled automatically.`;
|
|
1363
|
+
}
|
|
1364
|
+
return `${resolvePluginAutoEnableCandidateReason(entry).trim()}, enabled automatically.`;
|
|
1365
|
+
}
|
|
1366
|
+
function resolvePluginAutoEnableManifestRegistry(params) {
|
|
1367
|
+
return params.manifestRegistry ?? (configMayNeedPluginManifestRegistry(params.config, params.env) ? loadPluginManifestRegistry({
|
|
1368
|
+
config: params.config,
|
|
1369
|
+
env: params.env
|
|
1370
|
+
}) : EMPTY_PLUGIN_MANIFEST_REGISTRY);
|
|
1371
|
+
}
|
|
1372
|
+
function materializePluginAutoEnableCandidatesInternal(params) {
|
|
1373
|
+
let next = params.config ?? {};
|
|
1374
|
+
const changes = [];
|
|
1375
|
+
const autoEnabledReasons = /* @__PURE__ */ new Map();
|
|
1376
|
+
if (next.plugins?.enabled === false) return {
|
|
1377
|
+
config: next,
|
|
1378
|
+
changes,
|
|
1379
|
+
autoEnabledReasons: {}
|
|
1380
|
+
};
|
|
1381
|
+
const preferOverCache = /* @__PURE__ */ new Map();
|
|
1382
|
+
for (const entry of params.candidates) {
|
|
1383
|
+
const builtInChannelId = normalizeChatChannelId(entry.pluginId);
|
|
1384
|
+
if (isPluginDenied(next, entry.pluginId) || isPluginExplicitlyDisabled(next, entry.pluginId)) continue;
|
|
1385
|
+
if (shouldSkipPreferredPluginAutoEnable({
|
|
1386
|
+
config: next,
|
|
1387
|
+
entry,
|
|
1388
|
+
configured: params.candidates,
|
|
1389
|
+
env: params.env,
|
|
1390
|
+
registry: params.manifestRegistry,
|
|
1391
|
+
isPluginDenied,
|
|
1392
|
+
isPluginExplicitlyDisabled,
|
|
1393
|
+
preferOverCache
|
|
1394
|
+
})) continue;
|
|
1395
|
+
const allow = next.plugins?.allow;
|
|
1396
|
+
const allowMissing = Array.isArray(allow) && !allow.includes(entry.pluginId);
|
|
1397
|
+
if ((builtInChannelId != null ? isBuiltInChannelAlreadyEnabled(next, builtInChannelId) : next.plugins?.entries?.[entry.pluginId]?.enabled === true) && !allowMissing) continue;
|
|
1398
|
+
next = registerPluginEntry(next, entry.pluginId);
|
|
1399
|
+
next = ensurePluginAllowlisted(next, entry.pluginId);
|
|
1400
|
+
const reason = resolvePluginAutoEnableCandidateReason(entry);
|
|
1401
|
+
autoEnabledReasons.set(entry.pluginId, [...autoEnabledReasons.get(entry.pluginId) ?? [], reason]);
|
|
1402
|
+
changes.push(formatAutoEnableChange(entry, params.manifestRegistry));
|
|
1403
|
+
}
|
|
1404
|
+
next = materializeConfiguredPluginEntryAllowlist({
|
|
1405
|
+
config: next,
|
|
1406
|
+
changes,
|
|
1407
|
+
manifestRegistry: params.manifestRegistry
|
|
1408
|
+
});
|
|
1409
|
+
const autoEnabledReasonRecord = Object.create(null);
|
|
1410
|
+
for (const [pluginId, reasons] of autoEnabledReasons) if (!isBlockedObjectKey(pluginId)) autoEnabledReasonRecord[pluginId] = [...reasons];
|
|
1411
|
+
return {
|
|
1412
|
+
config: next,
|
|
1413
|
+
changes,
|
|
1414
|
+
autoEnabledReasons: autoEnabledReasonRecord
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
function detectPluginAutoEnableCandidates(params) {
|
|
1418
|
+
const env = params.env ?? process.env;
|
|
1419
|
+
const config = params.config ?? {};
|
|
1420
|
+
if (!configMayNeedPluginAutoEnable(config, env)) return [];
|
|
1421
|
+
return resolveConfiguredPluginAutoEnableCandidates({
|
|
1422
|
+
config,
|
|
1423
|
+
env,
|
|
1424
|
+
registry: resolvePluginAutoEnableManifestRegistry({
|
|
1425
|
+
config,
|
|
1426
|
+
env,
|
|
1427
|
+
manifestRegistry: params.manifestRegistry
|
|
1428
|
+
})
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1431
|
+
function materializePluginAutoEnableCandidates(params) {
|
|
1432
|
+
const env = params.env ?? process.env;
|
|
1433
|
+
const config = params.config ?? {};
|
|
1434
|
+
const manifestRegistry = resolvePluginAutoEnableManifestRegistry({
|
|
1435
|
+
config,
|
|
1436
|
+
env,
|
|
1437
|
+
manifestRegistry: params.manifestRegistry
|
|
1438
|
+
});
|
|
1439
|
+
return materializePluginAutoEnableCandidatesInternal({
|
|
1440
|
+
config,
|
|
1441
|
+
candidates: params.candidates,
|
|
1442
|
+
env,
|
|
1443
|
+
manifestRegistry
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
function applyPluginAutoEnable(params) {
|
|
1447
|
+
const candidates = detectPluginAutoEnableCandidates(params);
|
|
1448
|
+
return materializePluginAutoEnableCandidates({
|
|
1449
|
+
config: params.config,
|
|
1450
|
+
candidates,
|
|
1451
|
+
env: params.env,
|
|
1452
|
+
manifestRegistry: params.manifestRegistry
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
//#endregion
|
|
1456
|
+
export { hasExplicitPluginIdScope as _, resolveDiscoverableProviderOwnerPluginIds as a, resolveExternalAuthProfileCompatFallbackPluginIds as c, resolveOwningPluginIdsForProvider as d, withBundledProviderVitestCompat as f, createPluginIdScopeSet as g, buildPluginApi as h, resolveCatalogHookProviderPluginIds as i, resolveExternalAuthProfileProviderPluginIds as l, isChannelConfigured as m, resolveActivatableProviderOwnerPluginIds as n, resolveDiscoveredProviderPluginIds as o, resolvePluginSetupProvider as p, resolveBundledProviderCompatPluginIds as r, resolveEnabledProviderPluginIds as s, applyPluginAutoEnable as t, resolveOwningPluginIdsForModelRefs as u, normalizePluginIdScope as v, serializePluginIdScope as y };
|