@agent-team-foundation/first-tree-hub 0.6.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ -- NC2 (workspace-redesign S10): drop `session_outputs`, add `session_events`.
2
+ --
3
+ -- The old table held one `content` row per (agent, chat) with string
4
+ -- concatenation on upsert. The new table captures structured events
5
+ -- (`tool_call` / `error`) with a monotonic per-chat `seq` and a jsonb
6
+ -- payload. Integrity is enforced in the service layer (Zod discriminated
7
+ -- union on insert), so no FK / CHECK here — matches the project rule for
8
+ -- new tables.
9
+ --
10
+ -- Discarding `session_outputs` data is intentional (tech plan decision):
11
+ -- no content-migration path, no compatibility shim.
12
+
13
+ DROP TABLE IF EXISTS "session_outputs" CASCADE;
14
+
15
+ --> statement-breakpoint
16
+ CREATE TABLE IF NOT EXISTS "session_events" (
17
+ "id" text PRIMARY KEY NOT NULL,
18
+ "agent_id" text NOT NULL,
19
+ "chat_id" text NOT NULL,
20
+ "seq" integer NOT NULL,
21
+ "kind" text NOT NULL,
22
+ "payload" jsonb NOT NULL,
23
+ "created_at" timestamp with time zone NOT NULL DEFAULT now()
24
+ );
25
+
26
+ --> statement-breakpoint
27
+ CREATE UNIQUE INDEX IF NOT EXISTS "uq_session_events_chat_seq"
28
+ ON "session_events" ("agent_id", "chat_id", "seq");
29
+
30
+ --> statement-breakpoint
31
+ CREATE INDEX IF NOT EXISTS "idx_session_events_chat_created"
32
+ ON "session_events" ("agent_id", "chat_id", "created_at" DESC);
@@ -155,6 +155,13 @@
155
155
  "when": 1777075200000,
156
156
  "tag": "0021_drop_agents_profile",
157
157
  "breakpoints": true
158
+ },
159
+ {
160
+ "idx": 22,
161
+ "version": "7",
162
+ "when": 1777161600000,
163
+ "tag": "0022_session_events",
164
+ "breakpoints": true
158
165
  }
159
166
  ]
160
167
  }
@@ -579,18 +579,66 @@ z.object({
579
579
  createdAt: z.string(),
580
580
  updatedAt: z.string()
581
581
  });
582
+ const pulseBucketSchema = z.object({
583
+ workingCount: z.number().int().nonnegative(),
584
+ errorMask: z.boolean()
585
+ });
586
+ z.object({
587
+ type: z.literal("pulse:tick"),
588
+ organizationId: z.string(),
589
+ agents: z.record(z.string(), z.array(pulseBucketSchema).length(32))
590
+ });
591
+ const sessionEventKind = z.enum(["tool_call", "error"]);
592
+ const toolCallEventPayload = z.object({
593
+ toolUseId: z.string(),
594
+ name: z.string(),
595
+ args: z.unknown(),
596
+ status: z.enum([
597
+ "pending",
598
+ "ok",
599
+ "error"
600
+ ]),
601
+ durationMs: z.number().int().nonnegative().optional(),
602
+ resultPreview: z.string().max(400).optional()
603
+ });
604
+ const errorEventPayload = z.object({
605
+ source: z.enum([
606
+ "sdk",
607
+ "runtime",
608
+ "tool"
609
+ ]),
610
+ message: z.string().max(2e3)
611
+ });
612
+ const sessionEventSchema = z.discriminatedUnion("kind", [z.object({
613
+ kind: z.literal("tool_call"),
614
+ payload: toolCallEventPayload
615
+ }), z.object({
616
+ kind: z.literal("error"),
617
+ payload: errorEventPayload
618
+ })]);
582
619
  z.object({
583
620
  id: z.string(),
584
621
  agentId: z.string(),
585
622
  chatId: z.string(),
586
- content: z.string(),
587
- updatedAt: z.string()
623
+ seq: z.number().int().positive(),
624
+ kind: sessionEventKind,
625
+ payload: z.union([toolCallEventPayload, errorEventPayload]),
626
+ createdAt: z.string()
588
627
  });
