@agent-team-foundation/first-tree-hub 0.8.1 → 0.8.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.
@@ -0,0 +1,10 @@
1
+ import { f as __require, l as __commonJSMin } from "./esm-CYu4tXXn.mjs";
2
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/execAsync.js
3
+ var require_execAsync = /* @__PURE__ */ __commonJSMin(((exports) => {
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.execAsync = void 0;
6
+ const child_process = __require("child_process");
7
+ exports.execAsync = __require("util").promisify(child_process.exec);
8
+ }));
9
+ //#endregion
10
+ export { require_execAsync as t };
@@ -1,4 +1,4 @@
1
- import { t as __exportAll } from "./rolldown-runtime-twds-ZHy.mjs";
1
+ import { d as __exportAll } from "./esm-CYu4tXXn.mjs";
2
2
  import { z } from "zod";
3
3
  //#region ../shared/dist/index.mjs
4
4
  const adapterPlatformSchema = z.enum([
@@ -0,0 +1,26 @@
1
+ import { f as __require, l as __commonJSMin, n as init_esm, p as __toCommonJS, t as esm_exports } from "./esm-CYu4tXXn.mjs";
2
+ import { t as require_execAsync } from "./execAsync-CP8iWV5b.mjs";
3
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-bsd.js
4
+ var require_getMachineId_bsd = /* @__PURE__ */ __commonJSMin(((exports) => {
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getMachineId = void 0;
7
+ const fs_1 = __require("fs");
8
+ const execAsync_1 = require_execAsync();
9
+ const api_1 = (init_esm(), __toCommonJS(esm_exports));
10
+ async function getMachineId() {
11
+ try {
12
+ return (await fs_1.promises.readFile("/etc/hostid", { encoding: "utf8" })).trim();
13
+ } catch (e) {
14
+ api_1.diag.debug(`error reading machine id: ${e}`);
15
+ }
16
+ try {
17
+ return (await (0, execAsync_1.execAsync)("kenv -q smbios.system.uuid")).stdout.trim();
18
+ } catch (e) {
19
+ api_1.diag.debug(`error reading machine id: ${e}`);
20
+ }
21
+ }
22
+ exports.getMachineId = getMachineId;
23
+ }));
24
+ //#endregion
25
+ export default require_getMachineId_bsd();
26
+ export {};
@@ -0,0 +1,23 @@
1
+ import { l as __commonJSMin, n as init_esm, p as __toCommonJS, t as esm_exports } from "./esm-CYu4tXXn.mjs";
2
+ import { t as require_execAsync } from "./execAsync-CP8iWV5b.mjs";
3
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-darwin.js
4
+ var require_getMachineId_darwin = /* @__PURE__ */ __commonJSMin(((exports) => {
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getMachineId = void 0;
7
+ const execAsync_1 = require_execAsync();
8
+ const api_1 = (init_esm(), __toCommonJS(esm_exports));
9
+ async function getMachineId() {
10
+ try {
11
+ const idLine = (await (0, execAsync_1.execAsync)("ioreg -rd1 -c \"IOPlatformExpertDevice\"")).stdout.split("\n").find((line) => line.includes("IOPlatformUUID"));
12
+ if (!idLine) return;
13
+ const parts = idLine.split("\" = \"");
14
+ if (parts.length === 2) return parts[1].slice(0, -1);
15
+ } catch (e) {
16
+ api_1.diag.debug(`error reading machine id: ${e}`);
17
+ }
18
+ }
19
+ exports.getMachineId = getMachineId;
20
+ }));
21
+ //#endregion
22
+ export default require_getMachineId_darwin();
23
+ export {};
@@ -0,0 +1,19 @@
1
+ import { f as __require, l as __commonJSMin, n as init_esm, p as __toCommonJS, t as esm_exports } from "./esm-CYu4tXXn.mjs";
2
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-linux.js
3
+ var require_getMachineId_linux = /* @__PURE__ */ __commonJSMin(((exports) => {
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getMachineId = void 0;
6
+ const fs_1 = __require("fs");
7
+ const api_1 = (init_esm(), __toCommonJS(esm_exports));
8
+ async function getMachineId() {
9
+ for (const path of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) try {
10
+ return (await fs_1.promises.readFile(path, { encoding: "utf8" })).trim();
11
+ } catch (e) {
12
+ api_1.diag.debug(`error reading machine id: ${e}`);
13
+ }
14
+ }
15
+ exports.getMachineId = getMachineId;
16
+ }));
17
+ //#endregion
18
+ export default require_getMachineId_linux();
19
+ export {};
@@ -0,0 +1,14 @@
1
+ import { l as __commonJSMin, n as init_esm, p as __toCommonJS, t as esm_exports } from "./esm-CYu4tXXn.mjs";
2
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-unsupported.js
3
+ var require_getMachineId_unsupported = /* @__PURE__ */ __commonJSMin(((exports) => {
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getMachineId = void 0;
6
+ const api_1 = (init_esm(), __toCommonJS(esm_exports));
7
+ async function getMachineId() {
8
+ api_1.diag.debug("could not read machine-id: unsupported platform");
9
+ }
10
+ exports.getMachineId = getMachineId;
11
+ }));
12
+ //#endregion
13
+ export default require_getMachineId_unsupported();
14
+ export {};
@@ -0,0 +1,25 @@
1
+ import { f as __require, l as __commonJSMin, n as init_esm, p as __toCommonJS, t as esm_exports } from "./esm-CYu4tXXn.mjs";
2
+ import { t as require_execAsync } from "./execAsync-CP8iWV5b.mjs";
3
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-win.js
4
+ var require_getMachineId_win = /* @__PURE__ */ __commonJSMin(((exports) => {
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getMachineId = void 0;
7
+ const process = __require("process");
8
+ const execAsync_1 = require_execAsync();
9
+ const api_1 = (init_esm(), __toCommonJS(esm_exports));
10
+ async function getMachineId() {
11
+ const args = "QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
12
+ let command = "%windir%\\System32\\REG.exe";
13
+ if (process.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process.env) command = "%windir%\\sysnative\\cmd.exe /c " + command;
14
+ try {
15
+ const parts = (await (0, execAsync_1.execAsync)(`${command} ${args}`)).stdout.split("REG_SZ");
16
+ if (parts.length === 2) return parts[1].trim();
17
+ } catch (e) {
18
+ api_1.diag.debug(`error reading machine id: ${e}`);
19
+ }
20
+ }
21
+ exports.getMachineId = getMachineId;
22
+ }));
23
+ //#endregion
24
+ export default require_getMachineId_win();
25
+ export {};
package/dist/index.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import { a as resolveAccessToken, n as ensureFreshAccessToken, o as resolveServerUrl, r as ensureFreshAdminToken } from "./bootstrap-8nCntTrK.mjs";
2
- import { A as stopPostgres, C as checkServerReachable, D as status, E as blank, F as SdkError, M as createOwner, N as hasUser, O as ensurePostgres, P as FirstTreeHubSDK, S as checkServerHealth, T as printResults, _ as checkClientConfig, a as uninstallClientService, b as checkNodeVersion, c as promptAddAgent, f as onboardCheck, g as checkAgentConfigs, h as runMigrations, i as resolveCliInvocation, j as ClientRuntime, k as isDockerAvailable, l as promptMissingFields, n as installClientService, o as startServer, p as onboardCreate, r as isServiceSupported, s as isInteractive, t as getClientServiceStatus, u as formatCheckReport, v as checkDatabase, w as checkWebSocket, x as checkServerConfig, y as checkDocker } from "./core-BA5U1v9L.mjs";
3
- import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-D9JkMZnU.mjs";
1
+ import "./logger-core-2yeIU1fc-B-__AsQO.mjs";
2
+ import { a as resolveAccessToken, n as ensureFreshAccessToken, o as resolveServerUrl, r as ensureFreshAdminToken } from "./bootstrap-99vUYmLs.mjs";
3
+ import "./observability-CJzDFY_G-CmvgUuzc.mjs";
4
+ import { A as stopPostgres, C as checkServerReachable, D as status, E as blank, F as SdkError, M as createOwner, N as hasUser, O as ensurePostgres, P as FirstTreeHubSDK, S as checkServerHealth, T as printResults, _ as checkClientConfig, a as uninstallClientService, b as checkNodeVersion, c as promptAddAgent, f as onboardCheck, g as checkAgentConfigs, h as runMigrations, i as resolveCliInvocation, j as ClientRuntime, k as isDockerAvailable, l as promptMissingFields, n as installClientService, o as startServer, p as onboardCreate, r as isServiceSupported, s as isInteractive, t as getClientServiceStatus, u as formatCheckReport, v as checkDatabase, w as checkWebSocket, x as checkServerConfig, y as checkDocker } from "./core-CNR-lUlr.mjs";
5
+ import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-BOISS0DK.mjs";
4
6
  export { ClientRuntime, FirstTreeHubSDK, SdkError, bindFeishuBot, bindFeishuUser, blank, checkAgentConfigs, checkClientConfig, checkDatabase, checkDocker, checkNodeVersion, checkServerConfig, checkServerHealth, checkServerReachable, checkWebSocket, createOwner, ensureFreshAccessToken, ensureFreshAdminToken, ensurePostgres, formatCheckReport, getClientServiceStatus, hasUser, installClientService, isDockerAvailable, isInteractive, isServiceSupported, onboardCheck, onboardCreate, printResults, promptAddAgent, promptMissingFields, resolveAccessToken, resolveCliInvocation, resolveServerUrl, runMigrations, startServer, status, stopPostgres, uninstallClientService };
@@ -0,0 +1,111 @@
1
+ import { z } from "zod";
2
+ import { Writable } from "node:stream";
3
+ //#region ../shared/dist/logger-core-2yeIU1fc.mjs
4
+ /**
5
+ * Logger core — format / level primitives shared between server and client.
6
+ *
7
+ * This module intentionally has no dependency on `pino` so it can live in
8
+ * `@agent-team-foundation/first-tree-hub-shared`. Consumers construct their
9
+ * own pino instance and pass the output stream built here.
10
+ */
11
+ const LOG_LEVELS = [
12
+ "trace",
13
+ "debug",
14
+ "info",
15
+ "warn",
16
+ "error",
17
+ "fatal"
18
+ ];
19
+ const LOG_FORMATS = ["pretty", "json"];
20
+ const logLevelSchema = z.enum(LOG_LEVELS);
21
+ const logFormatSchema = z.enum(LOG_FORMATS);
22
+ /**
23
+ * Parse an env-var / config string into a LogLevel. Unknown values fall back
24
+ * to `info` so the process never fails to boot on a typo — the caller is
25
+ * responsible for emitting a warning when `fellBack` is true.
26
+ */
27
+ function parseLogLevel(raw) {
28
+ if (!raw) return {
29
+ level: "info",
30
+ fellBack: false
31
+ };
32
+ const parsed = logLevelSchema.safeParse(raw);
33
+ if (parsed.success) return {
34
+ level: parsed.data,
35
+ fellBack: false
36
+ };
37
+ return {
38
+ level: "info",
39
+ fellBack: true
40
+ };
41
+ }
42
+ const LEVEL_LABELS = {
43
+ 10: "TRACE",
44
+ 20: "DEBUG",
45
+ 30: "INFO",
46
+ 40: "WARN",
47
+ 50: "ERROR",
48
+ 60: "FATAL"
49
+ };
50
+ const LEVEL_COLORS = {
51
+ 10: "\x1B[90m",
52
+ 20: "\x1B[36m",
53
+ 30: "\x1B[32m",
54
+ 40: "\x1B[33m",
55
+ 50: "\x1B[31m",
56
+ 60: "\x1B[35m"
57
+ };
58
+ const RESET = "\x1B[0m";
59
+ const DIM = "\x1B[2m";
60
+ const SKIP_KEYS = new Set([
61
+ "level",
62
+ "time",
63
+ "msg",
64
+ "module",
65
+ "pid",
66
+ "hostname",
67
+ "v"
68
+ ]);
69
+ function formatPrettyEntry(json) {
70
+ const obj = JSON.parse(json);
71
+ const level = obj.level;
72
+ const label = LEVEL_LABELS[level] ?? "???";
73
+ const color = LEVEL_COLORS[level] ?? "";
74
+ const time = obj.time ?? (/* @__PURE__ */ new Date()).toISOString();
75
+ const module = obj.module ? `[${String(obj.module)}] ` : "";
76
+ const msg = obj.msg ?? "";
77
+ const extras = [];
78
+ let errStack = "";
79
+ for (const [k, v] of Object.entries(obj)) {
80
+ if (SKIP_KEYS.has(k)) continue;
81
+ if (k === "err" && v && typeof v === "object") {
82
+ const e = v;
83
+ if (e.message) extras.push(`err.message=${String(e.message)}`);
84
+ if (typeof e.stack === "string") errStack = `\n${DIM}${e.stack}${RESET}`;
85
+ } else extras.push(`${k}=${typeof v === "string" ? v : JSON.stringify(v)}`);
86
+ }
87
+ const extraStr = extras.length > 0 ? ` ${DIM}${extras.join(" ")}${RESET}` : "";
88
+ return `${DIM}${time}${RESET} ${color}${label.padEnd(5)}${RESET} ${module}${msg}${extraStr}${errStack}\n`;
89
+ }
90
+ function formatLocalTime() {
91
+ const d = /* @__PURE__ */ new Date();
92
+ return `${d.toLocaleDateString("sv-SE")} ${d.toLocaleTimeString("en-GB", { hour12: false })}`;
93
+ }
94
+ function createLoggerOutputStream(options) {
95
+ return new Writable({ write(chunk, _, callback) {
96
+ const text = chunk.toString();
97
+ try {
98
+ if (options.getFormat() === "pretty") process.stdout.write(formatPrettyEntry(text));
99
+ else process.stdout.write(text);
100
+ if (options.onJsonEntry) try {
101
+ const obj = JSON.parse(text);
102
+ options.onJsonEntry(obj);
103
+ } catch {}
104
+ } catch {
105
+ process.stdout.write(text);
106
+ }
107
+ callback();
108
+ } });
109
+ }
110
+ //#endregion
111
+ export { logLevelSchema as a, logFormatSchema as i, createLoggerOutputStream as n, parseLogLevel as o, formatLocalTime as r, SKIP_KEYS as t };