@yeaft/webchat-agent 1.0.413 → 1.0.414
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/browser-runtime/browser-install.js +497 -0
- package/browser-runtime/cli.js +88 -0
- package/browser-runtime/config.js +116 -0
- package/browser-runtime/errors.js +8 -0
- package/browser-runtime/extension/manifest.json +18 -0
- package/browser-runtime/extension/offscreen.html +5 -0
- package/browser-runtime/extension/offscreen.js +101 -0
- package/browser-runtime/extension/popup.html +5 -0
- package/browser-runtime/extension/popup.js +1 -0
- package/browser-runtime/extension/service-worker.js +48 -0
- package/browser-runtime/extension.js +45 -0
- package/browser-runtime/index.js +5 -0
- package/browser-runtime/probe.js +427 -0
- package/browser-runtime/protocol.js +71 -0
- package/browser-runtime/service.js +132 -0
- package/browser-runtime/windows-version-job.ps1 +233 -0
- package/browser-runtime/windows-version-worker.js +75 -0
- package/browser-runtime/windows-version.js +85 -0
- package/cli.js +24 -7
- package/context.js +1 -0
- package/index.js +18 -1
- package/llm-config-cli.js +24 -21
- package/local-runtime/version.json +1 -1
- package/package.json +5 -1
- package/service/config.js +23 -2
- package/service/index.js +1 -0
- package/service/linux.js +3 -2
- package/yeaft/config-api.js +138 -192
- package/yeaft/config-store.js +192 -0
- package/yeaft/config.js +3 -0
- package/yeaft/init.js +20 -7
- package/yeaft/sessions/feature-flag.js +15 -33
- package/yeaft/storage/atomic.js +43 -17
- package/yeaft/tools/process-runner.js +86 -13
package/cli.js
CHANGED
|
@@ -61,6 +61,14 @@ const SERVICE_COMMANDS = ['install', 'uninstall', 'start', 'stop', 'restart', 's
|
|
|
61
61
|
|
|
62
62
|
if (command === 'doctor') {
|
|
63
63
|
await handleDoctorCommand(subArgs);
|
|
64
|
+
} else if (command === 'browser') {
|
|
65
|
+
try {
|
|
66
|
+
const { handleBrowserCommand } = await import('./browser-runtime/cli.js');
|
|
67
|
+
await handleBrowserCommand(subArgs);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(`Browser Runtime command failed: ${error.code || error.message}`);
|
|
70
|
+
process.exitCode = 1;
|
|
71
|
+
}
|
|
64
72
|
} else if (command === 'llm') {
|
|
65
73
|
await handleLlmCommand(subArgs);
|
|
66
74
|
} else if (command === 'local') {
|
|
@@ -137,6 +145,10 @@ function printHelp() {
|
|
|
137
145
|
yeaft-agent status [options] Show service status
|
|
138
146
|
yeaft-agent logs [options] View service logs (follow mode)
|
|
139
147
|
yeaft-agent doctor Diagnose service configuration
|
|
148
|
+
yeaft-agent browser install Install the pinned Chrome for Testing build
|
|
149
|
+
yeaft-agent browser probe Validate tabCapture → offscreen → WebRTC
|
|
150
|
+
yeaft-agent browser enable|disable Change the Browser Runtime feature flag
|
|
151
|
+
yeaft-agent browser status Show config and managed browser install status
|
|
140
152
|
yeaft-agent llm <command> Configure local Yeaft LLM providers/models
|
|
141
153
|
yeaft-agent container <command> Manage a Dockerized yeaft-agent
|
|
142
154
|
yeaft-agent upgrade [--name <id>] Upgrade and restart the selected service
|
|
@@ -153,6 +165,11 @@ function printHelp() {
|
|
|
153
165
|
--yeaft-dir <dir> Yeaft data directory for this instance
|
|
154
166
|
--auto-upgrade Check for updates on startup
|
|
155
167
|
|
|
168
|
+
Browser options:
|
|
169
|
+
--executable <path> Explicit compatible Chrome for Testing executable
|
|
170
|
+
--headful Run the Browser Runtime probe with a visible browser
|
|
171
|
+
--name <id> Select the named Agent instance
|
|
172
|
+
|
|
156
173
|
Environment variables (alternative to flags):
|
|
157
174
|
YEAFT_AGENT_INSTANCE Deprecated local service instance id override
|
|
158
175
|
SERVER_URL WebSocket server URL
|
|
@@ -174,7 +191,7 @@ function printHelp() {
|
|
|
174
191
|
`);
|
|
175
192
|
}
|
|
176
193
|
|
|
177
|
-
function printLlmHelp() {
|
|
194
|
+
export function printLlmHelp() {
|
|
178
195
|
console.log(`
|
|
179
196
|
Configure local Yeaft LLM providers/models in ~/.yeaft/config.json.
|
|
180
197
|
|
|
@@ -257,7 +274,7 @@ async function handleLlmCommand(args) {
|
|
|
257
274
|
const preset = args[1];
|
|
258
275
|
if (preset === 'github-copilot') {
|
|
259
276
|
result = await useGitHubCopilot(current, options);
|
|
260
|
-
writeLocalLlmConfig(result.config, configPath);
|
|
277
|
+
writeLocalLlmConfig(result.config, configPath, current);
|
|
261
278
|
console.log(`Configured GitHub Copilot provider with ${result.discovery.models.length} ${result.discovery.source} models.`);
|
|
262
279
|
if (result.discovery.warning) console.log(`Warning: ${result.discovery.warning}`);
|
|
263
280
|
console.log(`Primary model: ${result.config.primaryModel}`);
|
|
@@ -266,7 +283,7 @@ async function handleLlmCommand(args) {
|
|
|
266
283
|
}
|
|
267
284
|
if (preset === 'openai-compatible') {
|
|
268
285
|
result = await useOpenAICompatible(current, options, process.env);
|
|
269
|
-
writeLocalLlmConfig(result.config, configPath);
|
|
286
|
+
writeLocalLlmConfig(result.config, configPath, current);
|
|
270
287
|
console.log(`Configured ${result.provider.name} with ${result.discovery.models.length} live models.`);
|
|
271
288
|
console.log(`Primary model: ${result.config.primaryModel}`);
|
|
272
289
|
if (result.config.fastModel) console.log(`Fast model: ${result.config.fastModel}`);
|
|
@@ -277,7 +294,7 @@ async function handleLlmCommand(args) {
|
|
|
277
294
|
|
|
278
295
|
if (subcommand === 'add-provider') {
|
|
279
296
|
result = addOrUpdateProvider(current, options, process.env);
|
|
280
|
-
writeLocalLlmConfig(result.config, configPath);
|
|
297
|
+
writeLocalLlmConfig(result.config, configPath, current);
|
|
281
298
|
console.log(`${result.replaced ? 'Updated' : 'Added'} provider: ${result.provider.name}`);
|
|
282
299
|
if (result.config.primaryModel) console.log(`Primary model: ${result.config.primaryModel}`);
|
|
283
300
|
if (result.config.fastModel) console.log(`Fast model: ${result.config.fastModel}`);
|
|
@@ -286,7 +303,7 @@ async function handleLlmCommand(args) {
|
|
|
286
303
|
|
|
287
304
|
if (subcommand === 'set-model') {
|
|
288
305
|
result = setLocalModels(current, options);
|
|
289
|
-
writeLocalLlmConfig(result.config, configPath);
|
|
306
|
+
writeLocalLlmConfig(result.config, configPath, current);
|
|
290
307
|
if (result.config.primaryModel) console.log(`Primary model: ${result.config.primaryModel}`);
|
|
291
308
|
if (result.config.fastModel) console.log(`Fast model: ${result.config.fastModel}`);
|
|
292
309
|
return;
|
|
@@ -294,7 +311,7 @@ async function handleLlmCommand(args) {
|
|
|
294
311
|
|
|
295
312
|
if (subcommand === 'remove-provider') {
|
|
296
313
|
result = removeProvider(current, options);
|
|
297
|
-
writeLocalLlmConfig(result.config, configPath);
|
|
314
|
+
writeLocalLlmConfig(result.config, configPath, current);
|
|
298
315
|
console.log(result.removed ? `Removed provider: ${options.name}` : `Provider not found: ${options.name}`);
|
|
299
316
|
if (result.cleared.length) {
|
|
300
317
|
console.log(`Cleared ${result.cleared.join(', ')} because it referenced ${options.name}`);
|
|
@@ -426,7 +443,7 @@ async function runLlmSetup(current, configPath) {
|
|
|
426
443
|
const fastAnswer = (await rl.question('Fast model number or id (optional): ')).trim();
|
|
427
444
|
const fast = fastAnswer ? (ids[Number(fastAnswer) - 1] || fastAnswer) : null;
|
|
428
445
|
const result = await useGitHubCopilot(current, { model: primary, fast, allowUnknownModel: false });
|
|
429
|
-
writeLocalLlmConfig(result.config, configPath);
|
|
446
|
+
writeLocalLlmConfig(result.config, configPath, current);
|
|
430
447
|
console.log(`Configured GitHub Copilot with ${result.discovery.models.length} ${result.discovery.source} models.`);
|
|
431
448
|
if (result.discovery.warning) console.log(`Warning: ${result.discovery.warning}`);
|
|
432
449
|
console.log(`Primary model: ${result.config.primaryModel}`);
|
package/context.js
CHANGED
|
@@ -20,6 +20,7 @@ export default {
|
|
|
20
20
|
CONFIG: null,
|
|
21
21
|
managedCliReady: Promise.resolve([]),
|
|
22
22
|
agentCapabilities: [],
|
|
23
|
+
browserRuntime: null,
|
|
23
24
|
// Agent 级别的 slash commands 缓存(所有 conversation 共用)
|
|
24
25
|
slashCommands: [],
|
|
25
26
|
// Slash command 描述映射: { commandName: description } — 从 plugin commands/*.md 提取
|
package/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { connect } from './connection.js';
|
|
|
23
23
|
import { loadMcpServers } from './mcp.js';
|
|
24
24
|
import { SAFE_REMOTE_UPGRADE_CAPABILITY } from './upgrade-command.js';
|
|
25
25
|
import { loadConfig as loadYeaftConfig } from './yeaft/config.js';
|
|
26
|
+
import { bootBrowserRuntime, shutdownBrowserRuntime } from './browser-runtime/index.js';
|
|
26
27
|
import {
|
|
27
28
|
ensureManagedCliTools,
|
|
28
29
|
prepareManagedCliToolEnvironment,
|
|
@@ -104,7 +105,7 @@ const { agentName: AGENT_NAME, instanceId: INSTANCE_ID } = resolveRuntimeIdentit
|
|
|
104
105
|
const YEAFT_DIR = process.env.YEAFT_DIR || fileConfig.yeaftDir || getDefaultYeaftDir(INSTANCE_ID);
|
|
105
106
|
try {
|
|
106
107
|
if (!existsSync(YEAFT_DIR)) {
|
|
107
|
-
mkdirSync(YEAFT_DIR, { recursive: true });
|
|
108
|
+
mkdirSync(YEAFT_DIR, { recursive: true, mode: 0o700 });
|
|
108
109
|
console.log(`[Agent] Created yeaft dir: ${YEAFT_DIR}`);
|
|
109
110
|
}
|
|
110
111
|
} catch (err) {
|
|
@@ -356,6 +357,7 @@ function cleanup() {
|
|
|
356
357
|
const { shutdownWorkCenter } = await import('./yeaft/work-center/bridge.js');
|
|
357
358
|
await shutdownWorkCenter();
|
|
358
359
|
} catch {}
|
|
360
|
+
try { await shutdownBrowserRuntime(); } catch {}
|
|
359
361
|
if (ctx.ws) ctx.ws.close();
|
|
360
362
|
});
|
|
361
363
|
}
|
|
@@ -396,6 +398,21 @@ process.on('SIGTERM', async () => {
|
|
|
396
398
|
} catch (error) {
|
|
397
399
|
console.warn(`[Startup] managed rg environment setup failed; using built-in fallback: ${error?.message || error}`);
|
|
398
400
|
}
|
|
401
|
+
try {
|
|
402
|
+
const runtimeConfig = loadYeaftConfig({ dir: YEAFT_DIR }).browserRuntime;
|
|
403
|
+
ctx.browserRuntime = await bootBrowserRuntime({
|
|
404
|
+
yeaftDir: YEAFT_DIR,
|
|
405
|
+
config: runtimeConfig,
|
|
406
|
+
});
|
|
407
|
+
const probe = ctx.browserRuntime.snapshot().probe;
|
|
408
|
+
if (probe?.ok) {
|
|
409
|
+
console.log(`[BrowserRuntime] ready: capture=${probe.captureMode} build=${probe.actualBuildId || probe.expectedBuildId}`);
|
|
410
|
+
} else if (runtimeConfig?.enabled) {
|
|
411
|
+
console.warn(`[BrowserRuntime] unavailable: ${probe?.code || 'probe_failed'}`);
|
|
412
|
+
}
|
|
413
|
+
} catch (err) {
|
|
414
|
+
console.warn(`[BrowserRuntime] startup probe failed: ${err?.message || err}`);
|
|
415
|
+
}
|
|
399
416
|
ctx.agentCapabilities = await detectCapabilities();
|
|
400
417
|
// Prime the models.dev community catalog so the Yeaft engine's *synchronous*
|
|
401
418
|
// hot path (engine.js / config.js / cli.js all read context-window inline)
|
package/llm-config-cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { existsSync, readFileSync
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
3
|
import { homedir } from 'os';
|
|
4
4
|
import { normalizePluginConfig } from './yeaft/plugins.js';
|
|
5
|
+
import { mutateAgentConfigPath } from './yeaft/config-store.js';
|
|
5
6
|
import {
|
|
6
7
|
discoverGitHubCopilotModels,
|
|
7
8
|
discoverOpenAICompatibleModels,
|
|
@@ -40,31 +41,33 @@ export function readLocalLlmConfig(configPath = getDefaultYeaftConfigPath()) {
|
|
|
40
41
|
return parsed;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
export function writeLocalLlmConfig(config, configPath = getDefaultYeaftConfigPath()) {
|
|
44
|
-
// The CLI exposes this writer publicly, so do not rely on callers having
|
|
45
|
-
// already used readLocalLlmConfig(). An existing invalid Plugins policy must
|
|
46
|
-
// remain on disk and keep runtime fail-closed until the user repairs it.
|
|
47
|
-
const existing = existsSync(configPath) ? readLocalLlmConfig(configPath) : null;
|
|
44
|
+
export function writeLocalLlmConfig(config, configPath = getDefaultYeaftConfigPath(), baseConfig = null) {
|
|
48
45
|
if (!config || typeof config !== 'object' || Array.isArray(config)
|
|
49
46
|
|| Object.getPrototypeOf(config) !== Object.prototype) {
|
|
50
47
|
throw new Error(`Invalid config file: expected JSON object at ${configPath}`);
|
|
51
48
|
}
|
|
52
|
-
|
|
53
|
-
if (next.plugins === undefined
|
|
54
|
-
&& Object.prototype.hasOwnProperty.call(existing || {}, 'plugins')) {
|
|
55
|
-
// LLM commands change provider/model fields. They must not remove a
|
|
56
|
-
// separately-managed Plugin allowlist merely because their payload omits it.
|
|
57
|
-
next.plugins = existing.plugins;
|
|
58
|
-
}
|
|
59
|
-
if (next.plugins !== undefined) {
|
|
49
|
+
if (config.plugins !== undefined) {
|
|
60
50
|
try {
|
|
61
|
-
normalizePluginConfig(
|
|
62
|
-
} catch (
|
|
63
|
-
throw new Error(`Invalid config file: ${
|
|
51
|
+
normalizePluginConfig(config.plugins);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
throw new Error(`Invalid config file: ${error?.message || error}`);
|
|
64
54
|
}
|
|
65
55
|
}
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
|
|
57
|
+
mutateAgentConfigPath(configPath, current => {
|
|
58
|
+
const baseline = baseConfig && typeof baseConfig === 'object' && !Array.isArray(baseConfig)
|
|
59
|
+
? baseConfig
|
|
60
|
+
: {};
|
|
61
|
+
const keys = new Set([...Object.keys(baseline), ...Object.keys(config)]);
|
|
62
|
+
for (const key of keys) {
|
|
63
|
+
if (key === 'plugins' && !Object.prototype.hasOwnProperty.call(config, key)) continue;
|
|
64
|
+
const before = baseline[key];
|
|
65
|
+
const after = config[key];
|
|
66
|
+
if (JSON.stringify(before) === JSON.stringify(after)) continue;
|
|
67
|
+
if (Object.prototype.hasOwnProperty.call(config, key)) current[key] = after;
|
|
68
|
+
else delete current[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
export function parseModelsCsv(value) {
|
|
@@ -313,7 +316,7 @@ export async function tryAutoConfigureGitHubCopilot(configPath = getDefaultYeaft
|
|
|
313
316
|
...options,
|
|
314
317
|
model: options.model || DEFAULT_GITHUB_COPILOT_MODEL,
|
|
315
318
|
});
|
|
316
|
-
writeLocalLlmConfig(result.config, configPath);
|
|
319
|
+
writeLocalLlmConfig(result.config, configPath, current);
|
|
317
320
|
return { configured: true, reason: 'configured', ...result };
|
|
318
321
|
} catch (error) {
|
|
319
322
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.
|
|
1
|
+
{"version":"1.0.414"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yeaft/webchat-agent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.414",
|
|
4
4
|
"description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"docker-entrypoint.sh",
|
|
42
42
|
"yeaft/templates/**/*.md",
|
|
43
43
|
"yeaft/dream/prompts/**/*.md",
|
|
44
|
+
"browser-runtime/extension/**/*",
|
|
45
|
+
"browser-runtime/*.ps1",
|
|
44
46
|
"local-runtime/**/*"
|
|
45
47
|
],
|
|
46
48
|
"license": "MIT",
|
|
@@ -62,6 +64,7 @@
|
|
|
62
64
|
},
|
|
63
65
|
"dependencies": {
|
|
64
66
|
"@homebridge/node-pty-prebuilt-multiarch": "^0.13.1",
|
|
67
|
+
"@puppeteer/browsers": "2.13.0",
|
|
65
68
|
"bcrypt": "^6.0.0",
|
|
66
69
|
"compression": "^1.8.1",
|
|
67
70
|
"dotenv": "^16.3.1",
|
|
@@ -69,6 +72,7 @@
|
|
|
69
72
|
"jsonwebtoken": "^9.0.2",
|
|
70
73
|
"multer": "^2.2.0",
|
|
71
74
|
"nodemailer": "^9.0.3",
|
|
75
|
+
"puppeteer-core": "24.41.0",
|
|
72
76
|
"qrcode": "^1.5.4",
|
|
73
77
|
"speakeasy": "^2.0.0",
|
|
74
78
|
"tweetnacl": "^1.0.3",
|
package/service/config.js
CHANGED
|
@@ -113,7 +113,7 @@ export function resolveServiceInstanceId(args = [], env = process.env, options =
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/** Resolve the CLI/env/default Yeaft data root for one Agent instance. */
|
|
116
|
-
|
|
116
|
+
function explicitYeaftDirFromArgs(args = []) {
|
|
117
117
|
let explicitYeaftDir = null;
|
|
118
118
|
for (let index = 0; index < args.length; index += 1) {
|
|
119
119
|
if (args[index] !== '--yeaft-dir') continue;
|
|
@@ -122,7 +122,28 @@ export function resolveYeaftDir(args = [], env = process.env, instanceId = DEFAU
|
|
|
122
122
|
explicitYeaftDir = value;
|
|
123
123
|
index += 1;
|
|
124
124
|
}
|
|
125
|
-
return explicitYeaftDir
|
|
125
|
+
return explicitYeaftDir;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function resolveYeaftDir(args = [], env = process.env, instanceId = DEFAULT_INSTANCE_ID) {
|
|
129
|
+
return explicitYeaftDirFromArgs(args) || env.YEAFT_DIR || getDefaultYeaftDir(instanceId);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Resolve the persisted data root for an explicitly selected management target. */
|
|
133
|
+
export function resolveManagedYeaftDir(
|
|
134
|
+
args = [],
|
|
135
|
+
env = process.env,
|
|
136
|
+
instanceId = DEFAULT_INSTANCE_ID,
|
|
137
|
+
dependencies = {},
|
|
138
|
+
) {
|
|
139
|
+
const explicitYeaftDir = explicitYeaftDirFromArgs(args);
|
|
140
|
+
if (explicitYeaftDir) return explicitYeaftDir;
|
|
141
|
+
const hasExplicitIdentity = args.includes('--name') || args.includes('--instance');
|
|
142
|
+
if (!hasExplicitIdentity && env.YEAFT_DIR) return env.YEAFT_DIR;
|
|
143
|
+
const readServiceConfig = dependencies.loadServiceConfig || loadServiceConfig;
|
|
144
|
+
const defaultYeaftDir = dependencies.getDefaultYeaftDir || getDefaultYeaftDir;
|
|
145
|
+
const persisted = readServiceConfig(instanceId)?.yeaftDir;
|
|
146
|
+
return persisted || defaultYeaftDir(instanceId);
|
|
126
147
|
}
|
|
127
148
|
|
|
128
149
|
/** Legacy alias for resolveServiceInstanceId(). */
|
package/service/index.js
CHANGED
package/service/linux.js
CHANGED
|
@@ -12,7 +12,7 @@ export function getSystemdServicePath(instanceId = DEFAULT_INSTANCE_ID) {
|
|
|
12
12
|
return join(homedir(), '.config', 'systemd', 'user', `${getServiceName(instanceId)}.service`);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function generateSystemdUnit(config) {
|
|
15
|
+
export function generateSystemdUnit(config) {
|
|
16
16
|
const nodePath = getNodePath();
|
|
17
17
|
const cliPath = getCliPath();
|
|
18
18
|
const logDir = getLogDir(config.instanceId);
|
|
@@ -38,7 +38,8 @@ ExecStart=${nodePath} ${cliPath}
|
|
|
38
38
|
WorkingDirectory=${config.workDir || homedir()}
|
|
39
39
|
Restart=on-failure
|
|
40
40
|
RestartSec=10
|
|
41
|
-
KillMode=
|
|
41
|
+
KillMode=mixed
|
|
42
|
+
TimeoutStopSec=15
|
|
42
43
|
${envLines.join('\n')}
|
|
43
44
|
Environment=PATH=${nodeBinDir}:${homedir()}/.local/bin:${homedir()}/.npm-global/bin:/usr/local/bin:/usr/bin:/bin
|
|
44
45
|
|