xmux-bridge 1.0.39
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 +219 -0
- package/bin/xmux +9 -0
- package/bridge-mcp-server.js +407 -0
- package/dist/bin/xmux-mailbox.js +6 -0
- package/dist/mailbox/cli.js +3 -0
- package/dist/mailbox/core.js +3 -0
- package/package.json +38 -0
- package/scripts/setup_claude_mcp.js +149 -0
- package/scripts/setup_copilot_mcp.js +87 -0
- package/scripts/setup_gemini_mcp.js +89 -0
- package/scripts/setup_xmux_codex_mcp.js +799 -0
- package/scripts/trust_codex_project.js +44 -0
- package/scripts/trust_copilot_project.js +49 -0
- package/scripts/trust_gemini_project.js +47 -0
- package/src/mailbox/cli.js +251 -0
- package/src/mailbox/core.js +887 -0
- package/src/runtime/errors.js +12 -0
- package/src/runtime/json.js +75 -0
- package/src/runtime/lock.js +56 -0
- package/src/runtime/time.js +27 -0
- package/xmux-bridge.zsh +481 -0
- package/xmux-lead-mcp-server.js +486 -0
- package/xmux.zsh +5146 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const os = require("node:os");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
const TOML_PATH = path.join(os.homedir(), ".codex", "config.toml");
|
|
9
|
+
|
|
10
|
+
function usage() {
|
|
11
|
+
process.stderr.write("usage: trust_codex_project.js <path>\n");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function main(argv = process.argv.slice(2)) {
|
|
15
|
+
if (argv.length !== 1) {
|
|
16
|
+
usage();
|
|
17
|
+
return 1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const projectPath = fs.realpathSync(path.resolve(argv[0]));
|
|
21
|
+
const section = `[projects."${projectPath}"]`;
|
|
22
|
+
let content = "";
|
|
23
|
+
if (fs.existsSync(TOML_PATH)) {
|
|
24
|
+
content = fs.readFileSync(TOML_PATH, "utf-8");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (content.includes(section)) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const entry = `${section}\ntrust_level = "trusted"\n`;
|
|
32
|
+
fs.mkdirSync(path.dirname(TOML_PATH), { recursive: true });
|
|
33
|
+
if (content && !content.endsWith("\n")) {
|
|
34
|
+
content += "\n";
|
|
35
|
+
}
|
|
36
|
+
fs.writeFileSync(TOML_PATH, `${content}\n${entry}`, "utf-8");
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (require.main === module) {
|
|
41
|
+
process.exitCode = main();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = { main };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const os = require("node:os");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
const FILE_PATH = path.join(os.homedir(), ".copilot", "config.json");
|
|
9
|
+
|
|
10
|
+
function usage() {
|
|
11
|
+
process.stderr.write("usage: trust_copilot_project.js <path>\n");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function main(argv = process.argv.slice(2)) {
|
|
15
|
+
if (argv.length !== 1) {
|
|
16
|
+
usage();
|
|
17
|
+
return 1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const projectPath = fs.realpathSync(path.resolve(argv[0]));
|
|
21
|
+
let data = {};
|
|
22
|
+
if (fs.existsSync(FILE_PATH)) {
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(fs.readFileSync(FILE_PATH, "utf-8"));
|
|
25
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
26
|
+
data = parsed;
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
data = {};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const folders = Array.isArray(data.trusted_folders) ? data.trusted_folders : [];
|
|
34
|
+
if (folders.includes(projectPath)) {
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
folders.push(projectPath);
|
|
39
|
+
data.trusted_folders = folders;
|
|
40
|
+
fs.mkdirSync(path.dirname(FILE_PATH), { recursive: true });
|
|
41
|
+
fs.writeFileSync(FILE_PATH, `${JSON.stringify(data, null, 2)}\n`, "utf-8");
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (require.main === module) {
|
|
46
|
+
process.exitCode = main();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = { main };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const os = require("node:os");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
const FILE_PATH = path.join(os.homedir(), ".gemini", "trustedFolders.json");
|
|
9
|
+
|
|
10
|
+
function usage() {
|
|
11
|
+
process.stderr.write("usage: trust_gemini_project.js <path>\n");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function main(argv = process.argv.slice(2)) {
|
|
15
|
+
if (argv.length !== 1) {
|
|
16
|
+
usage();
|
|
17
|
+
return 1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const projectPath = fs.realpathSync(path.resolve(argv[0]));
|
|
21
|
+
let data = {};
|
|
22
|
+
if (fs.existsSync(FILE_PATH)) {
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(fs.readFileSync(FILE_PATH, "utf-8"));
|
|
25
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
26
|
+
data = parsed;
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
data = {};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (data[projectPath] === "TRUST_FOLDER") {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
data[projectPath] = "TRUST_FOLDER";
|
|
38
|
+
fs.mkdirSync(path.dirname(FILE_PATH), { recursive: true });
|
|
39
|
+
fs.writeFileSync(FILE_PATH, `${JSON.stringify(data, null, 2)}\n`, "utf-8");
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (require.main === module) {
|
|
44
|
+
process.exitCode = main();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = { main };
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
MailboxError,
|
|
5
|
+
enqueueRequest,
|
|
6
|
+
initTeam,
|
|
7
|
+
listEvents,
|
|
8
|
+
listRequests,
|
|
9
|
+
markInboxRead,
|
|
10
|
+
readResponse,
|
|
11
|
+
registerMember,
|
|
12
|
+
teamStatus,
|
|
13
|
+
updateMember,
|
|
14
|
+
waitResponse,
|
|
15
|
+
writeResponse,
|
|
16
|
+
} = require('./core');
|
|
17
|
+
const { printJson } = require('../runtime/json');
|
|
18
|
+
|
|
19
|
+
const COMMANDS = {
|
|
20
|
+
'init-team': {
|
|
21
|
+
positionals: ['team'],
|
|
22
|
+
options: {
|
|
23
|
+
'--lead-name': { key: 'leadName', required: true, needsValue: true },
|
|
24
|
+
'--lead-provider': { key: 'leadProvider', required: true, needsValue: true },
|
|
25
|
+
'--lead-pane': { key: 'leadPane', needsValue: true },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
'register-member': {
|
|
29
|
+
positionals: ['team', 'name'],
|
|
30
|
+
options: {
|
|
31
|
+
'--provider': { key: 'provider', required: true, needsValue: true },
|
|
32
|
+
'--pane': { key: 'pane', needsValue: true },
|
|
33
|
+
'--backend': { key: 'backend', needsValue: true, defaultValue: 'tmux' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
'update-member': {
|
|
37
|
+
positionals: ['team', 'name'],
|
|
38
|
+
options: {
|
|
39
|
+
'--provider': { key: 'provider', needsValue: true },
|
|
40
|
+
'--pane': { key: 'pane', needsValue: true },
|
|
41
|
+
'--backend': { key: 'backend', needsValue: true },
|
|
42
|
+
'--session': { key: 'session', needsValue: true },
|
|
43
|
+
'--display-mode': { key: 'displayMode', needsValue: true },
|
|
44
|
+
'--active': { key: 'active', needsValue: true, choices: ['true', 'false'] },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
'enqueue-request': {
|
|
48
|
+
positionals: ['team', 'to'],
|
|
49
|
+
options: {
|
|
50
|
+
'--from': { key: 'fromName', required: true, needsValue: true },
|
|
51
|
+
'--message': { key: 'message', required: true, needsValue: true },
|
|
52
|
+
'--request-id': { key: 'requestId', needsValue: true },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
'write-response': {
|
|
56
|
+
positionals: ['team'],
|
|
57
|
+
options: {
|
|
58
|
+
'--from': { key: 'fromName', required: true, needsValue: true },
|
|
59
|
+
'--text': { key: 'text', required: true, needsValue: true },
|
|
60
|
+
'--summary': { key: 'summary', needsValue: true },
|
|
61
|
+
'--request-id': { key: 'requestId', needsValue: true },
|
|
62
|
+
'--status': {
|
|
63
|
+
key: 'status',
|
|
64
|
+
needsValue: true,
|
|
65
|
+
defaultValue: 'done',
|
|
66
|
+
choices: ['done', 'pending'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
'read-response': {
|
|
71
|
+
positionals: ['team', 'requestId'],
|
|
72
|
+
options: {
|
|
73
|
+
'--mark-read': { key: 'markRead', needsValue: false, defaultValue: false },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
'wait-response': {
|
|
77
|
+
positionals: ['team', 'requestId'],
|
|
78
|
+
options: {
|
|
79
|
+
'--timeout': { key: 'timeout', needsValue: true, defaultValue: '60.0' },
|
|
80
|
+
'--interval': { key: 'interval', needsValue: true, defaultValue: '1.0' },
|
|
81
|
+
'--mark-read': { key: 'markRead', needsValue: false, defaultValue: false },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
'team-status': {
|
|
85
|
+
positionals: ['team'],
|
|
86
|
+
options: {},
|
|
87
|
+
},
|
|
88
|
+
'mark-read': {
|
|
89
|
+
positionals: ['team', 'owner'],
|
|
90
|
+
options: {
|
|
91
|
+
'--timestamp': { key: 'timestamp', needsValue: true },
|
|
92
|
+
'--request-id': { key: 'requestId', needsValue: true },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
'list-events': {
|
|
96
|
+
positionals: ['team'],
|
|
97
|
+
options: {
|
|
98
|
+
'--status': { key: 'status', needsValue: true },
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
'list-requests': {
|
|
102
|
+
positionals: ['team'],
|
|
103
|
+
options: {
|
|
104
|
+
'--status': { key: 'status', needsValue: true },
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
function parseArgs(argv) {
|
|
110
|
+
if (!argv || argv.length === 0) {
|
|
111
|
+
throw new MailboxError('command is required');
|
|
112
|
+
}
|
|
113
|
+
const command = argv[0];
|
|
114
|
+
const spec = COMMANDS[command];
|
|
115
|
+
if (!spec) {
|
|
116
|
+
throw new MailboxError(`unknown command: ${command}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const parsed = { command };
|
|
120
|
+
const positionals = [];
|
|
121
|
+
|
|
122
|
+
for (let i = 1; i < argv.length; i += 1) {
|
|
123
|
+
const token = argv[i];
|
|
124
|
+
if (token.startsWith('--')) {
|
|
125
|
+
const opt = spec.options[token];
|
|
126
|
+
if (!opt) {
|
|
127
|
+
throw new MailboxError(`unknown option for ${command}: ${token}`);
|
|
128
|
+
}
|
|
129
|
+
if (!opt.needsValue) {
|
|
130
|
+
parsed[opt.key] = true;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (i + 1 >= argv.length) {
|
|
134
|
+
throw new MailboxError(`${token} requires a value`);
|
|
135
|
+
}
|
|
136
|
+
const value = argv[i + 1];
|
|
137
|
+
i += 1;
|
|
138
|
+
if (opt.choices && !opt.choices.includes(value)) {
|
|
139
|
+
throw new MailboxError(`${token} must be one of: ${opt.choices.join(', ')}`);
|
|
140
|
+
}
|
|
141
|
+
parsed[opt.key] = value;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
positionals.push(token);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (positionals.length < spec.positionals.length) {
|
|
148
|
+
const missing = spec.positionals[positionals.length];
|
|
149
|
+
throw new MailboxError(`${missing} is required`);
|
|
150
|
+
}
|
|
151
|
+
if (positionals.length > spec.positionals.length) {
|
|
152
|
+
throw new MailboxError(`unexpected argument: ${positionals[spec.positionals.length]}`);
|
|
153
|
+
}
|
|
154
|
+
spec.positionals.forEach((name, index) => {
|
|
155
|
+
parsed[name] = positionals[index];
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
for (const [flag, opt] of Object.entries(spec.options)) {
|
|
159
|
+
if (parsed[opt.key] === undefined && opt.defaultValue !== undefined) {
|
|
160
|
+
parsed[opt.key] = opt.defaultValue;
|
|
161
|
+
}
|
|
162
|
+
if (opt.required && (parsed[opt.key] === undefined || parsed[opt.key] === null)) {
|
|
163
|
+
throw new MailboxError(`${flag} is required`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (parsed.active !== undefined) {
|
|
168
|
+
parsed.active = parsed.active === 'true';
|
|
169
|
+
}
|
|
170
|
+
if (parsed.timeout !== undefined) {
|
|
171
|
+
parsed.timeout = Number(parsed.timeout);
|
|
172
|
+
if (!Number.isFinite(parsed.timeout)) {
|
|
173
|
+
throw new MailboxError('--timeout must be a valid number');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (parsed.interval !== undefined) {
|
|
177
|
+
parsed.interval = Number(parsed.interval);
|
|
178
|
+
if (!Number.isFinite(parsed.interval)) {
|
|
179
|
+
throw new MailboxError('--interval must be a valid number');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return parsed;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function runCommand(args) {
|
|
187
|
+
switch (args.command) {
|
|
188
|
+
case 'init-team':
|
|
189
|
+
return initTeam(args.team, args.leadName, args.leadProvider, args.leadPane);
|
|
190
|
+
case 'register-member':
|
|
191
|
+
return registerMember(args.team, args.name, args.provider, args.pane, args.backend);
|
|
192
|
+
case 'update-member':
|
|
193
|
+
return updateMember(args.team, args.name, {
|
|
194
|
+
provider: args.provider,
|
|
195
|
+
pane: args.pane,
|
|
196
|
+
backend: args.backend,
|
|
197
|
+
session: args.session,
|
|
198
|
+
displayMode: args.displayMode,
|
|
199
|
+
active: args.active,
|
|
200
|
+
});
|
|
201
|
+
case 'enqueue-request':
|
|
202
|
+
return enqueueRequest(args.team, args.to, args.fromName, args.message, args.requestId);
|
|
203
|
+
case 'write-response':
|
|
204
|
+
return writeResponse(args.team, args.fromName, args.text, {
|
|
205
|
+
summary: args.summary,
|
|
206
|
+
requestId: args.requestId,
|
|
207
|
+
status: args.status,
|
|
208
|
+
});
|
|
209
|
+
case 'read-response':
|
|
210
|
+
return readResponse(args.team, args.requestId, Boolean(args.markRead));
|
|
211
|
+
case 'wait-response':
|
|
212
|
+
return waitResponse(args.team, args.requestId, {
|
|
213
|
+
timeout: args.timeout,
|
|
214
|
+
interval: args.interval,
|
|
215
|
+
markRead: Boolean(args.markRead),
|
|
216
|
+
});
|
|
217
|
+
case 'team-status':
|
|
218
|
+
return teamStatus(args.team);
|
|
219
|
+
case 'mark-read':
|
|
220
|
+
return markInboxRead(args.team, args.owner, args.timestamp, args.requestId);
|
|
221
|
+
case 'list-events':
|
|
222
|
+
return listEvents(args.team, args.status);
|
|
223
|
+
case 'list-requests':
|
|
224
|
+
return listRequests(args.team, args.status);
|
|
225
|
+
default:
|
|
226
|
+
throw new MailboxError(`unknown command: ${args.command}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function main(argv = process.argv.slice(2)) {
|
|
231
|
+
try {
|
|
232
|
+
const args = parseArgs(argv);
|
|
233
|
+
const result = runCommand(args);
|
|
234
|
+
printJson(result);
|
|
235
|
+
return 0;
|
|
236
|
+
} catch (err) {
|
|
237
|
+
const detail = err && err.message ? err.message : String(err);
|
|
238
|
+
process.stderr.write(`xmux-mailbox: ${detail}\n`);
|
|
239
|
+
return 1;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
module.exports = {
|
|
244
|
+
main,
|
|
245
|
+
parseArgs,
|
|
246
|
+
runCommand,
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
if (require.main === module) {
|
|
250
|
+
process.exit(main(process.argv.slice(2)));
|
|
251
|
+
}
|