@symerian/symi 2.3.4 → 2.4.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/dist/{agents-E_Ere0qU.js → agents-CI3xxYc_.js} +4 -4
- package/dist/{agents.config-Cv_wsBXL.js → agents.config-DCE3RGr9.js} +1 -1
- package/dist/{agents.config-DJTb7Jka.js → agents.config-DTUAM1AG.js} +1 -1
- package/dist/{auth-choice-D8ynWABO.js → auth-choice-DuQwRfJc.js} +1 -1
- package/dist/{auth-choice-B3D_jLQw.js → auth-choice-IiIysHGO.js} +1 -1
- package/dist/{banner-ChYzCy5p.js → banner-xhDZu_ZJ.js} +1 -1
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +1 -1
- package/dist/bundled/session-memory/handler.js +1 -1
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{channel-options-BYUiEgev.js → channel-options-D3gGVwBd.js} +1 -1
- package/dist/{channel-options-CMNzHg4p.js → channel-options-Dvxd7eJY.js} +1 -1
- package/dist/{channel-web-C-HLPbLL.js → channel-web-a5tX1YI3.js} +1 -1
- package/dist/{channels-cli-CcCmH-Tp.js → channels-cli-BLUkl5Li.js} +4 -4
- package/dist/{channels-cli-CyhXPEWq.js → channels-cli-C9wBYmDe.js} +4 -4
- package/dist/{cli-Gcuf3NTF.js → cli-CaEE46xi.js} +1 -1
- package/dist/{cli-Cp-NQ7yu.js → cli-Cw45F0yJ.js} +1 -1
- package/dist/{command-registry-Cvr_dlLY.js → command-registry-ea9SD1eA.js} +9 -9
- package/dist/{completion-cli-DaOHSXM3.js → completion-cli-CMJmUQbI.js} +1 -1
- package/dist/{completion-cli-DDlYn0ya.js → completion-cli-DVkiEAEA.js} +2 -2
- package/dist/{config-cli-CmUPAVUz.js → config-cli-B2d28_hb.js} +1 -1
- package/dist/{config-cli-BcuAsDOu.js → config-cli-VIg0PSyq.js} +1 -1
- package/dist/{configure-Ctwt1377.js → configure-C_TVBt76.js} +3 -3
- package/dist/{configure-OxYdT2hU.js → configure-D-3FiJbK.js} +3 -3
- package/dist/{doctor-completion-D7ShsgUp.js → doctor-completion-CJHJYIwQ.js} +1 -1
- package/dist/{doctor-completion-Dw78bQaQ.js → doctor-completion-DeRX6gkI.js} +1 -1
- package/dist/entry.js +1 -1
- package/dist/extensionAPI.js +1 -1
- package/dist/{gateway-cli-Bd7u0krH.js → gateway-cli-BDDHBfYP.js} +9 -9
- package/dist/{gateway-cli-D7nxPtEc.js → gateway-cli-DiDJ6Z2d.js} +9 -9
- package/dist/{glass-ui-ws-CzH0ikhI.js → glass-ui-ws-Bj1IuJXt.js} +7 -7
- package/dist/{glass-ui-ws-DBivjzVA.js → glass-ui-ws-rGIAkViC.js} +7 -7
- package/dist/{health-BSOMI4B6.js → health-Bst5HnLF.js} +1 -1
- package/dist/{health-rR61mwm3.js → health-CypF_2ZD.js} +1 -1
- package/dist/{hooks-cli-BbiA-gGi.js → hooks-cli-CDMcqTy4.js} +2 -2
- package/dist/{hooks-cli-dS4fMEKE.js → hooks-cli-CfsqqxPX.js} +2 -2
- package/dist/index.js +6 -6
- package/dist/llm-slug-generator.js +1 -1
- package/dist/{models-DqE1s0YL.js → models-ZEOGlFx7.js} +2 -2
- package/dist/{models-cli-6v9jkDxp.js → models-cli-BM1QyeXr.js} +3 -3
- package/dist/{models-cli-BWC7jYp4.js → models-cli-BwOQhZ_c.js} +2 -2
- package/dist/{onboard-Bxoibs4p.js → onboard-CU-pntZD.js} +2 -2
- package/dist/{onboard-BUEYf2m9.js → onboard-DQ34giB5.js} +2 -2
- package/dist/{onboard-channels-af6Cu6fT.js → onboard-channels-BOBxxhHX.js} +1 -1
- package/dist/{onboard-channels-C3UYzZNC.js → onboard-channels-g5cvwJpx.js} +1 -1
- package/dist/{onboarding-DW-7o6Ln.js → onboarding-CXWUjdM5.js} +3 -3
- package/dist/{onboarding-CDdMZbov.js → onboarding-DWs6tHZ9.js} +3 -3
- package/dist/{onboarding.finalize-29jsMLO2.js → onboarding.finalize-CAYf88mf.js} +6 -6
- package/dist/{onboarding.finalize-BI70KOeI.js → onboarding.finalize-vupGASMK.js} +5 -5
- package/dist/{pi-embedded-PkSwAmVq.js → pi-embedded-CJsSOG2j.js} +103 -168
- package/dist/{pi-embedded-JXvD5-F-.js → pi-embedded-DwbQz0MC.js} +103 -168
- package/dist/{plugin-registry-B7AdPXfF.js → plugin-registry-BDpdOTei.js} +1 -1
- package/dist/{plugin-registry-Reem6P3K.js → plugin-registry-CZeHSx_c.js} +1 -1
- package/dist/plugin-sdk/agents/model-aware-stream.d.ts +41 -0
- package/dist/plugin-sdk/agents/pi-embedded-runner/extra-params.d.ts +13 -0
- package/dist/plugin-sdk/{channel-web-CM7A3Y7G.js → channel-web-uUypcT9Q.js} +1 -1
- package/dist/plugin-sdk/index.js +2 -2
- package/dist/plugin-sdk/{reply-CDloTGFF.js → reply-DTKTuCrn.js} +103 -168
- package/dist/plugin-sdk/{web-CWNoMlnF.js → web-Dh6Youzv.js} +2 -2
- package/dist/{plugins-cli-V8mTTTnD.js → plugins-cli-CCQ3skeQ.js} +2 -2
- package/dist/{plugins-cli-B-6wVg3A.js → plugins-cli-D_RzeRoE.js} +2 -2
- package/dist/{program-DBtlRiFS.js → program-Cl9i8ubQ.js} +7 -7
- package/dist/{program-context-BHPNVgg2.js → program-context-BbmYGW-V.js} +17 -17
- package/dist/{prompt-select-styled-Bh-zAqW1.js → prompt-select-styled-BN0T6GxF.js} +4 -4
- package/dist/{prompt-select-styled-Cup1c9RJ.js → prompt-select-styled-BfuyvChh.js} +4 -4
- package/dist/{provider-auth-helpers-CiuLdUK3.js → provider-auth-helpers-CkmLFHXL.js} +1 -1
- package/dist/{provider-auth-helpers-BNmU48Ez.js → provider-auth-helpers-CuT5EHza.js} +1 -1
- package/dist/{push-apns-8VJkVSdh.js → push-apns-CFkFVwEz.js} +1 -1
- package/dist/{push-apns-9zUNNHgy.js → push-apns-DeJt9kAO.js} +1 -1
- package/dist/{register.agent-BtNmleKV.js → register.agent-BQm4YmZp.js} +6 -6
- package/dist/{register.agent-DnglG42G.js → register.agent-BygseJ7t.js} +5 -5
- package/dist/{register.configure-DfQOfV1W.js → register.configure-C2fhjZze.js} +6 -6
- package/dist/{register.configure-CLW9tdE4.js → register.configure-Cj95vB2U.js} +6 -6
- package/dist/{register.maintenance-BQfMsgo7.js → register.maintenance-CClfXq5e.js} +8 -8
- package/dist/{register.maintenance-jFYcRLEN.js → register.maintenance-K1x3E7OS.js} +7 -7
- package/dist/{register.message-DUsBvFSF.js → register.message-BSr-kUvJ.js} +2 -2
- package/dist/{register.message-BhoZYcqM.js → register.message-CSRzBl-c.js} +2 -2
- package/dist/{register.onboard-BBwhoeoE.js → register.onboard-Bd6wPydW.js} +4 -4
- package/dist/{register.onboard-DQOkpYBY.js → register.onboard-TsU21RR7.js} +4 -4
- package/dist/{register.setup-Ca6khTSz.js → register.setup-C9gu0W5l.js} +4 -4
- package/dist/{register.setup-6jlL3L1h.js → register.setup-DK-zsne2.js} +4 -4
- package/dist/{register.status-health-sessions-DQDXZYI3.js → register.status-health-sessions-DN5Ui3V0.js} +3 -3
- package/dist/{register.status-health-sessions-DsYNMl06.js → register.status-health-sessions-rZsuoqtr.js} +3 -3
- package/dist/{register.subclis-DJf3ihsW.js → register.subclis-DnzHFtLz.js} +9 -9
- package/dist/{reply-DSjeqLEz.js → reply-Ca3slrA3.js} +103 -168
- package/dist/{run-main-B2coomPj.js → run-main-DlHh5iOO.js} +14 -14
- package/dist/{server-methods-QNBQbsvr.js → server-methods-BYOkyf-q.js} +7 -7
- package/dist/{server-methods-DHo5e8Gj.js → server-methods-b_Qod4tt.js} +7 -7
- package/dist/{server-node-events-D_S0NRCQ.js → server-node-events-60nWpTh1.js} +2 -2
- package/dist/{server-node-events-CJOo8WcL.js → server-node-events-oU4Amei7.js} +2 -2
- package/dist/{status-B8yaGk2o.js → status-BXW5l4sd.js} +2 -2
- package/dist/{status-4DaGE8j5.js → status-BxbbINLV.js} +2 -2
- package/dist/{status-D_J6qcC1.js → status-D3-lP2_9.js} +1 -1
- package/dist/{status-kfEtYX22.js → status-kdz9P3tw.js} +1 -1
- package/dist/{subagent-registry-CyW0EDWw.js → subagent-registry-CbTbJKLs.js} +103 -168
- package/dist/{update-cli-DJupxo-f.js → update-cli-B5TI650v.js} +7 -7
- package/dist/{update-cli-C-ZGqknl.js → update-cli-Cy0gdWRf.js} +8 -8
- package/dist/{update-runner-BF5UULe-.js → update-runner-B0NdgPvD.js} +1 -1
- package/dist/{update-runner-AiIhp7fw.js → update-runner-Bacq0oLK.js} +1 -1
- package/dist/{web-6026eRzJ.js → web-D-oCzJTU.js} +1 -1
- package/dist/{web-CryqKXT4.js → web-DWNtg4iV.js} +1 -1
- package/dist/{web-HeObJp6A.js → web-DmED3zDP.js} +2 -2
- package/dist/{web-6vYYN17n.js → web-QVwKg99Q.js} +1 -1
- package/package.json +1 -1
|
@@ -51789,7 +51789,7 @@ function isVoiceChannelType(type) {
|
|
|
51789
51789
|
function createDefaultDeps() {
|
|
51790
51790
|
return {
|
|
51791
51791
|
sendMessageWhatsApp: async (...args) => {
|
|
51792
|
-
const { sendMessageWhatsApp } = await import("./web-
|
|
51792
|
+
const { sendMessageWhatsApp } = await import("./web-QVwKg99Q.js");
|
|
51793
51793
|
return await sendMessageWhatsApp(...args);
|
|
51794
51794
|
},
|
|
51795
51795
|
sendMessageTelegram: async (...args) => {
|
|
@@ -67071,7 +67071,7 @@ function loadWebLoginQr() {
|
|
|
67071
67071
|
return webLoginQrPromise;
|
|
67072
67072
|
}
|
|
67073
67073
|
function loadWebChannel() {
|
|
67074
|
-
webChannelPromise ??= import("./web-
|
|
67074
|
+
webChannelPromise ??= import("./web-QVwKg99Q.js");
|
|
67075
67075
|
return webChannelPromise;
|
|
67076
67076
|
}
|
|
67077
67077
|
function loadWhatsAppActions() {
|
|
@@ -72838,10 +72838,6 @@ function resolveModelProfile(modelId, userProfiles) {
|
|
|
72838
72838
|
|
|
72839
72839
|
//#endregion
|
|
72840
72840
|
//#region src/agents/pi-embedded-runner/extra-params.ts
|
|
72841
|
-
const OPENROUTER_APP_HEADERS = {
|
|
72842
|
-
"HTTP-Referer": "https://symi.ai",
|
|
72843
|
-
"X-Title": "Symi"
|
|
72844
|
-
};
|
|
72845
72841
|
const ANTHROPIC_CONTEXT_1M_BETA = "context-1m-2025-08-07";
|
|
72846
72842
|
const ANTHROPIC_1M_MODEL_PREFIXES = ["claude-opus-4", "claude-sonnet-4"];
|
|
72847
72843
|
const OPENAI_RESPONSES_APIS = new Set(["openai-responses"]);
|
|
@@ -72859,70 +72855,6 @@ function resolveExtraParams(params) {
|
|
|
72859
72855
|
const profile = resolveModelProfile(modelKey, params.cfg?.models?.profiles);
|
|
72860
72856
|
if (profile.params && Object.keys(profile.params).length > 0) return { ...profile.params };
|
|
72861
72857
|
}
|
|
72862
|
-
/**
|
|
72863
|
-
* Resolve cacheRetention from extraParams, supporting both new `cacheRetention`
|
|
72864
|
-
* and legacy `cacheControlTtl` values for backwards compatibility.
|
|
72865
|
-
*
|
|
72866
|
-
* Mapping: "5m" → "short", "1h" → "long"
|
|
72867
|
-
*
|
|
72868
|
-
* Only applies to Anthropic provider (OpenRouter uses openai-completions API
|
|
72869
|
-
* with hardcoded cache_control, not the cacheRetention stream option).
|
|
72870
|
-
*
|
|
72871
|
-
* Defaults to "short" for Anthropic provider when not explicitly configured.
|
|
72872
|
-
*/
|
|
72873
|
-
function resolveCacheRetention(extraParams, provider) {
|
|
72874
|
-
if (provider !== "anthropic") return;
|
|
72875
|
-
const newVal = extraParams?.cacheRetention;
|
|
72876
|
-
if (newVal === "none" || newVal === "short" || newVal === "long") return newVal;
|
|
72877
|
-
const legacy = extraParams?.cacheControlTtl;
|
|
72878
|
-
if (legacy === "5m") return "short";
|
|
72879
|
-
if (legacy === "1h") return "long";
|
|
72880
|
-
return "short";
|
|
72881
|
-
}
|
|
72882
|
-
function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
72883
|
-
if (!extraParams || Object.keys(extraParams).length === 0) return;
|
|
72884
|
-
const streamParams = {};
|
|
72885
|
-
if (typeof extraParams.temperature === "number") streamParams.temperature = extraParams.temperature;
|
|
72886
|
-
if (typeof extraParams.maxTokens === "number") streamParams.maxTokens = extraParams.maxTokens;
|
|
72887
|
-
if (typeof extraParams.top_p === "number") streamParams.top_p = extraParams.top_p;
|
|
72888
|
-
if (typeof extraParams.top_k === "number") streamParams.top_k = extraParams.top_k;
|
|
72889
|
-
if (typeof extraParams.repeat_penalty === "number") streamParams.repeat_penalty = extraParams.repeat_penalty;
|
|
72890
|
-
if (Array.isArray(extraParams.stop) && extraParams.stop.length > 0) streamParams.stop = extraParams.stop;
|
|
72891
|
-
if (extraParams.chat_template_kwargs && typeof extraParams.chat_template_kwargs === "object") streamParams.chat_template_kwargs = extraParams.chat_template_kwargs;
|
|
72892
|
-
const cacheRetention = resolveCacheRetention(extraParams, provider);
|
|
72893
|
-
if (cacheRetention) streamParams.cacheRetention = cacheRetention;
|
|
72894
|
-
if (Object.keys(streamParams).length === 0) return;
|
|
72895
|
-
log$2.debug(`creating streamFn wrapper with params: ${JSON.stringify(streamParams)}`);
|
|
72896
|
-
const sp = streamParams;
|
|
72897
|
-
const payloadOverrides = {};
|
|
72898
|
-
if (Array.isArray(sp.stop) && sp.stop.length > 0) payloadOverrides.stop = sp.stop;
|
|
72899
|
-
if (typeof sp.top_p === "number") payloadOverrides.top_p = sp.top_p;
|
|
72900
|
-
if (typeof sp.top_k === "number") payloadOverrides.top_k = sp.top_k;
|
|
72901
|
-
if (typeof sp.repeat_penalty === "number") payloadOverrides.repeat_penalty = sp.repeat_penalty;
|
|
72902
|
-
const hasPayloadOverrides = Object.keys(payloadOverrides).length > 0;
|
|
72903
|
-
const underlying = baseStreamFn ?? streamSimple;
|
|
72904
|
-
const wrappedStreamFn = (model, context, options) => {
|
|
72905
|
-
if (hasPayloadOverrides) {
|
|
72906
|
-
const originalOnPayload = options?.onPayload;
|
|
72907
|
-
return underlying(model, context, {
|
|
72908
|
-
...streamParams,
|
|
72909
|
-
...options,
|
|
72910
|
-
onPayload: (payload) => {
|
|
72911
|
-
if (payload && typeof payload === "object") {
|
|
72912
|
-
const p = payload;
|
|
72913
|
-
for (const [key, value] of Object.entries(payloadOverrides)) if (p[key] === void 0) p[key] = value;
|
|
72914
|
-
}
|
|
72915
|
-
originalOnPayload?.(payload);
|
|
72916
|
-
}
|
|
72917
|
-
});
|
|
72918
|
-
}
|
|
72919
|
-
return underlying(model, context, {
|
|
72920
|
-
...streamParams,
|
|
72921
|
-
...options
|
|
72922
|
-
});
|
|
72923
|
-
};
|
|
72924
|
-
return wrappedStreamFn;
|
|
72925
|
-
}
|
|
72926
72858
|
function isDirectOpenAIBaseUrl(baseUrl) {
|
|
72927
72859
|
if (typeof baseUrl !== "string" || !baseUrl.trim()) return true;
|
|
72928
72860
|
try {
|
|
@@ -73003,20 +72935,6 @@ function createAnthropicBetaHeadersWrapper(baseStreamFn, betas) {
|
|
|
73003
72935
|
};
|
|
73004
72936
|
}
|
|
73005
72937
|
/**
|
|
73006
|
-
* Create a streamFn wrapper that adds OpenRouter app attribution headers.
|
|
73007
|
-
* These headers allow Symi to appear on OpenRouter's leaderboard.
|
|
73008
|
-
*/
|
|
73009
|
-
function createOpenRouterHeadersWrapper(baseStreamFn) {
|
|
73010
|
-
const underlying = baseStreamFn ?? streamSimple;
|
|
73011
|
-
return (model, context, options) => underlying(model, context, {
|
|
73012
|
-
...options,
|
|
73013
|
-
headers: {
|
|
73014
|
-
...OPENROUTER_APP_HEADERS,
|
|
73015
|
-
...options?.headers
|
|
73016
|
-
}
|
|
73017
|
-
});
|
|
73018
|
-
}
|
|
73019
|
-
/**
|
|
73020
72938
|
* Create a streamFn wrapper that injects tool_stream=true for Z.AI providers.
|
|
73021
72939
|
*
|
|
73022
72940
|
* Z.AI's API supports the `tool_stream` parameter to enable real-time streaming
|
|
@@ -73039,82 +72957,6 @@ function createZaiToolStreamWrapper(baseStreamFn, enabled) {
|
|
|
73039
72957
|
});
|
|
73040
72958
|
};
|
|
73041
72959
|
}
|
|
73042
|
-
const GEMMA_STOP_SEQUENCES = ["<end_of_turn>", "<eos>"];
|
|
73043
|
-
const VLLM_GEMMA_HINTS = ["gemma", "redsand"];
|
|
73044
|
-
function isVllmOrGemmaProvider(provider, modelId, cfg) {
|
|
73045
|
-
const lower = `${provider}/${modelId}`.toLowerCase();
|
|
73046
|
-
if (VLLM_GEMMA_HINTS.some((h) => lower.includes(h))) return true;
|
|
73047
|
-
const baseUrl = ((cfg?.models?.providers?.[provider])?.baseUrl ?? "").toLowerCase();
|
|
73048
|
-
return baseUrl.includes("coreweave") || baseUrl.includes("vllm");
|
|
73049
|
-
}
|
|
73050
|
-
/**
|
|
73051
|
-
* Wrap the stream function to fix vLLM/Gemma compat issues via onPayload:
|
|
73052
|
-
* 1. Replace `max_completion_tokens` with `max_tokens` (vLLM ignores the former)
|
|
73053
|
-
* 2. Inject Gemma stop sequences if none are set
|
|
73054
|
-
* 3. Remove unsupported fields (store, stream_options.include_usage on older vLLM)
|
|
73055
|
-
*/
|
|
73056
|
-
function createVllmCompatWrapper(baseStreamFn, extraParams) {
|
|
73057
|
-
const underlying = baseStreamFn ?? streamSimple;
|
|
73058
|
-
const configuredStop = Array.isArray(extraParams.stop) ? extraParams.stop : GEMMA_STOP_SEQUENCES;
|
|
73059
|
-
return (model, context, options) => {
|
|
73060
|
-
const originalOnPayload = options?.onPayload;
|
|
73061
|
-
return underlying(model, context, {
|
|
73062
|
-
...options,
|
|
73063
|
-
onPayload: (payload) => {
|
|
73064
|
-
if (payload && typeof payload === "object") {
|
|
73065
|
-
const p = payload;
|
|
73066
|
-
if (p.max_completion_tokens && !p.max_tokens) {
|
|
73067
|
-
p.max_tokens = p.max_completion_tokens;
|
|
73068
|
-
delete p.max_completion_tokens;
|
|
73069
|
-
}
|
|
73070
|
-
if (!p.stop && configuredStop.length > 0) p.stop = configuredStop;
|
|
73071
|
-
delete p.store;
|
|
73072
|
-
}
|
|
73073
|
-
originalOnPayload?.(payload);
|
|
73074
|
-
}
|
|
73075
|
-
});
|
|
73076
|
-
};
|
|
73077
|
-
}
|
|
73078
|
-
/**
|
|
73079
|
-
* Apply extra params (like temperature) to an agent's streamFn.
|
|
73080
|
-
* Also adds OpenRouter app attribution headers when using the OpenRouter provider.
|
|
73081
|
-
*
|
|
73082
|
-
* @internal Exported for testing
|
|
73083
|
-
*/
|
|
73084
|
-
function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverride) {
|
|
73085
|
-
const extraParams = resolveExtraParams({
|
|
73086
|
-
cfg,
|
|
73087
|
-
provider,
|
|
73088
|
-
modelId
|
|
73089
|
-
});
|
|
73090
|
-
const override = extraParamsOverride && Object.keys(extraParamsOverride).length > 0 ? Object.fromEntries(Object.entries(extraParamsOverride).filter(([, value]) => value !== void 0)) : void 0;
|
|
73091
|
-
const merged = Object.assign({}, extraParams, override);
|
|
73092
|
-
const wrappedStreamFn = createStreamFnWithExtraParams(agent.streamFn, merged, provider);
|
|
73093
|
-
if (wrappedStreamFn) {
|
|
73094
|
-
log$2.debug(`applying extraParams to agent streamFn for ${provider}/${modelId}`);
|
|
73095
|
-
agent.streamFn = wrappedStreamFn;
|
|
73096
|
-
}
|
|
73097
|
-
const anthropicBetas = resolveAnthropicBetas(merged, provider, modelId);
|
|
73098
|
-
if (anthropicBetas?.length) {
|
|
73099
|
-
log$2.debug(`applying Anthropic beta header for ${provider}/${modelId}: ${anthropicBetas.join(",")}`);
|
|
73100
|
-
agent.streamFn = createAnthropicBetaHeadersWrapper(agent.streamFn, anthropicBetas);
|
|
73101
|
-
}
|
|
73102
|
-
if (provider === "openrouter") {
|
|
73103
|
-
log$2.debug(`applying OpenRouter app attribution headers for ${provider}/${modelId}`);
|
|
73104
|
-
agent.streamFn = createOpenRouterHeadersWrapper(agent.streamFn);
|
|
73105
|
-
}
|
|
73106
|
-
if (provider === "zai" || provider === "z-ai") {
|
|
73107
|
-
if (merged?.tool_stream !== false) {
|
|
73108
|
-
log$2.debug(`enabling Z.AI tool_stream for ${provider}/${modelId}`);
|
|
73109
|
-
agent.streamFn = createZaiToolStreamWrapper(agent.streamFn, true);
|
|
73110
|
-
}
|
|
73111
|
-
}
|
|
73112
|
-
if (isVllmOrGemmaProvider(provider, modelId, cfg)) {
|
|
73113
|
-
log$2.debug(`applying vLLM/Gemma compat wrapper for ${provider}/${modelId}`);
|
|
73114
|
-
agent.streamFn = createVllmCompatWrapper(agent.streamFn, merged);
|
|
73115
|
-
}
|
|
73116
|
-
agent.streamFn = createOpenAIResponsesStoreWrapper(agent.streamFn);
|
|
73117
|
-
}
|
|
73118
72960
|
|
|
73119
72961
|
//#endregion
|
|
73120
72962
|
//#region src/utils/safe-json.ts
|
|
@@ -73391,6 +73233,74 @@ function createCacheTrace(params) {
|
|
|
73391
73233
|
};
|
|
73392
73234
|
}
|
|
73393
73235
|
|
|
73236
|
+
//#endregion
|
|
73237
|
+
//#region src/agents/model-aware-stream.ts
|
|
73238
|
+
/**
|
|
73239
|
+
* Create a single stream function wrapper that handles all provider-specific
|
|
73240
|
+
* param injection via one onPayload hook.
|
|
73241
|
+
*
|
|
73242
|
+
* Replaces: createStreamFnWithExtraParams, createVllmCompatWrapper,
|
|
73243
|
+
* createOpenRouterHeadersWrapper.
|
|
73244
|
+
*/
|
|
73245
|
+
function createModelAwareStreamFn(opts) {
|
|
73246
|
+
const underlying = opts.baseStreamFn ?? streamSimple;
|
|
73247
|
+
const mergedParams = {
|
|
73248
|
+
...opts.profile.params,
|
|
73249
|
+
...opts.configExtraParams,
|
|
73250
|
+
...opts.streamParamsOverride
|
|
73251
|
+
};
|
|
73252
|
+
const nativeOpts = {};
|
|
73253
|
+
if (typeof mergedParams.temperature === "number") nativeOpts.temperature = mergedParams.temperature;
|
|
73254
|
+
if (typeof mergedParams.max_tokens === "number") nativeOpts.maxTokens = mergedParams.max_tokens;
|
|
73255
|
+
else if (typeof mergedParams.maxTokens === "number") nativeOpts.maxTokens = mergedParams.maxTokens;
|
|
73256
|
+
const injections = {};
|
|
73257
|
+
if (Array.isArray(mergedParams.stop) && mergedParams.stop.length > 0) injections.stop = mergedParams.stop;
|
|
73258
|
+
if (typeof mergedParams.top_p === "number") injections.top_p = mergedParams.top_p;
|
|
73259
|
+
if (typeof mergedParams.top_k === "number") injections.top_k = mergedParams.top_k;
|
|
73260
|
+
if (typeof mergedParams.repeat_penalty === "number") injections.repeat_penalty = mergedParams.repeat_penalty;
|
|
73261
|
+
const isVllm = isVllmProvider(opts.provider, opts.modelId, opts.config);
|
|
73262
|
+
const isOpenRouter = opts.provider === "openrouter";
|
|
73263
|
+
const extraHeaders = {};
|
|
73264
|
+
if (isOpenRouter) {
|
|
73265
|
+
extraHeaders["HTTP-Referer"] = "https://symi.ai";
|
|
73266
|
+
extraHeaders["X-Title"] = "Symi";
|
|
73267
|
+
}
|
|
73268
|
+
const hasExtraHeaders = Object.keys(extraHeaders).length > 0;
|
|
73269
|
+
const onPayloadHook = (payload, callerOnPayload) => {
|
|
73270
|
+
if (payload && typeof payload === "object") {
|
|
73271
|
+
const p = payload;
|
|
73272
|
+
for (const [key, val] of Object.entries(injections)) if (p[key] === void 0) p[key] = val;
|
|
73273
|
+
if (isVllm) {
|
|
73274
|
+
if (p.max_completion_tokens && !p.max_tokens) {
|
|
73275
|
+
p.max_tokens = p.max_completion_tokens;
|
|
73276
|
+
delete p.max_completion_tokens;
|
|
73277
|
+
}
|
|
73278
|
+
delete p.store;
|
|
73279
|
+
}
|
|
73280
|
+
}
|
|
73281
|
+
callerOnPayload?.(payload);
|
|
73282
|
+
};
|
|
73283
|
+
return (model, context, options) => {
|
|
73284
|
+
const callerOnPayload = options?.onPayload;
|
|
73285
|
+
return underlying(model, context, {
|
|
73286
|
+
...nativeOpts,
|
|
73287
|
+
...options,
|
|
73288
|
+
onPayload: (payload) => onPayloadHook(payload, callerOnPayload),
|
|
73289
|
+
...hasExtraHeaders ? { headers: {
|
|
73290
|
+
...extraHeaders,
|
|
73291
|
+
...options?.headers
|
|
73292
|
+
} } : {}
|
|
73293
|
+
});
|
|
73294
|
+
};
|
|
73295
|
+
}
|
|
73296
|
+
/** Detect vLLM/Gemma providers by model hints or baseUrl patterns. */
|
|
73297
|
+
function isVllmProvider(provider, modelId, config) {
|
|
73298
|
+
const lower = `${provider}/${modelId}`.toLowerCase();
|
|
73299
|
+
if (["gemma", "redsand"].some((h) => lower.includes(h))) return true;
|
|
73300
|
+
const baseUrl = ((config?.models?.providers?.[provider])?.baseUrl ?? "").toLowerCase();
|
|
73301
|
+
return baseUrl.includes("coreweave") || baseUrl.includes("vllm");
|
|
73302
|
+
}
|
|
73303
|
+
|
|
73394
73304
|
//#endregion
|
|
73395
73305
|
//#region src/auto-reply/reply/streaming-directives.ts
|
|
73396
73306
|
const splitTrailingDirective = (text) => {
|
|
@@ -76438,14 +76348,39 @@ async function runEmbeddedAttempt(params) {
|
|
|
76438
76348
|
modelApi: params.model.api,
|
|
76439
76349
|
workspaceDir: params.workspaceDir
|
|
76440
76350
|
});
|
|
76441
|
-
|
|
76442
|
-
|
|
76443
|
-
|
|
76444
|
-
|
|
76445
|
-
|
|
76446
|
-
|
|
76447
|
-
|
|
76448
|
-
|
|
76351
|
+
{
|
|
76352
|
+
let baseStreamFn = streamSimple;
|
|
76353
|
+
if (params.model.api === "ollama") {
|
|
76354
|
+
const providerConfig = params.config?.models?.providers?.[params.model.provider];
|
|
76355
|
+
const modelBaseUrl = typeof params.model.baseUrl === "string" ? params.model.baseUrl.trim() : "";
|
|
76356
|
+
const providerBaseUrl = typeof providerConfig?.baseUrl === "string" ? providerConfig.baseUrl.trim() : "";
|
|
76357
|
+
baseStreamFn = createOllamaStreamFn(modelBaseUrl || providerBaseUrl || OLLAMA_NATIVE_BASE_URL);
|
|
76358
|
+
}
|
|
76359
|
+
const configExtraParams = resolveExtraParams({
|
|
76360
|
+
cfg: params.config,
|
|
76361
|
+
provider: params.provider,
|
|
76362
|
+
modelId: params.modelId
|
|
76363
|
+
});
|
|
76364
|
+
activeSession.agent.streamFn = createModelAwareStreamFn({
|
|
76365
|
+
baseStreamFn,
|
|
76366
|
+
profile: modelProfile,
|
|
76367
|
+
provider: params.provider,
|
|
76368
|
+
modelId: params.modelId,
|
|
76369
|
+
config: params.config,
|
|
76370
|
+
configExtraParams,
|
|
76371
|
+
streamParamsOverride: params.streamParams
|
|
76372
|
+
});
|
|
76373
|
+
const merged = {
|
|
76374
|
+
...configExtraParams,
|
|
76375
|
+
...params.streamParams
|
|
76376
|
+
};
|
|
76377
|
+
const anthropicBetas = resolveAnthropicBetas(merged, params.provider, params.modelId);
|
|
76378
|
+
if (anthropicBetas?.length) activeSession.agent.streamFn = createAnthropicBetaHeadersWrapper(activeSession.agent.streamFn, anthropicBetas);
|
|
76379
|
+
if (params.provider === "zai" || params.provider === "z-ai") {
|
|
76380
|
+
if (merged?.tool_stream !== false) activeSession.agent.streamFn = createZaiToolStreamWrapper(activeSession.agent.streamFn, true);
|
|
76381
|
+
}
|
|
76382
|
+
activeSession.agent.streamFn = createOpenAIResponsesStoreWrapper(activeSession.agent.streamFn);
|
|
76383
|
+
}
|
|
76449
76384
|
if (cacheTrace) {
|
|
76450
76385
|
cacheTrace.recordStage("session:loaded", {
|
|
76451
76386
|
messages: activeSession.messages,
|
|
@@ -51787,7 +51787,7 @@ function isVoiceChannelType(type) {
|
|
|
51787
51787
|
function createDefaultDeps() {
|
|
51788
51788
|
return {
|
|
51789
51789
|
sendMessageWhatsApp: async (...args) => {
|
|
51790
|
-
const { sendMessageWhatsApp } = await import("./web-
|
|
51790
|
+
const { sendMessageWhatsApp } = await import("./web-DWNtg4iV.js");
|
|
51791
51791
|
return await sendMessageWhatsApp(...args);
|
|
51792
51792
|
},
|
|
51793
51793
|
sendMessageTelegram: async (...args) => {
|
|
@@ -67069,7 +67069,7 @@ function loadWebLoginQr() {
|
|
|
67069
67069
|
return webLoginQrPromise;
|
|
67070
67070
|
}
|
|
67071
67071
|
function loadWebChannel() {
|
|
67072
|
-
webChannelPromise ??= import("./web-
|
|
67072
|
+
webChannelPromise ??= import("./web-DWNtg4iV.js");
|
|
67073
67073
|
return webChannelPromise;
|
|
67074
67074
|
}
|
|
67075
67075
|
function loadWhatsAppActions() {
|
|
@@ -72836,10 +72836,6 @@ function resolveModelProfile(modelId, userProfiles) {
|
|
|
72836
72836
|
|
|
72837
72837
|
//#endregion
|
|
72838
72838
|
//#region src/agents/pi-embedded-runner/extra-params.ts
|
|
72839
|
-
const OPENROUTER_APP_HEADERS = {
|
|
72840
|
-
"HTTP-Referer": "https://symi.ai",
|
|
72841
|
-
"X-Title": "Symi"
|
|
72842
|
-
};
|
|
72843
72839
|
const ANTHROPIC_CONTEXT_1M_BETA = "context-1m-2025-08-07";
|
|
72844
72840
|
const ANTHROPIC_1M_MODEL_PREFIXES = ["claude-opus-4", "claude-sonnet-4"];
|
|
72845
72841
|
const OPENAI_RESPONSES_APIS = new Set(["openai-responses"]);
|
|
@@ -72857,70 +72853,6 @@ function resolveExtraParams(params) {
|
|
|
72857
72853
|
const profile = resolveModelProfile(modelKey, params.cfg?.models?.profiles);
|
|
72858
72854
|
if (profile.params && Object.keys(profile.params).length > 0) return { ...profile.params };
|
|
72859
72855
|
}
|
|
72860
|
-
/**
|
|
72861
|
-
* Resolve cacheRetention from extraParams, supporting both new `cacheRetention`
|
|
72862
|
-
* and legacy `cacheControlTtl` values for backwards compatibility.
|
|
72863
|
-
*
|
|
72864
|
-
* Mapping: "5m" → "short", "1h" → "long"
|
|
72865
|
-
*
|
|
72866
|
-
* Only applies to Anthropic provider (OpenRouter uses openai-completions API
|
|
72867
|
-
* with hardcoded cache_control, not the cacheRetention stream option).
|
|
72868
|
-
*
|
|
72869
|
-
* Defaults to "short" for Anthropic provider when not explicitly configured.
|
|
72870
|
-
*/
|
|
72871
|
-
function resolveCacheRetention(extraParams, provider) {
|
|
72872
|
-
if (provider !== "anthropic") return;
|
|
72873
|
-
const newVal = extraParams?.cacheRetention;
|
|
72874
|
-
if (newVal === "none" || newVal === "short" || newVal === "long") return newVal;
|
|
72875
|
-
const legacy = extraParams?.cacheControlTtl;
|
|
72876
|
-
if (legacy === "5m") return "short";
|
|
72877
|
-
if (legacy === "1h") return "long";
|
|
72878
|
-
return "short";
|
|
72879
|
-
}
|
|
72880
|
-
function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
72881
|
-
if (!extraParams || Object.keys(extraParams).length === 0) return;
|
|
72882
|
-
const streamParams = {};
|
|
72883
|
-
if (typeof extraParams.temperature === "number") streamParams.temperature = extraParams.temperature;
|
|
72884
|
-
if (typeof extraParams.maxTokens === "number") streamParams.maxTokens = extraParams.maxTokens;
|
|
72885
|
-
if (typeof extraParams.top_p === "number") streamParams.top_p = extraParams.top_p;
|
|
72886
|
-
if (typeof extraParams.top_k === "number") streamParams.top_k = extraParams.top_k;
|
|
72887
|
-
if (typeof extraParams.repeat_penalty === "number") streamParams.repeat_penalty = extraParams.repeat_penalty;
|
|
72888
|
-
if (Array.isArray(extraParams.stop) && extraParams.stop.length > 0) streamParams.stop = extraParams.stop;
|
|
72889
|
-
if (extraParams.chat_template_kwargs && typeof extraParams.chat_template_kwargs === "object") streamParams.chat_template_kwargs = extraParams.chat_template_kwargs;
|
|
72890
|
-
const cacheRetention = resolveCacheRetention(extraParams, provider);
|
|
72891
|
-
if (cacheRetention) streamParams.cacheRetention = cacheRetention;
|
|
72892
|
-
if (Object.keys(streamParams).length === 0) return;
|
|
72893
|
-
log$2.debug(`creating streamFn wrapper with params: ${JSON.stringify(streamParams)}`);
|
|
72894
|
-
const sp = streamParams;
|
|
72895
|
-
const payloadOverrides = {};
|
|
72896
|
-
if (Array.isArray(sp.stop) && sp.stop.length > 0) payloadOverrides.stop = sp.stop;
|
|
72897
|
-
if (typeof sp.top_p === "number") payloadOverrides.top_p = sp.top_p;
|
|
72898
|
-
if (typeof sp.top_k === "number") payloadOverrides.top_k = sp.top_k;
|
|
72899
|
-
if (typeof sp.repeat_penalty === "number") payloadOverrides.repeat_penalty = sp.repeat_penalty;
|
|
72900
|
-
const hasPayloadOverrides = Object.keys(payloadOverrides).length > 0;
|
|
72901
|
-
const underlying = baseStreamFn ?? streamSimple;
|
|
72902
|
-
const wrappedStreamFn = (model, context, options) => {
|
|
72903
|
-
if (hasPayloadOverrides) {
|
|
72904
|
-
const originalOnPayload = options?.onPayload;
|
|
72905
|
-
return underlying(model, context, {
|
|
72906
|
-
...streamParams,
|
|
72907
|
-
...options,
|
|
72908
|
-
onPayload: (payload) => {
|
|
72909
|
-
if (payload && typeof payload === "object") {
|
|
72910
|
-
const p = payload;
|
|
72911
|
-
for (const [key, value] of Object.entries(payloadOverrides)) if (p[key] === void 0) p[key] = value;
|
|
72912
|
-
}
|
|
72913
|
-
originalOnPayload?.(payload);
|
|
72914
|
-
}
|
|
72915
|
-
});
|
|
72916
|
-
}
|
|
72917
|
-
return underlying(model, context, {
|
|
72918
|
-
...streamParams,
|
|
72919
|
-
...options
|
|
72920
|
-
});
|
|
72921
|
-
};
|
|
72922
|
-
return wrappedStreamFn;
|
|
72923
|
-
}
|
|
72924
72856
|
function isDirectOpenAIBaseUrl(baseUrl) {
|
|
72925
72857
|
if (typeof baseUrl !== "string" || !baseUrl.trim()) return true;
|
|
72926
72858
|
try {
|
|
@@ -73001,20 +72933,6 @@ function createAnthropicBetaHeadersWrapper(baseStreamFn, betas) {
|
|
|
73001
72933
|
};
|
|
73002
72934
|
}
|
|
73003
72935
|
/**
|
|
73004
|
-
* Create a streamFn wrapper that adds OpenRouter app attribution headers.
|
|
73005
|
-
* These headers allow Symi to appear on OpenRouter's leaderboard.
|
|
73006
|
-
*/
|
|
73007
|
-
function createOpenRouterHeadersWrapper(baseStreamFn) {
|
|
73008
|
-
const underlying = baseStreamFn ?? streamSimple;
|
|
73009
|
-
return (model, context, options) => underlying(model, context, {
|
|
73010
|
-
...options,
|
|
73011
|
-
headers: {
|
|
73012
|
-
...OPENROUTER_APP_HEADERS,
|
|
73013
|
-
...options?.headers
|
|
73014
|
-
}
|
|
73015
|
-
});
|
|
73016
|
-
}
|
|
73017
|
-
/**
|
|
73018
72936
|
* Create a streamFn wrapper that injects tool_stream=true for Z.AI providers.
|
|
73019
72937
|
*
|
|
73020
72938
|
* Z.AI's API supports the `tool_stream` parameter to enable real-time streaming
|
|
@@ -73037,82 +72955,6 @@ function createZaiToolStreamWrapper(baseStreamFn, enabled) {
|
|
|
73037
72955
|
});
|
|
73038
72956
|
};
|
|
73039
72957
|
}
|
|
73040
|
-
const GEMMA_STOP_SEQUENCES = ["<end_of_turn>", "<eos>"];
|
|
73041
|
-
const VLLM_GEMMA_HINTS = ["gemma", "redsand"];
|
|
73042
|
-
function isVllmOrGemmaProvider(provider, modelId, cfg) {
|
|
73043
|
-
const lower = `${provider}/${modelId}`.toLowerCase();
|
|
73044
|
-
if (VLLM_GEMMA_HINTS.some((h) => lower.includes(h))) return true;
|
|
73045
|
-
const baseUrl = ((cfg?.models?.providers?.[provider])?.baseUrl ?? "").toLowerCase();
|
|
73046
|
-
return baseUrl.includes("coreweave") || baseUrl.includes("vllm");
|
|
73047
|
-
}
|
|
73048
|
-
/**
|
|
73049
|
-
* Wrap the stream function to fix vLLM/Gemma compat issues via onPayload:
|
|
73050
|
-
* 1. Replace `max_completion_tokens` with `max_tokens` (vLLM ignores the former)
|
|
73051
|
-
* 2. Inject Gemma stop sequences if none are set
|
|
73052
|
-
* 3. Remove unsupported fields (store, stream_options.include_usage on older vLLM)
|
|
73053
|
-
*/
|
|
73054
|
-
function createVllmCompatWrapper(baseStreamFn, extraParams) {
|
|
73055
|
-
const underlying = baseStreamFn ?? streamSimple;
|
|
73056
|
-
const configuredStop = Array.isArray(extraParams.stop) ? extraParams.stop : GEMMA_STOP_SEQUENCES;
|
|
73057
|
-
return (model, context, options) => {
|
|
73058
|
-
const originalOnPayload = options?.onPayload;
|
|
73059
|
-
return underlying(model, context, {
|
|
73060
|
-
...options,
|
|
73061
|
-
onPayload: (payload) => {
|
|
73062
|
-
if (payload && typeof payload === "object") {
|
|
73063
|
-
const p = payload;
|
|
73064
|
-
if (p.max_completion_tokens && !p.max_tokens) {
|
|
73065
|
-
p.max_tokens = p.max_completion_tokens;
|
|
73066
|
-
delete p.max_completion_tokens;
|
|
73067
|
-
}
|
|
73068
|
-
if (!p.stop && configuredStop.length > 0) p.stop = configuredStop;
|
|
73069
|
-
delete p.store;
|
|
73070
|
-
}
|
|
73071
|
-
originalOnPayload?.(payload);
|
|
73072
|
-
}
|
|
73073
|
-
});
|
|
73074
|
-
};
|
|
73075
|
-
}
|
|
73076
|
-
/**
|
|
73077
|
-
* Apply extra params (like temperature) to an agent's streamFn.
|
|
73078
|
-
* Also adds OpenRouter app attribution headers when using the OpenRouter provider.
|
|
73079
|
-
*
|
|
73080
|
-
* @internal Exported for testing
|
|
73081
|
-
*/
|
|
73082
|
-
function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverride) {
|
|
73083
|
-
const extraParams = resolveExtraParams({
|
|
73084
|
-
cfg,
|
|
73085
|
-
provider,
|
|
73086
|
-
modelId
|
|
73087
|
-
});
|
|
73088
|
-
const override = extraParamsOverride && Object.keys(extraParamsOverride).length > 0 ? Object.fromEntries(Object.entries(extraParamsOverride).filter(([, value]) => value !== void 0)) : void 0;
|
|
73089
|
-
const merged = Object.assign({}, extraParams, override);
|
|
73090
|
-
const wrappedStreamFn = createStreamFnWithExtraParams(agent.streamFn, merged, provider);
|
|
73091
|
-
if (wrappedStreamFn) {
|
|
73092
|
-
log$2.debug(`applying extraParams to agent streamFn for ${provider}/${modelId}`);
|
|
73093
|
-
agent.streamFn = wrappedStreamFn;
|
|
73094
|
-
}
|
|
73095
|
-
const anthropicBetas = resolveAnthropicBetas(merged, provider, modelId);
|
|
73096
|
-
if (anthropicBetas?.length) {
|
|
73097
|
-
log$2.debug(`applying Anthropic beta header for ${provider}/${modelId}: ${anthropicBetas.join(",")}`);
|
|
73098
|
-
agent.streamFn = createAnthropicBetaHeadersWrapper(agent.streamFn, anthropicBetas);
|
|
73099
|
-
}
|
|
73100
|
-
if (provider === "openrouter") {
|
|
73101
|
-
log$2.debug(`applying OpenRouter app attribution headers for ${provider}/${modelId}`);
|
|
73102
|
-
agent.streamFn = createOpenRouterHeadersWrapper(agent.streamFn);
|
|
73103
|
-
}
|
|
73104
|
-
if (provider === "zai" || provider === "z-ai") {
|
|
73105
|
-
if (merged?.tool_stream !== false) {
|
|
73106
|
-
log$2.debug(`enabling Z.AI tool_stream for ${provider}/${modelId}`);
|
|
73107
|
-
agent.streamFn = createZaiToolStreamWrapper(agent.streamFn, true);
|
|
73108
|
-
}
|
|
73109
|
-
}
|
|
73110
|
-
if (isVllmOrGemmaProvider(provider, modelId, cfg)) {
|
|
73111
|
-
log$2.debug(`applying vLLM/Gemma compat wrapper for ${provider}/${modelId}`);
|
|
73112
|
-
agent.streamFn = createVllmCompatWrapper(agent.streamFn, merged);
|
|
73113
|
-
}
|
|
73114
|
-
agent.streamFn = createOpenAIResponsesStoreWrapper(agent.streamFn);
|
|
73115
|
-
}
|
|
73116
72958
|
|
|
73117
72959
|
//#endregion
|
|
73118
72960
|
//#region src/utils/safe-json.ts
|
|
@@ -73389,6 +73231,74 @@ function createCacheTrace(params) {
|
|
|
73389
73231
|
};
|
|
73390
73232
|
}
|
|
73391
73233
|
|
|
73234
|
+
//#endregion
|
|
73235
|
+
//#region src/agents/model-aware-stream.ts
|
|
73236
|
+
/**
|
|
73237
|
+
* Create a single stream function wrapper that handles all provider-specific
|
|
73238
|
+
* param injection via one onPayload hook.
|
|
73239
|
+
*
|
|
73240
|
+
* Replaces: createStreamFnWithExtraParams, createVllmCompatWrapper,
|
|
73241
|
+
* createOpenRouterHeadersWrapper.
|
|
73242
|
+
*/
|
|
73243
|
+
function createModelAwareStreamFn(opts) {
|
|
73244
|
+
const underlying = opts.baseStreamFn ?? streamSimple;
|
|
73245
|
+
const mergedParams = {
|
|
73246
|
+
...opts.profile.params,
|
|
73247
|
+
...opts.configExtraParams,
|
|
73248
|
+
...opts.streamParamsOverride
|
|
73249
|
+
};
|
|
73250
|
+
const nativeOpts = {};
|
|
73251
|
+
if (typeof mergedParams.temperature === "number") nativeOpts.temperature = mergedParams.temperature;
|
|
73252
|
+
if (typeof mergedParams.max_tokens === "number") nativeOpts.maxTokens = mergedParams.max_tokens;
|
|
73253
|
+
else if (typeof mergedParams.maxTokens === "number") nativeOpts.maxTokens = mergedParams.maxTokens;
|
|
73254
|
+
const injections = {};
|
|
73255
|
+
if (Array.isArray(mergedParams.stop) && mergedParams.stop.length > 0) injections.stop = mergedParams.stop;
|
|
73256
|
+
if (typeof mergedParams.top_p === "number") injections.top_p = mergedParams.top_p;
|
|
73257
|
+
if (typeof mergedParams.top_k === "number") injections.top_k = mergedParams.top_k;
|
|
73258
|
+
if (typeof mergedParams.repeat_penalty === "number") injections.repeat_penalty = mergedParams.repeat_penalty;
|
|
73259
|
+
const isVllm = isVllmProvider(opts.provider, opts.modelId, opts.config);
|
|
73260
|
+
const isOpenRouter = opts.provider === "openrouter";
|
|
73261
|
+
const extraHeaders = {};
|
|
73262
|
+
if (isOpenRouter) {
|
|
73263
|
+
extraHeaders["HTTP-Referer"] = "https://symi.ai";
|
|
73264
|
+
extraHeaders["X-Title"] = "Symi";
|
|
73265
|
+
}
|
|
73266
|
+
const hasExtraHeaders = Object.keys(extraHeaders).length > 0;
|
|
73267
|
+
const onPayloadHook = (payload, callerOnPayload) => {
|
|
73268
|
+
if (payload && typeof payload === "object") {
|
|
73269
|
+
const p = payload;
|
|
73270
|
+
for (const [key, val] of Object.entries(injections)) if (p[key] === void 0) p[key] = val;
|
|
73271
|
+
if (isVllm) {
|
|
73272
|
+
if (p.max_completion_tokens && !p.max_tokens) {
|
|
73273
|
+
p.max_tokens = p.max_completion_tokens;
|
|
73274
|
+
delete p.max_completion_tokens;
|
|
73275
|
+
}
|
|
73276
|
+
delete p.store;
|
|
73277
|
+
}
|
|
73278
|
+
}
|
|
73279
|
+
callerOnPayload?.(payload);
|
|
73280
|
+
};
|
|
73281
|
+
return (model, context, options) => {
|
|
73282
|
+
const callerOnPayload = options?.onPayload;
|
|
73283
|
+
return underlying(model, context, {
|
|
73284
|
+
...nativeOpts,
|
|
73285
|
+
...options,
|
|
73286
|
+
onPayload: (payload) => onPayloadHook(payload, callerOnPayload),
|
|
73287
|
+
...hasExtraHeaders ? { headers: {
|
|
73288
|
+
...extraHeaders,
|
|
73289
|
+
...options?.headers
|
|
73290
|
+
} } : {}
|
|
73291
|
+
});
|
|
73292
|
+
};
|
|
73293
|
+
}
|
|
73294
|
+
/** Detect vLLM/Gemma providers by model hints or baseUrl patterns. */
|
|
73295
|
+
function isVllmProvider(provider, modelId, config) {
|
|
73296
|
+
const lower = `${provider}/${modelId}`.toLowerCase();
|
|
73297
|
+
if (["gemma", "redsand"].some((h) => lower.includes(h))) return true;
|
|
73298
|
+
const baseUrl = ((config?.models?.providers?.[provider])?.baseUrl ?? "").toLowerCase();
|
|
73299
|
+
return baseUrl.includes("coreweave") || baseUrl.includes("vllm");
|
|
73300
|
+
}
|
|
73301
|
+
|
|
73392
73302
|
//#endregion
|
|
73393
73303
|
//#region src/auto-reply/reply/streaming-directives.ts
|
|
73394
73304
|
const splitTrailingDirective = (text) => {
|
|
@@ -76436,14 +76346,39 @@ async function runEmbeddedAttempt(params) {
|
|
|
76436
76346
|
modelApi: params.model.api,
|
|
76437
76347
|
workspaceDir: params.workspaceDir
|
|
76438
76348
|
});
|
|
76439
|
-
|
|
76440
|
-
|
|
76441
|
-
|
|
76442
|
-
|
|
76443
|
-
|
|
76444
|
-
|
|
76445
|
-
|
|
76446
|
-
|
|
76349
|
+
{
|
|
76350
|
+
let baseStreamFn = streamSimple;
|
|
76351
|
+
if (params.model.api === "ollama") {
|
|
76352
|
+
const providerConfig = params.config?.models?.providers?.[params.model.provider];
|
|
76353
|
+
const modelBaseUrl = typeof params.model.baseUrl === "string" ? params.model.baseUrl.trim() : "";
|
|
76354
|
+
const providerBaseUrl = typeof providerConfig?.baseUrl === "string" ? providerConfig.baseUrl.trim() : "";
|
|
76355
|
+
baseStreamFn = createOllamaStreamFn(modelBaseUrl || providerBaseUrl || OLLAMA_NATIVE_BASE_URL);
|
|
76356
|
+
}
|
|
76357
|
+
const configExtraParams = resolveExtraParams({
|
|
76358
|
+
cfg: params.config,
|
|
76359
|
+
provider: params.provider,
|
|
76360
|
+
modelId: params.modelId
|
|
76361
|
+
});
|
|
76362
|
+
activeSession.agent.streamFn = createModelAwareStreamFn({
|
|
76363
|
+
baseStreamFn,
|
|
76364
|
+
profile: modelProfile,
|
|
76365
|
+
provider: params.provider,
|
|
76366
|
+
modelId: params.modelId,
|
|
76367
|
+
config: params.config,
|
|
76368
|
+
configExtraParams,
|
|
76369
|
+
streamParamsOverride: params.streamParams
|
|
76370
|
+
});
|
|
76371
|
+
const merged = {
|
|
76372
|
+
...configExtraParams,
|
|
76373
|
+
...params.streamParams
|
|
76374
|
+
};
|
|
76375
|
+
const anthropicBetas = resolveAnthropicBetas(merged, params.provider, params.modelId);
|
|
76376
|
+
if (anthropicBetas?.length) activeSession.agent.streamFn = createAnthropicBetaHeadersWrapper(activeSession.agent.streamFn, anthropicBetas);
|
|
76377
|
+
if (params.provider === "zai" || params.provider === "z-ai") {
|
|
76378
|
+
if (merged?.tool_stream !== false) activeSession.agent.streamFn = createZaiToolStreamWrapper(activeSession.agent.streamFn, true);
|
|
76379
|
+
}
|
|
76380
|
+
activeSession.agent.streamFn = createOpenAIResponsesStoreWrapper(activeSession.agent.streamFn);
|
|
76381
|
+
}
|
|
76447
76382
|
if (cacheTrace) {
|
|
76448
76383
|
cacheTrace.recordStage("session:loaded", {
|
|
76449
76384
|
messages: activeSession.messages,
|
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
|
2
2
|
import { M as getActivePluginRegistry, o as createSubsystemLogger } from "./entry.js";
|
|
3
3
|
import { c as resolveAgentWorkspaceDir, l as resolveDefaultAgentId } from "./agent-scope-D-jRCY0d.js";
|
|
4
4
|
import { i as loadConfig } from "./config-DHBLS1Hl.js";
|
|
5
|
-
import { b as loadSymiPlugins } from "./subagent-registry-
|
|
5
|
+
import { b as loadSymiPlugins } from "./subagent-registry-CbTbJKLs.js";
|
|
6
6
|
|
|
7
7
|
//#region src/cli/plugin-registry.ts
|
|
8
8
|
var plugin_registry_exports = /* @__PURE__ */ __exportAll({ ensurePluginRegistryLoaded: () => ensurePluginRegistryLoaded });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
2
|
-
import { vt as loadSymiPlugins } from "./reply-
|
|
2
|
+
import { vt as loadSymiPlugins } from "./reply-Ca3slrA3.js";
|
|
3
3
|
import { d as getActivePluginRegistry } from "./registry-Cja8eT7G.js";
|
|
4
4
|
import { t as createSubsystemLogger } from "./subsystem-D9vIQve0.js";
|
|
5
5
|
import { c as resolveAgentWorkspaceDir, l as resolveDefaultAgentId } from "./agent-scope-CgUHAtCo.js";
|