@yeaft/webchat-agent 1.0.162 → 1.0.164

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/cli.js CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  discoverOpenAICompatibleModels,
30
30
  GITHUB_COPILOT_PROVIDER,
31
31
  } from './llm-model-discovery.js';
32
+ import { applyAgentIdentityToEnv, warnDeprecatedInstanceArg } from './service/config.js';
32
33
 
33
34
  const __dirname = dirname(fileURLToPath(import.meta.url));
34
35
  const pkg = JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf-8'));
@@ -76,18 +77,18 @@ function printHelp() {
76
77
  yeaft-agent --version Show version
77
78
 
78
79
  Options:
79
- --instance <id> Local service instance id (default: default)
80
+ --instance <id> Deprecated alias for the local service instance id
80
81
  --server <url> WebSocket server URL (default: ws://localhost:3456)
81
- --name <name> Agent display name (default: Worker-{platform}-{pid})
82
+ --name <name> Agent name and instance id (letters, numbers, ._-)
82
83
  --secret <secret> Agent secret for authentication
83
84
  --work-dir <dir> Default working directory (default: cwd)
84
85
  --yeaft-dir <dir> Yeaft data directory for this instance
85
86
  --auto-upgrade Check for updates on startup
86
87
 
87
88
  Environment variables (alternative to flags):
88
- YEAFT_AGENT_INSTANCE Local service instance id
89
+ YEAFT_AGENT_INSTANCE Deprecated local service instance id override
89
90
  SERVER_URL WebSocket server URL
90
- AGENT_NAME Agent display name
91
+ AGENT_NAME Agent name and instance id fallback
91
92
  AGENT_SECRET Agent secret
92
93
  WORK_DIR Working directory
93
94
  YEAFT_DIR Yeaft data directory
@@ -95,9 +96,9 @@ function printHelp() {
95
96
  Examples:
96
97
  yeaft-agent --server wss://your-server.com --name my-worker --secret xxx
97
98
  yeaft-agent install --server wss://your-server.com --name my-worker --secret xxx
98
- yeaft-agent install --instance second --server wss://your-server.com --name my-worker-2 --secret xxx
99
- yeaft-agent status --instance second
100
- yeaft-agent logs --instance second
99
+ yeaft-agent install --server wss://your-server.com --name my-worker-2 --secret xxx
100
+ yeaft-agent status --name my-worker-2
101
+ yeaft-agent logs --name my-worker-2
101
102
  `);
102
103
  }
103
104
 
@@ -383,6 +384,7 @@ function parseLlmArgs(args) {
383
384
  }
384
385
 
385
386
  async function handleServiceCommand(command, args) {
387
+ warnDeprecatedInstanceArg(args);
386
388
  const service = await import('./service.js');
387
389
  switch (command) {
388
390
  case 'install': await service.install(args); break;
@@ -401,20 +403,23 @@ async function handleDoctorCommand() {
401
403
  }
402
404
 
403
405
  function parseAndStart(args) {
404
- // Parse CLI flags → set environment variables (env vars take precedence over flags)
406
+ warnDeprecatedInstanceArg(args);
407
+ applyAgentIdentityToEnv(args);
408
+
409
+ // Parse non-identity flags. Saved environment remains the fallback for these options.
405
410
  for (let i = 0; i < args.length; i++) {
406
411
  const arg = args[i];
407
412
  const next = args[i + 1];
408
413
 
409
414
  switch (arg) {
410
415
  case '--instance':
411
- if (next) { process.env.YEAFT_AGENT_INSTANCE = process.env.YEAFT_AGENT_INSTANCE || next; i++; }
416
+ if (next) i++;
412
417
  break;
413
418
  case '--server':
414
419
  if (next) { process.env.SERVER_URL = process.env.SERVER_URL || next; i++; }
415
420
  break;
416
421
  case '--name':
417
- if (next) { process.env.AGENT_NAME = process.env.AGENT_NAME || next; i++; }
422
+ if (next) i++;
418
423
  break;
419
424
  case '--secret':
420
425
  if (next) { process.env.AGENT_SECRET = process.env.AGENT_SECRET || next; i++; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.162",
3
+ "version": "1.0.164",
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",
package/service/config.js CHANGED
@@ -59,16 +59,45 @@ export function validateInstanceId(instanceId) {
59
59
  }
60
60
 
61
61
  export function getInstanceIdFromArgs(args = [], env = process.env) {
62
- let instanceId = env.YEAFT_AGENT_INSTANCE || '';
62
+ let instanceId = '';
63
+ let agentName = '';
63
64
  for (let i = 0; i < args.length; i++) {
64
65
  const arg = args[i];
65
66
  const next = args[i + 1];
66
67
  if (arg === '--instance' && next) {
67
68
  instanceId = next;
68
69
  i++;
70
+ } else if (arg === '--name' && next) {
71
+ agentName = next;
72
+ i++;
73
+ }
74
+ }
75
+ return validateInstanceId(
76
+ instanceId
77
+ || agentName
78
+ || env.YEAFT_AGENT_INSTANCE
79
+ || env.AGENT_NAME
80
+ || DEFAULT_INSTANCE_ID,
81
+ );
82
+ }
83
+
84
+ export function applyAgentIdentityToEnv(args = [], env = process.env) {
85
+ env.YEAFT_AGENT_INSTANCE = getInstanceIdFromArgs(args, env);
86
+
87
+ for (let i = 0; i < args.length; i++) {
88
+ if (args[i] === '--name' && args[i + 1]) {
89
+ env.AGENT_NAME = args[i + 1];
90
+ i++;
69
91
  }
70
92
  }
71
- return validateInstanceId(instanceId || DEFAULT_INSTANCE_ID);
93
+
94
+ return env.YEAFT_AGENT_INSTANCE;
95
+ }
96
+
97
+ export function warnDeprecatedInstanceArg(args = [], warn = console.warn) {
98
+ if (args.includes('--instance')) {
99
+ warn('Warning: --instance is deprecated; use --name instead. The instance id now defaults to the agent name.');
100
+ }
72
101
  }
73
102
 
74
103
  export function getServiceName(instanceId = DEFAULT_INSTANCE_ID) {
package/service/index.js CHANGED
@@ -29,6 +29,7 @@ export {
29
29
  isDefaultInstance,
30
30
  validateInstanceId,
31
31
  getInstanceIdFromArgs,
32
+ warnDeprecatedInstanceArg,
32
33
  getServiceName,
33
34
  getPm2AppName,
34
35
  getLaunchdLabel,
package/service/linux.js CHANGED
@@ -62,10 +62,10 @@ export function linuxInstall(config) {
62
62
  execSync(`systemctl --user start ${serviceName}`);
63
63
  console.log(`Service installed and started: ${serviceName}`);
64
64
  console.log(`\nManage with:`);
65
- console.log(` yeaft-agent status --instance ${config.instanceId}`);
66
- console.log(` yeaft-agent logs --instance ${config.instanceId}`);
67
- console.log(` yeaft-agent restart --instance ${config.instanceId}`);
68
- console.log(` yeaft-agent uninstall --instance ${config.instanceId}`);
65
+ console.log(` yeaft-agent status --name ${config.instanceId}`);
66
+ console.log(` yeaft-agent logs --name ${config.instanceId}`);
67
+ console.log(` yeaft-agent restart --name ${config.instanceId}`);
68
+ console.log(` yeaft-agent uninstall --name ${config.instanceId}`);
69
69
  console.log(`\nTo run when not logged in:`);
70
70
  console.log(` sudo loginctl enable-linger $(whoami)`);
71
71
  }
package/service/macos.js CHANGED
@@ -74,10 +74,10 @@ export function macInstall(config) {
74
74
  execSync(`launchctl load ${plistPath}`);
75
75
  console.log(`Service installed and started: ${getLaunchdLabel(config.instanceId)}`);
76
76
  console.log(`\nManage with:`);
77
- console.log(` yeaft-agent status --instance ${config.instanceId}`);
78
- console.log(` yeaft-agent logs --instance ${config.instanceId}`);
79
- console.log(` yeaft-agent restart --instance ${config.instanceId}`);
80
- console.log(` yeaft-agent uninstall --instance ${config.instanceId}`);
77
+ console.log(` yeaft-agent status --name ${config.instanceId}`);
78
+ console.log(` yeaft-agent logs --name ${config.instanceId}`);
79
+ console.log(` yeaft-agent restart --name ${config.instanceId}`);
80
+ console.log(` yeaft-agent uninstall --name ${config.instanceId}`);
81
81
  }
82
82
 
83
83
  export function macUninstall(instanceId = DEFAULT_INSTANCE_ID) {
@@ -123,10 +123,10 @@ export function winInstall(config) {
123
123
  console.log(` Ecosystem: ${ecoPath}`);
124
124
  console.log(` Startup: ${startupBat}`);
125
125
  console.log(`\nManage with:`);
126
- console.log(` yeaft-agent status --instance ${config.instanceId}`);
127
- console.log(` yeaft-agent logs --instance ${config.instanceId}`);
128
- console.log(` yeaft-agent restart --instance ${config.instanceId}`);
129
- console.log(` yeaft-agent uninstall --instance ${config.instanceId}`);
126
+ console.log(` yeaft-agent status --name ${config.instanceId}`);
127
+ console.log(` yeaft-agent logs --name ${config.instanceId}`);
128
+ console.log(` yeaft-agent restart --name ${config.instanceId}`);
129
+ console.log(` yeaft-agent uninstall --name ${config.instanceId}`);
130
130
  }
131
131
 
132
132
  export function winUninstall(instanceId = DEFAULT_INSTANCE_ID) {
package/service.js CHANGED
@@ -22,6 +22,7 @@ export {
22
22
  isDefaultInstance,
23
23
  validateInstanceId,
24
24
  getInstanceIdFromArgs,
25
+ warnDeprecatedInstanceArg,
25
26
  getServiceName,
26
27
  getPm2AppName,
27
28
  getLaunchdLabel,
@@ -111,26 +111,29 @@ export function selectRespondingVps(input) {
111
111
  };
112
112
  }
113
113
 
114
- // Explicit @-mentions
114
+ // Explicit @-mentions. Unknown tokens may be ordinary user text rather
115
+ // than VP routing, so ignore them. If none resolve to a roster member,
116
+ // continue to the normal default-VP fallback instead of rejecting the turn.
115
117
  if (mentions.length > 0) {
116
118
  const dispatched = [];
117
119
  const errors = [];
120
+ let hasRosterMention = false;
118
121
  for (const vpId of mentions) {
119
122
  const canonicalVpId = resolveMemberId(meta, vpId);
120
- if (!canonicalVpId) {
121
- errors.push({ vpId, error: 'not_in_roster' });
122
- continue;
123
- }
123
+ if (!canonicalVpId) continue;
124
+ hasRosterMention = true;
124
125
  if (taskMembers && !taskMembers.includes(canonicalVpId)) {
125
126
  errors.push({ vpId, error: 'not_in_task_members' });
126
127
  continue;
127
128
  }
128
129
  if (!dispatched.includes(canonicalVpId)) dispatched.push(canonicalVpId);
129
130
  }
130
- return { dispatched, fallback: null, errors, reason: 'mention' };
131
+ if (hasRosterMention) {
132
+ return { dispatched, fallback: null, errors, reason: 'mention' };
133
+ }
131
134
  }
132
135
 
133
- // No @-mention → fallback to defaultVpId (architecture G2)
136
+ // No valid @-mention → fallback to defaultVpId (architecture G2)
134
137
  const fallback = resolveFallbackVp(meta);
135
138
  if (!fallback) {
136
139
  return {