@kingsoftcloud/agentkit-harness-node 0.0.16 → 0.0.17
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/index.mjs +18 -14
- package/dist/rpc-entry.mjs +18 -14
- package/package.json +2 -2
- package/src/native/model-provider-compat.mjs +12 -7
package/dist/index.mjs
CHANGED
|
@@ -2009,6 +2009,7 @@ function taggedPrefixProjector(marker) {
|
|
|
2009
2009
|
}
|
|
2010
2010
|
|
|
2011
2011
|
// packages/agentkit-harness-node/src/native/model-provider-compat.mjs
|
|
2012
|
+
import { FINAL_SUBMISSION_TOOL as FINAL_SUBMISSION_TOOL2 } from "@kingsoftcloud/agentkit-harness-core";
|
|
2012
2013
|
var strict = /* @__PURE__ */ new Set(["openai", "strict-openai", "cerebras", "groq"]);
|
|
2013
2014
|
var requiredAuto = /* @__PURE__ */ new Set(["claude-opus-5-5", "claude-sonnet-5-5", "claude-fable-5-1", "claude-mythos-5-1"]);
|
|
2014
2015
|
var mandatory = /* @__PURE__ */ new Set(["claude-fable-5-1", "claude-opus-5-5", "claude-sonnet-5-5"]);
|
|
@@ -2039,26 +2040,28 @@ function applyAnthropicThinking(payload, profile, binding) {
|
|
|
2039
2040
|
}
|
|
2040
2041
|
function resolveProviderCompatibility(policy, binding) {
|
|
2041
2042
|
if (!policy) return null;
|
|
2042
|
-
|
|
2043
|
+
const version = ["provider-compat/v1", "provider-compat/v2", "provider-compat/v3", "provider-compat/v4", "provider-compat/v5"].indexOf(policy.contract) + 1;
|
|
2044
|
+
if (!version) throw new ProtocolError("invalid_provider_compatibility_policy");
|
|
2043
2045
|
const rule = resolveCompatibilityRule(policy.rule, binding);
|
|
2044
2046
|
const name = String(binding.model ?? "").trim().toLowerCase();
|
|
2045
2047
|
const kimi = ["kspmas-gateway", "moonshot"].includes(rule) && ["kimi-k2.7-code", "kimi-k2.7-code-highspeed"].includes(name);
|
|
2046
|
-
const modern =
|
|
2048
|
+
const modern = version >= 3;
|
|
2047
2049
|
const reasoningRequired = modern && rule === "kspmas-gateway" && name === "glm-5.3-flash";
|
|
2048
2050
|
const disabledEfforts = mandatory.has(name) || reasoningRequired ? [] : name === "claude-haiku-5-5" ? ["low", "medium", "high"] : null;
|
|
2049
2051
|
return {
|
|
2050
2052
|
rule,
|
|
2051
2053
|
supportsUsage: !strict.has(rule),
|
|
2052
2054
|
supportsThinking: !strict.has(rule) && !kimi,
|
|
2053
|
-
supportsToolArgumentStreaming:
|
|
2055
|
+
supportsToolArgumentStreaming: version >= 2 && ["zai", "kspmas-gateway"].includes(rule) && incrementalToolModels.has(normalized(binding.model)),
|
|
2054
2056
|
reasoningRequired,
|
|
2055
2057
|
modern,
|
|
2058
|
+
firstToolLowEffort: version >= 5 && reasoningRequired,
|
|
2056
2059
|
// This route already uses the supported non-thinking mode for tool work.
|
|
2057
2060
|
// A bounded summary has no tools: omitting the switch can instead select
|
|
2058
2061
|
// the provider's default high reasoning and consume its whole output cap.
|
|
2059
2062
|
// Freeze this purpose-specific default only on new admissions; mandatory
|
|
2060
2063
|
// thinking models and explicit caller choices remain authoritative.
|
|
2061
|
-
compactionThinkingOff:
|
|
2064
|
+
compactionThinkingOff: version >= 4 && rule === "kspmas-gateway" && !kimi,
|
|
2062
2065
|
// Only the observed provider/model dialects may seal without [DONE].
|
|
2063
2066
|
finishOnEof: modern && ["permissive", "kspmas-gateway"].includes(rule) && ["minimax-m3", "minimax-m2.5"].includes(name),
|
|
2064
2067
|
supportsEffort: !kimi,
|
|
@@ -2099,7 +2102,9 @@ function applyProviderChatCompatibility(payload, request, binding) {
|
|
|
2099
2102
|
}
|
|
2100
2103
|
const model = binding.model, name = normalized(model);
|
|
2101
2104
|
const requested = options.reasoningEffort ?? result.reasoning_effort ?? null;
|
|
2105
|
+
const mode = options.thinkingMode ?? result.thinking?.type;
|
|
2102
2106
|
let effort = requested;
|
|
2107
|
+
if (requested === null && mode === void 0 && compat.firstToolLowEffort && request.beforeFirstTool && !request.finalizationOnly && result.tool_choice !== "none" && result.tools?.some((tool) => tool.type === "function" && tool.function?.name !== FINAL_SUBMISSION_TOOL2)) effort = "low";
|
|
2103
2108
|
if (requested === null && options.controllerReasoningPolicy === "disclosed-delegate/v1" && ["zai", "kspmas-gateway"].includes(compat.rule) && name.startsWith("glm-5.3") && result.tools?.some((tool) => tool.type === "function" && tool.function?.name === "delegate_task")) effort = "low";
|
|
2104
2109
|
if (requested === null && request.purpose === "compaction" && compat.rule === "kspmas-gateway" && ["glm-5.2", "deepseek-v4-flash"].includes(name)) effort = "none";
|
|
2105
2110
|
if (requested === null && request.purpose === "compaction" && compat.reasoningRequired) effort = "low";
|
|
@@ -2111,7 +2116,6 @@ function applyProviderChatCompatibility(payload, request, binding) {
|
|
|
2111
2116
|
delete result.stream_options.include_usage;
|
|
2112
2117
|
if (!Object.keys(result.stream_options).length) delete result.stream_options;
|
|
2113
2118
|
}
|
|
2114
|
-
const mode = options.thinkingMode ?? result.thinking?.type;
|
|
2115
2119
|
if (mode === "disabled" && compat.reasoningRequired) throw new ProtocolError("model_thinking_disable_unsupported");
|
|
2116
2120
|
const mayDisable = compat.supportsThinking && (compat.disabledEfforts === null || compat.disabledEfforts.includes(effort));
|
|
2117
2121
|
const summaryOff = request.purpose === "compaction" && requested === null && compat.rule === "kspmas-gateway" && name === "glm-5.3-flash";
|
|
@@ -2249,7 +2253,7 @@ function mergeChatUsage(previous, reported, policy, finalized = false) {
|
|
|
2249
2253
|
}
|
|
2250
2254
|
|
|
2251
2255
|
// packages/agentkit-harness-node/src/native/model-openai-chat.mjs
|
|
2252
|
-
import { parseModelJson, stringifyModelJson, modelWireToolCall as modelWireToolCall2, FINAL_SUBMISSION_TOOL as
|
|
2256
|
+
import { parseModelJson, stringifyModelJson, modelWireToolCall as modelWireToolCall2, FINAL_SUBMISSION_TOOL as FINAL_SUBMISSION_TOOL3 } from "@kingsoftcloud/agentkit-harness-core";
|
|
2253
2257
|
function strictParseJson(text) {
|
|
2254
2258
|
try {
|
|
2255
2259
|
return parseModelJson(text);
|
|
@@ -2317,13 +2321,13 @@ function buildOpenAIRequest(binding, request) {
|
|
|
2317
2321
|
payload.max_tokens = boundOutputTokens(parameters.max_tokens, profile.maxOutputTokens);
|
|
2318
2322
|
}
|
|
2319
2323
|
const tools = request.tools || [];
|
|
2320
|
-
const advertised = request.finalizationOnly ? tools.filter((tool) => tool.name ===
|
|
2324
|
+
const advertised = request.finalizationOnly ? tools.filter((tool) => tool.name === FINAL_SUBMISSION_TOOL3) : tools;
|
|
2321
2325
|
if (advertised.length) {
|
|
2322
2326
|
payload.tools = advertised.map((tool) => ({
|
|
2323
2327
|
type: "function",
|
|
2324
2328
|
function: { name: tool.name, description: tool.description, parameters: tool.parameters || { type: "object", properties: {} } }
|
|
2325
2329
|
}));
|
|
2326
|
-
payload.tool_choice = request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly ? { type: "function", function: { name:
|
|
2330
|
+
payload.tool_choice = request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly ? { type: "function", function: { name: FINAL_SUBMISSION_TOOL3 } } : "auto");
|
|
2327
2331
|
}
|
|
2328
2332
|
if (profile.parallelToolCalls !== void 0) payload.parallel_tool_calls = profile.parallelToolCalls;
|
|
2329
2333
|
if (profile.temperature !== void 0) payload.temperature = profile.temperature;
|
|
@@ -2813,7 +2817,7 @@ function usageCounters(usage) {
|
|
|
2813
2817
|
}
|
|
2814
2818
|
|
|
2815
2819
|
// packages/agentkit-harness-node/src/native/model-anthropic.mjs
|
|
2816
|
-
import { parseModelJson as parseModelJson2, stringifyModelJson as stringifyModelJson2, parseNativeJson as parseNativeJson3, modelWireToolCall as modelWireToolCall3, FINAL_SUBMISSION_TOOL as
|
|
2820
|
+
import { parseModelJson as parseModelJson2, stringifyModelJson as stringifyModelJson2, parseNativeJson as parseNativeJson3, modelWireToolCall as modelWireToolCall3, FINAL_SUBMISSION_TOOL as FINAL_SUBMISSION_TOOL4 } from "@kingsoftcloud/agentkit-harness-core";
|
|
2817
2821
|
|
|
2818
2822
|
// packages/agentkit-harness-node/src/native/model-anthropic-cache.mjs
|
|
2819
2823
|
var ephemeral = () => ({ type: "ephemeral" });
|
|
@@ -2985,7 +2989,7 @@ function buildAnthropicRequest(binding, request) {
|
|
|
2985
2989
|
payload[key] = value;
|
|
2986
2990
|
}
|
|
2987
2991
|
const tools = request.tools || [];
|
|
2988
|
-
const advertised = request.finalizationOnly && profile.toolCatalogPolicy !== "stable-task/v1" && !native ? tools.filter((tool) => tool.name ===
|
|
2992
|
+
const advertised = request.finalizationOnly && profile.toolCatalogPolicy !== "stable-task/v1" && !native ? tools.filter((tool) => tool.name === FINAL_SUBMISSION_TOOL4) : tools;
|
|
2989
2993
|
if (advertised.length) {
|
|
2990
2994
|
payload.tools = advertised.map((tool) => native ? anthropicToolEntry(tool) : {
|
|
2991
2995
|
name: tool.name,
|
|
@@ -2993,7 +2997,7 @@ function buildAnthropicRequest(binding, request) {
|
|
|
2993
2997
|
input_schema: tool.parameters || { type: "object", properties: {} }
|
|
2994
2998
|
});
|
|
2995
2999
|
const choice = projectProviderToolChoice(
|
|
2996
|
-
request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly && advertised.some((tool) => tool.name ===
|
|
3000
|
+
request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly && advertised.some((tool) => tool.name === FINAL_SUBMISSION_TOOL4) ? { type: "function", function: { name: FINAL_SUBMISSION_TOOL4 } } : "auto"),
|
|
2997
3001
|
resolveProviderCompatibility(profile.providerCompatibilityPolicy, binding)
|
|
2998
3002
|
);
|
|
2999
3003
|
payload.tool_choice = typeof choice === "string" ? { type: choice === "required" ? "any" : choice } : { type: "tool", name: choice.function.name };
|
|
@@ -3593,7 +3597,7 @@ function deepCopy(value) {
|
|
|
3593
3597
|
}
|
|
3594
3598
|
|
|
3595
3599
|
// packages/agentkit-harness-node/src/native/model-responses.mjs
|
|
3596
|
-
import { parseModelJson as parseModelJson3, stringifyModelJson as stringifyModelJson3, modelWireToolCall as modelWireToolCall4, FINAL_SUBMISSION_TOOL as
|
|
3600
|
+
import { parseModelJson as parseModelJson3, stringifyModelJson as stringifyModelJson3, modelWireToolCall as modelWireToolCall4, FINAL_SUBMISSION_TOOL as FINAL_SUBMISSION_TOOL5 } from "@kingsoftcloud/agentkit-harness-core";
|
|
3597
3601
|
function strictParseJson3(text) {
|
|
3598
3602
|
try {
|
|
3599
3603
|
return parseModelJson3(text);
|
|
@@ -3710,7 +3714,7 @@ function buildResponsesRequest(binding, request) {
|
|
|
3710
3714
|
payload.max_output_tokens = boundOutputTokens(parameters.max_output_tokens, profile.maxOutputTokens);
|
|
3711
3715
|
}
|
|
3712
3716
|
const tools = request.tools || [];
|
|
3713
|
-
const advertised = request.finalizationOnly ? tools.filter((tool) => tool.name ===
|
|
3717
|
+
const advertised = request.finalizationOnly ? tools.filter((tool) => tool.name === FINAL_SUBMISSION_TOOL5) : tools;
|
|
3714
3718
|
if (advertised.length) {
|
|
3715
3719
|
payload.tools = advertised.map((tool) => {
|
|
3716
3720
|
const flat = {
|
|
@@ -3721,7 +3725,7 @@ function buildResponsesRequest(binding, request) {
|
|
|
3721
3725
|
};
|
|
3722
3726
|
return flat;
|
|
3723
3727
|
});
|
|
3724
|
-
const choice = request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly ? { type: "function", function: { name:
|
|
3728
|
+
const choice = request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly ? { type: "function", function: { name: FINAL_SUBMISSION_TOOL5 } } : "auto");
|
|
3725
3729
|
payload.tool_choice = typeof choice === "string" ? choice : { type: "function", name: choice.function.name };
|
|
3726
3730
|
payload.parallel_tool_calls = profile.parallelToolCalls ?? true;
|
|
3727
3731
|
}
|
package/dist/rpc-entry.mjs
CHANGED
|
@@ -2020,6 +2020,7 @@ function taggedPrefixProjector(marker) {
|
|
|
2020
2020
|
}
|
|
2021
2021
|
|
|
2022
2022
|
// packages/agentkit-harness-node/src/native/model-provider-compat.mjs
|
|
2023
|
+
import { FINAL_SUBMISSION_TOOL as FINAL_SUBMISSION_TOOL2 } from "@kingsoftcloud/agentkit-harness-core";
|
|
2023
2024
|
var strict = /* @__PURE__ */ new Set(["openai", "strict-openai", "cerebras", "groq"]);
|
|
2024
2025
|
var requiredAuto = /* @__PURE__ */ new Set(["claude-opus-5-5", "claude-sonnet-5-5", "claude-fable-5-1", "claude-mythos-5-1"]);
|
|
2025
2026
|
var mandatory = /* @__PURE__ */ new Set(["claude-fable-5-1", "claude-opus-5-5", "claude-sonnet-5-5"]);
|
|
@@ -2050,26 +2051,28 @@ function applyAnthropicThinking(payload, profile, binding) {
|
|
|
2050
2051
|
}
|
|
2051
2052
|
function resolveProviderCompatibility(policy, binding) {
|
|
2052
2053
|
if (!policy) return null;
|
|
2053
|
-
|
|
2054
|
+
const version = ["provider-compat/v1", "provider-compat/v2", "provider-compat/v3", "provider-compat/v4", "provider-compat/v5"].indexOf(policy.contract) + 1;
|
|
2055
|
+
if (!version) throw new ProtocolError("invalid_provider_compatibility_policy");
|
|
2054
2056
|
const rule = resolveCompatibilityRule(policy.rule, binding);
|
|
2055
2057
|
const name = String(binding.model ?? "").trim().toLowerCase();
|
|
2056
2058
|
const kimi = ["kspmas-gateway", "moonshot"].includes(rule) && ["kimi-k2.7-code", "kimi-k2.7-code-highspeed"].includes(name);
|
|
2057
|
-
const modern =
|
|
2059
|
+
const modern = version >= 3;
|
|
2058
2060
|
const reasoningRequired = modern && rule === "kspmas-gateway" && name === "glm-5.3-flash";
|
|
2059
2061
|
const disabledEfforts = mandatory.has(name) || reasoningRequired ? [] : name === "claude-haiku-5-5" ? ["low", "medium", "high"] : null;
|
|
2060
2062
|
return {
|
|
2061
2063
|
rule,
|
|
2062
2064
|
supportsUsage: !strict.has(rule),
|
|
2063
2065
|
supportsThinking: !strict.has(rule) && !kimi,
|
|
2064
|
-
supportsToolArgumentStreaming:
|
|
2066
|
+
supportsToolArgumentStreaming: version >= 2 && ["zai", "kspmas-gateway"].includes(rule) && incrementalToolModels.has(normalized(binding.model)),
|
|
2065
2067
|
reasoningRequired,
|
|
2066
2068
|
modern,
|
|
2069
|
+
firstToolLowEffort: version >= 5 && reasoningRequired,
|
|
2067
2070
|
// This route already uses the supported non-thinking mode for tool work.
|
|
2068
2071
|
// A bounded summary has no tools: omitting the switch can instead select
|
|
2069
2072
|
// the provider's default high reasoning and consume its whole output cap.
|
|
2070
2073
|
// Freeze this purpose-specific default only on new admissions; mandatory
|
|
2071
2074
|
// thinking models and explicit caller choices remain authoritative.
|
|
2072
|
-
compactionThinkingOff:
|
|
2075
|
+
compactionThinkingOff: version >= 4 && rule === "kspmas-gateway" && !kimi,
|
|
2073
2076
|
// Only the observed provider/model dialects may seal without [DONE].
|
|
2074
2077
|
finishOnEof: modern && ["permissive", "kspmas-gateway"].includes(rule) && ["minimax-m3", "minimax-m2.5"].includes(name),
|
|
2075
2078
|
supportsEffort: !kimi,
|
|
@@ -2110,7 +2113,9 @@ function applyProviderChatCompatibility(payload, request, binding) {
|
|
|
2110
2113
|
}
|
|
2111
2114
|
const model = binding.model, name = normalized(model);
|
|
2112
2115
|
const requested = options.reasoningEffort ?? result.reasoning_effort ?? null;
|
|
2116
|
+
const mode = options.thinkingMode ?? result.thinking?.type;
|
|
2113
2117
|
let effort = requested;
|
|
2118
|
+
if (requested === null && mode === void 0 && compat.firstToolLowEffort && request.beforeFirstTool && !request.finalizationOnly && result.tool_choice !== "none" && result.tools?.some((tool) => tool.type === "function" && tool.function?.name !== FINAL_SUBMISSION_TOOL2)) effort = "low";
|
|
2114
2119
|
if (requested === null && options.controllerReasoningPolicy === "disclosed-delegate/v1" && ["zai", "kspmas-gateway"].includes(compat.rule) && name.startsWith("glm-5.3") && result.tools?.some((tool) => tool.type === "function" && tool.function?.name === "delegate_task")) effort = "low";
|
|
2115
2120
|
if (requested === null && request.purpose === "compaction" && compat.rule === "kspmas-gateway" && ["glm-5.2", "deepseek-v4-flash"].includes(name)) effort = "none";
|
|
2116
2121
|
if (requested === null && request.purpose === "compaction" && compat.reasoningRequired) effort = "low";
|
|
@@ -2122,7 +2127,6 @@ function applyProviderChatCompatibility(payload, request, binding) {
|
|
|
2122
2127
|
delete result.stream_options.include_usage;
|
|
2123
2128
|
if (!Object.keys(result.stream_options).length) delete result.stream_options;
|
|
2124
2129
|
}
|
|
2125
|
-
const mode = options.thinkingMode ?? result.thinking?.type;
|
|
2126
2130
|
if (mode === "disabled" && compat.reasoningRequired) throw new ProtocolError("model_thinking_disable_unsupported");
|
|
2127
2131
|
const mayDisable = compat.supportsThinking && (compat.disabledEfforts === null || compat.disabledEfforts.includes(effort));
|
|
2128
2132
|
const summaryOff = request.purpose === "compaction" && requested === null && compat.rule === "kspmas-gateway" && name === "glm-5.3-flash";
|
|
@@ -2260,7 +2264,7 @@ function mergeChatUsage(previous, reported, policy, finalized = false) {
|
|
|
2260
2264
|
}
|
|
2261
2265
|
|
|
2262
2266
|
// packages/agentkit-harness-node/src/native/model-openai-chat.mjs
|
|
2263
|
-
import { parseModelJson, stringifyModelJson, modelWireToolCall as modelWireToolCall2, FINAL_SUBMISSION_TOOL as
|
|
2267
|
+
import { parseModelJson, stringifyModelJson, modelWireToolCall as modelWireToolCall2, FINAL_SUBMISSION_TOOL as FINAL_SUBMISSION_TOOL3 } from "@kingsoftcloud/agentkit-harness-core";
|
|
2264
2268
|
function strictParseJson(text) {
|
|
2265
2269
|
try {
|
|
2266
2270
|
return parseModelJson(text);
|
|
@@ -2328,13 +2332,13 @@ function buildOpenAIRequest(binding, request) {
|
|
|
2328
2332
|
payload.max_tokens = boundOutputTokens(parameters.max_tokens, profile.maxOutputTokens);
|
|
2329
2333
|
}
|
|
2330
2334
|
const tools = request.tools || [];
|
|
2331
|
-
const advertised = request.finalizationOnly ? tools.filter((tool) => tool.name ===
|
|
2335
|
+
const advertised = request.finalizationOnly ? tools.filter((tool) => tool.name === FINAL_SUBMISSION_TOOL3) : tools;
|
|
2332
2336
|
if (advertised.length) {
|
|
2333
2337
|
payload.tools = advertised.map((tool) => ({
|
|
2334
2338
|
type: "function",
|
|
2335
2339
|
function: { name: tool.name, description: tool.description, parameters: tool.parameters || { type: "object", properties: {} } }
|
|
2336
2340
|
}));
|
|
2337
|
-
payload.tool_choice = request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly ? { type: "function", function: { name:
|
|
2341
|
+
payload.tool_choice = request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly ? { type: "function", function: { name: FINAL_SUBMISSION_TOOL3 } } : "auto");
|
|
2338
2342
|
}
|
|
2339
2343
|
if (profile.parallelToolCalls !== void 0) payload.parallel_tool_calls = profile.parallelToolCalls;
|
|
2340
2344
|
if (profile.temperature !== void 0) payload.temperature = profile.temperature;
|
|
@@ -2824,7 +2828,7 @@ function usageCounters(usage) {
|
|
|
2824
2828
|
}
|
|
2825
2829
|
|
|
2826
2830
|
// packages/agentkit-harness-node/src/native/model-anthropic.mjs
|
|
2827
|
-
import { parseModelJson as parseModelJson2, stringifyModelJson as stringifyModelJson2, parseNativeJson as parseNativeJson3, modelWireToolCall as modelWireToolCall3, FINAL_SUBMISSION_TOOL as
|
|
2831
|
+
import { parseModelJson as parseModelJson2, stringifyModelJson as stringifyModelJson2, parseNativeJson as parseNativeJson3, modelWireToolCall as modelWireToolCall3, FINAL_SUBMISSION_TOOL as FINAL_SUBMISSION_TOOL4 } from "@kingsoftcloud/agentkit-harness-core";
|
|
2828
2832
|
|
|
2829
2833
|
// packages/agentkit-harness-node/src/native/model-anthropic-cache.mjs
|
|
2830
2834
|
var ephemeral = () => ({ type: "ephemeral" });
|
|
@@ -2996,7 +3000,7 @@ function buildAnthropicRequest(binding, request) {
|
|
|
2996
3000
|
payload[key] = value;
|
|
2997
3001
|
}
|
|
2998
3002
|
const tools = request.tools || [];
|
|
2999
|
-
const advertised = request.finalizationOnly && profile.toolCatalogPolicy !== "stable-task/v1" && !native ? tools.filter((tool) => tool.name ===
|
|
3003
|
+
const advertised = request.finalizationOnly && profile.toolCatalogPolicy !== "stable-task/v1" && !native ? tools.filter((tool) => tool.name === FINAL_SUBMISSION_TOOL4) : tools;
|
|
3000
3004
|
if (advertised.length) {
|
|
3001
3005
|
payload.tools = advertised.map((tool) => native ? anthropicToolEntry(tool) : {
|
|
3002
3006
|
name: tool.name,
|
|
@@ -3004,7 +3008,7 @@ function buildAnthropicRequest(binding, request) {
|
|
|
3004
3008
|
input_schema: tool.parameters || { type: "object", properties: {} }
|
|
3005
3009
|
});
|
|
3006
3010
|
const choice = projectProviderToolChoice(
|
|
3007
|
-
request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly && advertised.some((tool) => tool.name ===
|
|
3011
|
+
request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly && advertised.some((tool) => tool.name === FINAL_SUBMISSION_TOOL4) ? { type: "function", function: { name: FINAL_SUBMISSION_TOOL4 } } : "auto"),
|
|
3008
3012
|
resolveProviderCompatibility(profile.providerCompatibilityPolicy, binding)
|
|
3009
3013
|
);
|
|
3010
3014
|
payload.tool_choice = typeof choice === "string" ? { type: choice === "required" ? "any" : choice } : { type: "tool", name: choice.function.name };
|
|
@@ -3604,7 +3608,7 @@ function deepCopy(value) {
|
|
|
3604
3608
|
}
|
|
3605
3609
|
|
|
3606
3610
|
// packages/agentkit-harness-node/src/native/model-responses.mjs
|
|
3607
|
-
import { parseModelJson as parseModelJson3, stringifyModelJson as stringifyModelJson3, modelWireToolCall as modelWireToolCall4, FINAL_SUBMISSION_TOOL as
|
|
3611
|
+
import { parseModelJson as parseModelJson3, stringifyModelJson as stringifyModelJson3, modelWireToolCall as modelWireToolCall4, FINAL_SUBMISSION_TOOL as FINAL_SUBMISSION_TOOL5 } from "@kingsoftcloud/agentkit-harness-core";
|
|
3608
3612
|
function strictParseJson3(text) {
|
|
3609
3613
|
try {
|
|
3610
3614
|
return parseModelJson3(text);
|
|
@@ -3721,7 +3725,7 @@ function buildResponsesRequest(binding, request) {
|
|
|
3721
3725
|
payload.max_output_tokens = boundOutputTokens(parameters.max_output_tokens, profile.maxOutputTokens);
|
|
3722
3726
|
}
|
|
3723
3727
|
const tools = request.tools || [];
|
|
3724
|
-
const advertised = request.finalizationOnly ? tools.filter((tool) => tool.name ===
|
|
3728
|
+
const advertised = request.finalizationOnly ? tools.filter((tool) => tool.name === FINAL_SUBMISSION_TOOL5) : tools;
|
|
3725
3729
|
if (advertised.length) {
|
|
3726
3730
|
payload.tools = advertised.map((tool) => {
|
|
3727
3731
|
const flat = {
|
|
@@ -3732,7 +3736,7 @@ function buildResponsesRequest(binding, request) {
|
|
|
3732
3736
|
};
|
|
3733
3737
|
return flat;
|
|
3734
3738
|
});
|
|
3735
|
-
const choice = request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly ? { type: "function", function: { name:
|
|
3739
|
+
const choice = request.toolChoice ?? (profile.providerCompatibilityPolicy && request.finalizationOnly ? { type: "function", function: { name: FINAL_SUBMISSION_TOOL5 } } : "auto");
|
|
3736
3740
|
payload.tool_choice = typeof choice === "string" ? choice : { type: "function", name: choice.function.name };
|
|
3737
3741
|
payload.parallel_tool_calls = profile.parallelToolCalls ?? true;
|
|
3738
3742
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingsoftcloud/agentkit-harness-node",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Standalone Native Harness Node adapters: a durable SQLite run store, a one-request model HTTP port, and a minimal versioned JSON-RPC 2.0 over NDJSON process entry. Reuses the shared Native adapter implementations and externalizes @kingsoftcloud/agentkit-harness-core; depends on no Studio/DSH code at runtime.",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"src/package-integrity.mjs"
|
|
141
141
|
],
|
|
142
142
|
"dependencies": {
|
|
143
|
-
"@kingsoftcloud/agentkit-harness-core": "0.0.
|
|
143
|
+
"@kingsoftcloud/agentkit-harness-core": "0.0.17",
|
|
144
144
|
"@astral-sh/ruff-wasm-nodejs": "0.16.8",
|
|
145
145
|
"parse5": "7.3.0",
|
|
146
146
|
"playwright-core": "1.58.2",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Frozen Chat Completions request policy, ported from the pinned Python
|
|
2
2
|
// model_proxy.compat and transform.model-effort-map/v2. No IO or retries here.
|
|
3
|
+
import { FINAL_SUBMISSION_TOOL } from '@kingsoftcloud/agentkit-harness-core';
|
|
3
4
|
import { admitInlineReasoningPolicy, resolveCompatibilityRule } from './model-inline-reasoning.mjs';
|
|
4
5
|
import { ProtocolError } from './model-normalize.mjs';
|
|
5
6
|
|
|
@@ -44,29 +45,30 @@ export function applyAnthropicThinking(payload, profile, binding) {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export function admitProviderCompatibilityPolicy(override) {
|
|
47
|
-
return { contract: 'provider-compat/
|
|
48
|
+
return { contract: 'provider-compat/v5', rule: admitInlineReasoningPolicy(override).rule };
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export function resolveProviderCompatibility(policy, binding) {
|
|
51
52
|
if (!policy) return null;
|
|
52
|
-
|
|
53
|
+
const version = ['provider-compat/v1', 'provider-compat/v2', 'provider-compat/v3', 'provider-compat/v4', 'provider-compat/v5'].indexOf(policy.contract) + 1;
|
|
54
|
+
if (!version) throw new ProtocolError('invalid_provider_compatibility_policy');
|
|
53
55
|
const rule = resolveCompatibilityRule(policy.rule, binding);
|
|
54
56
|
const name = String(binding.model ?? '').trim().toLowerCase();
|
|
55
57
|
const kimi = ['kspmas-gateway', 'moonshot'].includes(rule)
|
|
56
58
|
&& ['kimi-k2.7-code', 'kimi-k2.7-code-highspeed'].includes(name);
|
|
57
|
-
const modern =
|
|
59
|
+
const modern = version >= 3;
|
|
58
60
|
const reasoningRequired = modern && rule === 'kspmas-gateway' && name === 'glm-5.3-flash';
|
|
59
61
|
const disabledEfforts = mandatory.has(name) || reasoningRequired ? [] : name === 'claude-haiku-5-5' ? ['low', 'medium', 'high'] : null;
|
|
60
62
|
return { rule, supportsUsage: !strict.has(rule), supportsThinking: !strict.has(rule) && !kimi,
|
|
61
|
-
supportsToolArgumentStreaming:
|
|
63
|
+
supportsToolArgumentStreaming: version >= 2
|
|
62
64
|
&& ['zai', 'kspmas-gateway'].includes(rule) && incrementalToolModels.has(normalized(binding.model)),
|
|
63
|
-
reasoningRequired, modern,
|
|
65
|
+
reasoningRequired, modern, firstToolLowEffort: version >= 5 && reasoningRequired,
|
|
64
66
|
// This route already uses the supported non-thinking mode for tool work.
|
|
65
67
|
// A bounded summary has no tools: omitting the switch can instead select
|
|
66
68
|
// the provider's default high reasoning and consume its whole output cap.
|
|
67
69
|
// Freeze this purpose-specific default only on new admissions; mandatory
|
|
68
70
|
// thinking models and explicit caller choices remain authoritative.
|
|
69
|
-
compactionThinkingOff:
|
|
71
|
+
compactionThinkingOff: version >= 4 && rule === 'kspmas-gateway' && !kimi,
|
|
70
72
|
// Only the observed provider/model dialects may seal without [DONE].
|
|
71
73
|
finishOnEof: modern && ['permissive', 'kspmas-gateway'].includes(rule)
|
|
72
74
|
&& ['minimax-m3', 'minimax-m2.5'].includes(name),
|
|
@@ -105,7 +107,11 @@ export function applyProviderChatCompatibility(payload, request, binding) {
|
|
|
105
107
|
}
|
|
106
108
|
const model = binding.model, name = normalized(model);
|
|
107
109
|
const requested = options.reasoningEffort ?? result.reasoning_effort ?? null;
|
|
110
|
+
const mode = options.thinkingMode ?? result.thinking?.type;
|
|
108
111
|
let effort = requested;
|
|
112
|
+
if (requested === null && mode === undefined && compat.firstToolLowEffort && request.beforeFirstTool
|
|
113
|
+
&& !request.finalizationOnly && result.tool_choice !== 'none'
|
|
114
|
+
&& result.tools?.some(tool => tool.type === 'function' && tool.function?.name !== FINAL_SUBMISSION_TOOL)) effort = 'low';
|
|
109
115
|
if (requested === null && options.controllerReasoningPolicy === 'disclosed-delegate/v1'
|
|
110
116
|
&& ['zai', 'kspmas-gateway'].includes(compat.rule) && name.startsWith('glm-5.3')
|
|
111
117
|
&& result.tools?.some(tool => tool.type === 'function' && tool.function?.name === 'delegate_task')) effort = 'low';
|
|
@@ -119,7 +125,6 @@ export function applyProviderChatCompatibility(payload, request, binding) {
|
|
|
119
125
|
result.stream_options = { ...result.stream_options }; delete result.stream_options.include_usage;
|
|
120
126
|
if (!Object.keys(result.stream_options).length) delete result.stream_options;
|
|
121
127
|
}
|
|
122
|
-
const mode = options.thinkingMode ?? result.thinking?.type;
|
|
123
128
|
if (mode === 'disabled' && compat.reasoningRequired) throw new ProtocolError('model_thinking_disable_unsupported');
|
|
124
129
|
const mayDisable = compat.supportsThinking && (compat.disabledEfforts === null || compat.disabledEfforts.includes(effort));
|
|
125
130
|
const summaryOff = request.purpose === 'compaction' && requested === null && compat.rule === 'kspmas-gateway' && name === 'glm-5.3-flash';
|