@primusclaw/personal-agent-runtime 0.6.0 → 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.
package/dist/index.js CHANGED
@@ -4031,6 +4031,40 @@ var SqliteGroupContextRepository = class {
4031
4031
  }
4032
4032
  };
4033
4033
 
4034
+ // packages/runtime/src/sqlite/group-language-repository.ts
4035
+ var LANGS = /* @__PURE__ */ new Set(["zh", "en", "auto"]);
4036
+ var SqliteGroupLanguageRepository = class {
4037
+ constructor(ctx) {
4038
+ this.ctx = ctx;
4039
+ }
4040
+ ctx;
4041
+ groupLanguage(conversationId) {
4042
+ const row = this.ctx.db.get("SELECT lang FROM group_language WHERE conversation_id = ?", conversationId);
4043
+ if (row === void 0) return null;
4044
+ const lang = row["lang"];
4045
+ return typeof lang === "string" && LANGS.has(lang) ? lang : "";
4046
+ }
4047
+ setGroupLanguage(conversationId, lang) {
4048
+ this.ctx.db.run(
4049
+ "INSERT INTO group_language (conversation_id, lang, updated_at) VALUES (?, ?, ?) ON CONFLICT (conversation_id) DO UPDATE SET lang = excluded.lang, updated_at = excluded.updated_at",
4050
+ conversationId,
4051
+ lang,
4052
+ this.ctx.now()
4053
+ );
4054
+ }
4055
+ markGroupLanguageAsked(conversationId) {
4056
+ const changes = this.ctx.db.run(
4057
+ "INSERT INTO group_language (conversation_id, lang, updated_at) VALUES (?, '', ?) ON CONFLICT (conversation_id) DO NOTHING",
4058
+ conversationId,
4059
+ this.ctx.now()
4060
+ );
4061
+ return changes > 0;
4062
+ }
4063
+ unmarkGroupLanguageAsked(conversationId) {
4064
+ this.ctx.db.run("DELETE FROM group_language WHERE conversation_id = ? AND lang = ''", conversationId);
4065
+ }
4066
+ };
4067
+
4034
4068
  // packages/runtime/src/sqlite/people-repository.ts
4035
4069
  import {
4036
4070
  DEFAULT_QUIET,
@@ -4706,6 +4740,7 @@ var SqliteStore = class {
4706
4740
  approvals;
4707
4741
  observe;
4708
4742
  groupContext;
4743
+ groupLanguage;
4709
4744
  assistantCards;
4710
4745
  assistantButtons;
4711
4746
  assistantMessages;
@@ -4738,6 +4773,7 @@ var SqliteStore = class {
4738
4773
  this.approvals = new SqliteApprovalRepository(ctx);
4739
4774
  this.observe = new SqliteObserveRepository(ctx);
4740
4775
  this.groupContext = new SqliteGroupContextRepository(ctx);
4776
+ this.groupLanguage = new SqliteGroupLanguageRepository(ctx);
4741
4777
  this.assistantCards = new SqliteAssistantCardRepository(ctx);
4742
4778
  this.assistantButtons = new SqliteAssistantButtonRepository(ctx);
4743
4779
  this.assistantMessages = new SqliteAssistantMessageRepository(ctx);
@@ -125,5 +125,7 @@ CREATE TABLE IF NOT EXISTS observe_cards (
125
125
  CREATE INDEX IF NOT EXISTS observe_cards_by_suggestion ON observe_cards (aad_id, run_id, seq);
126
126
  CREATE TABLE IF NOT EXISTS group_context_off (
127
127
  conversation_id TEXT PRIMARY KEY, updated_at REAL NOT NULL);
128
+ CREATE TABLE IF NOT EXISTS group_language (
129
+ conversation_id TEXT PRIMARY KEY, lang TEXT NOT NULL, updated_at REAL NOT NULL);
128
130
  CREATE TABLE IF NOT EXISTS bound_users (
129
131
  aad_id TEXT PRIMARY KEY, claw_user_id TEXT NOT NULL, token_hash TEXT NOT NULL, updated_at REAL NOT NULL);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * GroupLanguageRepository on SQLite (table `group_language`: one row per group chat that was asked which language to use, or set
3
+ * one; `lang` "" while it was asked and nobody chose).
4
+ */
5
+ import type { GroupLanguage, GroupLanguageRepository } from "@primusclaw/personal-agent";
6
+ import type { StoreContext } from "./context.js";
7
+ export declare class SqliteGroupLanguageRepository implements GroupLanguageRepository {
8
+ private readonly ctx;
9
+ constructor(ctx: StoreContext);
10
+ groupLanguage(conversationId: string): GroupLanguage | "" | null;
11
+ setGroupLanguage(conversationId: string, lang: GroupLanguage): void;
12
+ markGroupLanguageAsked(conversationId: string): boolean;
13
+ unmarkGroupLanguageAsked(conversationId: string): void;
14
+ }
@@ -14,6 +14,7 @@ import { SqliteMemberDirectoryRepository } from "./member-repository.js";
14
14
  import { SqliteNotifySubscriptionRepository } from "./notify-repository.js";
15
15
  import { SqliteObserveRepository } from "./observe-repository.js";
16
16
  import { SqliteGroupContextRepository } from "./group-context-repository.js";
17
+ import { SqliteGroupLanguageRepository } from "./group-language-repository.js";
17
18
  import { SqliteOnboardingRepository } from "./onboarding-repository.js";
18
19
  import { SqliteConversationRefRepository, SqliteHeldEventRepository, SqlitePrefsRepository } from "./people-repository.js";
19
20
  import { type ReencryptCounts } from "./reencrypt.js";
@@ -47,6 +48,7 @@ export declare class SqliteStore implements StorePort {
47
48
  readonly approvals: SqliteApprovalRepository;
48
49
  readonly observe: SqliteObserveRepository;
49
50
  readonly groupContext: SqliteGroupContextRepository;
51
+ readonly groupLanguage: SqliteGroupLanguageRepository;
50
52
  readonly assistantCards: SqliteAssistantCardRepository;
51
53
  readonly assistantButtons: SqliteAssistantButtonRepository;
52
54
  readonly assistantMessages: SqliteAssistantMessageRepository;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primusclaw/personal-agent-runtime",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Node adapters for the personal agent's ports: clock, randomness, logging (and, as the port lands, storage, Claw, metrics, HTTP).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@primusclaw/personal-agent": "0.6.0",
32
+ "@primusclaw/personal-agent": "0.7.0",
33
33
  "fastify": "^5.12.8",
34
34
  "zod": "^4.6.7"
35
35
  }