ソースを参照

fix(webfetch): harden tool-count check against undefined disabledTools

Default parameters may be skipped by the plugin transpiler when an
argument arrives as undefined (arguments.length semantics), so
Array.isArray coercion keeps minimumExpectedToolCount from throwing on
an undefined disabledTools set.

Adds webfetch config schema entries for enabled flag and dedicated
smartfetch model(s).
adikpb 2 週間 前
コミット
eec7c83338
2 ファイル変更49 行追加5 行削除
  1. 44 0
      oh-my-opencode-slim.schema.json
  2. 5 5
      src/index.ts

+ 44 - 0
oh-my-opencode-slim.schema.json

@@ -1171,6 +1171,50 @@
         }
       }
     },
+    "webfetch": {
+      "type": "object",
+      "properties": {
+        "enabled": {
+          "default": true,
+          "description": "When false, skip registering this enhanced webfetch so OpenCode uses its built-in version.",
+          "type": "boolean"
+        },
+        "model": {
+          "description": "Dedicated model(s) for smartfetch secondary-model summarization. Same shape as agent model config (string, array of strings/objects with id+variant). Takes priority over small_model, agents.explorer.model, and agents.librarian.model.",
+          "anyOf": [
+            {
+              "type": "string"
+            },
+            {
+              "minItems": 1,
+              "type": "array",
+              "items": {
+                "anyOf": [
+                  {
+                    "type": "string"
+                  },
+                  {
+                    "type": "object",
+                    "properties": {
+                      "id": {
+                        "type": "string"
+                      },
+                      "variant": {
+                        "type": "string"
+                      }
+                    },
+                    "required": [
+                      "id"
+                    ]
+                  }
+                ]
+              }
+            }
+          ]
+        }
+      },
+      "additionalProperties": false
+    },
     "acpAgents": {
       "type": "object",
       "propertyNames": {

+ 5 - 5
src/index.ts

@@ -120,10 +120,13 @@ export function minimumExpectedToolCount(
   disabledTools: readonly string[] = [],
   webfetchEnabled = true,
 ): number {
+  // Coerce explicitly: the plugin transpiler may skip default params when
+  // an argument is passed as undefined (arguments.length semantics).
+  const tools = Array.isArray(disabledTools) ? disabledTools : [];
   let count = HEALTH_CHECK.minTools;
   if (!webfetchEnabled) count -= 1;
   const disabledBaselineTools = new Set(
-    disabledTools.filter((toolName) => BASELINE_TOOL_NAMES.has(toolName)),
+    tools.filter((toolName) => BASELINE_TOOL_NAMES.has(toolName)),
   );
   return count - disabledBaselineTools.size;
 }
@@ -291,9 +294,7 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
       const entries = Array.isArray(webfetchModel)
         ? webfetchModel
         : [webfetchModel];
-      type ModelRefInput =
-        | string
-        | { id: string; variant?: string };
+      type ModelRefInput = string | { id: string; variant?: string };
       const models: Array<{ id: string; variant?: string }> = [];
       for (const entry of entries as ModelRefInput[]) {
         const id = typeof entry === 'string' ? entry : entry.id;
@@ -520,7 +521,6 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
     config.disabled_tools,
     config.webfetch?.enabled !== false,
   );
-
   if (
     agentCount < HEALTH_CHECK.minAgents ||
     toolCount < toolThreshold ||