@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.
Files changed (43) hide show
  1. package/dist/{bootstrap-DUeYbwm-.mjs → bootstrap-TJRy0B9m.mjs} +10 -2
  2. package/dist/chunk-BSw8zbkd.mjs +37 -0
  3. package/dist/cli/index.mjs +94 -35
  4. package/dist/client-BCaK653p-CZjDNcdM.mjs +516 -0
  5. package/dist/client-m1OM4Iag-HKWgB3Yk.mjs +4 -0
  6. package/dist/dist-BLY7Bu-l.mjs +430 -0
  7. package/dist/{dist-BoHl9HwW.mjs → dist-BkvrONSQ.mjs} +2 -22
  8. package/dist/drizzle/0031_drop_system_configs.sql +11 -0
  9. package/dist/drizzle/meta/_journal.json +7 -0
  10. package/dist/errors-BmyRwN0Y-CIZZ_sDc.mjs +92 -0
  11. package/dist/{esm-CYu4tXXn.mjs → esm-iadMkGbV.mjs} +2 -37
  12. package/dist/execAsync-CCyouKZM.mjs +10 -0
  13. package/dist/{execAsync-XMc-nFn-.mjs → execAsync-pImxPKN5.mjs} +1 -1
  14. package/dist/{feishu-Dxk6ArOK.mjs → feishu-AEMHwT6L.mjs} +2 -2
  15. package/dist/from-CaD373S1.mjs +3840 -0
  16. package/dist/{getMachineId-bsd-D0w3uAZa.mjs → getMachineId-bsd-DR4-Dysy.mjs} +3 -2
  17. package/dist/getMachineId-bsd-DjLgZlll.mjs +27 -0
  18. package/dist/getMachineId-darwin-B6WCAhc4.mjs +24 -0
  19. package/dist/{getMachineId-darwin-DOoYFb2_.mjs → getMachineId-darwin-CaD2juTg.mjs} +3 -2
  20. package/dist/getMachineId-linux-BeWHG1gK.mjs +20 -0
  21. package/dist/{getMachineId-linux-MlY63Zsw.mjs → getMachineId-linux-Dk3gWdQK.mjs} +2 -1
  22. package/dist/getMachineId-unsupported-BMJQItvF.mjs +15 -0
  23. package/dist/{getMachineId-unsupported-BS652RIy.mjs → getMachineId-unsupported-Bgz_Je1J.mjs} +2 -1
  24. package/dist/getMachineId-win-CdgcrzCW.mjs +26 -0
  25. package/dist/{getMachineId-win-B6hY8edq.mjs → getMachineId-win-vJ6VfDRI.mjs} +3 -2
  26. package/dist/index.mjs +9 -6
  27. package/dist/invitation-DWlyNb8x-DZTW9I26.mjs +4 -0
  28. package/dist/{invitation-B1pjAyOz-BaCA9PII.mjs → invitation-Dnn5gGGX-Ce7zbZpn.mjs} +4 -90
  29. package/dist/multipart-parser-BIksYTkk.mjs +294 -0
  30. package/dist/observability-C3nY6Jcz-Dpsi3eFk.mjs +96006 -0
  31. package/dist/observability-Co8OO0og.mjs +5 -0
  32. package/dist/{saas-connect-DLSyrQcC.mjs → saas-connect-Bd0g0v_b.mjs} +6442 -6923
  33. package/dist/src-DNBS5Yjj.mjs +735 -0
  34. package/dist/src-uVZSbShB.mjs +1176 -0
  35. package/dist/web/assets/{index-DDqPt6PI.css → index-7RvlJjJ9.css} +1 -1
  36. package/dist/web/assets/{index-COflQOwF.js → index-Dbwa40_B.js} +1 -1
  37. package/dist/web/assets/index-cpdSFHAJ.js +383 -0
  38. package/dist/web/index.html +2 -2
  39. package/package.json +1 -1
  40. package/dist/invitation-CBnQyB7o-TmnIj3kx.mjs +0 -3
  41. package/dist/observability-C08jUFsJ.mjs +0 -4
  42. package/dist/observability-DPyf745N-BSc8QNcR.mjs +0 -33897
  43. package/dist/web/assets/index-BxGzfDTS.js +0 -383