589
- /** WS message: client reports session output text to server. */
590
- const sessionOutputMessageSchema = z.object({
628
+ /** WS message: client reports a session event (tool_call / error) to the server. */
629
+ const sessionEventMessageSchema = z.object({
591
630
  agentId: z.string(),
592
631
  chatId: z.string(),
593
- content: z.string().max(5e4)
632
+ event: sessionEventSchema
633
+ });
634
+ /**
635
+ * WS control message: client signals that a query completed end-to-end.
636
+ * Decoupled from `session:event` so the `session_completed` notification
637
+ * fires on actual result forwarding, not on incidental tool activity.
638
+ */
639
+ const sessionCompletionMessageSchema = z.object({
640
+ agentId: z.string(),
641
+ chatId: z.string()
594
642
  });
595
643
  const orgStatsSchema = z.object({
596
644
  organizationId: z.string(),
@@ -829,4 +877,4 @@ async function bindFeishuUser(serverUrl, accessToken, agentId, humanAgentId, fei
829
877
  }
830
878
  }
831
879
  //#endregion
832
- export { updateOrganizationSchema as $, createOrganizationSchema as A, paginationQuerySchema as B, clientRegisterSchema as C, createAgentSchema as D, createAdapterMappingSchema as E, isRedactedEnvValue as F, sendToAgentSchema as G, runtimeStateMessageSchema as H, linkTaskChatSchema as I, taskListQuerySchema as J, sessionOutputMessageSchema as K, loginSchema as L, delegateFeishuUserSchema as M, dryRunAgentRuntimeConfigSchema as N, createChatSchema as O, inboxPollQuerySchema as P, updateMemberSchema as Q, messageSourceSchema as R, agentTypeSchema as S, createAdapterConfigSchema as T, selfServiceFeishuBotSchema as U, refreshTokenSchema as V, sendMessageSchema as W, updateAgentRuntimeConfigSchema as X, updateAdapterConfigSchema as Y, updateAgentSchema as Z, addParticipantSchema as _, AGENT_SELECTOR_HEADER as a, agentBindRequestSchema as b, AGENT_TYPES as c, SYSTEM_CONFIG_DEFAULTS as d, updateSystemConfigSchema as et, TASK_CREATOR_TYPES as f, WS_AUTH_FRAME_TIMEOUT_MS as g, TASK_TERMINAL_STATUSES as h, AGENT_BIND_REJECT_REASONS as i, createTaskSchema as j, createMemberSchema as k, AGENT_VISIBILITY as l, TASK_STATUSES as m, bindFeishuUser as n, wsAuthFrameSchema as nt, AGENT_SOURCES as o, TASK_HEALTH_SIGNALS as p, sessionStateMessageSchema as q, feishu_exports as r, AGENT_STATUSES as s, bindFeishuBot as t, updateTaskStatusSchema as tt, DEFAULT_AGENT_RUNTIME_CONFIG_PAYLOAD as u, adminCreateTaskSchema as v, connectTokenExchangeSchema as w, agentRuntimeConfigPayloadSchema as x, adminUpdateTaskSchema as y, notificationQuerySchema as z };
880
+ export { updateAgentSchema as $, createOrganizationSchema as A, paginationQuerySchema as B, clientRegisterSchema as C, createAgentSchema as D, createAdapterMappingSchema as E, isRedactedEnvValue as F, sendToAgentSchema as G, runtimeStateMessageSchema as H, linkTaskChatSchema as I, sessionEventSchema as J, sessionCompletionMessageSchema as K, loginSchema as L, delegateFeishuUserSchema as M, dryRunAgentRuntimeConfigSchema as N, createChatSchema as O, inboxPollQuerySchema as P, updateAgentRuntimeConfigSchema as Q, messageSourceSchema as R, agentTypeSchema as S, createAdapterConfigSchema as T, selfServiceFeishuBotSchema as U, refreshTokenSchema as V, sendMessageSchema as W, taskListQuerySchema as X, sessionStateMessageSchema as Y, updateAdapterConfigSchema as Z, addParticipantSchema as _, AGENT_SELECTOR_HEADER as a, agentBindRequestSchema as b, AGENT_TYPES as c, SYSTEM_CONFIG_DEFAULTS as d, updateMemberSchema as et, TASK_CREATOR_TYPES as f, WS_AUTH_FRAME_TIMEOUT_MS as g, TASK_TERMINAL_STATUSES as h, AGENT_BIND_REJECT_REASONS as i, wsAuthFrameSchema as it, createTaskSchema as j, createMemberSchema as k, AGENT_VISIBILITY as l, TASK_STATUSES as m, bindFeishuUser as n, updateSystemConfigSchema as nt, AGENT_SOURCES as o, TASK_HEALTH_SIGNALS as p, sessionEventMessageSchema as q, feishu_exports as r, updateTaskStatusSchema as rt, AGENT_STATUSES as s, bindFeishuBot as t, updateOrganizationSchema as tt, DEFAULT_AGENT_RUNTIME_CONFIG_PAYLOAD as u, adminCreateTaskSchema as v, connectTokenExchangeSchema as w, agentRuntimeConfigPayloadSchema as x, adminUpdateTaskSchema as y, notificationQuerySchema as z };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as resolveAccessToken, n as ensureFreshAccessToken, o as resolveServerUrl, r as ensureFreshAdminToken } from "./bootstrap-DNL1cEwv.mjs";
2
- import { A as SdkError, C as ensurePostgres, D as createOwner, E as ClientRuntime, O as hasUser, S as status, T as stopPostgres, _ as checkServerHealth, a as formatCheckReport, b as printResults, c as onboardCreate, d as checkAgentConfigs, f as checkClientConfig, g as checkServerConfig, h as checkNodeVersion, i as promptMissingFields, k as FirstTreeHubSDK, m as checkDocker, n as isInteractive, p as checkDatabase, r as promptAddAgent, s as onboardCheck, t as startServer, u as runMigrations, v as checkServerReachable, w as isDockerAvailable, x as blank, y as checkWebSocket } from "./core-B10jgThe.mjs";
3
- import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-BoMJHlOv.mjs";
1
+ import { a as resolveAccessToken, n as ensureFreshAccessToken, o as resolveServerUrl, r as ensureFreshAdminToken } from "./bootstrap-CRDR6NwE.mjs";
2
+ import { A as SdkError, C as ensurePostgres, D as createOwner, E as ClientRuntime, O as hasUser, S as status, T as stopPostgres, _ as checkServerHealth, a as formatCheckReport, b as printResults, c as onboardCreate, d as checkAgentConfigs, f as checkClientConfig, g as checkServerConfig, h as checkNodeVersion, i as promptMissingFields, k as FirstTreeHubSDK, m as checkDocker, n as isInteractive, p as checkDatabase, r as promptAddAgent, s as onboardCheck, t as startServer, u as runMigrations, v as checkServerReachable, w as isDockerAvailable, x as blank, y as checkWebSocket } from "./core-4nvleGlC.mjs";
3
+ import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-CJ08ntOD.mjs";
4
4
  export { ClientRuntime, FirstTreeHubSDK, SdkError, bindFeishuBot, bindFeishuUser, blank, checkAgentConfigs, checkClientConfig, checkDatabase, checkDocker, checkNodeVersion, checkServerConfig, checkServerHealth, checkServerReachable, checkWebSocket, createOwner, ensureFreshAccessToken, ensureFreshAdminToken, ensurePostgres, formatCheckReport, hasUser, isDockerAvailable, isInteractive, onboardCheck, onboardCreate, printResults, promptAddAgent, promptMissingFields, resolveAccessToken, resolveServerUrl, runMigrations, startServer, status, stopPostgres };