@miruzero/zero-agent 0.3.1 → 0.3.3
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/README.md +10 -23
- package/package.json +1 -1
- package/src/autostart.js +10 -7
- package/src/capabilities.js +14 -3
- package/src/local-tools.js +13 -2
package/README.md
CHANGED
|
@@ -1,34 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
# Zero Agent
|
|
2
2
|
|
|
3
3
|
Local worker agent for Zero MCP multi-device execution.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
For a normal user, start with npm/npx and let the agent create local files automatically:
|
|
5
|
+
## Quick start
|
|
8
6
|
|
|
9
7
|
```powershell
|
|
10
|
-
npx @miruzero/zero-agent@latest start --
|
|
8
|
+
npx @miruzero/zero-agent@latest start --once
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```powershell
|
|
16
|
-
npm start
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
On first start, the agent creates:
|
|
20
|
-
|
|
21
|
-
```text
|
|
22
|
-
%USERPROFILE%\.zero-agent\device.json
|
|
23
|
-
%USERPROFILE%\.zero-agent\start-zero-agent.cmd
|
|
24
|
-
%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\MiruZeroAgent.vbs
|
|
25
|
-
%USERPROFILE%\.zero-agent\logs\zero-agent.log
|
|
26
|
-
```
|
|
11
|
+
On first run, `start` creates local config, a launcher, and a Windows user-logon autostart file automatically.
|
|
27
12
|
|
|
28
13
|
## Commands
|
|
29
14
|
|
|
30
15
|
```powershell
|
|
31
|
-
zero-agent setup --
|
|
16
|
+
zero-agent setup --name TON --code ZERO-XXXX
|
|
32
17
|
zero-agent start --once
|
|
33
18
|
zero-agent start
|
|
34
19
|
zero-agent status
|
|
@@ -38,15 +23,17 @@ zero-agent tools
|
|
|
38
23
|
zero-agent capabilities
|
|
39
24
|
```
|
|
40
25
|
|
|
41
|
-
##
|
|
26
|
+
## Autostart
|
|
42
27
|
|
|
43
28
|
Default state path:
|
|
44
29
|
|
|
45
30
|
```text
|
|
46
31
|
%USERPROFILE%\.zero-agent\device.json
|
|
32
|
+
%USERPROFILE%\.zero-agent\start-zero-agent.cmd
|
|
33
|
+
%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\MiruZeroAgent.vbs
|
|
47
34
|
```
|
|
48
35
|
|
|
49
|
-
|
|
36
|
+
The launcher uses `npx -y @miruzero/zero-agent@<current-version> start` so the user-logon agent does not depend on a stale global install.
|
|
50
37
|
|
|
51
38
|
Device tokens are local secrets and must not be printed or committed.
|
|
52
39
|
|
|
@@ -55,4 +42,4 @@ Device tokens are local secrets and must not be printed or committed.
|
|
|
55
42
|
```powershell
|
|
56
43
|
npm test
|
|
57
44
|
npm pack --dry-run
|
|
58
|
-
```
|
|
45
|
+
```
|
package/package.json
CHANGED
package/src/autostart.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
const fs = require('node:fs');
|
|
4
4
|
const os = require('node:os');
|
|
5
5
|
const path = require('node:path');
|
|
6
6
|
const config = require('./config');
|
|
7
|
+
const pkg = require('../package.json');
|
|
7
8
|
|
|
8
9
|
const DEFAULT_INTERVAL = 30000;
|
|
9
10
|
|
|
@@ -23,7 +24,6 @@ const startupDir = (env = process.env) => {
|
|
|
23
24
|
const appData = env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming');
|
|
24
25
|
return path.join(appData, 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup');
|
|
25
26
|
};
|
|
26
|
-
|
|
27
27
|
const paths = (env = process.env) => {
|
|
28
28
|
const home = config.agentHome(env);
|
|
29
29
|
return {
|
|
@@ -34,8 +34,11 @@ const paths = (env = process.env) => {
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
const packageSpec = () => pkg.name + '@' + pkg.version;
|
|
38
|
+
|
|
37
39
|
const launcherContent = ({ interval = DEFAULT_INTERVAL, roots, logFile }, env = process.env) => {
|
|
38
40
|
const home = config.agentHome(env);
|
|
41
|
+
const spec = packageSpec();
|
|
39
42
|
return [
|
|
40
43
|
'@echo off',
|
|
41
44
|
'setlocal',
|
|
@@ -45,8 +48,8 @@ const launcherContent = ({ interval = DEFAULT_INTERVAL, roots, logFile }, env =
|
|
|
45
48
|
'set "ZERO_AGENT_INTERVAL=' + Number(interval || DEFAULT_INTERVAL) + '"',
|
|
46
49
|
'rem interval=' + Number(interval || DEFAULT_INTERVAL) + 'ms',
|
|
47
50
|
'if not exist ' + q(winPath(path.dirname(logFile))) + ' mkdir ' + q(winPath(path.dirname(logFile))),
|
|
48
|
-
'echo [%date% %time%] starting
|
|
49
|
-
'
|
|
51
|
+
'echo [%date% %time%] starting ' + spec + ' >> ' + q(winPath(logFile)),
|
|
52
|
+
'npx -y ' + spec + ' start --interval %ZERO_AGENT_INTERVAL% >> ' + q(winPath(logFile)) + ' 2>&1',
|
|
50
53
|
''
|
|
51
54
|
].join('\r\n');
|
|
52
55
|
};
|
|
@@ -74,8 +77,8 @@ const autostart = {
|
|
|
74
77
|
DEFAULT_INTERVAL,
|
|
75
78
|
defaultRoots,
|
|
76
79
|
paths,
|
|
77
|
-
prepare
|
|
80
|
+
prepare,
|
|
81
|
+
launcherContent
|
|
78
82
|
};
|
|
79
83
|
|
|
80
|
-
Object.assign(exports, autostart);
|
|
81
|
-
|
|
84
|
+
Object.assign(exports, autostart);
|
package/src/capabilities.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const crypto = require('node:crypto');
|
|
4
4
|
const fs = require('node:fs');
|
|
5
5
|
const path = require('node:path');
|
|
6
|
+
const localTools = require('./local-tools');
|
|
6
7
|
|
|
7
8
|
const defaultMcpRoot = () => path.resolve(__dirname, '../..');
|
|
8
9
|
const mcpRoot = (env = process.env) => path.resolve(env.ZERO_MCP_ROOT || defaultMcpRoot());
|
|
@@ -55,8 +56,17 @@ const safeInternalTools = (provider) => {
|
|
|
55
56
|
return [{ name: '__scan_error__', description: error.message, inputSchema: null }];
|
|
56
57
|
}
|
|
57
58
|
};
|
|
59
|
+
const builtInLocalProvider = () => ({
|
|
60
|
+
name: 'zero-agent-local',
|
|
61
|
+
type: 'internal',
|
|
62
|
+
description: 'Built-in safe local filesystem tools exposed by zero-agent.',
|
|
63
|
+
status: 'present',
|
|
64
|
+
tools: localTools.listTools(),
|
|
65
|
+
tool_count: localTools.listTools().length
|
|
66
|
+
});
|
|
67
|
+
|
|
58
68
|
const buildCapabilities = (env = process.env) => {
|
|
59
|
-
const providers = manifestProviders(env).map((provider) => {
|
|
69
|
+
const providers = [builtInLocalProvider(), ...manifestProviders(env).map((provider) => {
|
|
60
70
|
const tools = provider.type === 'internal' ? safeInternalTools(provider) : [];
|
|
61
71
|
return {
|
|
62
72
|
name: provider.name,
|
|
@@ -67,7 +77,7 @@ const buildCapabilities = (env = process.env) => {
|
|
|
67
77
|
tool_count: tools.length,
|
|
68
78
|
mcp_stdio_live_scan: provider.type === 'mcp-stdio' ? false : undefined
|
|
69
79
|
};
|
|
70
|
-
});
|
|
80
|
+
})];
|
|
71
81
|
const payload = {
|
|
72
82
|
agent_version: require('../package.json').version,
|
|
73
83
|
mcp_root: mcpRoot(env),
|
|
@@ -80,4 +90,5 @@ const buildCapabilities = (env = process.env) => {
|
|
|
80
90
|
return payload;
|
|
81
91
|
};
|
|
82
92
|
|
|
83
|
-
|
|
93
|
+
const capabilities = { mcpRoot, providersDir, manifestProviders, buildCapabilities };
|
|
94
|
+
Object.assign(exports, capabilities);
|
package/src/local-tools.js
CHANGED
|
@@ -135,11 +135,22 @@ const grepFiles = (args, env) => {
|
|
|
135
135
|
|
|
136
136
|
const handlers = { listDirectory, getFileInfo, readFile, globFiles, grepFiles };
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
const schemaObject = (properties, required = []) => ({ type: 'object', properties, required });
|
|
139
|
+
const toolSchemas = [
|
|
140
|
+
{ name: 'listDirectory', description: 'List files and folders inside ZERO_AGENT_ROOTS.', inputSchema: schemaObject({ path: { type: 'string' }, depth: { type: 'number' } }, ['path']) },
|
|
141
|
+
{ name: 'getFileInfo', description: 'Get metadata for a file or directory inside ZERO_AGENT_ROOTS.', inputSchema: schemaObject({ path: { type: 'string' } }, ['path']) },
|
|
142
|
+
{ 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']) },
|
|
143
|
+
{ 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
|
+
{ 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
|
+
];
|
|
146
|
+
|
|
147
|
+
const execute = (tool, args = {}, env = process.env) => {
|
|
139
148
|
const cleanTool = String(tool || '').replace(/^command\./, '');
|
|
140
149
|
const handler = handlers[cleanTool];
|
|
141
150
|
if (!handler) throw err('UNKNOWN_AGENT_TOOL', 'unknown or unsafe agent tool: ' + tool);
|
|
142
151
|
return handler(args, env);
|
|
143
152
|
};
|
|
153
|
+
const listTools = () => toolSchemas.map((tool) => ({ ...tool }));
|
|
144
154
|
|
|
145
|
-
|
|
155
|
+
const localTools = { execute, listTools, _private: { rootsFor, resolveAllowed, wildcard } };
|
|
156
|
+
Object.assign(exports, localTools);
|