@yeaft/webchat-agent 1.0.415 → 1.0.417

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.415",
3
+ "version": "1.0.417",
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",
@@ -1,25 +1,44 @@
1
1
  import { cpSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
2
- import { dirname, join } from 'path';
2
+ import { dirname, join, resolve } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
 
5
- const agentDir = join(dirname(fileURLToPath(import.meta.url)), '..');
6
- const rootDir = join(agentDir, '..');
7
- const runtimeDir = join(agentDir, 'local-runtime');
5
+ const scriptPath = fileURLToPath(import.meta.url);
6
+ const defaultAgentDir = join(dirname(scriptPath), '..');
8
7
 
9
- rmSync(runtimeDir, { recursive: true, force: true });
10
- mkdirSync(runtimeDir, { recursive: true });
11
- const excludedServerPaths = new Set([
12
- join(rootDir, 'server', 'node_modules'),
13
- join(rootDir, 'server', 'data'),
14
- join(rootDir, 'server', '.env'),
15
- join(rootDir, 'server', 'user.json'),
16
- join(rootDir, 'server', 'users.json'),
17
- ]);
18
- cpSync(join(rootDir, 'server'), join(runtimeDir, 'server'), {
19
- recursive: true,
20
- filter: source => !excludedServerPaths.has(source),
21
- });
22
- cpSync(join(rootDir, 'web', 'dist'), join(runtimeDir, 'web'), { recursive: true });
8
+ /**
9
+ * Build the Server and Web payload embedded in the published Agent package.
10
+ * Server imports that cross into agent/ must be copied explicitly so the
11
+ * packaged local runtime has the same module boundary as the source tree.
12
+ */
13
+ export function prepareLocalRuntime({
14
+ agentDir = defaultAgentDir,
15
+ rootDir = join(agentDir, '..'),
16
+ runtimeDir = join(agentDir, 'local-runtime'),
17
+ } = {}) {
18
+ rmSync(runtimeDir, { recursive: true, force: true });
19
+ mkdirSync(runtimeDir, { recursive: true });
20
+ const excludedServerPaths = new Set([
21
+ join(rootDir, 'server', 'node_modules'),
22
+ join(rootDir, 'server', 'data'),
23
+ join(rootDir, 'server', '.env'),
24
+ join(rootDir, 'server', 'user.json'),
25
+ join(rootDir, 'server', 'users.json'),
26
+ ]);
27
+ cpSync(join(rootDir, 'server'), join(runtimeDir, 'server'), {
28
+ recursive: true,
29
+ filter: source => !excludedServerPaths.has(source),
30
+ });
31
+ cpSync(join(rootDir, 'web', 'dist'), join(runtimeDir, 'web'), { recursive: true });
23
32
 
24
- const { version } = JSON.parse(readFileSync(join(agentDir, 'package.json'), 'utf8'));
25
- writeFileSync(join(runtimeDir, 'version.json'), `${JSON.stringify({ version })}\n`);
33
+ const runtimeAgentDir = join(runtimeDir, 'agent');
34
+ mkdirSync(runtimeAgentDir, { recursive: true });
35
+ cpSync(join(agentDir, 'container-manager.js'), join(runtimeAgentDir, 'container-manager.js'));
36
+
37
+ const { version } = JSON.parse(readFileSync(join(agentDir, 'package.json'), 'utf8'));
38
+ writeFileSync(join(runtimeDir, 'version.json'), `${JSON.stringify({ version })}\n`);
39
+ return runtimeDir;
40
+ }
41
+
42
+ if (process.argv[1] && resolve(process.argv[1]) === resolve(scriptPath)) {
43
+ prepareLocalRuntime();
44
+ }