@usabledev/usable-chat 1.191.2 → 1.192.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.
Files changed (2) hide show
  1. package/cli.js +78 -1
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -105712,6 +105712,8 @@ var init_schema2 = __esm({
105712
105712
  // User display name from Keycloak
105713
105713
  debugMode: boolean4("debug_mode").notNull().default(false),
105714
105714
  betaFeatures: jsonb("beta_features").notNull().default({}).$type(),
105715
+ globalSystemPrompt: text2("global_system_prompt").notNull().default(""),
105716
+ voiceSystemPrompt: text2("voice_system_prompt").notNull().default(""),
105715
105717
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
105716
105718
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
105717
105719
  },
@@ -216663,6 +216665,16 @@ var init_spill_payload = __esm({
216663
216665
  }
216664
216666
  });
216665
216667
 
216668
+ // src/lib/personalization-prompt.ts
216669
+ function prependPersonalizationPrompts(basePrompt, prompts) {
216670
+ return [prompts.globalSystemPrompt?.trim(), prompts.voiceSystemPrompt?.trim(), basePrompt].filter((part) => Boolean(part)).join("\n\n");
216671
+ }
216672
+ var init_personalization_prompt = __esm({
216673
+ "src/lib/personalization-prompt.ts"() {
216674
+ "use strict";
216675
+ }
216676
+ });
216677
+
216666
216678
  // src/core/ask-question/recovery-utils.ts
216667
216679
  function toolResultContent(value) {
216668
216680
  if (typeof value === "string") return value;
@@ -216865,6 +216877,53 @@ var init_store2 = __esm({
216865
216877
  }
216866
216878
  });
216867
216879
 
216880
+ // src/lib/services/user.service.ts
216881
+ var user_service_exports = {};
216882
+ __export(user_service_exports, {
216883
+ getOrCreateUser: () => getOrCreateUser,
216884
+ getUserByEmail: () => getUserByEmail
216885
+ });
216886
+ async function getOrCreateUser(userId, options2) {
216887
+ const [existing] = await db.select().from(users).where(eq(users.id, userId)).limit(1);
216888
+ if (existing) {
216889
+ if (options2?.email || options2?.name) {
216890
+ const needsUpdate = options2.email && existing.email !== options2.email || options2.name && existing.name !== options2.name;
216891
+ if (needsUpdate) {
216892
+ const [updated] = await db.update(users).set({
216893
+ email: options2.email ?? existing.email,
216894
+ name: options2.name ?? existing.name,
216895
+ updatedAt: /* @__PURE__ */ new Date()
216896
+ }).where(eq(users.id, userId)).returning();
216897
+ return updated;
216898
+ }
216899
+ }
216900
+ return existing;
216901
+ }
216902
+ const [inserted] = await db.insert(users).values({
216903
+ id: userId,
216904
+ email: options2?.email,
216905
+ name: options2?.name,
216906
+ debugMode: false,
216907
+ betaFeatures: {},
216908
+ globalSystemPrompt: "",
216909
+ voiceSystemPrompt: ""
216910
+ }).returning();
216911
+ return inserted;
216912
+ }
216913
+ async function getUserByEmail(email3) {
216914
+ const normalizedEmail = email3.toLowerCase().trim();
216915
+ const [user] = await db.select().from(users).where(eq(users.email, normalizedEmail)).limit(1);
216916
+ return user ?? null;
216917
+ }
216918
+ var init_user_service = __esm({
216919
+ "src/lib/services/user.service.ts"() {
216920
+ "use strict";
216921
+ init_client2();
216922
+ init_schema2();
216923
+ init_drizzle_orm();
216924
+ }
216925
+ });
216926
+
216868
216927
  // src/core/utils/workspace-context.ts
216869
216928
  var workspace_context_exports = {};
216870
216929
  __export(workspace_context_exports, {
@@ -289506,6 +289565,23 @@ Folder behavior:
289506
289565
  };
289507
289566
  const systemMessageParts = [];
289508
289567
  let contextTokens = 0;
289568
+ if (context.session.user?.id) {
289569
+ try {
289570
+ const { getOrCreateUser: getOrCreateUser2 } = await Promise.resolve().then(() => (init_user_service(), user_service_exports));
289571
+ const user = await getOrCreateUser2(context.session.user.id, {
289572
+ email: context.session.user.email?.toLowerCase(),
289573
+ name: context.session.user.name
289574
+ });
289575
+ const personalizedPrompt = prependPersonalizationPrompts("", {
289576
+ globalSystemPrompt: user.globalSystemPrompt
289577
+ });
289578
+ if (personalizedPrompt) systemMessageParts.push(personalizedPrompt);
289579
+ } catch (error41) {
289580
+ orchestrationLogger.warn("Failed to load user personalization", {
289581
+ error: error41 instanceof Error ? error41.message : String(error41)
289582
+ });
289583
+ }
289584
+ }
289509
289585
  const conversationId = context.metadata?.conversationId;
289510
289586
  if (conversationId) {
289511
289587
  try {
@@ -292495,6 +292571,7 @@ var init_orchestrator = __esm({
292495
292571
  init_discoverable_skills_prompt();
292496
292572
  init_mcp_server_tools_prompt();
292497
292573
  init_spill_payload();
292574
+ init_personalization_prompt();
292498
292575
  init_token_counter();
292499
292576
  HARNESS_COMPACT_RATIO = 0.75;
292500
292577
  HARNESS_KEEP_RECENT_RATIO = 0.35;
@@ -311487,7 +311564,7 @@ init_tui_select();
311487
311564
  init_model_registry();
311488
311565
 
311489
311566
  // package.json
311490
- var version2 = "1.191.2";
311567
+ var version2 = "1.192.0";
311491
311568
 
311492
311569
  // src/adapters/cli/model-catalog.ts
311493
311570
  init_codex_auth();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usabledev/usable-chat",
3
- "version": "1.191.2",
3
+ "version": "1.192.0",
4
4
  "description": "usable-chat — terminal harness for usable-chat (headless + TUI)",
5
5
  "type": "module",
6
6
  "bin": {