@miruzero/zero-agent 0.3.3 → 0.3.4

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": "@miruzero/zero-agent",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "MiruZero local worker agent for multi-device tool execution.",
5
5
  "type": "commonjs",
6
6
  "bin": {
package/src/autostart.js CHANGED
@@ -35,10 +35,12 @@ const paths = (env = process.env) => {
35
35
  };
36
36
 
37
37
  const packageSpec = () => pkg.name + '@' + pkg.version;
38
+ const packageBin = () => path.join(__dirname, '..', 'bin', 'zero-agent.js');
38
39
 
39
40
  const launcherContent = ({ interval = DEFAULT_INTERVAL, roots, logFile }, env = process.env) => {
40
41
  const home = config.agentHome(env);
41
42
  const spec = packageSpec();
43
+ const bin = packageBin();
42
44
  return [
43
45
  '@echo off',
44
46
  'setlocal',
@@ -49,7 +51,7 @@ const launcherContent = ({ interval = DEFAULT_INTERVAL, roots, logFile }, env =
49
51
  'rem interval=' + Number(interval || DEFAULT_INTERVAL) + 'ms',
50
52
  'if not exist ' + q(winPath(path.dirname(logFile))) + ' mkdir ' + q(winPath(path.dirname(logFile))),
51
53
  'echo [%date% %time%] starting ' + spec + ' >> ' + q(winPath(logFile)),
52
- 'npx -y ' + spec + ' start --interval %ZERO_AGENT_INTERVAL% >> ' + q(winPath(logFile)) + ' 2>&1',
54
+ 'node ' + q(winPath(bin)) + ' start --interval %ZERO_AGENT_INTERVAL% >> ' + q(winPath(logFile)) + ' 2>&1',
53
55
  ''
54
56
  ].join('\r\n');
55
57
  };
@@ -101,6 +101,20 @@ const readFile = (args, env) => {
101
101
  return { ok: true, path: file, totalLines: lines.length, offset: start, length: slice.length, content: numbered(slice, start) };
102
102
  };
103
103
 
104
+ const readFiles = (args = {}, env) => {
105
+ const requests = Array.isArray(args.files) && args.files.length
106
+ ? args.files.map((item) => ({ path: item.path, offset: item.offset, length: item.length }))
107
+ : (Array.isArray(args.paths) ? args.paths : []).map((inputPath) => ({ path: inputPath, offset: args.offset, length: args.length }));
108
+ if (!requests.length) throw err('INVALID_PATHS', 'paths or files must contain at least one file');
109
+ if (requests.length > 50) throw err('TOO_MANY_PATHS', 'readFiles supports up to 50 files');
110
+ const files = requests.map((request) => {
111
+ try { return readFile(request, env); }
112
+ catch (error) { return { ok: false, path: String(request.path), error: { code: error.code || 'READ_FAILED', message: error.message || String(error) } }; }
113
+ });
114
+ const succeeded = files.filter((item) => item.ok).length;
115
+ return { ok: succeeded === files.length, count: files.length, succeeded, failed: files.length - succeeded, files };
116
+ };
117
+
104
118
  const globFiles = (args, env) => {
105
119
  const root = resolveAllowed(args.path, env);
106
120
  const rx = wildcard(args.pattern || '*');
@@ -133,13 +147,14 @@ const grepFiles = (args, env) => {
133
147
  return { ok: true, path: root, pattern: args.pattern, matches };
134
148
  };
135
149
 
136
- const handlers = { listDirectory, getFileInfo, readFile, globFiles, grepFiles };
150
+ const handlers = { listDirectory, getFileInfo, readFile, readFiles, globFiles, grepFiles };
137
151
 
138
152
  const schemaObject = (properties, required = []) => ({ type: 'object', properties, required });
139
153
  const toolSchemas = [
140
154
  { name: 'listDirectory', description: 'List files and folders inside ZERO_AGENT_ROOTS.', inputSchema: schemaObject({ path: { type: 'string' }, depth: { type: 'number' } }, ['path']) },
141
155
  { name: 'getFileInfo', description: 'Get metadata for a file or directory inside ZERO_AGENT_ROOTS.', inputSchema: schemaObject({ path: { type: 'string' } }, ['path']) },
142
156
  { name: 'readFile', description: 'Read a UTF-8 text file inside ZERO_AGENT_ROOTS with line pagination.', inputSchema: schemaObject({ path: { type: 'string' }, offset: { type: 'number' }, length: { type: 'number' } }, ['path']) },
157
+ { name: 'readFiles', description: 'Read multiple UTF-8 text files inside ZERO_AGENT_ROOTS. Accept paths[] or files[].', inputSchema: schemaObject({ paths: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: 50 }, files: { type: 'array', minItems: 1, maxItems: 50, items: schemaObject({ path: { type: 'string' }, offset: { type: 'number' }, length: { type: 'number' } }, ['path']) }, offset: { type: 'number' }, length: { type: 'number' } }) },
143
158
  { name: 'globFiles', description: 'Find files by wildcard pattern inside ZERO_AGENT_ROOTS.', inputSchema: schemaObject({ path: { type: 'string' }, pattern: { type: 'string' }, maxResults: { type: 'number' } }, ['path']) },
144
159
  { name: 'grepFiles', description: 'Search text files inside ZERO_AGENT_ROOTS.', inputSchema: schemaObject({ path: { type: 'string' }, pattern: { type: 'string' }, literal: { type: 'boolean' }, filePattern: { type: 'string' }, maxResults: { type: 'number' } }, ['path', 'pattern']) }
145
160
  ];