aai-gateway 0.3.2 → 0.3.4
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/dist/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import require$$0 from "ajv";
|
|
2
2
|
import process$1 from "node:process";
|
|
3
3
|
import pino from "pino";
|
|
4
|
+
import { existsSync, mkdirSync } from "fs";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import { homedir } from "os";
|
|
4
7
|
import { execFileSync, exec, execFile } from "node:child_process";
|
|
5
8
|
import { promisify } from "node:util";
|
|
6
9
|
import { readFile, mkdir, writeFile } from "node:fs/promises";
|
|
7
|
-
import { dirname, join } from "node:path";
|
|
10
|
+
import { dirname, join as join$1 } from "node:path";
|
|
8
11
|
import { z } from "zod";
|
|
9
|
-
import { homedir } from "node:os";
|
|
12
|
+
import { homedir as homedir$1 } from "node:os";
|
|
10
13
|
import { randomUUID, randomBytes, createHash } from "node:crypto";
|
|
11
14
|
import { createServer } from "node:http";
|
|
12
15
|
function $constructor(name, initializer2, params) {
|
|
@@ -7826,14 +7829,24 @@ class StdioServerTransport {
|
|
|
7826
7829
|
}
|
|
7827
7830
|
}
|
|
7828
7831
|
const logLevel = process.env.AAI_LOG_LEVEL || "info";
|
|
7832
|
+
const logDir = join(homedir(), ".aai", "logs");
|
|
7833
|
+
const logFile = join(logDir, "gateway.log");
|
|
7834
|
+
try {
|
|
7835
|
+
if (!existsSync(logDir)) {
|
|
7836
|
+
mkdirSync(logDir, { recursive: true });
|
|
7837
|
+
}
|
|
7838
|
+
} catch {
|
|
7839
|
+
}
|
|
7829
7840
|
const logger = pino({
|
|
7830
7841
|
level: logLevel,
|
|
7831
7842
|
transport: process.env.NODE_ENV !== "production" ? {
|
|
7832
7843
|
target: "pino-pretty",
|
|
7833
7844
|
options: {
|
|
7834
|
-
colorize:
|
|
7845
|
+
colorize: false,
|
|
7835
7846
|
translateTime: "SYS:standard",
|
|
7836
|
-
ignore: "pid,hostname"
|
|
7847
|
+
ignore: "pid,hostname",
|
|
7848
|
+
destination: logFile
|
|
7849
|
+
// Output to file instead of stdout
|
|
7837
7850
|
}
|
|
7838
7851
|
} : void 0,
|
|
7839
7852
|
base: {
|
|
@@ -8143,7 +8156,7 @@ class LinuxDiscovery {
|
|
|
8143
8156
|
const xdgPaths = [
|
|
8144
8157
|
"/usr/share/applications",
|
|
8145
8158
|
"/usr/local/share/applications",
|
|
8146
|
-
join(process.env.HOME || "", ".local/share/applications")
|
|
8159
|
+
join$1(process.env.HOME || "", ".local/share/applications")
|
|
8147
8160
|
];
|
|
8148
8161
|
try {
|
|
8149
8162
|
const { stdout } = await execAsync(
|
|
@@ -8171,17 +8184,17 @@ function createDesktopDiscovery() {
|
|
|
8171
8184
|
return new WindowsDiscovery();
|
|
8172
8185
|
}
|
|
8173
8186
|
}
|
|
8174
|
-
const CACHE_DIR = join(homedir(), ".cache", "aai-gateway");
|
|
8187
|
+
const CACHE_DIR = join$1(homedir$1(), ".cache", "aai-gateway");
|
|
8175
8188
|
const TTL_SECONDS = 86400;
|
|
8176
8189
|
function hostDir(host) {
|
|
8177
|
-
return join(CACHE_DIR, host.replace(/[^a-zA-Z0-9._-]/g, "_"));
|
|
8190
|
+
return join$1(CACHE_DIR, host.replace(/[^a-zA-Z0-9._-]/g, "_"));
|
|
8178
8191
|
}
|
|
8179
8192
|
async function getDescriptorCache(host) {
|
|
8180
8193
|
const dir = hostDir(host);
|
|
8181
8194
|
try {
|
|
8182
8195
|
const [raw, metaRaw] = await Promise.all([
|
|
8183
|
-
readFile(join(dir, "aai.json"), "utf-8"),
|
|
8184
|
-
readFile(join(dir, "aai.json.meta"), "utf-8")
|
|
8196
|
+
readFile(join$1(dir, "aai.json"), "utf-8"),
|
|
8197
|
+
readFile(join$1(dir, "aai.json.meta"), "utf-8")
|
|
8185
8198
|
]);
|
|
8186
8199
|
const meta = JSON.parse(metaRaw);
|
|
8187
8200
|
const age = (Date.now() - new Date(meta.fetched_at).getTime()) / 1e3;
|
|
@@ -8200,14 +8213,14 @@ async function setDescriptorCache(host, descriptor, sourceUrl) {
|
|
|
8200
8213
|
source_url: sourceUrl
|
|
8201
8214
|
};
|
|
8202
8215
|
await Promise.all([
|
|
8203
|
-
writeFile(join(dir, "aai.json"), JSON.stringify(descriptor), "utf-8"),
|
|
8204
|
-
writeFile(join(dir, "aai.json.meta"), JSON.stringify(meta), "utf-8")
|
|
8216
|
+
writeFile(join$1(dir, "aai.json"), JSON.stringify(descriptor), "utf-8"),
|
|
8217
|
+
writeFile(join$1(dir, "aai.json.meta"), JSON.stringify(meta), "utf-8")
|
|
8205
8218
|
]);
|
|
8206
8219
|
}
|
|
8207
8220
|
async function getStaleDescriptorCache(host) {
|
|
8208
8221
|
const dir = hostDir(host);
|
|
8209
8222
|
try {
|
|
8210
|
-
const raw = await readFile(join(dir, "aai.json"), "utf-8");
|
|
8223
|
+
const raw = await readFile(join$1(dir, "aai.json"), "utf-8");
|
|
8211
8224
|
return JSON.parse(raw);
|
|
8212
8225
|
} catch {
|
|
8213
8226
|
return null;
|
|
@@ -10244,7 +10257,7 @@ class AaiGatewayServer {
|
|
|
10244
10257
|
constructor(options) {
|
|
10245
10258
|
this.options = options ?? {};
|
|
10246
10259
|
this.server = new Server(
|
|
10247
|
-
{ name: "aai-gateway", version: "0.3.
|
|
10260
|
+
{ name: "aai-gateway", version: "0.3.4" },
|
|
10248
10261
|
{ capabilities: { tools: {} } }
|
|
10249
10262
|
);
|
|
10250
10263
|
this.setupHandlers();
|
|
@@ -10272,21 +10285,14 @@ class AaiGatewayServer {
|
|
|
10272
10285
|
}
|
|
10273
10286
|
}
|
|
10274
10287
|
setupHandlers() {
|
|
10275
|
-
this.server.
|
|
10276
|
-
const
|
|
10288
|
+
this.server.oninitialized = () => {
|
|
10289
|
+
const clientVersion = this.server.getClientVersion();
|
|
10277
10290
|
this.callerIdentity = {
|
|
10278
|
-
name:
|
|
10279
|
-
version:
|
|
10291
|
+
name: clientVersion?.name ?? "Unknown Client",
|
|
10292
|
+
version: clientVersion?.version
|
|
10280
10293
|
};
|
|
10281
10294
|
logger.info({ caller: this.callerIdentity }, "Caller identity extracted");
|
|
10282
|
-
|
|
10283
|
-
protocolVersion: "2024-11-05",
|
|
10284
|
-
serverInfo: {
|
|
10285
|
-
name: "aai-gateway",
|
|
10286
|
-
version: "0.3.1"
|
|
10287
|
-
}
|
|
10288
|
-
};
|
|
10289
|
-
});
|
|
10295
|
+
};
|
|
10290
10296
|
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
10291
10297
|
const tools = [];
|
|
10292
10298
|
for (const app of this.desktopRegistry.values()) {
|
|
@@ -10487,4 +10493,4 @@ export {
|
|
|
10487
10493
|
parseAaiJson as p,
|
|
10488
10494
|
startOAuthFlow as s
|
|
10489
10495
|
};
|
|
10490
|
-
//# sourceMappingURL=server-
|
|
10496
|
+
//# sourceMappingURL=server-BYtx5KIZ.js.map
|