@agent-team-foundation/first-tree-hub 0.14.1 → 0.14.3

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.
@@ -1,7 +1,7 @@
1
1
  import "./observability-BAScT_5S-BcW9HgkG.mjs";
2
2
  import "./logger-core-BTmvdflj-DjW8FM4T.mjs";
3
- import "./dist-1XGLJMOq.mjs";
4
- import "./errors-LPcARA4K-Dbrptiyz.mjs";
3
+ import "./dist-CwsiHGX7.mjs";
4
+ import "./uuid-DbS_4vFh-iFghv4zA.mjs";
5
5
  import "./src-DNBS5Yjj.mjs";
6
- import { J as listMyPinnedAgents } from "./client-CzXmweS9-DhUiuQvL.mjs";
6
+ import { xt as listMyPinnedAgents } from "./client-BSfCc0pJ-BP_1f21y.mjs";
7
7
  export { listMyPinnedAgents };
@@ -728,13 +728,17 @@ const createChatSchema = z.object({
728
728
  participantIds: z.array(z.string()).min(1),
729
729
  metadata: optionalChatMetadataSchema.optional()
730
730
  });
731
- const chatParticipantSchema = z.object({
731
+ /**
732
+ * Participant row with the agent's public-ish metadata resolved — used by the
733
+ * client runtime for `@<name>` mention extraction against the authoritative
734
+ * participant set (see proposals/hub-agent-messaging-reply-and-mentions §4).
735
+ */
736
+ const chatParticipantDetailSchema = z.object({
732
737
  agentId: z.string(),
733
738
  role: z.string(),
734
739
  mode: z.string(),
735
740
  joinedAt: z.string()
736
- });
737
- chatParticipantSchema.extend({
741
+ }).extend({
738
742
  name: z.string().nullable(),
739
743
  displayName: z.string(),
740
744
  type: z.string()
@@ -749,7 +753,7 @@ z.object({
749
753
  createdAt: z.string(),
750
754
  updatedAt: z.string()
751
755
  }).extend({
752
- participants: z.array(chatParticipantSchema),
756
+ participants: z.array(chatParticipantDetailSchema),
753
757
  title: z.string(),
754
758
  firstMessagePreview: z.string().nullable(),
755
759
  engagementStatus: chatEngagementStatusSchema
@@ -799,9 +803,13 @@ z.object({
799
803
  * Optional opt-in flags the client carries on `client:register` to advertise
800
804
  * which negotiable wire-protocol features it implements. Distinct from
801
805
  * `clientCapabilitiesSchema` (per-runtime-provider availability — different
802
- * concept). Older clients omit the field; the server treats every unset flag
803
- * as `false` and falls back to the legacy path. See proposal
804
- * hub-inbox-ws-data-plane §3.6.
806
+ * concept).
807
+ *
808
+ * 0.10.4 ~ 0.14.2 clients still send this block (with `wsInboxDeliver: true`
809
+ * hard-coded). The 0.14.3+ runtime omits it. The schema is retained so that
810
+ * middle-version `client:register` frames still parse, even though the
811
+ * server no longer reads any of these fields — the WS inbox data plane is
812
+ * mandatory on this server build.
805
813
  */
806
814
  const clientWireCapabilitiesSchema = z.object({ wsInboxDeliver: z.boolean().default(false) }).partial();
807
815
  const clientRegisterSchema = z.object({
@@ -1062,6 +1070,23 @@ const messageFormatSchema = z.enum([
1062
1070
  "question",
1063
1071
  "question_answer"
1064
1072
  ]);
1073
+ /**
1074
+ * Optional intent tag set by the client when posting through
1075
+ * `POST /agent/chats/:id/messages`. Tells the server *why* this write is
1076
+ * happening so it can pick the right enforcement profile.
1077
+ *
1078
+ * - `"agent-final-text"`: handler-initiated forward of an agent's final
1079
+ * reply text (today: `runtime/result-sink.ts`) OR an `AskUserQuestion`
1080
+ * payload posted via the canUseTool bridge. Both should land in chat
1081
+ * history so human observers in the web UI can see what the agent is
1082
+ * doing, but neither should wake other agents and neither should be
1083
+ * subject to the group-chat `@mention required` guard — they are not
1084
+ * a user-typed group broadcast. v1 §四 改造 4 (b) bypass channel.
1085
+ *
1086
+ * Default-`undefined` means a regular agent-initiated send (CLI `chat send`,
1087
+ * adapter, etc.) and goes through the normal enforcement profile.
1088
+ */
1089
+ const messagePurposeSchema = z.enum(["agent-final-text"]);
1065
1090
  const sendMessageSchema = z.object({
1066
1091
  format: messageFormatSchema.default("text"),
1067
1092
  content: z.unknown(),
@@ -1069,7 +1094,8 @@ const sendMessageSchema = z.object({
1069
1094
  inReplyTo: z.string().optional(),
1070
1095
  replyToInbox: z.string().optional(),
1071
1096
  replyToChat: z.string().optional(),
1072
- source: messageSourceSchema.optional()
1097
+ source: messageSourceSchema.optional(),
1098
+ purpose: messagePurposeSchema.optional()
1073
1099
  });
1074
1100
  const sendToAgentSchema = z.object({
1075
1101
  format: messageFormatSchema.default("text"),
@@ -1077,7 +1103,8 @@ const sendToAgentSchema = z.object({
1077
1103
  metadata: z.record(z.string(), z.unknown()).optional(),
1078
1104
  replyToInbox: z.string().optional(),
1079
1105
  replyToChat: z.string().optional(),
1080
- source: messageSourceSchema.optional()
1106
+ source: messageSourceSchema.optional(),
1107
+ direct: z.boolean().optional()
1081
1108
  });
1082
1109
  const messageSchema = z.object({
1083
1110
  id: z.string(),
@@ -1173,14 +1200,11 @@ z.object({
1173
1200
  }).extend({ message: clientMessageSchema });
1174
1201
  const inboxPollQuerySchema = z.object({ limit: z.coerce.number().int().min(1).max(50).default(10) });
1175
1202
  /**
1176
- * server → client: a single inbox entry pushed over the active WS connection,
1177
- * replacing the legacy `new_message` doorbell + HTTP `/inbox` poll round-trip.
1203
+ * server → client: a single inbox entry pushed over the active WS connection.
1178
1204
  *
1179
1205
  * `entryId` is the server-side `inbox_entries.id` the client must echo back
1180
- * in `inbox:ack`. `message` is exactly what the legacy poll path returned —
1181
- * `clientMessageSchema` already carries `precedingMessages`, so the client-
1182
- * side dispatch logic is reused verbatim (see proposal
1183
- * hub-inbox-ws-data-plane §3.1).
1206
+ * in `inbox:ack`. `clientMessageSchema` carries `precedingMessages`, so the
1207
+ * client-side dispatch logic handles the silent-context bundle uniformly.
1184
1208
  *
1185
1209
  * `.passthrough()` so a forward-rolling server may extend the frame without
1186
1210
  * breaking older clients that validate strictly. Older clients drop unknown
@@ -1194,8 +1218,7 @@ const inboxDeliverFrameSchema = z.object({
1194
1218
  message: clientMessageSchema
1195
1219
  }).passthrough();
1196
1220
  /**
1197
- * client → server: ack for an `inbox:deliver` frame. Replaces the legacy
1198
- * `POST /inbox/:id/ack` HTTP endpoint when the WS data plane is active.
1221
+ * client → server: ack for an `inbox:deliver` frame.
1199
1222
  */
1200
1223
  const inboxAckFrameSchema = z.object({
1201
1224
  type: z.literal("inbox:ack"),
@@ -1297,6 +1320,10 @@ z.object({
1297
1320
  lastReadAt: z.string(),
1298
1321
  unreadMentionCount: z.number().int()
1299
1322
  });
1323
+ z.object({
1324
+ chatId: z.string(),
1325
+ unreadMentionCount: z.number().int()
1326
+ });
1300
1327
  z.object({
1301
1328
  chatId: z.string(),
1302
1329
  membershipKind: meChatMembershipKindSchema.nullable()
@@ -1967,8 +1994,13 @@ const WS_AUTH_FRAME_TIMEOUT_MS = 5e3;
1967
1994
  /**
1968
1995
  * Negotiable wire-protocol features the server advertises in its `welcome`
1969
1996
  * frame. Older clients drop the `capabilities` field silently because the
1970
- * frame is `.passthrough()`. New clients gate optional code paths on it —
1971
- * absent ⇒ feature off, never assumed.
1997
+ * frame is `.passthrough()`.
1998
+ *
1999
+ * Required by clients in the 0.10.4 ~ 0.14.2 range: those builds read
2000
+ * `wsInboxDeliver` here to decide whether to skip the local HTTP poll loop
2001
+ * and rely on `inbox:deliver` push frames. The 0.14.3+ runtime ignores the
2002
+ * field (push is the only path) but the server still emits it so middle-
2003
+ * version clients keep working.
1972
2004
  */
1973
2005
  const serverCapabilitiesSchema = z.object({ wsInboxDeliver: z.boolean().default(false) }).partial();
1974
2006
  z.object({
@@ -1,6 +1,6 @@
1
1
  import { r as __exportAll } from "./chunk-BSw8zbkd.mjs";
2
2
  import { t as cliFetch } from "./cli-fetch--tiwKm5S.mjs";
3
- import { r as AGENT_SELECTOR_HEADER } from "./dist-1XGLJMOq.mjs";
3
+ import { r as AGENT_SELECTOR_HEADER } from "./dist-CwsiHGX7.mjs";
4
4
  //#region src/core/feishu.ts
5
5
  var feishu_exports = /* @__PURE__ */ __exportAll({
6
6
  bindFeishuBot: () => bindFeishuBot,
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import "./observability-BAScT_5S-BcW9HgkG.mjs";
2
- import { A as checkDocker, B as isServiceSupported, E as checkAgentConfigs, F as checkWebSocket, G as uninstallClientService, H as restartClientService, I as printResults, J as stopPostgres, K as ensurePostgres, M as checkServerConfig, N as checkServerHealth, O as checkClientConfig, P as checkServerReachable, R as getClientServiceStatus, S as runHomeMigration, T as runMigrations, U as startClientService, V as resolveCliInvocation, W as stopClientService, X as handleClientOrgMismatch, Y as ClientRuntime, Z as rotateClientIdWithBackup, _ as formatCheckReport, b as onboardCreate, d as startServer, g as promptMissingFields, h as promptAddAgent, j as checkNodeVersion, k as checkDatabase, lt as FirstTreeHubSDK, m as isInteractive, n as deriveHubUrlFromToken, nt as hasUser, q as isDockerAvailable, t as HubUrlDerivationError, tt as createOwner, ut as SdkError, y as onboardCheck, z as installClientService } from "./saas-connect-BBRxjmBS.mjs";
2
+ import { A as checkDocker, B as isServiceSupported, E as checkAgentConfigs, F as checkWebSocket, G as uninstallClientService, H as restartClientService, I as printResults, J as stopPostgres, K as ensurePostgres, M as checkServerConfig, N as checkServerHealth, O as checkClientConfig, P as checkServerReachable, R as getClientServiceStatus, S as runHomeMigration, T as runMigrations, U as startClientService, V as resolveCliInvocation, W as stopClientService, X as handleClientOrgMismatch, Y as ClientRuntime, Z as rotateClientIdWithBackup, _ as formatCheckReport, b as onboardCreate, d as startServer, g as promptMissingFields, h as promptAddAgent, j as checkNodeVersion, k as checkDatabase, lt as FirstTreeHubSDK, m as isInteractive, n as deriveHubUrlFromToken, nt as hasUser, q as isDockerAvailable, t as HubUrlDerivationError, tt as createOwner, ut as SdkError, y as onboardCheck, z as installClientService } from "./saas-connect-ChxZv2YQ.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-C15ZBOCC.mjs";
4
+ import { a as ensureFreshAdminToken, c as resolveServerUrl, i as ensureFreshAccessToken, n as AuthRefreshRateLimitedError, s as resolveAccessToken, t as AuthRefreshFailedError } from "./bootstrap-CQQGgIx1.mjs";
5
5
  import { i as blank, s as status } from "./cli-fetch--tiwKm5S.mjs";
6
- import "./dist-1XGLJMOq.mjs";
7
- import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-BGx71p5s.mjs";
8
- import "./errors-LPcARA4K-Dbrptiyz.mjs";
6
+ import "./dist-CwsiHGX7.mjs";
7
+ import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-DHSy6WDD.mjs";
8
+ import "./uuid-DbS_4vFh-iFghv4zA.mjs";
9
9
  import "./src-DNBS5Yjj.mjs";
10
- import "./client-CzXmweS9-DhUiuQvL.mjs";
11
- import "./invitation-DZO4NX3P-BPxTeHf-.mjs";
10
+ import "./client-BSfCc0pJ-BP_1f21y.mjs";
11
+ import "./invitation-D_ENPHyj-5ETiae5r.mjs";
12
12
  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 };
@@ -0,0 +1,4 @@
1
+ import "./dist-CwsiHGX7.mjs";
2
+ import "./uuid-DbS_4vFh-iFghv4zA.mjs";
3
+ import { s as previewInvitation } from "./invitation-D_ENPHyj-5ETiae5r.mjs";
4
+ export { previewInvitation };
@@ -1,28 +1,8 @@
1
- import { l as organizations, s as NotFoundError, u as users } from "./errors-LPcARA4K-Dbrptiyz.mjs";
1
+ import { c as NotFoundError, d as users, f as uuidv7, u as organizations } from "./uuid-DbS_4vFh-iFghv4zA.mjs";
2
2
  import { randomBytes } from "node:crypto";
3
3
  import { and, desc, eq, gt, isNull, or } from "drizzle-orm";
4
4
  import { index, pgTable, text, timestamp } from "drizzle-orm/pg-core";
5
- //#region ../server/dist/invitation-DZO4NX3P.mjs
6
- /** Generate a UUID v7 (time-ordered). No external dependency. */
7
- function uuidv7() {
8
- const now = BigInt(Date.now());
9
- const bytes = new Uint8Array(16);
10
- bytes[0] = Number(now >> 40n & 255n);
11
- bytes[1] = Number(now >> 32n & 255n);
12
- bytes[2] = Number(now >> 24n & 255n);
13
- bytes[3] = Number(now >> 16n & 255n);
14
- bytes[4] = Number(now >> 8n & 255n);
15
- bytes[5] = Number(now & 255n);
16
- const rand = randomBytes(10);
17
- for (let i = 0; i < 10; i++) {
18
- const b = rand[i];
19
- if (b !== void 0) bytes[6 + i] = b;
20
- }
21
- bytes[6] = (bytes[6] ?? 0) & 15 | 112;
22
- bytes[8] = (bytes[8] ?? 0) & 63 | 128;
23
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
24
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
25
- }
5
+ //#region ../server/dist/invitation-D_ENPHyj.mjs
26
6
  /**
27
7
  * Org-level invitation links. v1 enforces "one active link per org" via a
28
8
  * partial UNIQUE index added in the SQL migration (Drizzle's TS DSL does not
@@ -184,4 +164,4 @@ function buildInviteUrl(publicUrl, token) {
184
164
  return `${publicUrl.replace(/\/+$/, "")}/invite/${token}`;
185
165
  }
186
166
  //#endregion
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 };
167
+ 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 };