@agent-team-foundation/first-tree-hub 0.11.0 → 0.11.1
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/{bootstrap-DUeYbwm-.mjs → bootstrap-TJRy0B9m.mjs} +10 -2
- package/dist/chunk-BSw8zbkd.mjs +37 -0
- package/dist/cli/index.mjs +94 -35
- package/dist/client-BCaK653p-CZjDNcdM.mjs +516 -0
- package/dist/client-m1OM4Iag-HKWgB3Yk.mjs +4 -0
- package/dist/dist-BLY7Bu-l.mjs +430 -0
- package/dist/{dist-BoHl9HwW.mjs → dist-BkvrONSQ.mjs} +2 -22
- package/dist/drizzle/0031_drop_system_configs.sql +11 -0
- package/dist/drizzle/meta/_journal.json +7 -0
- package/dist/errors-BmyRwN0Y-CIZZ_sDc.mjs +92 -0
- package/dist/{esm-CYu4tXXn.mjs → esm-iadMkGbV.mjs} +2 -37
- package/dist/execAsync-CCyouKZM.mjs +10 -0
- package/dist/{execAsync-XMc-nFn-.mjs → execAsync-pImxPKN5.mjs} +1 -1
- package/dist/{feishu-Dxk6ArOK.mjs → feishu-AEMHwT6L.mjs} +2 -2
- package/dist/from-CaD373S1.mjs +3840 -0
- package/dist/{getMachineId-bsd-D0w3uAZa.mjs → getMachineId-bsd-DR4-Dysy.mjs} +3 -2
- package/dist/getMachineId-bsd-DjLgZlll.mjs +27 -0
- package/dist/getMachineId-darwin-B6WCAhc4.mjs +24 -0
- package/dist/{getMachineId-darwin-DOoYFb2_.mjs → getMachineId-darwin-CaD2juTg.mjs} +3 -2
- package/dist/getMachineId-linux-BeWHG1gK.mjs +20 -0
- package/dist/{getMachineId-linux-MlY63Zsw.mjs → getMachineId-linux-Dk3gWdQK.mjs} +2 -1
- package/dist/getMachineId-unsupported-BMJQItvF.mjs +15 -0
- package/dist/{getMachineId-unsupported-BS652RIy.mjs → getMachineId-unsupported-Bgz_Je1J.mjs} +2 -1
- package/dist/getMachineId-win-CdgcrzCW.mjs +26 -0
- package/dist/{getMachineId-win-B6hY8edq.mjs → getMachineId-win-vJ6VfDRI.mjs} +3 -2
- package/dist/index.mjs +9 -6
- package/dist/invitation-DWlyNb8x-DZTW9I26.mjs +4 -0
- package/dist/{invitation-B1pjAyOz-BaCA9PII.mjs → invitation-Dnn5gGGX-Ce7zbZpn.mjs} +4 -90
- package/dist/multipart-parser-BIksYTkk.mjs +294 -0
- package/dist/observability-C3nY6Jcz-Dpsi3eFk.mjs +96006 -0
- package/dist/observability-Co8OO0og.mjs +5 -0
- package/dist/{saas-connect-DLSyrQcC.mjs → saas-connect-Bd0g0v_b.mjs} +6442 -6923
- package/dist/src-DNBS5Yjj.mjs +735 -0
- package/dist/src-uVZSbShB.mjs +1176 -0
- package/dist/web/assets/{index-DDqPt6PI.css → index-7RvlJjJ9.css} +1 -1
- package/dist/web/assets/{index-COflQOwF.js → index-Dbwa40_B.js} +1 -1
- package/dist/web/assets/index-cpdSFHAJ.js +383 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/invitation-CBnQyB7o-TmnIj3kx.mjs +0 -3
- package/dist/observability-C08jUFsJ.mjs +0 -4
- package/dist/observability-DPyf745N-BSc8QNcR.mjs +0 -33897
- package/dist/web/assets/index-BxGzfDTS.js +0 -383
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
1
|
+
import { a as __toCommonJS, i as __require, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { n as init_esm, t as esm_exports } from "./esm-iadMkGbV.mjs";
|
|
3
|
+
import { t as require_execAsync } from "./execAsync-pImxPKN5.mjs";
|
|
3
4
|
//#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
5
|
var require_getMachineId_bsd = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { a as __toCommonJS, i as __require, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { n as init_esm, t as esm_exports } from "./esm-iadMkGbV.mjs";
|
|
3
|
+
import { t as require_execAsync } from "./execAsync-CCyouKZM.mjs";
|
|
4
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.1_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-bsd.js
|
|
5
|
+
var require_getMachineId_bsd = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getMachineId = void 0;
|
|
8
|
+
const fs_1 = __require("fs");
|
|
9
|
+
const execAsync_1 = require_execAsync();
|
|
10
|
+
const api_1 = (init_esm(), __toCommonJS(esm_exports));
|
|
11
|
+
async function getMachineId() {
|
|
12
|
+
try {
|
|
13
|
+
return (await fs_1.promises.readFile("/etc/hostid", { encoding: "utf8" })).trim();
|
|
14
|
+
} catch (e) {
|
|
15
|
+
api_1.diag.debug(`error reading machine id: ${e}`);
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
return (await (0, execAsync_1.execAsync)("kenv -q smbios.system.uuid")).stdout.trim();
|
|
19
|
+
} catch (e) {
|
|
20
|
+
api_1.diag.debug(`error reading machine id: ${e}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.getMachineId = getMachineId;
|
|
24
|
+
}));
|
|
25
|
+
//#endregion
|
|
26
|
+
export default require_getMachineId_bsd();
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { a as __toCommonJS, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { n as init_esm, t as esm_exports } from "./esm-iadMkGbV.mjs";
|
|
3
|
+
import { t as require_execAsync } from "./execAsync-CCyouKZM.mjs";
|
|
4
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.1_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-darwin.js
|
|
5
|
+
var require_getMachineId_darwin = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getMachineId = void 0;
|
|
8
|
+
const execAsync_1 = require_execAsync();
|
|
9
|
+
const api_1 = (init_esm(), __toCommonJS(esm_exports));
|
|
10
|
+
async function getMachineId() {
|
|
11
|
+
try {
|
|
12
|
+
const idLine = (await (0, execAsync_1.execAsync)("ioreg -rd1 -c \"IOPlatformExpertDevice\"")).stdout.split("\n").find((line) => line.includes("IOPlatformUUID"));
|
|
13
|
+
if (!idLine) return;
|
|
14
|
+
const parts = idLine.split("\" = \"");
|
|
15
|
+
if (parts.length === 2) return parts[1].slice(0, -1);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
api_1.diag.debug(`error reading machine id: ${e}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.getMachineId = getMachineId;
|
|
21
|
+
}));
|
|
22
|
+
//#endregion
|
|
23
|
+
export default require_getMachineId_darwin();
|
|
24
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
1
|
+
import { a as __toCommonJS, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { n as init_esm, t as esm_exports } from "./esm-iadMkGbV.mjs";
|
|
3
|
+
import { t as require_execAsync } from "./execAsync-pImxPKN5.mjs";
|
|
3
4
|
//#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
5
|
var require_getMachineId_darwin = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { a as __toCommonJS, i as __require, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { n as init_esm, t as esm_exports } from "./esm-iadMkGbV.mjs";
|
|
3
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.1_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-linux.js
|
|
4
|
+
var require_getMachineId_linux = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getMachineId = void 0;
|
|
7
|
+
const fs_1 = __require("fs");
|
|
8
|
+
const api_1 = (init_esm(), __toCommonJS(esm_exports));
|
|
9
|
+
async function getMachineId() {
|
|
10
|
+
for (const path of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) try {
|
|
11
|
+
return (await fs_1.promises.readFile(path, { encoding: "utf8" })).trim();
|
|
12
|
+
} catch (e) {
|
|
13
|
+
api_1.diag.debug(`error reading machine id: ${e}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.getMachineId = getMachineId;
|
|
17
|
+
}));
|
|
18
|
+
//#endregion
|
|
19
|
+
export default require_getMachineId_linux();
|
|
20
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as __toCommonJS, i as __require, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { n as init_esm, t as esm_exports } from "./esm-iadMkGbV.mjs";
|
|
2
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-linux.js
|
|
3
4
|
var require_getMachineId_linux = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { a as __toCommonJS, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { n as init_esm, t as esm_exports } from "./esm-iadMkGbV.mjs";
|
|
3
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.1_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-unsupported.js
|
|
4
|
+
var require_getMachineId_unsupported = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getMachineId = void 0;
|
|
7
|
+
const api_1 = (init_esm(), __toCommonJS(esm_exports));
|
|
8
|
+
async function getMachineId() {
|
|
9
|
+
api_1.diag.debug("could not read machine-id: unsupported platform");
|
|
10
|
+
}
|
|
11
|
+
exports.getMachineId = getMachineId;
|
|
12
|
+
}));
|
|
13
|
+
//#endregion
|
|
14
|
+
export default require_getMachineId_unsupported();
|
|
15
|
+
export {};
|
package/dist/{getMachineId-unsupported-BS652RIy.mjs → getMachineId-unsupported-Bgz_Je1J.mjs}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as __toCommonJS, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { n as init_esm, t as esm_exports } from "./esm-iadMkGbV.mjs";
|
|
2
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-unsupported.js
|
|
3
4
|
var require_getMachineId_unsupported = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { a as __toCommonJS, i as __require, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { n as init_esm, t as esm_exports } from "./esm-iadMkGbV.mjs";
|
|
3
|
+
import { t as require_execAsync } from "./execAsync-CCyouKZM.mjs";
|
|
4
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+resources@2.7.1_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-win.js
|
|
5
|
+
var require_getMachineId_win = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getMachineId = void 0;
|
|
8
|
+
const process = __require("process");
|
|
9
|
+
const execAsync_1 = require_execAsync();
|
|
10
|
+
const api_1 = (init_esm(), __toCommonJS(esm_exports));
|
|
11
|
+
async function getMachineId() {
|
|
12
|
+
const args = "QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
|
|
13
|
+
let command = "%windir%\\System32\\REG.exe";
|
|
14
|
+
if (process.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process.env) command = "%windir%\\sysnative\\cmd.exe /c " + command;
|
|
15
|
+
try {
|
|
16
|
+
const parts = (await (0, execAsync_1.execAsync)(`${command} ${args}`)).stdout.split("REG_SZ");
|
|
17
|
+
if (parts.length === 2) return parts[1].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_win();
|
|
26
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
1
|
+
import { a as __toCommonJS, i as __require, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { n as init_esm, t as esm_exports } from "./esm-iadMkGbV.mjs";
|
|
3
|
+
import { t as require_execAsync } from "./execAsync-pImxPKN5.mjs";
|
|
3
4
|
//#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
5
|
var require_getMachineId_win = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import "./observability-
|
|
2
|
-
import { A as checkDatabase, B as installClientService, C as runHomeMigration, D as checkAgentConfigs, E as runMigrations, F as checkServerReachable, G as stopClientService, H as resolveCliInvocation, I as checkWebSocket, J as isDockerAvailable, K as uninstallClientService, L as printResults, M as checkNodeVersion, N as checkServerConfig, P as checkServerHealth, Q as rotateClientIdWithBackup, U as restartClientService, V as isServiceSupported, W as startClientService, X as ClientRuntime, Y as stopPostgres, Z as handleClientOrgMismatch, _ as promptMissingFields, b as onboardCheck, d as startServer, g as promptAddAgent, h as isInteractive, j as checkDocker, k as checkClientConfig, mt as SdkError, n as deriveHubUrlFromToken, nt as createOwner, pt as FirstTreeHubSDK, q as ensurePostgres, rt as hasUser, st as blank, t as HubUrlDerivationError, ut as status, v as formatCheckReport, x as onboardCreate, z as getClientServiceStatus } from "./saas-connect-
|
|
1
|
+
import "./observability-C3nY6Jcz-Dpsi3eFk.mjs";
|
|
2
|
+
import { A as checkDatabase, B as installClientService, C as runHomeMigration, D as checkAgentConfigs, E as runMigrations, F as checkServerReachable, G as stopClientService, H as resolveCliInvocation, I as checkWebSocket, J as isDockerAvailable, K as uninstallClientService, L as printResults, M as checkNodeVersion, N as checkServerConfig, P as checkServerHealth, Q as rotateClientIdWithBackup, U as restartClientService, V as isServiceSupported, W as startClientService, X as ClientRuntime, Y as stopPostgres, Z as handleClientOrgMismatch, _ as promptMissingFields, b as onboardCheck, d as startServer, g as promptAddAgent, h as isInteractive, j as checkDocker, k as checkClientConfig, mt as SdkError, n as deriveHubUrlFromToken, nt as createOwner, pt as FirstTreeHubSDK, q as ensurePostgres, rt as hasUser, st as blank, t as HubUrlDerivationError, ut as status, v as formatCheckReport, x as onboardCreate, z as getClientServiceStatus } from "./saas-connect-Bd0g0v_b.mjs";
|
|
3
3
|
import "./logger-core-BTmvdflj-DjW8FM4T.mjs";
|
|
4
|
-
import { a as ensureFreshAdminToken, c as resolveServerUrl, i as ensureFreshAccessToken, n as AuthRefreshRateLimitedError, s as resolveAccessToken, t as AuthRefreshFailedError } from "./bootstrap-
|
|
5
|
-
import "./dist-
|
|
6
|
-
import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-
|
|
7
|
-
import "./
|
|
4
|
+
import { a as ensureFreshAdminToken, c as resolveServerUrl, i as ensureFreshAccessToken, n as AuthRefreshRateLimitedError, s as resolveAccessToken, t as AuthRefreshFailedError } from "./bootstrap-TJRy0B9m.mjs";
|
|
5
|
+
import "./dist-BkvrONSQ.mjs";
|
|
6
|
+
import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-AEMHwT6L.mjs";
|
|
7
|
+
import "./errors-BmyRwN0Y-CIZZ_sDc.mjs";
|
|
8
|
+
import "./client-BCaK653p-CZjDNcdM.mjs";
|
|
9
|
+
import "./src-DNBS5Yjj.mjs";
|
|
10
|
+
import "./invitation-Dnn5gGGX-Ce7zbZpn.mjs";
|
|
8
11
|
export { AuthRefreshFailedError, AuthRefreshRateLimitedError, ClientRuntime, FirstTreeHubSDK, HubUrlDerivationError, SdkError, bindFeishuBot, bindFeishuUser, blank, checkAgentConfigs, checkClientConfig, checkDatabase, checkDocker, checkNodeVersion, checkServerConfig, checkServerHealth, checkServerReachable, checkWebSocket, createOwner, deriveHubUrlFromToken, ensureFreshAccessToken, ensureFreshAdminToken, ensurePostgres, formatCheckReport, getClientServiceStatus, handleClientOrgMismatch, hasUser, installClientService, isDockerAvailable, isInteractive, isServiceSupported, onboardCheck, onboardCreate, printResults, promptAddAgent, promptMissingFields, resolveAccessToken, resolveCliInvocation, resolveServerUrl, restartClientService, rotateClientIdWithBackup, runHomeMigration, runMigrations, startClientService, startServer, status, stopClientService, stopPostgres, uninstallClientService };
|
|
@@ -1,94 +1,8 @@
|
|
|
1
|
+
import { l as organizations, s as NotFoundError, u as users } from "./errors-BmyRwN0Y-CIZZ_sDc.mjs";
|
|
1
2
|
import { randomBytes } from "node:crypto";
|
|
2
3
|
import { and, desc, eq, gt, isNull, or } from "drizzle-orm";
|
|
3
|
-
import { index,
|
|
4
|
-
//#region ../server/dist/invitation-
|
|
5
|
-
/** Organization entity. Agents and chats belong to exactly one organization. */
|
|
6
|
-
const organizations = pgTable("organizations", {
|
|
7
|
-
id: text("id").primaryKey(),
|
|
8
|
-
name: text("name").unique().notNull(),
|
|
9
|
-
displayName: text("display_name").notNull(),
|
|
10
|
-
maxAgents: integer("max_agents").notNull().default(0),
|
|
11
|
-
maxMessagesPerMinute: integer("max_messages_per_minute").notNull().default(0),
|
|
12
|
-
features: jsonb("features").$type().notNull().default({}),
|
|
13
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
14
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
15
|
-
});
|
|
16
|
-
/** User accounts. Passwords are stored as bcrypt hashes. */
|
|
17
|
-
const users = pgTable("users", {
|
|
18
|
-
id: text("id").primaryKey(),
|
|
19
|
-
username: text("username").unique().notNull(),
|
|
20
|
-
passwordHash: text("password_hash").notNull(),
|
|
21
|
-
displayName: text("display_name").notNull(),
|
|
22
|
-
avatarUrl: text("avatar_url"),
|
|
23
|
-
status: text("status").notNull().default("active"),
|
|
24
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
26
|
-
});
|
|
27
|
-
var AppError = class extends Error {
|
|
28
|
-
constructor(statusCode, message) {
|
|
29
|
-
super(message);
|
|
30
|
-
this.statusCode = statusCode;
|
|
31
|
-
this.name = "AppError";
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
var NotFoundError = class extends AppError {
|
|
35
|
-
constructor(message = "Not found") {
|
|
36
|
-
super(404, message);
|
|
37
|
-
this.name = "NotFoundError";
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var UnauthorizedError = class extends AppError {
|
|
41
|
-
constructor(message = "Unauthorized") {
|
|
42
|
-
super(401, message);
|
|
43
|
-
this.name = "UnauthorizedError";
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
var ForbiddenError = class extends AppError {
|
|
47
|
-
constructor(message = "Forbidden") {
|
|
48
|
-
super(403, message);
|
|
49
|
-
this.name = "ForbiddenError";
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var ConflictError = class extends AppError {
|
|
53
|
-
constructor(message = "Conflict") {
|
|
54
|
-
super(409, message);
|
|
55
|
-
this.name = "ConflictError";
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
var BadRequestError = class extends AppError {
|
|
59
|
-
constructor(message = "Bad request") {
|
|
60
|
-
super(400, message);
|
|
61
|
-
this.name = "BadRequestError";
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Thrown when an operation targets a client whose organization does not match
|
|
66
|
-
* the caller's authenticated organization. Retained for wire compatibility:
|
|
67
|
-
* the read paths that produced this error were retired in
|
|
68
|
-
* decouple-client-from-identity §4.1, so the server itself no longer raises
|
|
69
|
-
* it. SDK consumers may still pattern-match the `code` field on legacy
|
|
70
|
-
* payloads.
|
|
71
|
-
*/
|
|
72
|
-
var ClientOrgMismatchError = class extends AppError {
|
|
73
|
-
code = "CLIENT_ORG_MISMATCH";
|
|
74
|
-
constructor(message = "Client belongs to a different organization") {
|
|
75
|
-
super(403, message);
|
|
76
|
-
this.name = "ClientOrgMismatchError";
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Thrown when a client.yaml is presented with a JWT whose user_id does not
|
|
81
|
-
* match the row's owner. The CLI responds by guiding the operator through
|
|
82
|
-
* `first-tree-hub client claim --confirm` to take over ownership, which
|
|
83
|
-
* unpins the previous owner's agents from this machine.
|
|
84
|
-
*/
|
|
85
|
-
var ClientUserMismatchError = class extends AppError {
|
|
86
|
-
code = "CLIENT_USER_MISMATCH";
|
|
87
|
-
constructor(message = "Client belongs to a different user") {
|
|
88
|
-
super(403, message);
|
|
89
|
-
this.name = "ClientUserMismatchError";
|
|
90
|
-
}
|
|
91
|
-
};
|
|
4
|
+
import { index, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
5
|
+
//#region ../server/dist/invitation-Dnn5gGGX.mjs
|
|
92
6
|
/** Generate a UUID v7 (time-ordered). No external dependency. */
|
|
93
7
|
function uuidv7() {
|
|
94
8
|
const now = BigInt(Date.now());
|
|
@@ -270,4 +184,4 @@ function buildInviteUrl(publicUrl, token) {
|
|
|
270
184
|
return `${publicUrl.replace(/\/+$/, "")}/invite/${token}`;
|
|
271
185
|
}
|
|
272
186
|
//#endregion
|
|
273
|
-
export {
|
|
187
|
+
export { invitationRedemptions as a, recordRedemption as c, getActiveInvitation as i, rotateInvitation as l, ensureActiveInvitation as n, invitations as o, findActiveByToken as r, previewInvitation as s, buildInviteUrl as t, uuidv7 as u };
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { n as __esmMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import { a as File, i as init_esm_min, n as FormData, t as init_from } from "./from-CaD373S1.mjs";
|
|
3
|
+
//#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/multipart-parser.js
|
|
4
|
+
function _fileName(headerValue) {
|
|
5
|
+
const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
|
|
6
|
+
if (!m) return;
|
|
7
|
+
const match = m[2] || m[3] || "";
|
|
8
|
+
let filename = match.slice(match.lastIndexOf("\\") + 1);
|
|
9
|
+
filename = filename.replace(/%22/g, "\"");
|
|
10
|
+
filename = filename.replace(/&#(\d{4});/g, (m, code) => {
|
|
11
|
+
return String.fromCharCode(code);
|
|
12
|
+
});
|
|
13
|
+
return filename;
|
|
14
|
+
}
|
|
15
|
+
async function toFormData(Body, ct) {
|
|
16
|
+
if (!/multipart/i.test(ct)) throw new TypeError("Failed to fetch");
|
|
17
|
+
const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
|
18
|
+
if (!m) throw new TypeError("no or bad content-type header, no multipart boundary");
|
|
19
|
+
const parser = new MultipartParser(m[1] || m[2]);
|
|
20
|
+
let headerField;
|
|
21
|
+
let headerValue;
|
|
22
|
+
let entryValue;
|
|
23
|
+
let entryName;
|
|
24
|
+
let contentType;
|
|
25
|
+
let filename;
|
|
26
|
+
const entryChunks = [];
|
|
27
|
+
const formData = new FormData();
|
|
28
|
+
const onPartData = (ui8a) => {
|
|
29
|
+
entryValue += decoder.decode(ui8a, { stream: true });
|
|
30
|
+
};
|
|
31
|
+
const appendToFile = (ui8a) => {
|
|
32
|
+
entryChunks.push(ui8a);
|
|
33
|
+
};
|
|
34
|
+
const appendFileToFormData = () => {
|
|
35
|
+
const file = new File(entryChunks, filename, { type: contentType });
|
|
36
|
+
formData.append(entryName, file);
|
|
37
|
+
};
|
|
38
|
+
const appendEntryToFormData = () => {
|
|
39
|
+
formData.append(entryName, entryValue);
|
|
40
|
+
};
|
|
41
|
+
const decoder = new TextDecoder("utf-8");
|
|
42
|
+
decoder.decode();
|
|
43
|
+
parser.onPartBegin = function() {
|
|
44
|
+
parser.onPartData = onPartData;
|
|
45
|
+
parser.onPartEnd = appendEntryToFormData;
|
|
46
|
+
headerField = "";
|
|
47
|
+
headerValue = "";
|
|
48
|
+
entryValue = "";
|
|
49
|
+
entryName = "";
|
|
50
|
+
contentType = "";
|
|
51
|
+
filename = null;
|
|
52
|
+
entryChunks.length = 0;
|
|
53
|
+
};
|
|
54
|
+
parser.onHeaderField = function(ui8a) {
|
|
55
|
+
headerField += decoder.decode(ui8a, { stream: true });
|
|
56
|
+
};
|
|
57
|
+
parser.onHeaderValue = function(ui8a) {
|
|
58
|
+
headerValue += decoder.decode(ui8a, { stream: true });
|
|
59
|
+
};
|
|
60
|
+
parser.onHeaderEnd = function() {
|
|
61
|
+
headerValue += decoder.decode();
|
|
62
|
+
headerField = headerField.toLowerCase();
|
|
63
|
+
if (headerField === "content-disposition") {
|
|
64
|
+
const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
|
|
65
|
+
if (m) entryName = m[2] || m[3] || "";
|
|
66
|
+
filename = _fileName(headerValue);
|
|
67
|
+
if (filename) {
|
|
68
|
+
parser.onPartData = appendToFile;
|
|
69
|
+
parser.onPartEnd = appendFileToFormData;
|
|
70
|
+
}
|
|
71
|
+
} else if (headerField === "content-type") contentType = headerValue;
|
|
72
|
+
headerValue = "";
|
|
73
|
+
headerField = "";
|
|
74
|
+
};
|
|
75
|
+
for await (const chunk of Body) parser.write(chunk);
|
|
76
|
+
parser.end();
|
|
77
|
+
return formData;
|
|
78
|
+
}
|
|
79
|
+
var s, S, f, F, LF, CR, SPACE, HYPHEN, COLON, A, Z, lower, noop, MultipartParser;
|
|
80
|
+
//#endregion
|
|
81
|
+
__esmMin((() => {
|
|
82
|
+
init_from();
|
|
83
|
+
init_esm_min();
|
|
84
|
+
s = 0;
|
|
85
|
+
S = {
|
|
86
|
+
START_BOUNDARY: s++,
|
|
87
|
+
HEADER_FIELD_START: s++,
|
|
88
|
+
HEADER_FIELD: s++,
|
|
89
|
+
HEADER_VALUE_START: s++,
|
|
90
|
+
HEADER_VALUE: s++,
|
|
91
|
+
HEADER_VALUE_ALMOST_DONE: s++,
|
|
92
|
+
HEADERS_ALMOST_DONE: s++,
|
|
93
|
+
PART_DATA_START: s++,
|
|
94
|
+
PART_DATA: s++,
|
|
95
|
+
END: s++
|
|
96
|
+
};
|
|
97
|
+
f = 1;
|
|
98
|
+
F = {
|
|
99
|
+
PART_BOUNDARY: f,
|
|
100
|
+
LAST_BOUNDARY: f *= 2
|
|
101
|
+
};
|
|
102
|
+
LF = 10;
|
|
103
|
+
CR = 13;
|
|
104
|
+
SPACE = 32;
|
|
105
|
+
HYPHEN = 45;
|
|
106
|
+
COLON = 58;
|
|
107
|
+
A = 97;
|
|
108
|
+
Z = 122;
|
|
109
|
+
lower = (c) => c | 32;
|
|
110
|
+
noop = () => {};
|
|
111
|
+
MultipartParser = class {
|
|
112
|
+
/**
|
|
113
|
+
* @param {string} boundary
|
|
114
|
+
*/
|
|
115
|
+
constructor(boundary) {
|
|
116
|
+
this.index = 0;
|
|
117
|
+
this.flags = 0;
|
|
118
|
+
this.onHeaderEnd = noop;
|
|
119
|
+
this.onHeaderField = noop;
|
|
120
|
+
this.onHeadersEnd = noop;
|
|
121
|
+
this.onHeaderValue = noop;
|
|
122
|
+
this.onPartBegin = noop;
|
|
123
|
+
this.onPartData = noop;
|
|
124
|
+
this.onPartEnd = noop;
|
|
125
|
+
this.boundaryChars = {};
|
|
126
|
+
boundary = "\r\n--" + boundary;
|
|
127
|
+
const ui8a = new Uint8Array(boundary.length);
|
|
128
|
+
for (let i = 0; i < boundary.length; i++) {
|
|
129
|
+
ui8a[i] = boundary.charCodeAt(i);
|
|
130
|
+
this.boundaryChars[ui8a[i]] = true;
|
|
131
|
+
}
|
|
132
|
+
this.boundary = ui8a;
|
|
133
|
+
this.lookbehind = new Uint8Array(this.boundary.length + 8);
|
|
134
|
+
this.state = S.START_BOUNDARY;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @param {Uint8Array} data
|
|
138
|
+
*/
|
|
139
|
+
write(data) {
|
|
140
|
+
let i = 0;
|
|
141
|
+
const length_ = data.length;
|
|
142
|
+
let previousIndex = this.index;
|
|
143
|
+
let { lookbehind, boundary, boundaryChars, index, state, flags } = this;
|
|
144
|
+
const boundaryLength = this.boundary.length;
|
|
145
|
+
const boundaryEnd = boundaryLength - 1;
|
|
146
|
+
const bufferLength = data.length;
|
|
147
|
+
let c;
|
|
148
|
+
let cl;
|
|
149
|
+
const mark = (name) => {
|
|
150
|
+
this[name + "Mark"] = i;
|
|
151
|
+
};
|
|
152
|
+
const clear = (name) => {
|
|
153
|
+
delete this[name + "Mark"];
|
|
154
|
+
};
|
|
155
|
+
const callback = (callbackSymbol, start, end, ui8a) => {
|
|
156
|
+
if (start === void 0 || start !== end) this[callbackSymbol](ui8a && ui8a.subarray(start, end));
|
|
157
|
+
};
|
|
158
|
+
const dataCallback = (name, clear) => {
|
|
159
|
+
const markSymbol = name + "Mark";
|
|
160
|
+
if (!(markSymbol in this)) return;
|
|
161
|
+
if (clear) {
|
|
162
|
+
callback(name, this[markSymbol], i, data);
|
|
163
|
+
delete this[markSymbol];
|
|
164
|
+
} else {
|
|
165
|
+
callback(name, this[markSymbol], data.length, data);
|
|
166
|
+
this[markSymbol] = 0;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
for (i = 0; i < length_; i++) {
|
|
170
|
+
c = data[i];
|
|
171
|
+
switch (state) {
|
|
172
|
+
case S.START_BOUNDARY:
|
|
173
|
+
if (index === boundary.length - 2) {
|
|
174
|
+
if (c === HYPHEN) flags |= F.LAST_BOUNDARY;
|
|
175
|
+
else if (c !== CR) return;
|
|
176
|
+
index++;
|
|
177
|
+
break;
|
|
178
|
+
} else if (index - 1 === boundary.length - 2) {
|
|
179
|
+
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
|
|
180
|
+
state = S.END;
|
|
181
|
+
flags = 0;
|
|
182
|
+
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
|
|
183
|
+
index = 0;
|
|
184
|
+
callback("onPartBegin");
|
|
185
|
+
state = S.HEADER_FIELD_START;
|
|
186
|
+
} else return;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
if (c !== boundary[index + 2]) index = -2;
|
|
190
|
+
if (c === boundary[index + 2]) index++;
|
|
191
|
+
break;
|
|
192
|
+
case S.HEADER_FIELD_START:
|
|
193
|
+
state = S.HEADER_FIELD;
|
|
194
|
+
mark("onHeaderField");
|
|
195
|
+
index = 0;
|
|
196
|
+
case S.HEADER_FIELD:
|
|
197
|
+
if (c === CR) {
|
|
198
|
+
clear("onHeaderField");
|
|
199
|
+
state = S.HEADERS_ALMOST_DONE;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
index++;
|
|
203
|
+
if (c === HYPHEN) break;
|
|
204
|
+
if (c === COLON) {
|
|
205
|
+
if (index === 1) return;
|
|
206
|
+
dataCallback("onHeaderField", true);
|
|
207
|
+
state = S.HEADER_VALUE_START;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
cl = lower(c);
|
|
211
|
+
if (cl < A || cl > Z) return;
|
|
212
|
+
break;
|
|
213
|
+
case S.HEADER_VALUE_START:
|
|
214
|
+
if (c === SPACE) break;
|
|
215
|
+
mark("onHeaderValue");
|
|
216
|
+
state = S.HEADER_VALUE;
|
|
217
|
+
case S.HEADER_VALUE:
|
|
218
|
+
if (c === CR) {
|
|
219
|
+
dataCallback("onHeaderValue", true);
|
|
220
|
+
callback("onHeaderEnd");
|
|
221
|
+
state = S.HEADER_VALUE_ALMOST_DONE;
|
|
222
|
+
}
|
|
223
|
+
break;
|
|
224
|
+
case S.HEADER_VALUE_ALMOST_DONE:
|
|
225
|
+
if (c !== LF) return;
|
|
226
|
+
state = S.HEADER_FIELD_START;
|
|
227
|
+
break;
|
|
228
|
+
case S.HEADERS_ALMOST_DONE:
|
|
229
|
+
if (c !== LF) return;
|
|
230
|
+
callback("onHeadersEnd");
|
|
231
|
+
state = S.PART_DATA_START;
|
|
232
|
+
break;
|
|
233
|
+
case S.PART_DATA_START:
|
|
234
|
+
state = S.PART_DATA;
|
|
235
|
+
mark("onPartData");
|
|
236
|
+
case S.PART_DATA:
|
|
237
|
+
previousIndex = index;
|
|
238
|
+
if (index === 0) {
|
|
239
|
+
i += boundaryEnd;
|
|
240
|
+
while (i < bufferLength && !(data[i] in boundaryChars)) i += boundaryLength;
|
|
241
|
+
i -= boundaryEnd;
|
|
242
|
+
c = data[i];
|
|
243
|
+
}
|
|
244
|
+
if (index < boundary.length) if (boundary[index] === c) {
|
|
245
|
+
if (index === 0) dataCallback("onPartData", true);
|
|
246
|
+
index++;
|
|
247
|
+
} else index = 0;
|
|
248
|
+
else if (index === boundary.length) {
|
|
249
|
+
index++;
|
|
250
|
+
if (c === CR) flags |= F.PART_BOUNDARY;
|
|
251
|
+
else if (c === HYPHEN) flags |= F.LAST_BOUNDARY;
|
|
252
|
+
else index = 0;
|
|
253
|
+
} else if (index - 1 === boundary.length) if (flags & F.PART_BOUNDARY) {
|
|
254
|
+
index = 0;
|
|
255
|
+
if (c === LF) {
|
|
256
|
+
flags &= ~F.PART_BOUNDARY;
|
|
257
|
+
callback("onPartEnd");
|
|
258
|
+
callback("onPartBegin");
|
|
259
|
+
state = S.HEADER_FIELD_START;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
} else if (flags & F.LAST_BOUNDARY) if (c === HYPHEN) {
|
|
263
|
+
callback("onPartEnd");
|
|
264
|
+
state = S.END;
|
|
265
|
+
flags = 0;
|
|
266
|
+
} else index = 0;
|
|
267
|
+
else index = 0;
|
|
268
|
+
if (index > 0) lookbehind[index - 1] = c;
|
|
269
|
+
else if (previousIndex > 0) {
|
|
270
|
+
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
|
|
271
|
+
callback("onPartData", 0, previousIndex, _lookbehind);
|
|
272
|
+
previousIndex = 0;
|
|
273
|
+
mark("onPartData");
|
|
274
|
+
i--;
|
|
275
|
+
}
|
|
276
|
+
break;
|
|
277
|
+
case S.END: break;
|
|
278
|
+
default: throw new Error(`Unexpected state entered: ${state}`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
dataCallback("onHeaderField");
|
|
282
|
+
dataCallback("onHeaderValue");
|
|
283
|
+
dataCallback("onPartData");
|
|
284
|
+
this.index = index;
|
|
285
|
+
this.state = state;
|
|
286
|
+
this.flags = flags;
|
|
287
|
+
}
|
|
288
|
+
end() {
|
|
289
|
+
if (this.state === S.HEADER_FIELD_START && this.index === 0 || this.state === S.PART_DATA && this.index === this.boundary.length) this.onPartEnd();
|
|
290
|
+
else if (this.state !== S.END) throw new Error("MultipartParser.end(): stream ended unexpectedly");
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}))();
|
|
294
|
+
export { toFormData };
|