@@ -0,0 +1,430 @@
1
+ import { i as __require, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
2
+ import { t as require_src } from "./src-DNBS5Yjj.mjs";
3
+ //#region ../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js
4
+ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
5
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === void 0) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
9
+ enumerable: true,
10
+ get: function() {
11
+ return m[k];
12
+ }
13
+ };
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === void 0) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", {
21
+ enumerable: true,
22
+ value: v
23
+ });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = exports && exports.__importStar || function(mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) {
31
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
+ }
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.req = exports.json = exports.toBuffer = void 0;
38
+ const http$1 = __importStar(__require("http"));
39
+ const https = __importStar(__require("https"));
40
+ async function toBuffer(stream) {
41
+ let length = 0;
42
+ const chunks = [];
43
+ for await (const chunk of stream) {
44
+ length += chunk.length;
45
+ chunks.push(chunk);
46
+ }
47
+ return Buffer.concat(chunks, length);
48
+ }
49
+ exports.toBuffer = toBuffer;
50
+ async function json(stream) {
51
+ const str = (await toBuffer(stream)).toString("utf8");
52
+ try {
53
+ return JSON.parse(str);
54
+ } catch (_err) {
55
+ const err = _err;
56
+ err.message += ` (input: ${str})`;
57
+ throw err;
58
+ }
59
+ }
60
+ exports.json = json;
61
+ function req(url, opts = {}) {
62
+ const req = ((typeof url === "string" ? url : url.href).startsWith("https:") ? https : http$1).request(url, opts);
63
+ const promise = new Promise((resolve, reject) => {
64
+ req.once("response", resolve).once("error", reject).end();
65
+ });
66
+ req.then = promise.then.bind(promise);
67
+ return req;
68
+ }
69
+ exports.req = req;
70
+ }));
71
+ //#endregion
72
+ //#region ../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/index.js
73
+ var require_dist$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
74
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
75
+ if (k2 === void 0) k2 = k;
76
+ var desc = Object.getOwnPropertyDescriptor(m, k);
77
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
78
+ enumerable: true,
79
+ get: function() {
80
+ return m[k];
81
+ }
82
+ };
83
+ Object.defineProperty(o, k2, desc);
84
+ }) : (function(o, m, k, k2) {
85
+ if (k2 === void 0) k2 = k;
86
+ o[k2] = m[k];
87
+ }));
88
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
89
+ Object.defineProperty(o, "default", {
90
+ enumerable: true,
91
+ value: v
92
+ });
93
+ }) : function(o, v) {
94
+ o["default"] = v;
95
+ });
96
+ var __importStar = exports && exports.__importStar || function(mod) {
97
+ if (mod && mod.__esModule) return mod;
98
+ var result = {};
99
+ if (mod != null) {
100
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
101
+ }
102
+ __setModuleDefault(result, mod);
103
+ return result;
104
+ };
105
+ var __exportStar = exports && exports.__exportStar || function(m, exports$1) {
106
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
107
+ };
108
+ Object.defineProperty(exports, "__esModule", { value: true });
109
+ exports.Agent = void 0;
110
+ const net$1 = __importStar(__require("net"));
111
+ const http = __importStar(__require("http"));
112
+ const https_1 = __require("https");
113
+ __exportStar(require_helpers(), exports);
114
+ const INTERNAL = Symbol("AgentBaseInternalState");
115
+ var Agent = class extends http.Agent {
116
+ constructor(opts) {
117
+ super(opts);
118
+ this[INTERNAL] = {};
119
+ }
120
+ /**
121
+ * Determine whether this is an `http` or `https` request.
122
+ */
123
+ isSecureEndpoint(options) {
124
+ if (options) {
125
+ if (typeof options.secureEndpoint === "boolean") return options.secureEndpoint;
126
+ if (typeof options.protocol === "string") return options.protocol === "https:";
127
+ }
128
+ const { stack } = /* @__PURE__ */ new Error();
129
+ if (typeof stack !== "string") return false;
130
+ return stack.split("\n").some((l) => l.indexOf("(https.js:") !== -1 || l.indexOf("node:https:") !== -1);
131
+ }
132
+ incrementSockets(name) {
133
+ if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) return null;
134
+ if (!this.sockets[name]) this.sockets[name] = [];
135
+ const fakeSocket = new net$1.Socket({ writable: false });
136
+ this.sockets[name].push(fakeSocket);
137
+ this.totalSocketCount++;
138
+ return fakeSocket;
139
+ }
140
+ decrementSockets(name, socket) {
141
+ if (!this.sockets[name] || socket === null) return;
142
+ const sockets = this.sockets[name];
143
+ const index = sockets.indexOf(socket);
144
+ if (index !== -1) {
145
+ sockets.splice(index, 1);
146
+ this.totalSocketCount--;
147
+ if (sockets.length === 0) delete this.sockets[name];
148
+ }
149
+ }
150
+ getName(options) {
151
+ if (this.isSecureEndpoint(options)) return https_1.Agent.prototype.getName.call(this, options);
152
+ return super.getName(options);
153
+ }
154
+ createSocket(req, options, cb) {
155
+ const connectOpts = {
156
+ ...options,
157
+ secureEndpoint: this.isSecureEndpoint(options)
158
+ };
159
+ const name = this.getName(connectOpts);
160
+ const fakeSocket = this.incrementSockets(name);
161
+ Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => {
162
+ this.decrementSockets(name, fakeSocket);
163
+ if (socket instanceof http.Agent) try {
164
+ return socket.addRequest(req, connectOpts);
165
+ } catch (err) {
166
+ return cb(err);
167
+ }
168
+ this[INTERNAL].currentSocket = socket;
169
+ super.createSocket(req, options, cb);
170
+ }, (err) => {
171
+ this.decrementSockets(name, fakeSocket);
172
+ cb(err);
173
+ });
174
+ }
175
+ createConnection() {
176
+ const socket = this[INTERNAL].currentSocket;
177
+ this[INTERNAL].currentSocket = void 0;
178
+ if (!socket) throw new Error("No socket was returned in the `connect()` function");
179
+ return socket;
180
+ }
181
+ get defaultPort() {
182
+ return this[INTERNAL].defaultPort ?? (this.protocol === "https:" ? 443 : 80);
183
+ }
184
+ set defaultPort(v) {
185
+ if (this[INTERNAL]) this[INTERNAL].defaultPort = v;
186
+ }
187
+ get protocol() {
188
+ return this[INTERNAL].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:");
189
+ }
190
+ set protocol(v) {
191
+ if (this[INTERNAL]) this[INTERNAL].protocol = v;
192
+ }
193
+ };
194
+ exports.Agent = Agent;
195
+ }));
196
+ //#endregion
197
+ //#region ../../node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/parse-proxy-response.js
198
+ var require_parse_proxy_response = /* @__PURE__ */ __commonJSMin(((exports) => {
199
+ var __importDefault = exports && exports.__importDefault || function(mod) {
200
+ return mod && mod.__esModule ? mod : { "default": mod };
201
+ };
202
+ Object.defineProperty(exports, "__esModule", { value: true });
203
+ exports.parseProxyResponse = void 0;
204
+ const debug = (0, __importDefault(require_src()).default)("https-proxy-agent:parse-proxy-response");
205
+ function parseProxyResponse(socket) {
206
+ return new Promise((resolve, reject) => {
207
+ let buffersLength = 0;
208
+ const buffers = [];
209
+ function read() {
210
+ const b = socket.read();
211
+ if (b) ondata(b);
212
+ else socket.once("readable", read);
213
+ }
214
+ function cleanup() {
215
+ socket.removeListener("end", onend);
216
+ socket.removeListener("error", onerror);
217
+ socket.removeListener("readable", read);
218
+ }
219
+ function onend() {
220
+ cleanup();
221
+ debug("onend");
222
+ reject(/* @__PURE__ */ new Error("Proxy connection ended before receiving CONNECT response"));
223
+ }
224
+ function onerror(err) {
225
+ cleanup();
226
+ debug("onerror %o", err);
227
+ reject(err);
228
+ }
229
+ function ondata(b) {
230
+ buffers.push(b);
231
+ buffersLength += b.length;
232
+ const buffered = Buffer.concat(buffers, buffersLength);
233
+ const endOfHeaders = buffered.indexOf("\r\n\r\n");
234
+ if (endOfHeaders === -1) {
235
+ debug("have not received end of HTTP headers yet...");
236
+ read();
237
+ return;
238
+ }
239
+ const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split("\r\n");
240
+ const firstLine = headerParts.shift();
241
+ if (!firstLine) {
242
+ socket.destroy();
243
+ return reject(/* @__PURE__ */ new Error("No header received from proxy CONNECT response"));
244
+ }
245
+ const firstLineParts = firstLine.split(" ");
246
+ const statusCode = +firstLineParts[1];
247
+ const statusText = firstLineParts.slice(2).join(" ");
248
+ const headers = {};
249
+ for (const header of headerParts) {
250
+ if (!header) continue;
251
+ const firstColon = header.indexOf(":");
252
+ if (firstColon === -1) {
253
+ socket.destroy();
254
+ return reject(/* @__PURE__ */ new Error(`Invalid header from proxy CONNECT response: "${header}"`));
255
+ }
256
+ const key = header.slice(0, firstColon).toLowerCase();
257
+ const value = header.slice(firstColon + 1).trimStart();
258
+ const current = headers[key];
259
+ if (typeof current === "string") headers[key] = [current, value];
260
+ else if (Array.isArray(current)) current.push(value);
261
+ else headers[key] = value;
262
+ }
263
+ debug("got proxy server response: %o %o", firstLine, headers);
264
+ cleanup();
265
+ resolve({
266
+ connect: {
267
+ statusCode,
268
+ statusText,
269
+ headers
270
+ },
271
+ buffered
272
+ });
273
+ }
274
+ socket.on("error", onerror);
275
+ socket.on("end", onend);
276
+ read();
277
+ });
278
+ }
279
+ exports.parseProxyResponse = parseProxyResponse;
280
+ }));
281
+ //#endregion
282
+ //#region ../../node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js
283
+ var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
284
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
285
+ if (k2 === void 0) k2 = k;
286
+ var desc = Object.getOwnPropertyDescriptor(m, k);
287
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
288
+ enumerable: true,
289
+ get: function() {
290
+ return m[k];
291
+ }
292
+ };
293
+ Object.defineProperty(o, k2, desc);
294
+ }) : (function(o, m, k, k2) {
295
+ if (k2 === void 0) k2 = k;
296
+ o[k2] = m[k];
297
+ }));
298
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
299
+ Object.defineProperty(o, "default", {
300
+ enumerable: true,
301
+ value: v
302
+ });
303
+ }) : function(o, v) {
304
+ o["default"] = v;
305
+ });
306
+ var __importStar = exports && exports.__importStar || function(mod) {
307
+ if (mod && mod.__esModule) return mod;
308
+ var result = {};
309
+ if (mod != null) {
310
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
311
+ }
312
+ __setModuleDefault(result, mod);
313
+ return result;
314
+ };
315
+ var __importDefault = exports && exports.__importDefault || function(mod) {
316
+ return mod && mod.__esModule ? mod : { "default": mod };
317
+ };
318
+ Object.defineProperty(exports, "__esModule", { value: true });
319
+ exports.HttpsProxyAgent = void 0;
320
+ const net = __importStar(__require("net"));
321
+ const tls = __importStar(__require("tls"));
322
+ const assert_1 = __importDefault(__require("assert"));
323
+ const debug_1 = __importDefault(require_src());
324
+ const agent_base_1 = require_dist$1();
325
+ const url_1 = __require("url");
326
+ const parse_proxy_response_1 = require_parse_proxy_response();
327
+ const debug = (0, debug_1.default)("https-proxy-agent");
328
+ const setServernameFromNonIpHost = (options) => {
329
+ if (options.servername === void 0 && options.host && !net.isIP(options.host)) return {
330
+ ...options,
331
+ servername: options.host
332
+ };
333
+ return options;
334
+ };
335
+ /**
336
+ * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
337
+ * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
338
+ *
339
+ * Outgoing HTTP requests are first tunneled through the proxy server using the
340
+ * `CONNECT` HTTP request method to establish a connection to the proxy server,
341
+ * and then the proxy server connects to the destination target and issues the
342
+ * HTTP request from the proxy server.
343
+ *
344
+ * `https:` requests have their socket connection upgraded to TLS once
345
+ * the connection to the proxy server has been established.
346
+ */
347
+ var HttpsProxyAgent = class extends agent_base_1.Agent {
348
+ constructor(proxy, opts) {
349
+ super(opts);
350
+ this.options = { path: void 0 };
351
+ this.proxy = typeof proxy === "string" ? new url_1.URL(proxy) : proxy;
352
+ this.proxyHeaders = opts?.headers ?? {};
353
+ debug("Creating new HttpsProxyAgent instance: %o", this.proxy.href);
354
+ const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, "");
355
+ const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80;
356
+ this.connectOpts = {
357
+ ALPNProtocols: ["http/1.1"],
358
+ ...opts ? omit(opts, "headers") : null,
359
+ host,
360
+ port
361
+ };
362
+ }
363
+ /**
364
+ * Called when the node-core HTTP client library is creating a
365
+ * new HTTP request.
366
+ */
367
+ async connect(req, opts) {
368
+ const { proxy } = this;
369
+ if (!opts.host) throw new TypeError("No \"host\" provided");
370
+ let socket;
371
+ if (proxy.protocol === "https:") {
372
+ debug("Creating `tls.Socket`: %o", this.connectOpts);
373
+ socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
374
+ } else {
375
+ debug("Creating `net.Socket`: %o", this.connectOpts);
376
+ socket = net.connect(this.connectOpts);
377
+ }
378
+ const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
379
+ const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
380
+ let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
381
+ if (proxy.username || proxy.password) {
382
+ const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
383
+ headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`;
384
+ }
385
+ headers.Host = `${host}:${opts.port}`;
386
+ if (!headers["Proxy-Connection"]) headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close";
387
+ for (const name of Object.keys(headers)) payload += `${name}: ${headers[name]}\r\n`;
388
+ const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket);
389
+ socket.write(`${payload}\r\n`);
390
+ const { connect, buffered } = await proxyResponsePromise;
391
+ req.emit("proxyConnect", connect);
392
+ this.emit("proxyConnect", connect, req);
393
+ if (connect.statusCode === 200) {
394
+ req.once("socket", resume);
395
+ if (opts.secureEndpoint) {
396
+ debug("Upgrading socket connection to TLS");
397
+ return tls.connect({
398
+ ...omit(setServernameFromNonIpHost(opts), "host", "path", "port"),
399
+ socket
400
+ });
401
+ }
402
+ return socket;
403
+ }
404
+ socket.destroy();
405
+ const fakeSocket = new net.Socket({ writable: false });
406
+ fakeSocket.readable = true;
407
+ req.once("socket", (s) => {
408
+ debug("Replaying proxy buffer for failed request");
409
+ (0, assert_1.default)(s.listenerCount("data") > 0);
410
+ s.push(buffered);
411
+ s.push(null);
412
+ });
413
+ return fakeSocket;
414
+ }
415
+ };
416
+ HttpsProxyAgent.protocols = ["http", "https"];
417
+ exports.HttpsProxyAgent = HttpsProxyAgent;
418
+ function resume(socket) {
419
+ socket.resume();
420
+ }
421
+ function omit(obj, ...keys) {
422
+ const ret = {};
423
+ let key;
424
+ for (key in obj) if (!keys.includes(key)) ret[key] = obj[key];
425
+ return ret;
426
+ }
427
+ }));
428
+ //#endregion
429
+ export default require_dist();
430
+ export {};
@@ -956,8 +956,6 @@ const createOrgFromMeSchema = z.object({
956
956
  name: z.string().min(2).max(50).regex(/^[a-z0-9][a-z0-9-]*$/),
957
957
  displayName: z.string().min(1).max(200)
958
958
  });
959
- /** Body for `POST /auth/switch-org`. */
960
- const switchOrgSchema = z.object({ organizationId: z.string().min(1) });
961
959
  z.object({
962
960
  id: z.string(),
963
961
  organizationId: z.string(),
@@ -1045,7 +1043,7 @@ const githubDevCallbackQuerySchema = z.object({
1045
1043
  next: z.string().max(256).optional()
1046
1044
  });
1047
1045
  const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1048
- const createOrganizationSchema = z.object({
1046
+ z.object({
1049
1047
  name: z.string().min(2).max(50).regex(/^[a-z0-9][a-z0-9-]*$/, "Must start with a letter or digit and contain only lowercase alphanumeric and hyphens").refine((v) => !UUID_PATTERN.test(v), "Name must not be a UUID format"),
1050
1048
  displayName: z.string().min(1).max(200),
1051
1049
  maxAgents: z.number().int().min(0).default(0),
@@ -1200,24 +1198,6 @@ z.object({
1200
1198
  totalMessages: z.number(),
1201
1199
  byOrganization: z.array(orgStatsSchema)
1202
1200
  });
1203
- z.object({
1204
- key: z.string(),
1205
- value: z.unknown(),
1206
- updatedAt: z.string()
1207
- });
1208
- const updateSystemConfigSchema = z.record(z.string(), z.unknown());
1209
- const SYSTEM_CONFIG_KEYS = {
1210
- INBOX_TIMEOUT_SECONDS: "inbox_timeout_seconds",
1211
- MAX_RETRY_COUNT: "max_retry_count",
1212
- POLLING_INTERVAL_SECONDS: "polling_interval_seconds",
1213
- PRESENCE_CLEANUP_SECONDS: "presence_cleanup_seconds"
1214
- };
1215
- const SYSTEM_CONFIG_DEFAULTS = {
1216
- [SYSTEM_CONFIG_KEYS.INBOX_TIMEOUT_SECONDS]: 300,
1217
- [SYSTEM_CONFIG_KEYS.MAX_RETRY_COUNT]: 3,
1218
- [SYSTEM_CONFIG_KEYS.POLLING_INTERVAL_SECONDS]: 5,
1219
- [SYSTEM_CONFIG_KEYS.PRESENCE_CLEANUP_SECONDS]: 60
1220
- };
1221
1201
  /** Fixed 5-state machine. No custom statuses. */
1222
1202
  const TASK_STATUSES = {
1223
1203
  PENDING: "pending",
@@ -1389,4 +1369,4 @@ z.object({
1389
1369
  capabilities: serverCapabilitiesSchema.optional()
1390
1370
  }).passthrough();
1391
1371
  //#endregion
1392
- export { messageSourceSchema as $, createChatSchema as A, githubCallbackQuerySchema as B, agentTypeSchema as C, updateMemberSchema as Ct, createAdapterConfigSchema as D, wsAuthFrameSchema as Dt, connectTokenExchangeSchema as E, updateTaskStatusSchema as Et, createTaskSchema as F, inboxDeliverFrameSchema as G, githubStartQuerySchema as H, defaultRuntimeConfigPayload as I, isReservedAgentName as J, inboxPollQuerySchema as K, delegateFeishuUserSchema as L, createMemberSchema as M, createOrgFromMeSchema as N, createAdapterMappingSchema as O, createOrganizationSchema as P, loginSchema as Q, dryRunAgentRuntimeConfigSchema as R, agentRuntimeConfigPayloadSchema as S, updateClientCapabilitiesSchema as St, clientRegisterSchema as T, updateSystemConfigSchema as Tt, imageInlineContentSchema as U, githubDevCallbackQuerySchema as V, inboxAckFrameSchema as W, linkTaskChatSchema as X, joinByInvitationSchema as Y, listMeChatsQuerySchema as Z, addParticipantSchema as _, taskListQuerySchema as _t, AGENT_STATUSES as a, safeRedirectPath as at, agentBindRequestSchema as b, updateAgentSchema as bt, DEFAULT_RUNTIME_PROVIDER as c, sendMessageSchema as ct, TASK_CREATOR_TYPES as d, sessionEventMessageSchema as dt, notificationQuerySchema as et, TASK_HEALTH_SIGNALS as f, sessionEventSchema as ft, addMeChatParticipantsSchema as g, switchOrgSchema as gt, WS_AUTH_FRAME_TIMEOUT_MS as h, stripCode as ht, AGENT_SOURCES as i, runtimeStateMessageSchema as it, createMeChatSchema as j, createAgentSchema as k, MENTION_REGEX as l, sendToAgentSchema as lt, TASK_TERMINAL_STATUSES as m, sessionStateMessageSchema as mt, AGENT_NAME_REGEX as n, rebindAgentSchema as nt, AGENT_TYPES as o, scanMentionTokens as ot, TASK_STATUSES as p, sessionReconcileRequestSchema as pt, isRedactedEnvValue as q, AGENT_SELECTOR_HEADER as r, refreshTokenSchema as rt, AGENT_VISIBILITY as s, selfServiceFeishuBotSchema as st, AGENT_BIND_REJECT_REASONS as t, paginationQuerySchema as tt, SYSTEM_CONFIG_DEFAULTS as u, sessionCompletionMessageSchema as ut, adminCreateTaskSchema as v, updateAdapterConfigSchema as vt, clientCapabilitiesSchema as w, updateOrganizationSchema as wt, agentPinnedMessageSchema as x, updateChatSchema as xt, adminUpdateTaskSchema as y, updateAgentRuntimeConfigSchema as yt, extractMentions as z };
1372
+ export { paginationQuerySchema as $, createMeChatSchema as A, githubStartQuerySchema as B, clientCapabilitiesSchema as C, wsAuthFrameSchema as Ct, createAdapterMappingSchema as D, createAdapterConfigSchema as E, delegateFeishuUserSchema as F, isRedactedEnvValue as G, inboxAckFrameSchema as H, dryRunAgentRuntimeConfigSchema as I, linkTaskChatSchema as J, isReservedAgentName as K, extractMentions as L, createOrgFromMeSchema as M, createTaskSchema as N, createAgentSchema as O, defaultRuntimeConfigPayload as P, notificationQuerySchema as Q, githubCallbackQuerySchema as R, agentTypeSchema as S, updateTaskStatusSchema as St, connectTokenExchangeSchema as T, inboxDeliverFrameSchema as U, imageInlineContentSchema as V, inboxPollQuerySchema as W, loginSchema as X, listMeChatsQuerySchema as Y, messageSourceSchema as Z, adminCreateTaskSchema as _, updateAgentSchema as _t, AGENT_STATUSES as a, selfServiceFeishuBotSchema as at, agentPinnedMessageSchema as b, updateMemberSchema as bt, DEFAULT_RUNTIME_PROVIDER as c, sessionCompletionMessageSchema as ct, TASK_HEALTH_SIGNALS as d, sessionReconcileRequestSchema as dt, rebindAgentSchema as et, TASK_STATUSES as f, sessionStateMessageSchema as ft, addParticipantSchema as g, updateAgentRuntimeConfigSchema as gt, addMeChatParticipantsSchema as h, updateAdapterConfigSchema as ht, AGENT_SOURCES as i, scanMentionTokens as it, createMemberSchema as j, createChatSchema as k, MENTION_REGEX as l, sessionEventMessageSchema as lt, WS_AUTH_FRAME_TIMEOUT_MS as m, taskListQuerySchema as mt, AGENT_NAME_REGEX as n, runtimeStateMessageSchema as nt, AGENT_TYPES as o, sendMessageSchema as ot, TASK_TERMINAL_STATUSES as p, stripCode as pt, joinByInvitationSchema as q, AGENT_SELECTOR_HEADER as r, safeRedirectPath as rt, AGENT_VISIBILITY as s, sendToAgentSchema as st, AGENT_BIND_REJECT_REASONS as t, refreshTokenSchema as tt, TASK_CREATOR_TYPES as u, sessionEventSchema as ut, adminUpdateTaskSchema as v, updateChatSchema as vt, clientRegisterSchema as w, agentRuntimeConfigPayloadSchema as x, updateOrganizationSchema as xt, agentBindRequestSchema as y, updateClientCapabilitiesSchema as yt, githubDevCallbackQuerySchema as z };
@@ -0,0 +1,11 @@
1
+ -- Drop the `system_configs` table — replaced by deployment-level env
2
+ -- vars (FIRST_TREE_HUB_INBOX_TIMEOUT_SECONDS, FIRST_TREE_HUB_MAX_RETRY_COUNT,
3
+ -- FIRST_TREE_HUB_POLLING_INTERVAL_SECONDS, FIRST_TREE_HUB_PRESENCE_CLEANUP_SECONDS,
4
+ -- FIRST_TREE_HUB_NOTIFICATION_WEBHOOK_URL).
5
+ --
6
+ -- See proposals/hub-strip-jwt-ambient-scope.20260508.md §3.5 + §6.3.
7
+ -- The table held tunables that were never customer-configurable; promoting
8
+ -- them to env vars closes the multi-tenant security gap where any org admin
9
+ -- could mutate cross-org runtime behavior.
10
+
11
+ DROP TABLE IF EXISTS "system_configs";
@@ -218,6 +218,13 @@
218
218
  "when": 1777852800000,
219
219
  "tag": "0030_chat_first_workspace",
220
220
  "breakpoints": true
221
+ },
222
+ {
223
+ "idx": 31,
224
+ "version": "7",
225
+ "when": 1777939200000,
226
+ "tag": "0031_drop_system_configs",
227
+ "breakpoints": true
221
228
  }
222
229
  ]
223
230
  }
@@ -0,0 +1,92 @@
1
+ import { integer, jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";
2
+ //#region ../server/dist/errors-BmyRwN0Y.mjs
3
+ /** Organization entity. Agents and chats belong to exactly one organization. */
4
+ const organizations = pgTable("organizations", {
5
+ id: text("id").primaryKey(),
6
+ name: text("name").unique().notNull(),
7
+ displayName: text("display_name").notNull(),
8
+ maxAgents: integer("max_agents").notNull().default(0),
9
+ maxMessagesPerMinute: integer("max_messages_per_minute").notNull().default(0),
10
+ features: jsonb("features").$type().notNull().default({}),
11
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
12
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
13
+ });
14
+ /** User accounts. Passwords are stored as bcrypt hashes. */
15
+ const users = pgTable("users", {
16
+ id: text("id").primaryKey(),
17
+ username: text("username").unique().notNull(),
18
+ passwordHash: text("password_hash").notNull(),
19
+ displayName: text("display_name").notNull(),
20
+ avatarUrl: text("avatar_url"),
21
+ status: text("status").notNull().default("active"),
22
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
23
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
24
+ });
25
+ var AppError = class extends Error {
26
+ constructor(statusCode, message, attrs) {
27
+ super(message);
28
+ this.statusCode = statusCode;
29
+ this.attrs = attrs;
30
+ this.name = "AppError";
31
+ }
32
+ };
33
+ var NotFoundError = class extends AppError {
34
+ constructor(message = "Not found", attrs) {
35
+ super(404, message, attrs);
36
+ this.name = "NotFoundError";
37
+ }
38
+ };
39
+ var UnauthorizedError = class extends AppError {
40
+ constructor(message = "Unauthorized", attrs) {
41
+ super(401, message, attrs);
42
+ this.name = "UnauthorizedError";
43
+ }
44
+ };
45
+ var ForbiddenError = class extends AppError {
46
+ constructor(message = "Forbidden", attrs) {
47
+ super(403, message, attrs);
48
+ this.name = "ForbiddenError";
49
+ }
50
+ };
51
+ var ConflictError = class extends AppError {
52
+ constructor(message = "Conflict", attrs) {
53
+ super(409, message, attrs);
54
+ this.name = "ConflictError";
55
+ }
56
+ };
57
+ var BadRequestError = class extends AppError {
58
+ constructor(message = "Bad request", attrs) {
59
+ super(400, message, attrs);
60
+ this.name = "BadRequestError";
61
+ }
62
+ };
63
+ /**
64
+ * Thrown when an operation targets a client whose organization does not match
65
+ * the caller's authenticated organization. Retained for wire compatibility:
66
+ * the read paths that produced this error were retired in
67
+ * decouple-client-from-identity §4.1, so the server itself no longer raises
68
+ * it. SDK consumers may still pattern-match the `code` field on legacy
69
+ * payloads.
70
+ */
71
+ var ClientOrgMismatchError = class extends AppError {
72
+ code = "CLIENT_ORG_MISMATCH";
73
+ constructor(message = "Client belongs to a different organization", attrs) {
74
+ super(403, message, attrs);
75
+ this.name = "ClientOrgMismatchError";
76
+ }
77
+ };
78
+ /**
79
+ * Thrown when a client.yaml is presented with a JWT whose user_id does not
80
+ * match the row's owner. The CLI responds by guiding the operator through
81
+ * `first-tree-hub client claim --confirm` to take over ownership, which
82
+ * unpins the previous owner's agents from this machine.
83
+ */
84
+ var ClientUserMismatchError = class extends AppError {
85
+ code = "CLIENT_USER_MISMATCH";
86
+ constructor(message = "Client belongs to a different user", attrs) {
87
+ super(403, message, attrs);
88
+ this.name = "ClientUserMismatchError";
89
+ }
90
+ };
91
+ //#endregion
92
+ export { ConflictError as a, UnauthorizedError as c, ClientUserMismatchError as i, organizations as l, BadRequestError as n, ForbiddenError as o, ClientOrgMismatchError as r, NotFoundError as s, AppError as t, users as u };
@@ -1,39 +1,4 @@
1
- import { createRequire } from "node:module";
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
10
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
11
- var __exportAll = (all, no_symbols) => {
12
- let target = {};
13
- for (var name in all) __defProp(target, name, {
14
- get: all[name],
15
- enumerable: true
16
- });
17
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
18
- return target;
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
22
- key = keys[i];
23
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
24
- get: ((k) => from[k]).bind(null, key),
25
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
26
- });
27
- }
28
- return to;
29
- };
30
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
31
- value: mod,
32
- enumerable: true
33
- }) : target, mod));
34
- var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
36
- //#endregion
1
+ import { n as __esmMin, r as __exportAll } from "./chunk-BSw8zbkd.mjs";
37
2
  //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/version.js
38
3
  var VERSION;
39
4
  var init_version = __esmMin((() => {
@@ -1548,4 +1513,4 @@ var init_esm = __esmMin((() => {
1548
1513
  };
1549
1514
  }));
1550
1515
  //#endregion
1551
- export { diag as a, SpanKind as c, __exportAll as d, __require as f, propagation as i, __commonJSMin as l, __toESM as m, init_esm as n, context as o, __toCommonJS as p, trace as r, SpanStatusCode as s, esm_exports as t, __esmMin as u };
1516
+ export { metrics as a, SpanStatusCode as c, createContextKey as d, DiagLogLevel as f, propagation as i, SpanKind as l, init_esm as n, diag as o, trace as r, context as s, esm_exports as t, DiagConsoleLogger as u };
@@ -0,0 +1,10 @@
1
+ import { i as __require, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
2
+ //#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/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 { f as __require, l as __commonJSMin } from "./esm-CYu4tXXn.mjs";
1
+ import { i as __require, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
2
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
3
  var require_execAsync = /* @__PURE__ */ __commonJSMin(((exports) => {
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
- import { d as __exportAll } from "./esm-CYu4tXXn.mjs";
2
- import { r as AGENT_SELECTOR_HEADER } from "./dist-BoHl9HwW.mjs";
1
+ import { r as __exportAll } from "./chunk-BSw8zbkd.mjs";
2
+ import { r as AGENT_SELECTOR_HEADER } from "./dist-BkvrONSQ.mjs";
3
3
  //#region src/core/feishu.ts
4
4
  var feishu_exports = /* @__PURE__ */ __exportAll({
5
5
  bindFeishuBot: () => bindFeishuBot,