multicorn-shield 1.11.0 → 1.12.0
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/CHANGELOG.md +31 -0
- package/README.md +10 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/multicorn-proxy.js +349 -212
- package/dist/multicorn-shield.js +340 -209
- package/dist/openclaw-hook/HOOK.md +5 -3
- package/dist/openclaw-hook/handler.js +1 -1
- package/dist/openclaw-plugin/multicorn-shield.js +28 -7
- package/dist/openclaw-plugin/openclaw.plugin.json +1 -1
- package/dist/server.js +3499 -0
- package/dist/shield-extension.js +3 -12
- package/package.json +5 -3
- package/plugins/windsurf/hooks/scripts/pre-action.cjs +126 -17
|
@@ -33,9 +33,11 @@ metadata:
|
|
|
33
33
|
> "entries": {
|
|
34
34
|
> "multicorn-shield": {
|
|
35
35
|
> "enabled": true,
|
|
36
|
-
> "
|
|
37
|
-
> "
|
|
38
|
-
> "
|
|
36
|
+
> "config": {
|
|
37
|
+
> "apiKey": "${MULTICORN_API_KEY}",
|
|
38
|
+
> "baseUrl": "https://api.multicorn.ai",
|
|
39
|
+
> "agentName": "openclaw",
|
|
40
|
+
> "failMode": "closed"
|
|
39
41
|
> }
|
|
40
42
|
> }
|
|
41
43
|
> }
|
|
@@ -184,7 +184,7 @@ function handleHttpError(status, logger, retryDelaySeconds) {
|
|
|
184
184
|
if (status === 401 || status === 403) {
|
|
185
185
|
if (!authErrorLogged) {
|
|
186
186
|
authErrorLogged = true;
|
|
187
|
-
const errorMsg = "[multicorn-shield] ERROR: Authentication failed. Your MULTICORN_API_KEY is invalid or expired. Check the key in
|
|
187
|
+
const errorMsg = "[multicorn-shield] ERROR: Authentication failed. Your MULTICORN_API_KEY is invalid or expired. Check the key in ~/.multicorn/config.json (from npx multicorn-shield init) or ~/.openclaw/openclaw.json \u2192 plugins.entries.multicorn-shield.config.apiKey. Get a valid key from your Multicorn dashboard (Settings \u2192 API Keys).";
|
|
188
188
|
process.stderr.write(`${errorMsg}
|
|
189
189
|
`);
|
|
190
190
|
}
|
|
@@ -189,7 +189,7 @@ function handleHttpError(status, logger, retryDelaySeconds) {
|
|
|
189
189
|
if (status === 401 || status === 403) {
|
|
190
190
|
if (!authErrorLogged) {
|
|
191
191
|
authErrorLogged = true;
|
|
192
|
-
const errorMsg = "[multicorn-shield] ERROR: Authentication failed. Your MULTICORN_API_KEY is invalid or expired. Check the key in
|
|
192
|
+
const errorMsg = "[multicorn-shield] ERROR: Authentication failed. Your MULTICORN_API_KEY is invalid or expired. Check the key in ~/.multicorn/config.json (from npx multicorn-shield init) or ~/.openclaw/openclaw.json \u2192 plugins.entries.multicorn-shield.config.apiKey. Get a valid key from your Multicorn dashboard (Settings \u2192 API Keys).";
|
|
193
193
|
logger?.error(errorMsg);
|
|
194
194
|
process.stderr.write(`${errorMsg}
|
|
195
195
|
`);
|
|
@@ -491,20 +491,41 @@ function agentNameFromOpenclawPlatform(cfg) {
|
|
|
491
491
|
}
|
|
492
492
|
return void 0;
|
|
493
493
|
}
|
|
494
|
+
var ENV_REF_PATTERN = /^\$\{([A-Z_][A-Z0-9_]*)\}$/;
|
|
495
|
+
function resolveConfigString(value) {
|
|
496
|
+
const raw = asString(value);
|
|
497
|
+
if (raw === void 0) return void 0;
|
|
498
|
+
const match = ENV_REF_PATTERN.exec(raw.trim());
|
|
499
|
+
if (match === null) return raw;
|
|
500
|
+
const envName = match[1];
|
|
501
|
+
if (envName === void 0) return void 0;
|
|
502
|
+
const fromEnv = process.env[envName];
|
|
503
|
+
return typeof fromEnv === "string" && fromEnv.length > 0 ? fromEnv : void 0;
|
|
504
|
+
}
|
|
505
|
+
function parseFailMode(value) {
|
|
506
|
+
if (value === "open") return "open";
|
|
507
|
+
if (value === "closed") return "closed";
|
|
508
|
+
return "closed";
|
|
509
|
+
}
|
|
494
510
|
function readConfig() {
|
|
495
511
|
const pc = pluginConfig ?? {};
|
|
496
|
-
const
|
|
497
|
-
const
|
|
512
|
+
const fromFileKey = asString(cachedMulticornConfig?.apiKey);
|
|
513
|
+
const fromPluginKey = resolveConfigString(pc["apiKey"]);
|
|
514
|
+
const fromEnvKey = asString(process.env["MULTICORN_API_KEY"]);
|
|
515
|
+
let apiKey = fromFileKey ?? fromPluginKey ?? fromEnvKey ?? "";
|
|
516
|
+
const fromPluginBase = resolveConfigString(pc["baseUrl"]);
|
|
517
|
+
const fromFileBase = asString(cachedMulticornConfig?.baseUrl);
|
|
518
|
+
const fromEnvBase = asString(process.env["MULTICORN_BASE_URL"]);
|
|
519
|
+
const baseUrl = fromPluginBase ?? fromFileBase ?? fromEnvBase ?? "https://api.multicorn.ai";
|
|
498
520
|
const agentName = asString(pc["agentName"]) ?? process.env["MULTICORN_AGENT_NAME"] ?? agentNameFromOpenclawPlatform(cachedMulticornConfig) ?? asString(cachedMulticornConfig?.agentName) ?? null;
|
|
499
|
-
const failMode = "
|
|
500
|
-
let apiKey = resolvedApiKey;
|
|
521
|
+
const failMode = parseFailMode(pc["failMode"]);
|
|
501
522
|
if (apiKey.length > 0 && (!apiKey.startsWith("mcs_") || apiKey.length < 16)) {
|
|
502
523
|
pluginLogger?.error(
|
|
503
524
|
"Invalid API key format. Key must start with mcs_ and be at least 16 characters."
|
|
504
525
|
);
|
|
505
526
|
apiKey = "";
|
|
506
527
|
}
|
|
507
|
-
return { apiKey, baseUrl
|
|
528
|
+
return { apiKey, baseUrl, agentName, failMode };
|
|
508
529
|
}
|
|
509
530
|
function asString(value) {
|
|
510
531
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
@@ -919,4 +940,4 @@ function resetState() {
|
|
|
919
940
|
hasLoggedFirstAction = false;
|
|
920
941
|
}
|
|
921
942
|
|
|
922
|
-
export { afterToolCall, beforeToolCall, plugin, readConfig, register, resetState, resolveAgentName };
|
|
943
|
+
export { afterToolCall, beforeToolCall, plugin, readConfig, register, resetState, resolveAgentName, resolveConfigString };
|