@ctliz/agent-intercom-codex 0.11.0-connect.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/.codex-plugin/plugin.json +39 -0
- package/.mcp.json +10 -0
- package/COPYRIGHT +6 -0
- package/LICENSE +661 -0
- package/LICENSE_TRANSITION.md +25 -0
- package/README.md +572 -0
- package/THIRD_PARTY_NOTICES.md +17 -0
- package/assets/logo-generated.png +0 -0
- package/assets/logo.svg +22 -0
- package/boss-control-outbox.ts +195 -0
- package/broker/access-credential.ts +76 -0
- package/broker/access-registry.ts +464 -0
- package/broker/audit.ts +60 -0
- package/broker/authorization.ts +54 -0
- package/broker/boss-adapter.ts +531 -0
- package/broker/boss-control-ledger.ts +306 -0
- package/broker/broker.ts +2327 -0
- package/broker/client.ts +1111 -0
- package/broker/framing.ts +87 -0
- package/broker/ownership.ts +61 -0
- package/broker/paths.ts +161 -0
- package/broker/spawn.ts +453 -0
- package/codex/app-server-client.ts +562 -0
- package/codex/boss-client.ts +34 -0
- package/codex/bridge-config.ts +282 -0
- package/codex/bridge-daemon.ts +913 -0
- package/codex/clipboard.ts +142 -0
- package/codex/coi.ts +802 -0
- package/codex/contact.ts +54 -0
- package/codex/mcp-protocol.ts +248 -0
- package/codex/runtime.ts +488 -0
- package/codex/server.ts +60 -0
- package/codex/team.ts +249 -0
- package/codex/tui-input.ts +174 -0
- package/config.ts +195 -0
- package/dist/bridge-daemon.mjs +3781 -0
- package/dist/broker.mjs +3012 -0
- package/dist/build-info.json +12 -0
- package/dist/codex-server.mjs +2890 -0
- package/dist/coi.mjs +4686 -0
- package/durable-json.ts +25 -0
- package/licenses/MIT-pi-intercom.txt +21 -0
- package/outbound-outbox.ts +116 -0
- package/package.json +89 -0
- package/protocol-v4/contract.ts +27 -0
- package/provider/protected-service.ts +162 -0
- package/provider/provider.mjs +34 -0
- package/scripts/build-info.mjs +58 -0
- package/scripts/build.mjs +55 -0
- package/skills/codex-intercom/SKILL.md +104 -0
- package/tsconfig.json +16 -0
- package/types.ts +225 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
export interface ClipboardCopyResult {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
method?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ClipboardCopyOptions {
|
|
10
|
+
env?: NodeJS.ProcessEnv;
|
|
11
|
+
platform?: NodeJS.Platform;
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function errorMessage(error: unknown): string {
|
|
16
|
+
return error instanceof Error ? error.message : String(error);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function runDetachedClipboardCommand(
|
|
20
|
+
command: string,
|
|
21
|
+
args: string[],
|
|
22
|
+
text: string,
|
|
23
|
+
env: NodeJS.ProcessEnv,
|
|
24
|
+
timeoutMs: number,
|
|
25
|
+
): Promise<ClipboardCopyResult> {
|
|
26
|
+
return new Promise((resolve) => {
|
|
27
|
+
let settled = false;
|
|
28
|
+
const finish = (result: ClipboardCopyResult) => {
|
|
29
|
+
if (settled) return;
|
|
30
|
+
settled = true;
|
|
31
|
+
clearTimeout(timeout);
|
|
32
|
+
resolve(result);
|
|
33
|
+
};
|
|
34
|
+
const timeout = setTimeout(() => finish({ ok: false, error: `${command} did not start within ${timeoutMs}ms` }), timeoutMs);
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const proc = spawn(command, args, { env, stdio: ["pipe", "ignore", "ignore"] });
|
|
38
|
+
proc.once("error", (error) => finish({ ok: false, error: error.message }));
|
|
39
|
+
proc.once("spawn", () => {
|
|
40
|
+
proc.stdin.on("error", () => {
|
|
41
|
+
// Ignore EPIPE if the clipboard helper exits early.
|
|
42
|
+
});
|
|
43
|
+
proc.stdin.end(text);
|
|
44
|
+
proc.unref();
|
|
45
|
+
finish({ ok: true, method: command });
|
|
46
|
+
});
|
|
47
|
+
} catch (error) {
|
|
48
|
+
finish({ ok: false, error: errorMessage(error) });
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function runClipboardCommand(
|
|
54
|
+
command: string,
|
|
55
|
+
args: string[],
|
|
56
|
+
text: string,
|
|
57
|
+
env: NodeJS.ProcessEnv,
|
|
58
|
+
timeoutMs: number,
|
|
59
|
+
): Promise<ClipboardCopyResult> {
|
|
60
|
+
if (command === "wl-copy") return runDetachedClipboardCommand(command, args, text, env, timeoutMs);
|
|
61
|
+
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
let settled = false;
|
|
64
|
+
let stderr = "";
|
|
65
|
+
const finish = (result: ClipboardCopyResult) => {
|
|
66
|
+
if (settled) return;
|
|
67
|
+
settled = true;
|
|
68
|
+
clearTimeout(timeout);
|
|
69
|
+
resolve(result);
|
|
70
|
+
};
|
|
71
|
+
const timeout = setTimeout(() => {
|
|
72
|
+
proc?.kill("SIGKILL");
|
|
73
|
+
finish({ ok: false, error: `${command} timed out after ${timeoutMs}ms` });
|
|
74
|
+
}, timeoutMs);
|
|
75
|
+
let proc: ReturnType<typeof spawn> | undefined;
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
proc = spawn(command, args, { env, stdio: ["pipe", "ignore", "pipe"] });
|
|
79
|
+
proc.stderr?.setEncoding("utf8");
|
|
80
|
+
proc.stderr?.on("data", (chunk: string) => {
|
|
81
|
+
if (stderr.length < 4096) stderr += chunk;
|
|
82
|
+
});
|
|
83
|
+
proc.once("error", (error) => finish({ ok: false, error: error.message }));
|
|
84
|
+
proc.once("close", (code) => {
|
|
85
|
+
finish(code === 0
|
|
86
|
+
? { ok: true, method: command }
|
|
87
|
+
: { ok: false, error: stderr.trim() || `${command} exited ${code}` });
|
|
88
|
+
});
|
|
89
|
+
proc.stdin.on("error", (error) => finish({ ok: false, error: error.message }));
|
|
90
|
+
proc.stdin.end(text);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
finish({ ok: false, error: errorMessage(error) });
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function copyTextToClipboard(
|
|
98
|
+
text: string,
|
|
99
|
+
options: ClipboardCopyOptions = {},
|
|
100
|
+
): Promise<ClipboardCopyResult> {
|
|
101
|
+
const env = options.env ?? process.env;
|
|
102
|
+
const platform = options.platform ?? process.platform;
|
|
103
|
+
const timeoutMs = options.timeoutMs ?? 2000;
|
|
104
|
+
const candidates: Array<[string, string[]]> = [];
|
|
105
|
+
if (platform === "darwin") candidates.push(["pbcopy", []]);
|
|
106
|
+
else if (platform === "win32") candidates.push(["clip.exe", []]);
|
|
107
|
+
else {
|
|
108
|
+
if (env.WAYLAND_DISPLAY) candidates.push(["wl-copy", []]);
|
|
109
|
+
if (env.DISPLAY) {
|
|
110
|
+
candidates.push(["xclip", ["-selection", "clipboard"]]);
|
|
111
|
+
candidates.push(["xsel", ["--clipboard", "--input"]]);
|
|
112
|
+
}
|
|
113
|
+
candidates.push(["clip.exe", []]);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let lastError = "No clipboard command available";
|
|
117
|
+
for (const [command, args] of candidates) {
|
|
118
|
+
const result = await runClipboardCommand(command, args, text, env, timeoutMs);
|
|
119
|
+
if (result.ok) return result;
|
|
120
|
+
lastError = result.error ?? lastError;
|
|
121
|
+
}
|
|
122
|
+
return { ok: false, error: lastError };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function buildOsc52Sequence(text: string, env: NodeJS.ProcessEnv = process.env): string {
|
|
126
|
+
const osc = `\x1b]52;c;${Buffer.from(text, "utf8").toString("base64")}\x07`;
|
|
127
|
+
// tmux requires DCS passthrough and a doubled ESC for the nested OSC sequence.
|
|
128
|
+
return env.TMUX ? `\x1bPtmux;\x1b${osc}\x1b\\` : osc;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function copyTextToTerminalClipboard(
|
|
132
|
+
text: string,
|
|
133
|
+
write: (sequence: string) => unknown,
|
|
134
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
135
|
+
): ClipboardCopyResult {
|
|
136
|
+
try {
|
|
137
|
+
write(buildOsc52Sequence(text, env));
|
|
138
|
+
return { ok: true, method: "osc52" };
|
|
139
|
+
} catch (error) {
|
|
140
|
+
return { ok: false, error: errorMessage(error) };
|
|
141
|
+
}
|
|
142
|
+
}
|