@dns-data/remote 0.2.28 → 0.2.30
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 +43 -0
- package/bin/dns-data.js +236 -179
- package/bin/native-platform.js +9 -9
- package/integrations/codex_event_adapter.py +88 -0
- package/integrations/desktop_hook.py +95 -0
- package/integrations/setup_claude_code.py +111 -0
- package/native/ax-chat-capture-arm64 +0 -0
- package/native/macos-arm64 +0 -0
- package/package.json +40 -36
package/README.md
CHANGED
|
@@ -49,3 +49,46 @@ Only conversations whose real titles/checkpoints have been saved or authorized f
|
|
|
49
49
|
- Fix Unified Memory Manager item-count display: total active memories, number shown, and page index are separate.
|
|
50
50
|
- Counts all memory pages without treating the first 200 items as the total.
|
|
51
51
|
- Preserves macOS-only npm support, existing session authentication, and incremental encrypted LAN synchronization.
|
|
52
|
+
|
|
53
|
+
## macOS browser and desktop AI continuation
|
|
54
|
+
|
|
55
|
+
DNS-DATA 0.2.29: macOS Apple Silicon only; Windows remains the official EXE.
|
|
56
|
+
|
|
57
|
+
Browser: authorized Chrome DOM via Apple Events JavaScript. Source history may
|
|
58
|
+
be partially loaded. Data is written only to the account's existing encrypted
|
|
59
|
+
local memory when account authorization is active.
|
|
60
|
+
|
|
61
|
+
Native desktop apps: app-provided events (Claude Code Hooks and Codex App Server
|
|
62
|
+
client integration) can use the account-local Unix socket. Optional macOS
|
|
63
|
+
Accessibility captures currently visible text in ChatGPT/Claude/Codex
|
|
64
|
+
windows where a specific conversation title is exposed. Accessibility
|
|
65
|
+
snapshots are NOT complete chat histories and must not be treated as such.
|
|
66
|
+
|
|
67
|
+
Desktop permissions are not changed automatically. For Claude Code,
|
|
68
|
+
npx @dns-data/remote --setup-claude-code is an explicit user-authorized
|
|
69
|
+
configuration command; it merges DNS-DATA hooks while preserving other hooks.
|
|
70
|
+
The Claude Code application must be installed. To remove only DNS-DATA hooks:
|
|
71
|
+
npx @dns-data/remote --remove-claude-code.
|
|
72
|
+
|
|
73
|
+
Codex App Server consumers can forward item/completed and turn/completed
|
|
74
|
+
notifications to integrations/codex_event_adapter.py; this does not grant
|
|
75
|
+
access to unconnected or existing private Codex App Server connections.
|
|
76
|
+
|
|
77
|
+
Use npx @dns-data/remote --desktop-help for setup hints.
|
|
78
|
+
This package has no Windows npm support, cloud conversation storage, or
|
|
79
|
+
additional network ports.
|
|
80
|
+
|
|
81
|
+
## Version 0.2.30 — Native ChatGPT desktop capture
|
|
82
|
+
|
|
83
|
+
The bundled Swift Accessibility helper now uses AXUIElement instead of the
|
|
84
|
+
macOS System Events static-text traversal, which does not enumerate all of
|
|
85
|
+
Electron's accessible message text. It extracts visible role-labelled user
|
|
86
|
+
and ChatGPT messages from the local desktop app. User-permitted Accessibility
|
|
87
|
+
is required. It does not use screen OCR, capture login credentials, read
|
|
88
|
+
private browser storage, or claim access to unloaded historical messages.
|
|
89
|
+
|
|
90
|
+
Source conversation and message IDs are derived from currently visible
|
|
91
|
+
content, not guaranteed to equal official ChatGPT IDs. If a chat is renamed,
|
|
92
|
+
the fallback source may create a separate conversation key; history remains
|
|
93
|
+
marked incomplete. Accurate original IDs and full history remain a separate
|
|
94
|
+
adapter validation requirement.
|
package/bin/dns-data.js
CHANGED
|
@@ -1,179 +1,236 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
const fs=require('fs');
|
|
4
|
-
const path=require('path');
|
|
5
|
-
const crypto=require('crypto');
|
|
6
|
-
const os=require('os');
|
|
7
|
-
const {spawn}=require('child_process');
|
|
8
|
-
|
|
9
|
-
const {selectNative}=require('./native-platform');
|
|
10
|
-
const nativeSpec=selectNative(process.platform,process.arch);
|
|
11
|
-
if(!nativeSpec){
|
|
12
|
-
console.error('[ERROR] Unsupported DNS-DATA platform '+process.platform+'-'+process.arch+'. npm supports macOS Apple Silicon (arm64) only; Windows uses the official .exe client.');
|
|
13
|
-
process.exit(2);
|
|
14
|
-
}
|
|
15
|
-
const nativeName=nativeSpec.file;
|
|
16
|
-
const expected={[nativeName]:nativeSpec.sha256};
|
|
17
|
-
const binary=path.resolve(__dirname,'..','native',nativeName);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
if(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
((
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if(!
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
console.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
const fs=require('fs');
|
|
4
|
+
const path=require('path');
|
|
5
|
+
const crypto=require('crypto');
|
|
6
|
+
const os=require('os');
|
|
7
|
+
const {spawn}=require('child_process');
|
|
8
|
+
|
|
9
|
+
const {selectNative}=require('./native-platform');
|
|
10
|
+
const nativeSpec=selectNative(process.platform,process.arch);
|
|
11
|
+
if(!nativeSpec){
|
|
12
|
+
console.error('[ERROR] Unsupported DNS-DATA platform '+process.platform+'-'+process.arch+'. npm supports macOS Apple Silicon (arm64) only; Windows uses the official .exe client.');
|
|
13
|
+
process.exit(2);
|
|
14
|
+
}
|
|
15
|
+
const nativeName=nativeSpec.file;
|
|
16
|
+
const expected={[nativeName]:nativeSpec.sha256};
|
|
17
|
+
const binary=path.resolve(__dirname,'..','native',nativeName);
|
|
18
|
+
const helper=path.resolve(__dirname,'..','native','ax-chat-capture-arm64');
|
|
19
|
+
const expectedHelper=nativeSpec.axHelperSha256;
|
|
20
|
+
|
|
21
|
+
try{
|
|
22
|
+
const hash=crypto.createHash('sha256').update(fs.readFileSync(binary)).digest('hex');
|
|
23
|
+
if(hash.toLowerCase()!==expected[nativeName].toLowerCase()) throw Error('native binary integrity mismatch');
|
|
24
|
+
if(!expectedHelper || !/^[a-f0-9]{64}$/.test(expectedHelper)) throw Error('AX helper manifest missing');
|
|
25
|
+
const axHash=crypto.createHash('sha256').update(fs.readFileSync(helper)).digest('hex');
|
|
26
|
+
if(axHash!==expectedHelper) throw Error('AX helper binary integrity mismatch');
|
|
27
|
+
if(process.platform==='darwin'){
|
|
28
|
+
fs.chmodSync(binary,0o755);
|
|
29
|
+
fs.chmodSync(helper,0o755);
|
|
30
|
+
}
|
|
31
|
+
}catch(e){console.error('[ERROR] DNS-DATA integrity: '+e.message);process.exit(3);}
|
|
32
|
+
|
|
33
|
+
const args=process.argv.slice(2);
|
|
34
|
+
// macOS only: optional, explicit desktop AI hook management. The regular
|
|
35
|
+
// npm startup and Windows .exe usage remain unchanged.
|
|
36
|
+
if(process.platform==='darwin' && args.length===1 &&
|
|
37
|
+
['--desktop-help','--setup-claude-code','--remove-claude-code'].includes(args[0])){
|
|
38
|
+
if(args[0]==='--desktop-help'){
|
|
39
|
+
console.log('DNS-DATA browser + native desktop AI context capture (macOS).');
|
|
40
|
+
console.log('Chrome: View > Developer > Allow JavaScript from Apple Events.');
|
|
41
|
+
console.log('Native ChatGPT/Claude/Codex windows: grant Accessibility if prompted.');
|
|
42
|
+
console.log('Claude Code hooks: npx @dns-data/remote --setup-claude-code');
|
|
43
|
+
console.log('Remove DNS-DATA Claude hooks: npx @dns-data/remote --remove-claude-code');
|
|
44
|
+
console.log('Codex App Server event adapter: integrations/codex_event_adapter.py');
|
|
45
|
+
console.log('Only content exposed by authorized interfaces can be captured.');
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
const {spawnSync}=require('child_process');
|
|
49
|
+
const script=path.resolve(__dirname,'..','integrations','setup_claude_code.py');
|
|
50
|
+
const option=args[0]==='--setup-claude-code'?'--install':'--remove';
|
|
51
|
+
const result=spawnSync('python3',[script,option],{stdio:'inherit',shell:false});
|
|
52
|
+
process.exit(result.status===null?1:result.status);
|
|
53
|
+
}
|
|
54
|
+
const safe=new Set(['--version','--start','--pair-only','--hardware-check','--pair-probe','--policy-check']);
|
|
55
|
+
const isPreview=args.length===1&&args[0]==='--flow-preview';
|
|
56
|
+
if(isPreview){
|
|
57
|
+
console.log('DNS-DATA '+require('../package.json').version+': fresh motherboard/CPU/GPU + account -> native Go executor via npx');
|
|
58
|
+
console.log('New device: eight-digit pairing -> fresh hardware recheck -> built-in remote service (no .NET)');
|
|
59
|
+
console.log('V1 pairing, V1 device startup and legacy bootstrap: disabled');
|
|
60
|
+
process.exit(0);
|
|
61
|
+
}
|
|
62
|
+
// macOS uses a persistent, per-user Agent path. The executable and its
|
|
63
|
+
// associated network identity no longer change when npx rotates cache paths.
|
|
64
|
+
// All copies are verified against the package's embedded SHA-256. No root,
|
|
65
|
+
// SMB share, SSH daemon, or second macOS application is required.
|
|
66
|
+
|
|
67
|
+
// A version/help/setup request MUST NOT install or replace the persistent
|
|
68
|
+
// running Agent binary. These commands inspect only this package copy.
|
|
69
|
+
const diagnosticOnly=args.length===1 &&
|
|
70
|
+
['--version','--flow-preview','--desktop-help','--setup-claude-code',
|
|
71
|
+
'--remove-claude-code'].includes(args[0]);
|
|
72
|
+
let runtimeBinary=binary;
|
|
73
|
+
if(process.platform==='darwin' && !diagnosticOnly){
|
|
74
|
+
const stableDir=path.join(os.homedir(),'Library','Application Support',
|
|
75
|
+
'DNS-DATA','Remote-Agent');
|
|
76
|
+
const stableBinary=path.join(stableDir,'dns-data-agent-'+nativeName);
|
|
77
|
+
const digest=(p)=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex');
|
|
78
|
+
try {
|
|
79
|
+
fs.mkdirSync(stableDir,{recursive:true,mode:0o700});
|
|
80
|
+
const dirInfo=fs.lstatSync(stableDir);
|
|
81
|
+
if(!dirInfo.isDirectory()||dirInfo.isSymbolicLink())
|
|
82
|
+
throw Error('unsafe native agent directory');
|
|
83
|
+
fs.chmodSync(stableDir,0o700);
|
|
84
|
+
let current=false;
|
|
85
|
+
try{
|
|
86
|
+
const st=fs.lstatSync(stableBinary);
|
|
87
|
+
if(!st.isFile()||st.isSymbolicLink())throw Error('unsafe native agent path');
|
|
88
|
+
current=digest(stableBinary)===expected[nativeName];
|
|
89
|
+
}catch(e){if(e.code!=='ENOENT')throw e;}
|
|
90
|
+
if(!current){
|
|
91
|
+
const temp=path.join(stableDir,'.dns-data-agent-'+process.pid+
|
|
92
|
+
'-'+crypto.randomBytes(8).toString('hex')+'.tmp');
|
|
93
|
+
try{
|
|
94
|
+
fs.copyFileSync(binary,temp,fs.constants.COPYFILE_EXCL);
|
|
95
|
+
fs.chmodSync(temp,0o700);
|
|
96
|
+
if(digest(temp)!==expected[nativeName])throw Error('staged native hash mismatch');
|
|
97
|
+
fs.renameSync(temp,stableBinary);
|
|
98
|
+
}finally{if(fs.existsSync(temp))fs.unlinkSync(temp);}
|
|
99
|
+
}
|
|
100
|
+
fs.chmodSync(stableBinary,0o700);
|
|
101
|
+
if(digest(stableBinary)!==expected[nativeName])
|
|
102
|
+
throw Error('installed native hash mismatch');
|
|
103
|
+
// The Swift AX helper is bundled and hash-checked like the Agent.
|
|
104
|
+
// It never opens a TCP port and executes only within the signed-in
|
|
105
|
+
// Agent's local account session.
|
|
106
|
+
const stableHelper=path.join(stableDir,'ax-chat-capture-arm64');
|
|
107
|
+
let helperCurrent=false;
|
|
108
|
+
try{
|
|
109
|
+
const fi=fs.lstatSync(stableHelper);
|
|
110
|
+
if(!fi.isFile() || fi.isSymbolicLink()) throw Error('unsafe AX helper path');
|
|
111
|
+
helperCurrent=digest(stableHelper)===expectedHelper;
|
|
112
|
+
}catch(e){if(e.code!=='ENOENT')throw e;}
|
|
113
|
+
if(!helperCurrent){
|
|
114
|
+
const temp=path.join(stableDir,'.dnsdata-ax-'+process.pid+'-'+
|
|
115
|
+
crypto.randomBytes(8).toString('hex')+'.tmp');
|
|
116
|
+
try{
|
|
117
|
+
fs.copyFileSync(helper,temp,fs.constants.COPYFILE_EXCL);
|
|
118
|
+
fs.chmodSync(temp,0o700);
|
|
119
|
+
if(digest(temp)!==expectedHelper)throw Error('AX helper staged hash mismatch');
|
|
120
|
+
fs.renameSync(temp,stableHelper);
|
|
121
|
+
}finally{if(fs.existsSync(temp))fs.unlinkSync(temp);}
|
|
122
|
+
}
|
|
123
|
+
fs.chmodSync(stableHelper,0o700);
|
|
124
|
+
if(digest(stableHelper)!==expectedHelper)throw Error('AX helper install hash mismatch');
|
|
125
|
+
runtimeBinary=stableBinary;
|
|
126
|
+
}catch(e){
|
|
127
|
+
console.error('[ERROR] DNS-DATA macOS agent installation: '+e.message);
|
|
128
|
+
process.exit(4);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const isNativeLANCopy=process.platform==='darwin' &&
|
|
133
|
+
args.length===4 &&
|
|
134
|
+
((args[0]==='--lan-copy-send' && args[2]==='--lan-copy-done') ||
|
|
135
|
+
(args[0]==='--lan-copy-receive' && args[2]==='--lan-copy-offer-file')) &&
|
|
136
|
+
[args[1],args[3]].every(p=>typeof p==='string' && p.length>0 && p.length<4096 &&
|
|
137
|
+
path.isAbsolute(p) && [0,10,13].every(c=>!p.includes(String.fromCharCode(c))));
|
|
138
|
+
if(!isNativeLANCopy && (args.length>1||args.some(a=>!safe.has(a)))){console.error('[ERROR] Unknown or unsafe DNS-DATA arguments.');process.exit(2);}
|
|
139
|
+
// Create or repair one desktop shortcut on every ordinary npm startup, also
|
|
140
|
+
// for already-bound devices. Never trigger this for diagnostic or transfer verbs.
|
|
141
|
+
if(args.length===0 || (args.length===1 && (args[0]==='--start' || args[0]==='--pair-only'))){
|
|
142
|
+
try {
|
|
143
|
+
const shortcut=require('./desktop-shortcut').ensureDesktopShortcut();
|
|
144
|
+
if(shortcut.changed) console.log('DNS-DATA desktop launcher ready: '+shortcut.path);
|
|
145
|
+
} catch(e) {
|
|
146
|
+
// Desktop/OneDrive permissions must not prevent the existing service running.
|
|
147
|
+
console.warn('[WARN] DNS-DATA desktop launcher: '+e.message);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Reusing an existing macOS session must not attempt another native agent.
|
|
151
|
+
// The panel is bound to loopback and is verified before opening. No impact
|
|
152
|
+
// on Windows, diagnostic commands, pairing or direct LAN transfers.
|
|
153
|
+
// An immediately preceding browser navigation or listener startup may make
|
|
154
|
+
// the first probe transiently fail. Retry before attempting another session.
|
|
155
|
+
async function activeMacPanel(){
|
|
156
|
+
for(let attempt=0;attempt<3;attempt++){
|
|
157
|
+
if(await probeMacPanelOnce())return true;
|
|
158
|
+
if(attempt<2)await new Promise(resolve=>setTimeout(resolve,180));
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
function probeMacPanelOnce(){
|
|
163
|
+
return new Promise(resolve=>{
|
|
164
|
+
const http=require('http');
|
|
165
|
+
let finished=false;
|
|
166
|
+
const complete=ok=>{if(!finished){finished=true;resolve(ok);}};
|
|
167
|
+
const req=http.get({
|
|
168
|
+
hostname:'127.0.0.1',port:18761,path:'/',timeout:1500,
|
|
169
|
+
headers:{Host:'127.0.0.1:18761'}
|
|
170
|
+
},res=>{
|
|
171
|
+
if(res.statusCode!==200){res.resume();complete(false);return;}
|
|
172
|
+
let body='';
|
|
173
|
+
res.setEncoding('utf8');
|
|
174
|
+
res.on('data',chunk=>{
|
|
175
|
+
body+=chunk;
|
|
176
|
+
if(body.length>16384){req.destroy();complete(false);}
|
|
177
|
+
});
|
|
178
|
+
res.on('end',()=>complete(body.includes('<title>DNS-DATA · 统一记忆</title>') &&
|
|
179
|
+
body.includes('id="navigation"') &&
|
|
180
|
+
String(res.headers['content-security-policy']||'').includes("default-src 'none'")));
|
|
181
|
+
res.on('error',()=>complete(false));
|
|
182
|
+
});
|
|
183
|
+
req.on('timeout',()=>req.destroy(new Error('panel probe timeout')));
|
|
184
|
+
req.on('error',()=>complete(false));
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function launchNative(){
|
|
188
|
+
console.log('DNS-DATA Remote Connection - V2');
|
|
189
|
+
const child=spawn(runtimeBinary,args,{stdio:'inherit',shell:false,env:process.env});
|
|
190
|
+
let done=false;
|
|
191
|
+
function finish(code){if(done)return;done=true;process.exitCode=code;}
|
|
192
|
+
child.once('error',e=>{console.error('[ERROR] V2 launcher: '+e.message);finish(1);});
|
|
193
|
+
child.once('exit',(code,signal)=>finish(code===null?(signal==='SIGINT'?130:1):code));
|
|
194
|
+
for(const sig of ['SIGINT','SIGTERM','SIGHUP']){
|
|
195
|
+
try{process.on(sig,()=>{if(process.platform!=='win32'&&!child.killed)child.kill(sig);});}catch(_){}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if(process.platform==='darwin' && (args.length===0 || (args.length===1&&args[0]==='--start'))){
|
|
199
|
+
activeMacPanel().then(active=>{
|
|
200
|
+
if(!active){launchNative();return;}
|
|
201
|
+
const url='http://127.0.0.1:18761/';
|
|
202
|
+
console.log('DNS-DATA Remote Connection - V2');
|
|
203
|
+
console.log('[OK] DNS-DATA Agent already running');
|
|
204
|
+
console.log(' Local management page: '+url);
|
|
205
|
+
console.log(' This window monitors the existing service.');
|
|
206
|
+
console.log(' Press Ctrl+C to close this view; the existing service remains running.');
|
|
207
|
+
// Keep the invoked terminal occupied instead of silently returning to the
|
|
208
|
+
// shell. The original launcher still owns the Agent and its live logs.
|
|
209
|
+
// Never create a duplicate Agent, kill the existing one, or open a browser.
|
|
210
|
+
let polling=false;
|
|
211
|
+
const monitor=setInterval(async()=>{
|
|
212
|
+
if(polling)return;
|
|
213
|
+
polling=true;
|
|
214
|
+
try{
|
|
215
|
+
if(!await activeMacPanel()){
|
|
216
|
+
console.error('[WARN] Existing DNS-DATA Agent no longer responds. Run npx again to start the service.');
|
|
217
|
+
clearInterval(monitor);
|
|
218
|
+
process.exitCode=1;
|
|
219
|
+
}
|
|
220
|
+
}catch(e){
|
|
221
|
+
console.error('[WARN] Existing DNS-DATA Agent status unavailable.');
|
|
222
|
+
clearInterval(monitor);
|
|
223
|
+
process.exitCode=1;
|
|
224
|
+
}finally{polling=false;}
|
|
225
|
+
},5000);
|
|
226
|
+
for(const sig of ['SIGINT','SIGTERM']){
|
|
227
|
+
process.once(sig,()=>{
|
|
228
|
+
clearInterval(monitor);
|
|
229
|
+
console.log('DNS-DATA monitor closed; existing service was not stopped.');
|
|
230
|
+
process.exit(0);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}).catch(()=>launchNative());
|
|
234
|
+
}else{
|
|
235
|
+
launchNative();
|
|
236
|
+
}
|
package/bin/native-platform.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
// npm is supported only on Apple Silicon Macs. Windows installs its .exe client.
|
|
3
|
-
const nativeByPlatform=Object.freeze({
|
|
4
|
-
'darwin-arm64':Object.freeze({file:'macos-arm64',sha256:'
|
|
5
|
-
});
|
|
6
|
-
function selectNative(platform,arch){
|
|
7
|
-
return nativeByPlatform[platform+'-'+arch]||null;
|
|
8
|
-
}
|
|
9
|
-
module.exports={selectNative,nativeByPlatform};
|
|
1
|
+
'use strict';
|
|
2
|
+
// npm is supported only on Apple Silicon Macs. Windows installs its .exe client.
|
|
3
|
+
const nativeByPlatform=Object.freeze({
|
|
4
|
+
'darwin-arm64':Object.freeze({file:'macos-arm64',sha256:'d69398bd09e61c1d097fd73824cf3d7ade1e23e2353e68592162eed8cdbe056b',axHelperSha256:'68d7b855eb8f46d4006d4e30ca8a26bf465eec1d4292f43762276823066f946d'}),
|
|
5
|
+
});
|
|
6
|
+
function selectNative(platform,arch){
|
|
7
|
+
return nativeByPlatform[platform+'-'+arch]||null;
|
|
8
|
+
}
|
|
9
|
+
module.exports={selectNative,nativeByPlatform};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Codex App Server JSON-RPC event adapter to DNS-DATA's macOS Agent.
|
|
3
|
+
|
|
4
|
+
Input must come from a Codex App Server client that owns its protocol
|
|
5
|
+
connection (not from inspecting other users' processes). Stream newline-
|
|
6
|
+
delimited notifications on stdin; captures only text user/assistant items
|
|
7
|
+
and turn completion signals. A thread ID is required for exact identity.
|
|
8
|
+
"""
|
|
9
|
+
import json
|
|
10
|
+
import sys
|
|
11
|
+
from desktop_hook import send
|
|
12
|
+
|
|
13
|
+
MAX_LINE = 420 * 1024
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def content_text(item):
|
|
17
|
+
text = item.get("text")
|
|
18
|
+
if isinstance(text, str):
|
|
19
|
+
return text.strip()
|
|
20
|
+
pieces = []
|
|
21
|
+
for c in item.get("content", []) if isinstance(item.get("content"), list) else []:
|
|
22
|
+
if isinstance(c, dict) and c.get("type") in ("text", "inputText", "outputText"):
|
|
23
|
+
t = c.get("text")
|
|
24
|
+
if isinstance(t, str):
|
|
25
|
+
pieces.append(t)
|
|
26
|
+
return "\n".join(pieces).strip()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def normalize_codex_event(notification):
|
|
30
|
+
if not isinstance(notification, dict):
|
|
31
|
+
return None
|
|
32
|
+
method = notification.get("method")
|
|
33
|
+
params = notification.get("params") or {}
|
|
34
|
+
if not isinstance(params, dict):
|
|
35
|
+
return None
|
|
36
|
+
tid = params.get("threadId")
|
|
37
|
+
if not isinstance(tid, str) or not tid.strip():
|
|
38
|
+
return None
|
|
39
|
+
title = params.get("threadTitle")
|
|
40
|
+
verified = isinstance(title, str) and bool(title.strip())
|
|
41
|
+
if not verified:
|
|
42
|
+
title = "Codex(未命名)" + tid[:10]
|
|
43
|
+
messages, kind = [], None
|
|
44
|
+
if method == "item/completed":
|
|
45
|
+
item = params.get("item")
|
|
46
|
+
if not isinstance(item, dict):
|
|
47
|
+
return None
|
|
48
|
+
kind = "message"
|
|
49
|
+
typ = item.get("type")
|
|
50
|
+
if typ not in ("userMessage", "agentMessage"):
|
|
51
|
+
return None
|
|
52
|
+
mid = item.get("id")
|
|
53
|
+
if not isinstance(mid, str) or not mid:
|
|
54
|
+
return None
|
|
55
|
+
value = content_text(item)
|
|
56
|
+
if not value:
|
|
57
|
+
return None
|
|
58
|
+
messages = [{"id":mid[:240], "role":"user" if typ=="userMessage" else "assistant",
|
|
59
|
+
"text":value[:59000], "complete":True}]
|
|
60
|
+
elif method == "turn/completed":
|
|
61
|
+
kind = "turn_finished"
|
|
62
|
+
else:
|
|
63
|
+
return None
|
|
64
|
+
return {
|
|
65
|
+
"type":"conversation_event", "provider":"codex",
|
|
66
|
+
"conversation_id":tid[:150],
|
|
67
|
+
"title":str(title)[:240],
|
|
68
|
+
"title_verified":verified,
|
|
69
|
+
"source":"codex_app_server",
|
|
70
|
+
"event":kind, "messages":messages,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def main():
|
|
75
|
+
for line in sys.stdin.buffer:
|
|
76
|
+
if len(line) > MAX_LINE:
|
|
77
|
+
continue
|
|
78
|
+
try:
|
|
79
|
+
event = normalize_codex_event(json.loads(line))
|
|
80
|
+
if event:
|
|
81
|
+
send(event)
|
|
82
|
+
except (OSError, ValueError, json.JSONDecodeError, TimeoutError):
|
|
83
|
+
pass
|
|
84
|
+
return 0
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
if __name__ == "__main__":
|
|
88
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""macOS DNS-DATA desktop AI hook transport.
|
|
3
|
+
|
|
4
|
+
Invoked by a user-authorized Claude Code hook or another desktop integration.
|
|
5
|
+
No browser required. Writes only to the signed-in Agent's owner-only Unix socket;
|
|
6
|
+
the Agent applies its existing account authorization and encrypted Store.
|
|
7
|
+
No network calls, plaintext files, stdout credentials, or tool execution.
|
|
8
|
+
"""
|
|
9
|
+
import hashlib
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
import socket
|
|
14
|
+
import sys
|
|
15
|
+
import uuid
|
|
16
|
+
|
|
17
|
+
MAX_JSON = 420 * 1024
|
|
18
|
+
SOCKET = Path.home() / "Library/Application Support/DNS-DATA/Remote-Agent/conversation-events.sock"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def message_id(*values):
|
|
22
|
+
return "event-" + hashlib.sha256("|".join(map(str, values)).encode("utf-8")).hexdigest()[:32]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def from_claude_hook(data):
|
|
26
|
+
if not isinstance(data, dict):
|
|
27
|
+
return None
|
|
28
|
+
event = data.get("hook_event_name")
|
|
29
|
+
sid = str(data.get("session_id") or "").strip()
|
|
30
|
+
if not sid or event not in {"SessionStart", "UserPromptSubmit", "Stop", "SessionEnd"}:
|
|
31
|
+
return None
|
|
32
|
+
name = (data.get("session_title") or "").strip()
|
|
33
|
+
title_ok = bool(name)
|
|
34
|
+
title = name or "Claude Code(未命名)" + sid[:10]
|
|
35
|
+
messages = []
|
|
36
|
+
final = "session_start" if event == "SessionStart" else (
|
|
37
|
+
"turn_finished" if event == "Stop" else (
|
|
38
|
+
"session_end" if event == "SessionEnd" else "message"))
|
|
39
|
+
if event == "UserPromptSubmit" and isinstance(data.get("prompt"), str):
|
|
40
|
+
body = data["prompt"].strip()
|
|
41
|
+
if body:
|
|
42
|
+
messages.append({
|
|
43
|
+
"id": message_id(sid, event, uuid.uuid4().hex),
|
|
44
|
+
"role": "user", "text": body[:59000], "complete": True,
|
|
45
|
+
})
|
|
46
|
+
if event == "Stop" and isinstance(data.get("last_assistant_message"), str):
|
|
47
|
+
body = data["last_assistant_message"].strip()
|
|
48
|
+
if body:
|
|
49
|
+
messages.append({
|
|
50
|
+
"id": message_id(sid, event, uuid.uuid4().hex),
|
|
51
|
+
"role": "assistant", "text": body[:59000], "complete": True,
|
|
52
|
+
})
|
|
53
|
+
return {
|
|
54
|
+
"type": "conversation_event",
|
|
55
|
+
"provider": "claude",
|
|
56
|
+
"conversation_id": sid[:150],
|
|
57
|
+
"title": title[:240],
|
|
58
|
+
"title_verified": title_ok,
|
|
59
|
+
"source": "claude_code_hook",
|
|
60
|
+
"event": final,
|
|
61
|
+
"messages": messages,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def send(event, path=SOCKET, timeout=2):
|
|
66
|
+
raw = json.dumps(event, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
|
|
67
|
+
if len(raw) > MAX_JSON:
|
|
68
|
+
return {"ok": False, "reason": "payload_too_large"}
|
|
69
|
+
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as conn:
|
|
70
|
+
conn.settimeout(timeout)
|
|
71
|
+
conn.connect(str(path))
|
|
72
|
+
conn.sendall(raw)
|
|
73
|
+
conn.shutdown(socket.SHUT_WR)
|
|
74
|
+
answer = conn.recv(4096)
|
|
75
|
+
return json.loads(answer.split(b"\n", 1)[0])
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def main():
|
|
79
|
+
try:
|
|
80
|
+
raw = sys.stdin.buffer.read(MAX_JSON + 1)
|
|
81
|
+
if not raw or len(raw) > MAX_JSON:
|
|
82
|
+
return 0
|
|
83
|
+
data = json.loads(raw)
|
|
84
|
+
event = from_claude_hook(data)
|
|
85
|
+
if event:
|
|
86
|
+
send(event)
|
|
87
|
+
except (ValueError, OSError, TimeoutError, json.JSONDecodeError):
|
|
88
|
+
pass
|
|
89
|
+
# Claude Code hooks are observation only. Never block the prompt or
|
|
90
|
+
# session when DNS-DATA is offline or unconfigured.
|
|
91
|
+
return 0
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
if __name__ == "__main__":
|
|
95
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Optional, explicitly requested Claude Code hook setup for DNS-DATA macOS.
|
|
3
|
+
|
|
4
|
+
No changes occur unless invoked with --install or --remove. Only merges
|
|
5
|
+
DNS-DATA-owned hook commands, preserving existing hooks and user settings.
|
|
6
|
+
"""
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
import shlex
|
|
11
|
+
import sys
|
|
12
|
+
import tempfile
|
|
13
|
+
|
|
14
|
+
HOOK_EVENTS = ("SessionStart","UserPromptSubmit","Stop","SessionEnd")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def command_line():
|
|
18
|
+
source=Path(__file__).with_name("desktop_hook.py")
|
|
19
|
+
return "python3 " + shlex.quote(str(source))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def belongs_to_us(entry):
|
|
23
|
+
if not isinstance(entry,dict):
|
|
24
|
+
return False
|
|
25
|
+
cmds=entry.get("hooks",[])
|
|
26
|
+
if not isinstance(cmds,list):
|
|
27
|
+
return False
|
|
28
|
+
return any(isinstance(x,dict) and
|
|
29
|
+
"integrations/desktop_hook.py" in str(x.get("command","")).replace("\\","/")
|
|
30
|
+
for x in cmds)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def edit_settings(data, install):
|
|
34
|
+
if not isinstance(data,dict):
|
|
35
|
+
raise ValueError("Claude settings must be a JSON object")
|
|
36
|
+
hooks=data.setdefault("hooks",{})
|
|
37
|
+
if not isinstance(hooks,dict):
|
|
38
|
+
raise ValueError("Claude settings hooks must be an object")
|
|
39
|
+
line=command_line()
|
|
40
|
+
changes=0
|
|
41
|
+
for event in HOOK_EVENTS:
|
|
42
|
+
entries=hooks.get(event,[])
|
|
43
|
+
if not isinstance(entries,list):
|
|
44
|
+
raise ValueError("existing hook event must be an array: "+event)
|
|
45
|
+
before=len(entries)
|
|
46
|
+
entries=[item for item in entries if not belongs_to_us(item)]
|
|
47
|
+
if install:
|
|
48
|
+
entries.append({"hooks":[{"type":"command","command":line}]})
|
|
49
|
+
if len(entries)!=before or install:
|
|
50
|
+
changes+=1
|
|
51
|
+
if entries:
|
|
52
|
+
hooks[event]=entries
|
|
53
|
+
else:
|
|
54
|
+
hooks.pop(event,None)
|
|
55
|
+
return data, changes
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main():
|
|
59
|
+
args=sys.argv[1:]
|
|
60
|
+
if len(args)!=1 or args[0] not in ("--install","--remove","--show"):
|
|
61
|
+
print("usage: setup_claude_code.py --show|--install|--remove")
|
|
62
|
+
return 2
|
|
63
|
+
if args[0]=="--show":
|
|
64
|
+
print("Claude Code is supported via SessionStart, UserPromptSubmit, Stop and SessionEnd hooks.")
|
|
65
|
+
print("User consent required: run npx @dns-data/remote --setup-claude-code")
|
|
66
|
+
print("Does not support automatically reading existing historic messages.")
|
|
67
|
+
return 0
|
|
68
|
+
folder=Path.home()/".claude"
|
|
69
|
+
if not folder.exists():
|
|
70
|
+
print("Claude Code config not found. Nothing was changed.")
|
|
71
|
+
return 2
|
|
72
|
+
cfg=folder/"settings.json"
|
|
73
|
+
try:
|
|
74
|
+
if cfg.exists() and not cfg.is_file():
|
|
75
|
+
raise ValueError("settings.json is not a regular file")
|
|
76
|
+
data=json.loads(cfg.read_text(encoding="utf-8-sig")) if cfg.exists() else {}
|
|
77
|
+
before=json.dumps(data,sort_keys=True,ensure_ascii=False)
|
|
78
|
+
data,changes=edit_settings(data, args[0]=="--install")
|
|
79
|
+
after=json.dumps(data,sort_keys=True,ensure_ascii=False)
|
|
80
|
+
if before==after:
|
|
81
|
+
print("No configuration change required.")
|
|
82
|
+
return 0
|
|
83
|
+
# Back up once before a user-authorized configuration mutation.
|
|
84
|
+
if cfg.exists():
|
|
85
|
+
backup=folder/"settings.dnsdata-before-hooks.bak"
|
|
86
|
+
if not backup.exists():
|
|
87
|
+
backup.write_bytes(cfg.read_bytes())
|
|
88
|
+
os.chmod(backup,0o600)
|
|
89
|
+
dest=None
|
|
90
|
+
try:
|
|
91
|
+
with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8",
|
|
92
|
+
dir=str(folder), prefix=".dnsdata-settings-",suffix=".tmp",
|
|
93
|
+
delete=False) as tmp:
|
|
94
|
+
dest=Path(tmp.name)
|
|
95
|
+
json.dump(data,tmp,ensure_ascii=False,indent=2)
|
|
96
|
+
tmp.write("\n")
|
|
97
|
+
os.chmod(dest,0o600)
|
|
98
|
+
dest.replace(cfg)
|
|
99
|
+
finally:
|
|
100
|
+
if dest is not None and dest.exists():
|
|
101
|
+
dest.unlink()
|
|
102
|
+
print("DNS-DATA Claude Code hooks configured." if args[0]=="--install"
|
|
103
|
+
else "DNS-DATA Claude Code hooks removed.")
|
|
104
|
+
return 0
|
|
105
|
+
except (OSError,ValueError,json.JSONDecodeError) as e:
|
|
106
|
+
print("Claude Code settings unchanged: "+str(e),file=sys.stderr)
|
|
107
|
+
return 1
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
if __name__=="__main__":
|
|
111
|
+
raise SystemExit(main())
|
|
Binary file
|
package/native/macos-arm64
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dns-data/remote",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
5
|
-
"license": "UNLICENSED",
|
|
6
|
-
"private": false,
|
|
7
|
-
"bin": {
|
|
8
|
-
"dns-data": "bin/dns-data.js"
|
|
9
|
-
},
|
|
10
|
-
"engines": {
|
|
11
|
-
"node": ">=18"
|
|
12
|
-
},
|
|
13
|
-
"os": [
|
|
14
|
-
"darwin"
|
|
15
|
-
],
|
|
16
|
-
"files": [
|
|
17
|
-
"bin/dns-data.js",
|
|
18
|
-
"bin/native-platform.js",
|
|
19
|
-
"bin/desktop-shortcut.js",
|
|
20
|
-
"native/macos-arm64",
|
|
21
|
-
"README.md",
|
|
22
|
-
"DISCLOSURE"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@dns-data/remote",
|
|
3
|
+
"version": "0.2.30",
|
|
4
|
+
"description": "macOS Apple Silicon AI memory bridge with native ChatGPT desktop accessibility capture, automatic checkpointing and browser/Hooks adapters",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"private": false,
|
|
7
|
+
"bin": {
|
|
8
|
+
"dns-data": "bin/dns-data.js"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18"
|
|
12
|
+
},
|
|
13
|
+
"os": [
|
|
14
|
+
"darwin"
|
|
15
|
+
],
|
|
16
|
+
"files": [
|
|
17
|
+
"bin/dns-data.js",
|
|
18
|
+
"bin/native-platform.js",
|
|
19
|
+
"bin/desktop-shortcut.js",
|
|
20
|
+
"native/macos-arm64",
|
|
21
|
+
"README.md",
|
|
22
|
+
"DISCLOSURE",
|
|
23
|
+
"integrations/desktop_hook.py",
|
|
24
|
+
"integrations/codex_event_adapter.py",
|
|
25
|
+
"integrations/setup_claude_code.py",
|
|
26
|
+
"native/ax-chat-capture-arm64"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"dns-data",
|
|
30
|
+
"mcp",
|
|
31
|
+
"remote",
|
|
32
|
+
"native-launcher"
|
|
33
|
+
],
|
|
34
|
+
"contentPolicy": {
|
|
35
|
+
"class": "dual-use"
|
|
36
|
+
},
|
|
37
|
+
"cpu": [
|
|
38
|
+
"arm64"
|
|
39
|
+
]
|
|
40
|
+
}
|