@indexnetwork/protocol 8.2.0-rc.423.1 → 8.3.0-rc.424.1

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.
@@ -86,11 +86,11 @@ export declare const McpActivityCallerSchema: z.ZodObject<{
86
86
  /** A network agent's bound community; always null for humans. */
87
87
  networkScopeId: z.ZodNullable<z.ZodString>;
88
88
  }, "strict", z.ZodTypeAny, {
89
- kind: "human" | "agent";
89
+ kind: "agent" | "human";
90
90
  permissions: string[];
91
91
  networkScopeId: string | null;
92
92
  }, {
93
- kind: "human" | "agent";
93
+ kind: "agent" | "human";
94
94
  permissions: string[];
95
95
  networkScopeId: string | null;
96
96
  }>;
@@ -31,7 +31,8 @@ export interface ModelConfig {
31
31
  /** Override the chat reasoning effort. Falls back to CHAT_REASONING_EFFORT env var. */
32
32
  chatReasoningEffort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
33
33
  }
34
- declare function getModelConfig(config?: ModelConfig): {
34
+ /** Per-agent model settings before any eval-only override is applied. */
35
+ declare function getBaseModelConfig(config?: ModelConfig): {
35
36
  readonly intentInferrer: {
36
37
  readonly model: "google/gemini-2.5-flash";
37
38
  };
@@ -172,7 +173,7 @@ declare function getModelConfig(config?: ModelConfig): {
172
173
  };
173
174
  };
174
175
  /** Key identifying one of the per-agent model configurations. */
175
- export type ModelAgent = keyof ReturnType<typeof getModelConfig>;
176
+ export type ModelAgent = keyof ReturnType<typeof getBaseModelConfig>;
176
177
  /**
177
178
  * Returns the model name string for the given agent key.
178
179
  * @param agent - Key from MODEL_CONFIG identifying which agent's settings to use.
@@ -1,5 +1,49 @@
1
1
  import { ChatOpenAI } from "@langchain/openai";
2
- function getModelConfig(config) {
2
+ /**
3
+ * Eval-only per-agent model overrides, e.g.
4
+ * `EVAL_MODEL_OVERRIDES={"opportunityEvaluator":"anthropic/claude-sonnet-4"}`.
5
+ *
6
+ * Read on every call (no caching) to match the surrounding env convention, and
7
+ * ignored entirely in production so a deployed process can never be repointed at
8
+ * another model by an environment variable. A malformed value or an unknown agent
9
+ * key throws: a typo must not silently produce a run that measured the default.
10
+ */
11
+ function readModelOverrides(agentKeys) {
12
+ if (process.env.NODE_ENV === "production")
13
+ return {};
14
+ const raw = process.env.EVAL_MODEL_OVERRIDES?.trim();
15
+ if (!raw)
16
+ return {};
17
+ let parsed;
18
+ try {
19
+ parsed = JSON.parse(raw);
20
+ }
21
+ catch (err) {
22
+ // `new Error(msg, { cause })` needs lib ES2022; this package targets ES2020,
23
+ // so the cause is attached after construction (same pattern as elsewhere in src).
24
+ const wrapped = new Error(`EVAL_MODEL_OVERRIDES is not valid JSON: ${raw}`);
25
+ wrapped.cause = err;
26
+ throw wrapped;
27
+ }
28
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
29
+ throw new Error("EVAL_MODEL_OVERRIDES must be a JSON object of agent -> model id");
30
+ }
31
+ const overrides = {};
32
+ for (const [agent, model] of Object.entries(parsed)) {
33
+ if (!agentKeys.includes(agent)) {
34
+ throw new Error(`EVAL_MODEL_OVERRIDES names an unknown agent "${agent}". Known agents: ${agentKeys.join(", ")}`);
35
+ }
36
+ if (typeof model !== "string" || model.trim() === "") {
37
+ throw new Error(`EVAL_MODEL_OVERRIDES value for "${agent}" must be a non-empty model id string`);
38
+ }
39
+ // Store trimmed: surrounding whitespace in the JSON value would otherwise be
40
+ // sent verbatim to OpenRouter as part of the model id.
41
+ overrides[agent] = model.trim();
42
+ }
43
+ return overrides;
44
+ }
45
+ /** Per-agent model settings before any eval-only override is applied. */
46
+ function getBaseModelConfig(config) {
3
47
  return {
4
48
  intentInferrer: { model: "google/gemini-2.5-flash" },
5
49
  intentIndexer: { model: "google/gemini-2.5-flash" },
@@ -43,6 +87,22 @@ function getModelConfig(config) {
43
87
  },
44
88
  };
45
89
  }
90
+ /**
91
+ * Per-agent model settings, with `EVAL_MODEL_OVERRIDES` applied when present.
92
+ * Only the model id is overridable: temperature, token limits and reasoning
93
+ * effort stay fixed so an eval measures a model swap and nothing else.
94
+ */
95
+ function getModelConfig(config) {
96
+ const base = getBaseModelConfig(config);
97
+ const overrides = readModelOverrides(Object.keys(base));
98
+ if (Object.keys(overrides).length === 0)
99
+ return base;
100
+ const merged = Object.fromEntries(Object.entries(base).map(([agent, settings]) => {
101
+ const model = overrides[agent];
102
+ return [agent, model ? { ...settings, model } : settings];
103
+ }));
104
+ return merged;
105
+ }
46
106
  /**
47
107
  * Returns the model name string for the given agent key.
48
108
  * @param agent - Key from MODEL_CONFIG identifying which agent's settings to use.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indexnetwork/protocol",
3
- "version": "8.2.0-rc.423.1",
3
+ "version": "8.3.0-rc.424.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -43,6 +43,7 @@
43
43
  "eval:canary": "bun --env-file=../../.env.test ./eval/canary/canary.eval.ts",
44
44
  "eval:stance": "bun --env-file=../../.env.test ./eval/stance/stance.eval.ts",
45
45
  "eval:view": "bun ./eval/viewer/viewer.eval.ts",
46
+ "eval:web": "bun --env-file=../../.env.test ./eval/ops/ops.serve.ts",
46
47
  "eval:verify": "bun ./eval/verify.ts"
47
48
  },
48
49
  "dependencies": {