@yeaft/webchat-agent 0.1.1009 → 0.1.1011
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/package.json +1 -1
- package/yeaft/config.js +21 -0
- package/yeaft/status-cache.js +1 -1
- package/yeaft/web-bridge.js +27 -5
package/package.json
CHANGED
package/yeaft/config.js
CHANGED
|
@@ -413,6 +413,27 @@ export function loadConfig(overrides = {}) {
|
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
// Agent-level primaryModel is optional. When absent, use the first provider
|
|
417
|
+
// model as the effective runtime/UI default without writing it back to
|
|
418
|
+
// ~/.yeaft/config.json. New Sessions may copy this value into their own
|
|
419
|
+
// config, but global config remains only a fallback source.
|
|
420
|
+
if (!primaryModel && !overrides.model && config.availableModels.length > 0) {
|
|
421
|
+
const first = config.availableModels[0];
|
|
422
|
+
const firstRef = first.ref || (first.provider && first.id ? `${first.provider}/${first.id}` : first.id);
|
|
423
|
+
if (firstRef) {
|
|
424
|
+
const parsed = parseModelRef(firstRef);
|
|
425
|
+
const fallbackModelInfo = resolveModel(parsed.modelId) || null;
|
|
426
|
+
config.model = firstRef;
|
|
427
|
+
config.modelInfo = fallbackModelInfo;
|
|
428
|
+
if (overrides.maxContextTokens === undefined && jsonConfig.maxContextTokens === undefined) {
|
|
429
|
+
config.maxContextTokens = resolveContextWindow(parsed.modelId, { modelInfo: fallbackModelInfo });
|
|
430
|
+
}
|
|
431
|
+
if (overrides.maxOutputTokens === undefined && jsonConfig.maxOutputTokens === undefined) {
|
|
432
|
+
config.maxOutputTokens = resolveMaxOutputTokens(parsed.modelId, { modelInfo: fallbackModelInfo });
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
416
437
|
return config;
|
|
417
438
|
}
|
|
418
439
|
|
package/yeaft/status-cache.js
CHANGED
|
@@ -79,7 +79,7 @@ export function createYeaftStatusCache(options = {}) {
|
|
|
79
79
|
const previous = snapshot || {};
|
|
80
80
|
snapshot = {
|
|
81
81
|
...previous,
|
|
82
|
-
model: config.
|
|
82
|
+
model: config.primaryModel || config.model || previous.model || null,
|
|
83
83
|
availableModels: normalizeAvailableModels(config.availableModels),
|
|
84
84
|
yeaftDir: config.dir || yeaftDir || previous.yeaftDir || null,
|
|
85
85
|
skills: sessionStatus?.skills ?? previous.skills,
|
package/yeaft/web-bridge.js
CHANGED
|
@@ -80,8 +80,8 @@ function refreshLiveSessionConfig() {
|
|
|
80
80
|
const freshConfig = loadConfig({ dir: session.yeaftDir || ctx.CONFIG?.yeaftDir });
|
|
81
81
|
const freshModels = Array.isArray(freshConfig.availableModels) ? freshConfig.availableModels : [];
|
|
82
82
|
session.config.availableModels = freshModels;
|
|
83
|
-
if (freshConfig.model && !freshModels.some(m => m
|
|
84
|
-
session.config.model = freshConfig.model;
|
|
83
|
+
if (freshConfig.model && !freshModels.some(m => modelRefMatchesAvailable(m, session.config.model))) {
|
|
84
|
+
session.config.model = freshConfig.primaryModel || freshConfig.model;
|
|
85
85
|
}
|
|
86
86
|
if (freshConfig.providers) {
|
|
87
87
|
session.config.providers = freshConfig.providers;
|
|
@@ -94,6 +94,27 @@ function refreshLiveSessionConfig() {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
function defaultSessionModelConfig(baseConfig) {
|
|
98
|
+
const config = baseConfig || session?.config || {};
|
|
99
|
+
const out = {};
|
|
100
|
+
const model = typeof config.primaryModel === 'string' && config.primaryModel.trim()
|
|
101
|
+
? config.primaryModel.trim()
|
|
102
|
+
: (typeof config.model === 'string' && config.model.trim() ? config.model.trim() : '');
|
|
103
|
+
if (model) out.model = model;
|
|
104
|
+
if (typeof config.modelEffort === 'string' && config.modelEffort.trim()) {
|
|
105
|
+
out.modelEffort = config.modelEffort.trim();
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function withDefaultSessionConfig(payload) {
|
|
111
|
+
const next = payload && typeof payload === 'object' ? { ...payload } : {};
|
|
112
|
+
const existing = next.config && typeof next.config === 'object' ? next.config : {};
|
|
113
|
+
const seeded = { ...defaultSessionModelConfig(), ...existing };
|
|
114
|
+
if (Object.keys(seeded).length > 0) next.config = seeded;
|
|
115
|
+
return next;
|
|
116
|
+
}
|
|
117
|
+
|
|
97
118
|
/** Test-only: replace the lightweight VP thread classifier. */
|
|
98
119
|
export function __testSetThreadClassifier(fn) {
|
|
99
120
|
threadClassifier = typeof fn === 'function' ? fn : defaultClassifyThread;
|
|
@@ -1604,7 +1625,8 @@ export function handleYeaftCreateSession(msg) {
|
|
|
1604
1625
|
const payload = (msg && msg.payload) || {};
|
|
1605
1626
|
try {
|
|
1606
1627
|
const yeaftDir = ctx.CONFIG?.yeaftDir;
|
|
1607
|
-
const group = createSessionFromSpec(yeaftDir, payload);
|
|
1628
|
+
const group = createSessionFromSpec(yeaftDir, withDefaultSessionConfig(payload));
|
|
1629
|
+
group.config = loadSessionConfig(yeaftDir, group.id);
|
|
1608
1630
|
sendSessionCrudResult({ op: 'create', requestId, ok: true, session: group });
|
|
1609
1631
|
sendSessionSnapshotBroadcast();
|
|
1610
1632
|
} catch (err) {
|
|
@@ -2834,7 +2856,7 @@ async function ensureSessionLoaded() {
|
|
|
2834
2856
|
sendSessionEvent({
|
|
2835
2857
|
type: 'session_ready',
|
|
2836
2858
|
conversationId: yeaftConversationId,
|
|
2837
|
-
model: session.config.model,
|
|
2859
|
+
model: session.config.primaryModel || session.config.model,
|
|
2838
2860
|
modelEffort: session.config.modelEffort || null,
|
|
2839
2861
|
availableModels: session.config.availableModels || [],
|
|
2840
2862
|
skills: session.status.skills,
|
|
@@ -4051,7 +4073,7 @@ export async function handleYeaftLoadHistory(msg) {
|
|
|
4051
4073
|
sendSessionEvent({
|
|
4052
4074
|
type: 'session_ready',
|
|
4053
4075
|
conversationId: yeaftConversationId,
|
|
4054
|
-
model: session.config.model,
|
|
4076
|
+
model: session.config.primaryModel || session.config.model,
|
|
4055
4077
|
modelEffort: session.config.modelEffort || null,
|
|
4056
4078
|
availableModels: session.config.availableModels || [],
|
|
4057
4079
|
skills: session.status.skills,
|