@agent-team-foundation/first-tree-hub 0.10.3 → 0.10.5

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.
@@ -590,6 +590,7 @@ const serverConfigSchema = defineConfig({
590
590
  loginMax: field(z.number().default(5), { env: "FIRST_TREE_HUB_RATE_LIMIT_LOGIN_MAX" }),
591
591
  webhookMax: field(z.number().default(60), { env: "FIRST_TREE_HUB_RATE_LIMIT_WEBHOOK_MAX" })
592
592
  }),
593
+ inbox: optional({ maxInFlightPerAgent: field(z.number().int().min(1).max(1024).default(32), { env: "FIRST_TREE_HUB_INBOX_MAX_IN_FLIGHT_PER_AGENT" }) }),
593
594
  kael: optional({
594
595
  endpoint: field(z.string(), { env: "KAEL_ENDPOINT" }),
595
596
  apiKey: field(z.string(), {
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import "../observability-DPyf745N-BSc8QNcR.mjs";
3
- import { A as checkServerHealth, C as checkAgentConfigs, D as checkDocker, E as checkDatabase, F as installClientService, G as createOwner, H as ClientRuntime, I as isServiceSupported, J as fail, M as checkWebSocket, N as printResults, O as checkNodeVersion, P as getClientServiceStatus, Q as setJsonMode, S as runMigrations, T as checkClientConfig, U as handleClientOrgMismatch, V as stopPostgres, Y as success, Z as print, _ as onboardCreate, a as declineUpdate, at as probeCapabilities, b as createApiNameResolver, c as COMMAND_VERSION, d as isInteractive, et as ClientOrgMismatchError, f as promptAddAgent, g as onboardCheck, h as loadOnboardState, i as createExecuteUpdate, it as cleanWorkspaces, j as checkServerReachable, k as checkServerConfig, l as reconcileLocalRuntimeProviders, m as formatCheckReport, nt as SdkError, o as promptUpdate, ot as applyClientLoggerConfig, p as promptMissingFields, q as resolveReplyToFromEnv, r as registerSaaSConnectCommand, rt as SessionRegistry, s as startServer, st as configureClientLoggerForService, tt as FirstTreeHubSDK, u as uploadClientCapabilities, v as saveOnboardState, w as checkBackgroundService, x as migrateLocalAgentDirs, y as runHomeMigration } from "../saas-connect-3p-vBkuY.mjs";
3
+ import { A as checkServerHealth, C as checkAgentConfigs, D as checkDocker, E as checkDatabase, F as installClientService, G as createOwner, H as ClientRuntime, I as isServiceSupported, J as fail, M as checkWebSocket, N as printResults, O as checkNodeVersion, P as getClientServiceStatus, Q as setJsonMode, S as runMigrations, T as checkClientConfig, U as handleClientOrgMismatch, V as stopPostgres, Y as success, Z as print, _ as onboardCreate, a as declineUpdate, at as probeCapabilities, b as createApiNameResolver, c as COMMAND_VERSION, d as isInteractive, et as ClientOrgMismatchError, f as promptAddAgent, g as onboardCheck, h as loadOnboardState, i as createExecuteUpdate, it as cleanWorkspaces, j as checkServerReachable, k as checkServerConfig, l as reconcileLocalRuntimeProviders, m as formatCheckReport, nt as SdkError, o as promptUpdate, ot as applyClientLoggerConfig, p as promptMissingFields, q as resolveReplyToFromEnv, r as registerSaaSConnectCommand, rt as SessionRegistry, s as startServer, st as configureClientLoggerForService, tt as FirstTreeHubSDK, u as uploadClientCapabilities, v as saveOnboardState, w as checkBackgroundService, x as migrateLocalAgentDirs, y as runHomeMigration } from "../saas-connect-2puW1r3r.mjs";
4
4
  import "../logger-core-BTmvdflj-DjW8FM4T.mjs";
5
- import { C as serverConfigSchema, _ as loadAgents, b as resetConfig, c as saveCredentials, d as DEFAULT_HOME_DIR, f as agentConfigSchema, g as initConfig, h as getConfigValue, i as loadCredentials, l as DEFAULT_CONFIG_DIR, n as ensureFreshAccessToken, o as resolveServerUrl, p as clientConfigSchema, r as ensureFreshAdminToken, s as saveAgentConfig, u as DEFAULT_DATA_DIR, w as setConfigValue, x as resetConfigMeta, y as readConfigFile } from "../bootstrap-CBAVWQUT.mjs";
6
- import "../dist-DUCelK3Z.mjs";
7
- import { n as bindFeishuUser, t as bindFeishuBot } from "../feishu-Boy3n8CT.mjs";
8
- import "../invitation-C_zAhB8x-8Khychlu.mjs";
5
+ import { C as serverConfigSchema, _ as loadAgents, b as resetConfig, c as saveCredentials, d as DEFAULT_HOME_DIR, f as agentConfigSchema, g as initConfig, h as getConfigValue, i as loadCredentials, l as DEFAULT_CONFIG_DIR, n as ensureFreshAccessToken, o as resolveServerUrl, p as clientConfigSchema, r as ensureFreshAdminToken, s as saveAgentConfig, u as DEFAULT_DATA_DIR, w as setConfigValue, x as resetConfigMeta, y as readConfigFile } from "../bootstrap-jx5nN1qZ.mjs";
6
+ import "../dist-CbX9mUVH.mjs";
7
+ import { n as bindFeishuUser, t as bindFeishuBot } from "../feishu-DvjRZMdZ.mjs";
8
+ import "../invitation-BljIolbO-DLeHfURd.mjs";
9
9
  import { join } from "node:path";
10
10
  import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync } from "node:fs";
11
11
  import { Command } from "commander";
@@ -1265,13 +1265,13 @@ function isSecretField(schema, dotPath) {
1265
1265
  //#region src/commands/onboard.ts
1266
1266
  async function promptMissing(args) {
1267
1267
  if (!args.server) try {
1268
- const { resolveServerUrl } = await import("../bootstrap-CBAVWQUT.mjs").then((n) => n.t);
1268
+ const { resolveServerUrl } = await import("../bootstrap-jx5nN1qZ.mjs").then((n) => n.t);
1269
1269
  resolveServerUrl();
1270
1270
  } catch {
1271
1271
  args.server = await input({ message: "Hub server URL:" });
1272
1272
  saveOnboardState(args);
1273
1273
  }
1274
- const { loadCredentials } = await import("../bootstrap-CBAVWQUT.mjs").then((n) => n.t);
1274
+ const { loadCredentials } = await import("../bootstrap-jx5nN1qZ.mjs").then((n) => n.t);
1275
1275
  if (!loadCredentials()) throw new Error("No saved credentials. Run `first-tree-hub client connect <server-url>` before onboarding.");
1276
1276
  if (!args.id) {
1277
1277
  args.id = await input({ message: "Agent ID:" });
@@ -597,11 +597,21 @@ z.object({
597
597
  lastSeenAt: z.string(),
598
598
  metadata: z.record(z.string(), z.unknown()).nullable()
599
599
  });
600
+ /**
601
+ * Optional opt-in flags the client carries on `client:register` to advertise
602
+ * which negotiable wire-protocol features it implements. Distinct from
603
+ * `clientCapabilitiesSchema` (per-runtime-provider availability — different
604
+ * concept). Older clients omit the field; the server treats every unset flag
605
+ * as `false` and falls back to the legacy path. See proposal
606
+ * hub-inbox-ws-data-plane §3.6.
607
+ */
608
+ const clientWireCapabilitiesSchema = z.object({ wsInboxDeliver: z.boolean().default(false) }).partial();
600
609
  const clientRegisterSchema = z.object({
601
610
  clientId: z.string().min(1).max(100),
602
611
  hostname: z.string().max(100).optional(),
603
612
  os: z.string().max(50).optional(),
604
- sdkVersion: z.string().max(50).optional()
613
+ sdkVersion: z.string().max(50).optional(),
614
+ wireCapabilities: clientWireCapabilitiesSchema.optional()
605
615
  });
606
616
  const capabilityStateSchema = z.enum([
607
617
  "ok",
@@ -798,11 +808,41 @@ z.object({
798
808
  ackedAt: z.string().nullable()
799
809
  }).extend({ message: clientMessageSchema });
800
810
  const inboxPollQuerySchema = z.object({ limit: z.coerce.number().int().min(1).max(50).default(10) });
811
+ /**
812
+ * server → client: a single inbox entry pushed over the active WS connection,
813
+ * replacing the legacy `new_message` doorbell + HTTP `/inbox` poll round-trip.
814
+ *
815
+ * `entryId` is the server-side `inbox_entries.id` the client must echo back
816
+ * in `inbox:ack`. `message` is exactly what the legacy poll path returned —
817
+ * `clientMessageSchema` already carries `precedingMessages`, so the client-
818
+ * side dispatch logic is reused verbatim (see proposal
819
+ * hub-inbox-ws-data-plane §3.1).
820
+ *
821
+ * `.passthrough()` so a forward-rolling server may extend the frame without
822
+ * breaking older clients that validate strictly. Older clients drop unknown
823
+ * fields silently.
824
+ */
825
+ const inboxDeliverFrameSchema = z.object({
826
+ type: z.literal("inbox:deliver"),
827
+ entryId: z.number().int().nonnegative(),
828
+ inboxId: z.string().min(1),
829
+ chatId: z.string().nullable(),
830
+ message: clientMessageSchema
831
+ }).passthrough();
832
+ /**
833
+ * client → server: ack for an `inbox:deliver` frame. Replaces the legacy
834
+ * `POST /inbox/:id/ack` HTTP endpoint when the WS data plane is active.
835
+ */
836
+ const inboxAckFrameSchema = z.object({
837
+ type: z.literal("inbox:ack"),
838
+ entryId: z.number().int().nonnegative()
839
+ });
801
840
  z.object({
802
841
  organizationId: z.string(),
803
842
  organizationName: z.string(),
804
843
  organizationDisplayName: z.string(),
805
- role: z.string()
844
+ role: z.string(),
845
+ expiresAt: z.string().nullable()
806
846
  });
807
847
  z.object({
808
848
  id: z.string(),
@@ -1244,10 +1284,18 @@ const wsAuthFrameSchema = z.object({
1244
1284
  });
1245
1285
  /** How long the server waits for the first `auth` frame before closing the WS. */
1246
1286
  const WS_AUTH_FRAME_TIMEOUT_MS = 5e3;
1287
+ /**
1288
+ * Negotiable wire-protocol features the server advertises in its `welcome`
1289
+ * frame. Older clients drop the `capabilities` field silently because the
1290
+ * frame is `.passthrough()`. New clients gate optional code paths on it —
1291
+ * absent ⇒ feature off, never assumed.
1292
+ */
1293
+ const serverCapabilitiesSchema = z.object({ wsInboxDeliver: z.boolean().default(false) }).partial();
1247
1294
  z.object({
1248
1295
  type: z.literal("server:welcome"),
1249
1296
  serverCommandVersion: z.string().min(1),
1250
- serverTimeMs: z.number().int().nonnegative()
1297
+ serverTimeMs: z.number().int().nonnegative(),
1298
+ capabilities: serverCapabilitiesSchema.optional()
1251
1299
  }).passthrough();
1252
1300
  //#endregion
1253
- export { safeRedirectPath as $, createOrgFromMeSchema as A, imageInlineContentSchema as B, clientRegisterSchema as C, createAgentSchema as D, createAdapterMappingSchema as E, dryRunAgentRuntimeConfigSchema as F, linkTaskChatSchema as G, isRedactedEnvValue as H, extractMentions as I, notificationQuerySchema as J, loginSchema as K, githubCallbackQuerySchema as L, createTaskSchema as M, defaultRuntimeConfigPayload as N, createChatSchema as O, delegateFeishuUserSchema as P, runtimeStateMessageSchema as Q, githubDevCallbackQuerySchema as R, clientCapabilitiesSchema as S, createAdapterConfigSchema as T, isReservedAgentName as U, inboxPollQuerySchema as V, joinByInvitationSchema as W, rebindAgentSchema as X, paginationQuerySchema as Y, refreshTokenSchema as Z, adminUpdateTaskSchema as _, updateOrganizationSchema as _t, AGENT_STATUSES as a, sessionEventMessageSchema as at, agentRuntimeConfigPayloadSchema as b, wsAuthFrameSchema as bt, DEFAULT_RUNTIME_PROVIDER as c, sessionStateMessageSchema as ct, TASK_HEALTH_SIGNALS as d, updateAdapterConfigSchema as dt, scanMentionTokens as et, TASK_STATUSES as f, updateAgentRuntimeConfigSchema as ft, adminCreateTaskSchema as g, updateMemberSchema as gt, addParticipantSchema as h, updateClientCapabilitiesSchema as ht, AGENT_SOURCES as i, sessionCompletionMessageSchema as it, createOrganizationSchema as j, createMemberSchema as k, SYSTEM_CONFIG_DEFAULTS as l, switchOrgSchema as lt, WS_AUTH_FRAME_TIMEOUT_MS as m, updateChatSchema as mt, AGENT_NAME_REGEX as n, sendMessageSchema as nt, AGENT_TYPES as o, sessionEventSchema as ot, TASK_TERMINAL_STATUSES as p, updateAgentSchema as pt, messageSourceSchema as q, AGENT_SELECTOR_HEADER as r, sendToAgentSchema as rt, AGENT_VISIBILITY as s, sessionReconcileRequestSchema as st, AGENT_BIND_REJECT_REASONS as t, selfServiceFeishuBotSchema as tt, TASK_CREATOR_TYPES as u, taskListQuerySchema as ut, agentBindRequestSchema as v, updateSystemConfigSchema as vt, connectTokenExchangeSchema as w, agentTypeSchema as x, agentPinnedMessageSchema as y, updateTaskStatusSchema as yt, githubStartQuerySchema as z };
1301
+ export { refreshTokenSchema as $, createOrgFromMeSchema as A, imageInlineContentSchema as B, clientRegisterSchema as C, createAgentSchema as D, createAdapterMappingSchema as E, dryRunAgentRuntimeConfigSchema as F, isReservedAgentName as G, inboxDeliverFrameSchema as H, extractMentions as I, loginSchema as J, joinByInvitationSchema as K, githubCallbackQuerySchema as L, createTaskSchema as M, defaultRuntimeConfigPayload as N, createChatSchema as O, delegateFeishuUserSchema as P, rebindAgentSchema as Q, githubDevCallbackQuerySchema as R, clientCapabilitiesSchema as S, wsAuthFrameSchema as St, createAdapterConfigSchema as T, inboxPollQuerySchema as U, inboxAckFrameSchema as V, isRedactedEnvValue as W, notificationQuerySchema as X, messageSourceSchema as Y, paginationQuerySchema as Z, adminUpdateTaskSchema as _, updateClientCapabilitiesSchema as _t, AGENT_STATUSES as a, sendToAgentSchema as at, agentRuntimeConfigPayloadSchema as b, updateSystemConfigSchema as bt, DEFAULT_RUNTIME_PROVIDER as c, sessionEventSchema as ct, TASK_HEALTH_SIGNALS as d, switchOrgSchema as dt, runtimeStateMessageSchema as et, TASK_STATUSES as f, taskListQuerySchema as ft, adminCreateTaskSchema as g, updateChatSchema as gt, addParticipantSchema as h, updateAgentSchema as ht, AGENT_SOURCES as i, sendMessageSchema as it, createOrganizationSchema as j, createMemberSchema as k, SYSTEM_CONFIG_DEFAULTS as l, sessionReconcileRequestSchema as lt, WS_AUTH_FRAME_TIMEOUT_MS as m, updateAgentRuntimeConfigSchema as mt, AGENT_NAME_REGEX as n, scanMentionTokens as nt, AGENT_TYPES as o, sessionCompletionMessageSchema as ot, TASK_TERMINAL_STATUSES as p, updateAdapterConfigSchema as pt, linkTaskChatSchema as q, AGENT_SELECTOR_HEADER as r, selfServiceFeishuBotSchema as rt, AGENT_VISIBILITY as s, sessionEventMessageSchema as st, AGENT_BIND_REJECT_REASONS as t, safeRedirectPath as tt, TASK_CREATOR_TYPES as u, sessionStateMessageSchema as ut, agentBindRequestSchema as v, updateMemberSchema as vt, connectTokenExchangeSchema as w, agentTypeSchema as x, updateTaskStatusSchema as xt, agentPinnedMessageSchema as y, updateOrganizationSchema as yt, githubStartQuerySchema as z };
@@ -1,5 +1,5 @@
1
1
  import { d as __exportAll } from "./esm-CYu4tXXn.mjs";
2
- import { r as AGENT_SELECTOR_HEADER } from "./dist-DUCelK3Z.mjs";
2
+ import { r as AGENT_SELECTOR_HEADER } from "./dist-CbX9mUVH.mjs";
3
3
  //#region src/core/feishu.ts
4
4
  var feishu_exports = /* @__PURE__ */ __exportAll({
5
5
  bindFeishuBot: () => bindFeishuBot,
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import "./observability-DPyf745N-BSc8QNcR.mjs";
2
- import { $ as status, A as checkServerHealth, B as isDockerAvailable, C as checkAgentConfigs, D as checkDocker, E as checkDatabase, F as installClientService, G as createOwner, H as ClientRuntime, I as isServiceSupported, K as hasUser, L as resolveCliInvocation, M as checkWebSocket, N as printResults, O as checkNodeVersion, P as getClientServiceStatus, R as uninstallClientService, S as runMigrations, T as checkClientConfig, U as handleClientOrgMismatch, V as stopPostgres, W as rotateClientIdWithBackup, X as blank, _ as onboardCreate, d as isInteractive, f as promptAddAgent, g as onboardCheck, j as checkServerReachable, k as checkServerConfig, m as formatCheckReport, n as deriveHubUrlFromToken, nt as SdkError, p as promptMissingFields, s as startServer, t as HubUrlDerivationError, tt as FirstTreeHubSDK, y as runHomeMigration, z as ensurePostgres } from "./saas-connect-3p-vBkuY.mjs";
2
+ import { $ as status, A as checkServerHealth, B as isDockerAvailable, C as checkAgentConfigs, D as checkDocker, E as checkDatabase, F as installClientService, G as createOwner, H as ClientRuntime, I as isServiceSupported, K as hasUser, L as resolveCliInvocation, M as checkWebSocket, N as printResults, O as checkNodeVersion, P as getClientServiceStatus, R as uninstallClientService, S as runMigrations, T as checkClientConfig, U as handleClientOrgMismatch, V as stopPostgres, W as rotateClientIdWithBackup, X as blank, _ as onboardCreate, d as isInteractive, f as promptAddAgent, g as onboardCheck, j as checkServerReachable, k as checkServerConfig, m as formatCheckReport, n as deriveHubUrlFromToken, nt as SdkError, p as promptMissingFields, s as startServer, t as HubUrlDerivationError, tt as FirstTreeHubSDK, y as runHomeMigration, z as ensurePostgres } from "./saas-connect-2puW1r3r.mjs";
3
3
  import "./logger-core-BTmvdflj-DjW8FM4T.mjs";
4
- import { a as resolveAccessToken, n as ensureFreshAccessToken, o as resolveServerUrl, r as ensureFreshAdminToken } from "./bootstrap-CBAVWQUT.mjs";
5
- import "./dist-DUCelK3Z.mjs";
6
- import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-Boy3n8CT.mjs";
7
- import "./invitation-C_zAhB8x-8Khychlu.mjs";
4
+ import { a as resolveAccessToken, n as ensureFreshAccessToken, o as resolveServerUrl, r as ensureFreshAdminToken } from "./bootstrap-jx5nN1qZ.mjs";
5
+ import "./dist-CbX9mUVH.mjs";
6
+ import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-DvjRZMdZ.mjs";
7
+ import "./invitation-BljIolbO-DLeHfURd.mjs";
8
8
  export { 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, rotateClientIdWithBackup, runHomeMigration, runMigrations, startServer, status, stopPostgres, uninstallClientService };
@@ -1,7 +1,7 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import { and, desc, eq, gt, isNull, or } from "drizzle-orm";
3
3
  import { index, integer, jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";
4
- //#region ../server/dist/invitation-C_zAhB8x.mjs
4
+ //#region ../server/dist/invitation-BljIolbO.mjs
5
5
  /** Organization entity. Agents and chats belong to exactly one organization. */
6
6
  const organizations = pgTable("organizations", {
7
7
  id: text("id").primaryKey(),
@@ -230,7 +230,8 @@ async function previewInvitation(db, token) {
230
230
  organizationId: org.id,
231
231
  organizationName: org.name,
232
232
  organizationDisplayName: org.displayName,
233
- role: inv.role
233
+ role: inv.role,
234
+ expiresAt: inv.expiresAt ? inv.expiresAt.toISOString() : null
234
235
  };
235
236
  }
236
237
  /**
@@ -1,3 +1,3 @@
1
- import "./dist-DUCelK3Z.mjs";
2
- import { _ as rotateInvitation, h as previewInvitation } from "./invitation-C_zAhB8x-8Khychlu.mjs";
1
+ import "./dist-CbX9mUVH.mjs";
2
+ import { _ as rotateInvitation, h as previewInvitation } from "./invitation-BljIolbO-DLeHfURd.mjs";
3
3
  export { previewInvitation, rotateInvitation };