@dev-zero/mcp-agent 0.0.1 → 0.0.2
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 +20 -0
- package/bin/zero-agent.mjs +8 -0
- package/package.json +4 -2
- package/src/first-run.mjs +16 -3
- package/src/local-agent-replacement.mjs +2 -0
package/README.md
CHANGED
|
@@ -13,6 +13,14 @@ npx @dev-zero/mcp-agent remote
|
|
|
13
13
|
|
|
14
14
|
This Agent connects to the Zero_SERVER gateway and securely restores its per-user local identity when available. Run `npx @dev-zero/mcp-agent --help` for the available commands.
|
|
15
15
|
|
|
16
|
+
On a brand-new Windows user/Chrome installation, select or create a Chrome profile
|
|
17
|
+
and sign in at `https://chatgpt.com/` when the Agent reports a missing local
|
|
18
|
+
session. During first Device Code enrollment the Agent keeps polling and rechecks
|
|
19
|
+
the Chrome session without generating another code or requiring a restart; it
|
|
20
|
+
never claims successful authorization until real local ChatGPT proof passes.
|
|
21
|
+
If the Device Code expires, start a new enrollment. No Remote connection to the
|
|
22
|
+
new machine is needed for the local Chrome sign-in step.
|
|
23
|
+
|
|
16
24
|
For a source checkout:
|
|
17
25
|
|
|
18
26
|
```powershell
|
|
@@ -59,4 +67,16 @@ that still supports `system.info` for existing live users. A real new-user
|
|
|
59
67
|
ChatGPT OAuth callback, production Agent replacement and reconnect remain
|
|
60
68
|
unverified acceptance gates.
|
|
61
69
|
|
|
70
|
+
## Publishing with EOTP on MiruZero
|
|
71
|
+
|
|
72
|
+
The Agent's **source-only** release helper follows the validated `M:\\Zero_ChatGPT` release workflow. It calls the installed `zgpt eotp npm --json`, passes the resulting 6-digit TOTP only to the child npm process through `npm_config_otp`, and never logs or stores the code. The helper is excluded from the published Agent tarball.
|
|
73
|
+
|
|
74
|
+
```powershell
|
|
75
|
+
Set-Location M:\\Zero_SERVER\\source\\agent\\zero-agent
|
|
76
|
+
npm run release:eotp:check # Tests, pack audit, public-registry version check; NO publish
|
|
77
|
+
npm run release:eotp # Verify npm login, obtain new EOTP, publish, verify registry
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This needs a **normal online PowerShell session** running as the Windows user who configured `zgpt eotp npm`; the Remote Desktop Commander execution environment may enforce `npm_config_offline=true` and cannot perform npm registry mutations. The helper reports `NPM_OFFLINE_ENV` without attempting a false publish in that environment. The npm account token needs permission to publish `@dev-zero/mcp-agent`; possessing a valid OTP alone does not grant package permissions. An OTP error (`EOTP`) is distinct from Registry HTTP404 (version absent, permissions, or package access). A release is VERIFIED only when the registry serves the exact published version; no automatic version bump, process restart, or npm global install occurs.
|
|
81
|
+
|
|
62
82
|
**Publish metadata:** `@dev-zero/mcp-agent` is configured for public npm distribution with `publishConfig.access=public`. Packaging readiness is not proof of a successful registry publication. Project runtime and credentials remain on the local machine; do not include them in an npm archive.
|
package/bin/zero-agent.mjs
CHANGED
|
@@ -100,6 +100,14 @@ async function start(){
|
|
|
100
100
|
console.log(' - 🔌 Connected to Local Zero MCP');
|
|
101
101
|
console.log('⏳ Connecting to Remote MCP '+gateway);
|
|
102
102
|
await bootstrapAgent({gatewayUrl:gateway,vaultFile:vault,
|
|
103
|
+
onAuthRequired:({reason})=>{
|
|
104
|
+
console.log(' - ChatGPT session is not ready ('+reason+').');
|
|
105
|
+
if(reason==='ambiguous')
|
|
106
|
+
console.log(' - Multiple signed-in Chrome profiles found; use one ChatGPT account.');
|
|
107
|
+
else
|
|
108
|
+
console.log(' - Open Chrome, select or create your profile, and sign in at https://chatgpt.com/');
|
|
109
|
+
console.log(' - Waiting for login with the same Device Code (no restart needed).');
|
|
110
|
+
},
|
|
103
111
|
onCode:({user_code,verification_uri_complete,expires_in})=>{
|
|
104
112
|
console.log(' - 🔌 Connected to Remote MCP');
|
|
105
113
|
console.log('');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev-zero/mcp-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
"status": "node bin/zero-agent.mjs status",
|
|
17
17
|
"doctor": "node bin/zero-agent.mjs remote --help",
|
|
18
18
|
"test": "node --test tests/*.test.mjs",
|
|
19
|
-
"packcheck": "npm pack --dry-run"
|
|
19
|
+
"packcheck": "npm pack --dry-run",
|
|
20
|
+
"release:eotp": "node scripts/release-eotp.mjs",
|
|
21
|
+
"release:eotp:check": "node scripts/release-eotp.mjs --check"
|
|
20
22
|
},
|
|
21
23
|
"files": [
|
|
22
24
|
"bin",
|
package/src/first-run.mjs
CHANGED
|
@@ -13,7 +13,7 @@ const json=async response=>{try{return await response.json()}catch{return {error
|
|
|
13
13
|
// and the local ChatGPT session check have completed.
|
|
14
14
|
export async function bootstrapAgent({gatewayUrl,vaultFile,ensure=ensureLocalChatGPTSession,
|
|
15
15
|
request=fetch,save=saveAgentCredential,wait=sleep,
|
|
16
|
-
onCode=()=>{},onConnected=()=>{},signal}={}){
|
|
16
|
+
onCode=()=>{},onConnected=()=>{},onAuthRequired=()=>{},signal}={}){
|
|
17
17
|
const base=validateAgentGateway(gatewayUrl);
|
|
18
18
|
const secret=randomBytes(32).toString('base64url');
|
|
19
19
|
const verifier=randomBytes(32).toString('base64url');
|
|
@@ -42,6 +42,7 @@ export async function bootstrapAgent({gatewayUrl,vaultFile,ensure=ensureLocalCha
|
|
|
42
42
|
verification_uri_complete:code.verification_uri_complete,expires_in:code.expires_in});
|
|
43
43
|
const until=Date.now()+Math.min(Math.max(1,Number(code.expires_in||900)),900)*1000;
|
|
44
44
|
let submitted=false,finalized=false;
|
|
45
|
+
const reportedAuthReasons=new Set();
|
|
45
46
|
while(Date.now()<until){
|
|
46
47
|
if(signal?.aborted)throw new Error('DEVICE_AUTH_ABORTED');
|
|
47
48
|
const interval=Math.max(250,Math.min(15000,Number(code.interval||5)*1000));
|
|
@@ -72,8 +73,20 @@ export async function bootstrapAgent({gatewayUrl,vaultFile,ensure=ensureLocalCha
|
|
|
72
73
|
if(polled.status===400&&polled.body?.error==='authorization_pending'){
|
|
73
74
|
if(polled.body.action==='zero.chatgpt.auth.ensure'&&!submitted){
|
|
74
75
|
const local=await ensure();
|
|
75
|
-
if(local?.state!=='auth_valid'||local?.auth!=='valid'||local?.redacted!==true)
|
|
76
|
-
|
|
76
|
+
if(local?.state!=='auth_valid'||local?.auth!=='valid'||local?.redacted!==true){
|
|
77
|
+
// A fresh Windows user may have Chrome but no signed-in ChatGPT profile.
|
|
78
|
+
// Keep the original Device Code alive while they sign in; never send
|
|
79
|
+
// a positive proof, register an Agent, or switch Chrome profiles here.
|
|
80
|
+
const reason=local?.auth;
|
|
81
|
+
if(local?.state!=='auth_required'||local?.redacted!==true||
|
|
82
|
+
!['missing','expired','invalid','ambiguous'].includes(reason))
|
|
83
|
+
throw new Error('CHATGPT_LOCAL_SESSION_REQUIRED');
|
|
84
|
+
if(!reportedAuthReasons.has(reason)){
|
|
85
|
+
reportedAuthReasons.add(reason);
|
|
86
|
+
await onAuthRequired({reason});
|
|
87
|
+
}
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
77
90
|
const confirm=await invoke('/device/auth-result',{device_code:code.device_code,
|
|
78
91
|
code_verifier:verifier,device_secret:secret,
|
|
79
92
|
result:{state:'auth_valid',auth:'valid',runtime:'ready',redacted:true}});
|
|
@@ -44,6 +44,8 @@ export function isOwnedZeroAgent(info){
|
|
|
44
44
|
const legacy=(script==='source/agent/main.mjs'||script.endsWith('/zero_server/source/agent/main.mjs'))&&!match[5]&&!match[6];
|
|
45
45
|
const standalone=(script==='bin/zero-agent.mjs'||script==='./bin/zero-agent.mjs'||
|
|
46
46
|
script.endsWith('/zero-agent/bin/zero-agent.mjs')||
|
|
47
|
+
// Exact published package path. Do not accept lookalike package names.
|
|
48
|
+
script.endsWith('/@dev-zero/mcp-agent/bin/zero-agent.mjs')||
|
|
47
49
|
script.endsWith('/zero-server-agent/bin/zero-agent.mjs'))&&
|
|
48
50
|
['start','remote'].includes((match[5]||'').toLowerCase());
|
|
49
51
|
return legacy||standalone;
|