@tangle-network/agent-interface 5.10.19 → 5.10.21

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.
@@ -55,7 +55,7 @@ export interface HarnessModelExclusion {
55
55
  *
56
56
  * pi's chat-completions client (pi-ai 0.85.1) marks a model as reasoning only when the profile asks
57
57
  * for a reasoning effort, and only a reasoning model is sent the `developer` role and
58
- * `reasoning_effort`; that is why the first two entries need a reasoning effort.
58
+ * `reasoning_effort`; that is why every entry needs a reasoning effort.
59
59
  */
60
60
  export declare const harnessModelExclusions: readonly HarnessModelExclusion[];
61
61
  /** The answer to "can this harness run this model", with the refusal a caller can show as-is. */
@@ -120,14 +120,7 @@ export interface ModelReasoningCapability {
120
120
  * lower ceiling caps the list there. Pass `model` from your catalog; omit it for the harness-only set.
121
121
  */
122
122
  export declare function reasoningEffortsFor(harness: HarnessType, model?: ModelReasoningCapability | null): readonly ReasoningEffort[];
123
- /**
124
- * The native control token a harness applies for one canonical effort, or `null` when it applies
125
- * none. `effort: null` (nothing requested) is always `null`.
126
- *
127
- * One owner for both sides of the check: the adapter that builds the harness argv and the caller
128
- * that verifies the receipt read this function, so a CLI that renames a rung moves both at once
129
- * instead of turning into a refused run.
130
- */
123
+ /** Native token shared by argv builders and receipt verification; null means no control. */
131
124
  export declare function nativeReasoningControl(harness: HarnessType, effort: ReasoningEffort | null, model?: string): string | null;
132
125
  /** Whether the harness's runner honors a per-turn MODEL override (vs. picking the model itself). */
133
126
  export declare function harnessHonorsModel(harness: HarnessType): boolean;
@@ -1,5 +1,6 @@
1
1
  import { REASONING_EFFORTS, } from "./agent-profile.js";
2
2
  import { resolveHarnessType } from "./harness.js";
3
+ import { findProfileKbModel } from "./profile-kb/models.js";
3
4
  /** Canonical harness/model, effort and prompt controls. Model-specific capability comes from the serving catalog. */
4
5
  /** low → high. `none` = thinking off; `ultracode` = max (claude-code mode). */
5
6
  export const reasoningLadder = REASONING_EFFORTS;
@@ -98,7 +99,7 @@ const SANDBOX_HARNESS_MATRIX_EVIDENCE = "https://github.com/tangle-network/agent
98
99
  *
99
100
  * pi's chat-completions client (pi-ai 0.85.1) marks a model as reasoning only when the profile asks
100
101
  * for a reasoning effort, and only a reasoning model is sent the `developer` role and
101
- * `reasoning_effort`; that is why the first two entries need a reasoning effort.
102
+ * `reasoning_effort`; that is why every entry needs a reasoning effort.
102
103
  */
103
104
  export const harnessModelExclusions = [
104
105
  {
@@ -119,15 +120,6 @@ export const harnessModelExclusions = [
119
120
  measuredOn: "2026-10-05",
120
121
  evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE,
121
122
  },
122
- {
123
- harness: "pi",
124
- models: /^google\/gemini-3\.8-flash$/,
125
- onlyWithReasoningEffort: false,
126
- reason: "the model requires each function call to return its thought_signature, which pi's " +
127
- "chat-completions client does not send back (400 Function call is missing a thought_signature)",
128
- measuredOn: "2026-10-05",
129
- evidence: SANDBOX_HARNESS_MATRIX_EVIDENCE,
130
- },
131
123
  ];
132
124
  /**
133
125
  * Whether a harness can run a model, and why not. A bare id resolves its provider through
@@ -262,12 +254,7 @@ export function reasoningEffortsFor(harness, model) {
262
254
  }
263
255
  // ── Native reasoning control (the exact token the harness process receives) ───
264
256
  /**
265
- * Canonical effort → the harness's OWN control token, or `null` when the harness applies no
266
- * native reasoning control for that request. This is the value a materialization receipt carries
267
- * as `reasoningEffort.applied`, so a caller can check that the effort it asked for reached the
268
- * process instead of trusting an echo of its own request.
269
- *
270
- * Read from the argv builders that actually spawn each CLI, not from help text:
257
+ * CLI controls recorded as reasoningEffort.applied in materialization receipts:
271
258
  * - claude-code — `--effort <value>`; it cannot express `none` or `minimal`, so both clamp to
272
259
  * `low`, and `ultracode` becomes its ceiling `max`.
273
260
  * - codex — `-c model_reasoning_effort="<value>"`; it takes the canonical rungs directly and
@@ -276,16 +263,10 @@ export function reasoningEffortsFor(harness, model) {
276
263
  * `max` (pi 1.4.0 `cli/args.js`, the prime fork's `cli/args.ts`, openclaw `agent --help`).
277
264
  * - kimi-code — the control is the FLAG itself, `--thinking` or `--no-thinking`, because kimi's
278
265
  * thinking switch is binary. `medium` is its default and passes no flag at all.
279
- * - opencode — `--variant <value>`, forwarded verbatim as the provider's reasoning effort; `none`
280
- * omits the flag, as the sandbox adapter does. No
281
- * provider spells `ultracode`, so it becomes the model's ceiling: `max` for GLM (Z.ai answers
282
- * 400 code 1210 for anything outside `none…max`) and `xhigh` for every other model (GPT-6
283
- * answers `max` with 400). Pass `model` so this rung resolves; without it `xhigh` is sent.
284
- *
285
- * A harness with no entry applies NO native control: either it derives thinking from the model
286
- * (gemini's `--thinking-budget`) or it plumbs no thinking flag at all (see
287
- * {@link harnessHonorsEffort}). Both answer `null`, which is what their receipts carry — so an
288
- * unknown harness is never asserted to have applied a control it cannot apply.
266
+ * - opencode — `--variant <value>`; `none` omits the flag. The sourced model KB owns native
267
+ * effort translations (Flash uses low/high/max). Otherwise `ultracode` becomes `max` for GLM
268
+ * and `xhigh` for other/unknown models; other rungs pass through.
269
+ * Unlisted harnesses apply no native control (see {@link harnessHonorsEffort}).
289
270
  */
290
271
  const thinkingRung = (effort) => {
291
272
  if (effort === "none")
@@ -312,19 +293,15 @@ const harnessNativeReasoningControl = {
312
293
  opencode: (effort, model) => {
313
294
  if (effort === "none")
314
295
  return null;
296
+ const native = findProfileKbModel(model)?.nativeEfforts?.[effort];
297
+ if (native !== undefined)
298
+ return native;
315
299
  if (effort !== "ultracode")
316
300
  return effort;
317
301
  return /(?:^|\/)glm-/iu.test(model ?? "") ? "max" : "xhigh";
318
302
  },
319
303
  };
320
- /**
321
- * The native control token a harness applies for one canonical effort, or `null` when it applies
322
- * none. `effort: null` (nothing requested) is always `null`.
323
- *
324
- * One owner for both sides of the check: the adapter that builds the harness argv and the caller
325
- * that verifies the receipt read this function, so a CLI that renames a rung moves both at once
326
- * instead of turning into a refused run.
327
- */
304
+ /** Native token shared by argv builders and receipt verification; null means no control. */
328
305
  export function nativeReasoningControl(harness, effort, model) {
329
306
  if (effort === null)
330
307
  return null;
@@ -9,18 +9,16 @@
9
9
  import { composeAgentProfileGuidance, type AgentProfile } from "../agent-profile.js";
10
10
  import type { HarnessType } from "../harness.js";
11
11
  import { profileKbHarnesses } from "./harnesses.js";
12
- import { profileKbModels } from "./models.js";
12
+ import { profileKbModels, profileKbNamesModel } from "./models.js";
13
13
  import { profileKbDiscrepancies, profileKbLearnings } from "./records.js";
14
14
  export type * from "./types.js";
15
15
  export type { AgentProfileGuidanceBlock, AgentProfileGuidanceChannel, AgentProfileGuidanceOptions, } from "../agent-profile.js";
16
- export { composeAgentProfileGuidance, profileKbDiscrepancies, profileKbHarnesses, profileKbLearnings, profileKbModels, };
16
+ export { composeAgentProfileGuidance, profileKbDiscrepancies, profileKbHarnesses, profileKbLearnings, profileKbModels, profileKbNamesModel, };
17
17
  /**
18
18
  * The guidance block sources the knowledge base owns. {@link withProfileKb}
19
19
  * replaces blocks from these sources and keeps blocks any other layer added.
20
20
  */
21
21
  export declare const PROFILE_KB_SOURCES: readonly ["harness", "model", "learning"];
22
- /** Whether the knowledge base lists this exact spelling: a model id or one of its aliases, such as `zai-coding-plan/glm-5.3`. */
23
- export declare const profileKbNamesModel: (name: string) => boolean;
24
22
  /** Which harness and model to compose guidance for. */
25
23
  export interface ProfileKbSelection {
26
24
  harness?: HarnessType | string;
@@ -10,9 +10,9 @@ import { composeAgentProfileGuidance, } from "../agent-profile.js";
10
10
  import { deepFreeze } from "../deep-freeze.js";
11
11
  import { harnessSystemPromptIntents } from "../harness-capabilities.js";
12
12
  import { profileKbHarnesses } from "./harnesses.js";
13
- import { profileKbModels } from "./models.js";
13
+ import { findProfileKbModel, profileKbModels, profileKbNamesModel } from "./models.js";
14
14
  import { profileKbDiscrepancies, profileKbLearnings } from "./records.js";
15
- export { composeAgentProfileGuidance, profileKbDiscrepancies, profileKbHarnesses, profileKbLearnings, profileKbModels, };
15
+ export { composeAgentProfileGuidance, profileKbDiscrepancies, profileKbHarnesses, profileKbLearnings, profileKbModels, profileKbNamesModel, };
16
16
  /**
17
17
  * The guidance block sources the knowledge base owns. {@link withProfileKb}
18
18
  * replaces blocks from these sources and keeps blocks any other layer added.
@@ -25,47 +25,10 @@ export const PROFILE_KB_SOURCES = ["harness", "model", "learning"];
25
25
  * types stay as they were published.
26
26
  */
27
27
  const harnessSnapshot = deepFreeze(structuredClone(profileKbHarnesses));
28
- const modelSnapshot = deepFreeze(structuredClone(profileKbModels));
29
28
  const learningSnapshot = deepFreeze(structuredClone(profileKbLearnings));
30
29
  function harnessPosition(harness) {
31
30
  return harnessSnapshot.findIndex((entry) => entry.id === harness);
32
31
  }
33
- const modelIndex = (() => {
34
- const index = new Map();
35
- modelSnapshot.forEach((model, position) => {
36
- for (const name of [model.id, ...model.aliases]) {
37
- const key = name.toLowerCase();
38
- if (index.has(key)) {
39
- throw new Error(`profile-kb: model name ${name} is declared twice`);
40
- }
41
- index.set(key, position);
42
- }
43
- });
44
- return index;
45
- })();
46
- /**
47
- * Try the name as given, then without each leading `provider/` or route
48
- * segment, after dropping a trailing `:suffix`.
49
- */
50
- function matchModelName(model, lookup) {
51
- if (!model)
52
- return undefined;
53
- const colon = model.lastIndexOf(":");
54
- let candidate = (colon > 0 ? model.slice(0, colon) : model)
55
- .trim()
56
- .toLowerCase();
57
- for (;;) {
58
- const found = lookup(candidate);
59
- if (found !== undefined)
60
- return found;
61
- const slash = candidate.indexOf("/");
62
- if (slash < 0)
63
- return undefined;
64
- candidate = candidate.slice(slash + 1);
65
- }
66
- }
67
- /** Whether the knowledge base lists this exact spelling: a model id or one of its aliases, such as `zai-coding-plan/glm-5.3`. */
68
- export const profileKbNamesModel = (name) => modelIndex.has(name.trim().toLowerCase());
69
32
  function learningsFor(harness, model) {
70
33
  return learningSnapshot.filter((learning) => {
71
34
  const scope = learning.appliesTo;
@@ -89,7 +52,7 @@ function profileKbGuidance(selection) {
89
52
  const harness = selection.harness
90
53
  ? harnessSnapshot[harnessPosition(selection.harness)]
91
54
  : undefined;
92
- const model = modelSnapshot[matchModelName(selection.model, (candidate) => modelIndex.get(candidate)) ?? -1];
55
+ const model = findProfileKbModel(selection.model);
93
56
  const blocks = [];
94
57
  if (harness && harness.prompt.length > 0) {
95
58
  blocks.push({
@@ -1,3 +1,7 @@
1
1
  import type { ProfileKbModel } from "./types.js";
2
2
  /** Source-backed facts and conditional advice. API controls never become agent instructions. */
3
3
  export declare const profileKbModels: readonly ProfileKbModel[];
4
+ /** Match an id/alias, then strip leading route segments and a trailing :suffix. */
5
+ export declare function findProfileKbModel(model: string | undefined): ProfileKbModel | undefined;
6
+ /** Whether this exact spelling is a declared model id or alias. */
7
+ export declare const profileKbNamesModel: (name: string) => boolean;
@@ -1,3 +1,4 @@
1
+ import { deepFreeze } from "../deep-freeze.js";
1
2
  import { claim, kbEntry } from "./entry.js";
2
3
  const CHECKED = "2026-10-04";
3
4
  const source = (url, locator) => ({
@@ -229,6 +230,14 @@ export const profileKbModels = [
229
230
  vendor: "DeepSeek",
230
231
  surfaces: ["api", "router", "opencode"],
231
232
  aliases: ["deepseek-flash", "deepseek/deepseek-v4.1-flash", "opencode/deepseek-v4.1-flash-free"],
233
+ nativeEfforts: {
234
+ minimal: "low",
235
+ low: "low",
236
+ medium: "high",
237
+ high: "high",
238
+ xhigh: "high",
239
+ ultracode: "max",
240
+ },
232
241
  claims: [
233
242
  claim("DeepSeek API ID deepseek-flash denotes V4.1-Flash: 1M context, 384K output, vision and tools; non-thinking mode is available. Router naming is a separate contract.", deepseekModel),
234
243
  claim("Thinking defaults on at high. Native efforts are low, high and max; minimal maps to low, medium/xhigh to high, and ultra to max. With tools, preserve all previous reasoning_content, including turns without tool calls.", deepseekThinking),
@@ -273,3 +282,38 @@ export const profileKbModels = [
273
282
  ],
274
283
  }),
275
284
  ];
285
+ // Both guidance and native controls read this snapshot, never mutable exports.
286
+ const modelSnapshot = deepFreeze(structuredClone(profileKbModels));
287
+ const modelIndex = (() => {
288
+ const index = new Map();
289
+ for (const model of modelSnapshot) {
290
+ for (const name of [model.id, ...model.aliases]) {
291
+ const key = name.toLowerCase();
292
+ if (index.has(key)) {
293
+ throw new Error(`profile-kb: model name ${name} is declared twice`);
294
+ }
295
+ index.set(key, model);
296
+ }
297
+ }
298
+ return index;
299
+ })();
300
+ /** Match an id/alias, then strip leading route segments and a trailing :suffix. */
301
+ export function findProfileKbModel(model) {
302
+ if (!model)
303
+ return undefined;
304
+ const colon = model.lastIndexOf(":");
305
+ let candidate = (colon > 0 ? model.slice(0, colon) : model)
306
+ .trim()
307
+ .toLowerCase();
308
+ for (;;) {
309
+ const found = modelIndex.get(candidate);
310
+ if (found !== undefined)
311
+ return found;
312
+ const slash = candidate.indexOf("/");
313
+ if (slash < 0)
314
+ return undefined;
315
+ candidate = candidate.slice(slash + 1);
316
+ }
317
+ }
318
+ /** Whether this exact spelling is a declared model id or alias. */
319
+ export const profileKbNamesModel = (name) => modelIndex.has(name.trim().toLowerCase());
@@ -55,6 +55,8 @@ export interface ProfileKbModel {
55
55
  aliases: string[];
56
56
  /** Documented API default mapped onto the portable scale (ultracode means max); harness defaults can differ. */
57
57
  defaultEffort?: ReasoningEffort;
58
+ /** Documented native tokens for the portable thinking rungs; none stays off. */
59
+ nativeEfforts?: Readonly<Record<Exclude<ReasoningEffort, "none">, string>>;
58
60
  sources: ProfileKbSource[];
59
61
  prompt: string[];
60
62
  operator: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-interface",
3
- "version": "5.10.19",
3
+ "version": "5.10.21",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",