@hellolynk-ai/codex-plugin 0.0.0-stage → 0.2.100
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/.agents/plugins/marketplace.json +20 -0
- package/LICENSE +92 -0
- package/README.md +101 -2
- package/bin/hellolynk-client-setup.mjs +2748 -0
- package/bin/hellolynk-mcp-config-shape.mjs +23 -0
- package/hellolynk-client-pack-manifest.json +619 -0
- package/hellolynk-client-pack-pin.json +4 -0
- package/package.json +58 -4
- package/plugins/hellolynk-codex/.app.json +3 -0
- package/plugins/hellolynk-codex/.codex-plugin/plugin.json +38 -0
- package/plugins/hellolynk-codex/.mcp.json +19 -0
- package/plugins/hellolynk-codex/assets/hellolynk-mark.png +0 -0
- package/plugins/hellolynk-codex/package.json +11 -0
- package/plugins/hellolynk-codex/runtime/bootstrap/core/hellolynk-client-account.mjs +180 -0
- package/plugins/hellolynk-codex/runtime/bootstrap/core/hellolynk-client-core.mjs +770 -0
- package/plugins/hellolynk-codex/runtime/bootstrap/core/hellolynk-client-profile.mjs +191 -0
- package/plugins/hellolynk-codex/runtime/bootstrap/core/hellolynk-host-auth.mjs +347 -0
- package/plugins/hellolynk-codex/runtime/bootstrap/core/hellolynk-host-protected-store.mjs +2721 -0
- package/plugins/hellolynk-codex/runtime/bootstrap/core/hellolynk-local-process-lock.mjs +157 -0
- package/plugins/hellolynk-codex/runtime/bootstrap/core/hellolynk-neutral-host-installation-store.mjs +765 -0
- package/plugins/hellolynk-codex/runtime/bootstrap/core/hellolynk-platform-credential-store.mjs +773 -0
- package/plugins/hellolynk-codex/runtime/bootstrap/core/hellolynk-runtime-safety.cjs +471 -0
- package/plugins/hellolynk-codex/runtime/bootstrap/platform/windows/hellolynk-host-protected-store.ps1 +2866 -0
- package/plugins/hellolynk-codex/runtime/connect-activate.mjs +837 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-agent-configurator.mjs +701 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-client-account.mjs +180 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-client-core.mjs +770 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-client-profile.mjs +191 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-client-update-entry.mjs +31 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-client-update-runtime.mjs +600 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-client-update.mjs +453 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-contact-request-e2ee.mjs +867 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-device-enrollment.mjs +435 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-direct-text-e2ee-client.mjs +1964 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-direct-text-e2ee.mjs +1207 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-host-auth.mjs +347 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-host-protected-store.mjs +2721 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-host-transport-client.mjs +946 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-host.mjs +2374 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-human-confirmation-ledger.mjs +256 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-human-relationship-controller.mjs +1234 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-inbox-read-state.mjs +11 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-indexed-message-store.mjs +1558 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-instance-conversation.mjs +185 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-local-contact-requests.mjs +1733 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-local-contacts.mjs +1228 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-local-data-migration.mjs +766 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-local-data-protection.mjs +747 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-local-identity-trust.mjs +274 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-local-messaging.mjs +3043 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-local-peer-transport.mjs +103 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-local-process-lock.mjs +157 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-model-inbox.mjs +230 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-model-notices.cjs +60 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-native-addressing-tools.cjs +231 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-native-conversations.mjs +280 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-native-human-confirmation-broker.mjs +1036 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-native-inbox-runtime.mjs +553 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-native-notice.mjs +50 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-native-reply-routes.mjs +96 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-native-worker-lease.mjs +84 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-neutral-host-assembly.mjs +955 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-neutral-host-installation-store.mjs +765 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-neutral-host-launcher.mjs +665 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-neutral-host-process.mjs +4374 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-neutral-host-store-adapters.mjs +548 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-neutral-host-workbench-read-model.mjs +1365 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-platform-credential-store.mjs +773 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-relay-client-cli.mjs +232 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-release-retention.mjs +277 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-runtime-safety.cjs +471 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-workbench-action-grants.mjs +457 -0
- package/plugins/hellolynk-codex/runtime/core/hellolynk-workbench-connection.mjs +234 -0
- package/plugins/hellolynk-codex/runtime/neutral-host-bootstrap.mjs +64 -0
- package/plugins/hellolynk-codex/runtime/neutral-host-release-entry.mjs +70 -0
- package/plugins/hellolynk-codex/runtime/neutral-host-release-loader.mjs +156 -0
- package/plugins/hellolynk-codex/runtime/neutral-host-release-manifest.json +358 -0
- package/plugins/hellolynk-codex/runtime/neutral-host-release-pin.json +4 -0
- package/plugins/hellolynk-codex/runtime/platform/windows/configure-agent.ps1 +281 -0
- package/plugins/hellolynk-codex/runtime/platform/windows/credential-store.ps1 +844 -0
- package/plugins/hellolynk-codex/runtime/platform/windows/hellolynk-host-protected-store.ps1 +2866 -0
- package/plugins/hellolynk-codex/runtime/platform/windows/hellolynk-human-confirmation-ledger.ps1 +155 -0
- package/plugins/hellolynk-codex/runtime/platform/windows/hellolynk-local-data-key.ps1 +300 -0
- package/plugins/hellolynk-codex/runtime/platform/windows/hellolynk-native-human-confirmation-broker.ps1 +216 -0
- package/plugins/hellolynk-codex/runtime/workbench/candidate-bootstrap.mjs +54 -0
- package/plugins/hellolynk-codex/runtime/workbench/contract.mjs +1314 -0
- package/plugins/hellolynk-codex/runtime/workbench/hellolynk-workbench-build.json +215 -0
- package/plugins/hellolynk-codex/runtime/workbench/host-capabilities.mjs +80 -0
- package/plugins/hellolynk-codex/runtime/workbench/i18n.mjs +1127 -0
- package/plugins/hellolynk-codex/runtime/workbench/loopback-surface.mjs +740 -0
- package/plugins/hellolynk-codex/runtime/workbench/mcp-app-bundle.mjs +97 -0
- package/plugins/hellolynk-codex/runtime/workbench/service.mjs +485 -0
- package/plugins/hellolynk-codex/runtime/workbench/state.mjs +421 -0
- package/plugins/hellolynk-codex/runtime/workbench/transports.mjs +171 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/app.mjs +6120 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/connection-form.mjs +155 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/hellolynk-mark.png +0 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/http-transport.mjs +247 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/icons/arrow-left.svg +3 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/icons/close.svg +3 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/icons/contacts.svg +3 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/icons/inbox.svg +3 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/icons/refresh.svg +3 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/icons/search.svg +3 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/icons/security.svg +3 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/icons/settings.svg +3 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/index.html +139 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/loopback-entry.mjs +26 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/mcp-app-client.mjs +151 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/mcp-app-entry.mjs +452 -0
- package/plugins/hellolynk-codex/runtime/workbench/ui/styles.css +686 -0
- package/plugins/hellolynk-codex/server/codex-neutral-production.mjs +520 -0
- package/plugins/hellolynk-codex/server/mcp-proxy.mjs +306 -0
- package/plugins/hellolynk-codex/server/mcp-server.mjs +1193 -0
- package/plugins/hellolynk-codex/server/native-conversation-directory.mjs +33 -0
- package/plugins/hellolynk-codex/server/native-reply-routes.mjs +32 -0
- package/plugins/hellolynk-codex/server/native-task-client.mjs +382 -0
- package/plugins/hellolynk-codex/server/native-task-runtime.mjs +8 -0
- package/plugins/hellolynk-codex/server/neutral-host-adapter.mjs +649 -0
- package/plugins/hellolynk-codex/server/workbench-runtime.mjs +180 -0
- package/plugins/hellolynk-codex/skills/hellolynk-open/SKILL.md +11 -0
- package/plugins/hellolynk-codex/skills/hellolynk-open/agents/openai.yaml +4 -0
- package/tools/hellolynk-activate-neutral-host-clients.mjs +837 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
import net from "node:net";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { performance } from "node:perf_hooks";
|
|
7
|
+
|
|
8
|
+
// Serialize lock-file changes with an OS-owned resource. A check followed by
|
|
9
|
+
// rename/unlink is not a compare-and-swap, even when the file is checked twice.
|
|
10
|
+
// The OS releases this guard if its process exits; there is no second stale
|
|
11
|
+
// lock file to reclaim. Nothing is read from or written to connected clients.
|
|
12
|
+
export async function withLocalProcessLock(target, operation, { timeoutMs = 10_000 } = {}) {
|
|
13
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || typeof operation !== "function") {
|
|
14
|
+
throw lockError("hellolynk_local_process_lock_invalid");
|
|
15
|
+
}
|
|
16
|
+
const started = performance.now();
|
|
17
|
+
const parent = await fs.realpath(path.dirname(target));
|
|
18
|
+
const canonical = path.join(parent, path.basename(target));
|
|
19
|
+
const scope = process.platform === "win32" || process.platform === "darwin"
|
|
20
|
+
? canonical.toLowerCase() : canonical;
|
|
21
|
+
const digest = crypto.createHash("sha256").update(scope).digest("hex");
|
|
22
|
+
const address = process.platform === "win32"
|
|
23
|
+
? { path: `\\\\.\\pipe\\hellolynk-file-lock-${digest}` }
|
|
24
|
+
: process.platform === "linux"
|
|
25
|
+
? { path: `\0hellolynk-file-lock-${digest}` }
|
|
26
|
+
// macOS has no abstract Unix sockets. A deterministic loopback port is
|
|
27
|
+
// also released on crash. A collision fails closed; never select another
|
|
28
|
+
// port, which would let contenders for the same file use different locks.
|
|
29
|
+
: { host: "127.0.0.1", port: 16_384 + (Number.parseInt(digest.slice(0, 8), 16) % 49_152) };
|
|
30
|
+
let server;
|
|
31
|
+
for (;;) {
|
|
32
|
+
if (performance.now() - started >= timeoutMs) throw lockError("hellolynk_local_process_lock_busy");
|
|
33
|
+
server = net.createServer((socket) => { socket.on("error", () => {}); socket.destroy(); });
|
|
34
|
+
try {
|
|
35
|
+
await new Promise((resolve, reject) => {
|
|
36
|
+
server.once("error", reject);
|
|
37
|
+
server.listen({ ...address, exclusive: true }, resolve);
|
|
38
|
+
});
|
|
39
|
+
break;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
server.close();
|
|
42
|
+
if (error?.code !== "EADDRINUSE") throw lockError("hellolynk_local_process_lock_unavailable", error);
|
|
43
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(25, Math.max(1, timeoutMs - (performance.now() - started)))));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
try { return await operation(); }
|
|
47
|
+
finally { await new Promise((resolve) => server.close(resolve)); }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function lockError(code, cause) { return Object.assign(new Error(code, cause ? { cause } : undefined), { code }); }
|
|
51
|
+
|
|
52
|
+
// Process birth identity distinguishes an active lock owner from a reused PID.
|
|
53
|
+
const SELF_PROCESS_STARTED_AT_MS = Date.now() - (process.uptime() * 1_000);
|
|
54
|
+
let selfProcessIdentityPromise = null;
|
|
55
|
+
|
|
56
|
+
export async function inspectProcessIdentity(pid) {
|
|
57
|
+
if (!Number.isSafeInteger(pid) || pid < 1) return null;
|
|
58
|
+
if (pid === process.pid) {
|
|
59
|
+
selfProcessIdentityPromise ||= inspectPlatformProcessIdentity(pid).then((value) => value || Object.freeze({
|
|
60
|
+
identity: `portable:${process.platform}:${Math.round(SELF_PROCESS_STARTED_AT_MS)}`,
|
|
61
|
+
startedAtMs: SELF_PROCESS_STARTED_AT_MS,
|
|
62
|
+
}));
|
|
63
|
+
return selfProcessIdentityPromise;
|
|
64
|
+
}
|
|
65
|
+
return inspectPlatformProcessIdentity(pid);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function inspectPlatformProcessIdentity(pid) {
|
|
69
|
+
if (process.platform === "linux") return inspectLinuxProcessIdentity(pid);
|
|
70
|
+
if (process.platform === "win32") return inspectWindowsProcessIdentity(pid);
|
|
71
|
+
if (process.platform === "darwin") return inspectDarwinProcessIdentity(pid);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function inspectLinuxProcessIdentity(pid) {
|
|
76
|
+
try {
|
|
77
|
+
const [statText, bootId, processMetadata] = await Promise.all([
|
|
78
|
+
fs.readFile(`/proc/${pid}/stat`, "utf8"),
|
|
79
|
+
fs.readFile("/proc/sys/kernel/random/boot_id", "utf8"),
|
|
80
|
+
fs.stat(`/proc/${pid}`),
|
|
81
|
+
]);
|
|
82
|
+
const close = statText.lastIndexOf(")");
|
|
83
|
+
if (close < 1) return null;
|
|
84
|
+
const fields = statText.slice(close + 2).trim().split(/\s+/);
|
|
85
|
+
const startTicks = fields[19];
|
|
86
|
+
const normalizedBootId = bootId.trim().toLowerCase();
|
|
87
|
+
if (!/^\d+$/.test(String(startTicks || ""))
|
|
88
|
+
|| !/^[a-f0-9-]{32,40}$/.test(normalizedBootId)) return null;
|
|
89
|
+
return Object.freeze({
|
|
90
|
+
identity: `linux:${normalizedBootId}:${startTicks}`,
|
|
91
|
+
startedAtMs: Number.isFinite(processMetadata.ctimeMs) ? processMetadata.ctimeMs : null,
|
|
92
|
+
});
|
|
93
|
+
} catch { return null; }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function inspectWindowsProcessIdentity(pid) {
|
|
97
|
+
const systemRoot = String(process.env.SystemRoot || "C:\\Windows");
|
|
98
|
+
if (!path.isAbsolute(systemRoot)) return null;
|
|
99
|
+
const powershell = path.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
100
|
+
const script = `$p=Get-Process -Id ${pid} -ErrorAction Stop;[Console]::Out.Write($p.StartTime.ToUniversalTime().Ticks.ToString())`;
|
|
101
|
+
const output = await runIdentityProbe(powershell, [
|
|
102
|
+
"-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script,
|
|
103
|
+
]);
|
|
104
|
+
if (!/^\d{12,20}$/.test(String(output || ""))) return null;
|
|
105
|
+
const ticks = Number(output);
|
|
106
|
+
const startedAtMs = (ticks / 10_000) - 62_135_596_800_000;
|
|
107
|
+
if (!Number.isFinite(startedAtMs) || startedAtMs < 0) return null;
|
|
108
|
+
return Object.freeze({ identity: `win32:${output}`, startedAtMs });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function inspectDarwinProcessIdentity(pid) {
|
|
112
|
+
const output = await runIdentityProbe("/bin/ps", ["-o", "lstart=", "-p", String(pid)]);
|
|
113
|
+
const startedAtMs = Date.parse(String(output || "").trim());
|
|
114
|
+
if (!Number.isFinite(startedAtMs)) return null;
|
|
115
|
+
return Object.freeze({
|
|
116
|
+
identity: `darwin:${crypto.createHash("sha256").update(output.trim()).digest("hex")}`,
|
|
117
|
+
startedAtMs,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function runIdentityProbe(executable, args) {
|
|
122
|
+
return new Promise((resolve) => {
|
|
123
|
+
let output = "";
|
|
124
|
+
let overflow = false;
|
|
125
|
+
let settled = false;
|
|
126
|
+
let child;
|
|
127
|
+
const settle = (value) => {
|
|
128
|
+
if (settled) return;
|
|
129
|
+
settled = true;
|
|
130
|
+
clearTimeout(timer);
|
|
131
|
+
resolve(value);
|
|
132
|
+
};
|
|
133
|
+
const timer = setTimeout(() => {
|
|
134
|
+
child?.kill();
|
|
135
|
+
settle(null);
|
|
136
|
+
}, 2_000);
|
|
137
|
+
try {
|
|
138
|
+
child = spawn(executable, args, {
|
|
139
|
+
windowsHide: true,
|
|
140
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
141
|
+
});
|
|
142
|
+
} catch {
|
|
143
|
+
settle(null);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
child.stdout.on("data", (chunk) => {
|
|
147
|
+
if (overflow) return;
|
|
148
|
+
output += chunk.toString("utf8");
|
|
149
|
+
if (Buffer.byteLength(output, "utf8") > 256) {
|
|
150
|
+
output = "";
|
|
151
|
+
overflow = true;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
child.once("error", () => settle(null));
|
|
155
|
+
child.once("close", (code) => settle(code === 0 && !overflow ? output.trim() : null));
|
|
156
|
+
});
|
|
157
|
+
}
|