@happyvertical/smrt-chat 0.38.24 → 0.38.26

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 (36) hide show
  1. package/AGENTS.md +24 -2
  2. package/README.md +123 -3
  3. package/dist/chunks/{ChatService-BRsE5HmY.js → ChatService-B9rJuwtb.js} +269 -110
  4. package/dist/chunks/ChatService-B9rJuwtb.js.map +1 -0
  5. package/dist/collections/VoiceGatewayTurnCollection.d.ts +13 -0
  6. package/dist/collections/VoiceGatewayTurnCollection.d.ts.map +1 -0
  7. package/dist/collections/VoiceSessionCollection.d.ts +11 -0
  8. package/dist/collections/VoiceSessionCollection.d.ts.map +1 -0
  9. package/dist/index.d.ts +4 -3
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +495 -13
  12. package/dist/index.js.map +1 -1
  13. package/dist/internal/agent-runtime.js +1 -1
  14. package/dist/manifest.json +2795 -1892
  15. package/dist/models/VoiceGatewayTurn.d.ts +20 -0
  16. package/dist/models/VoiceGatewayTurn.d.ts.map +1 -0
  17. package/dist/models/VoiceSession.d.ts +40 -0
  18. package/dist/models/VoiceSession.d.ts.map +1 -0
  19. package/dist/models/index.d.ts +2 -0
  20. package/dist/models/index.d.ts.map +1 -1
  21. package/dist/persona-conversation.d.ts +8 -0
  22. package/dist/persona-conversation.d.ts.map +1 -1
  23. package/dist/services/ChatService.d.ts.map +1 -1
  24. package/dist/smrt-knowledge.json +597 -125
  25. package/dist/svelte/components/layout/ChatLayout.svelte +7 -3
  26. package/dist/svelte/components/messages/MessageInput.svelte +22 -15
  27. package/dist/svelte/components/messages/MessageInput.svelte.d.ts.map +1 -1
  28. package/dist/types.d.ts +30 -0
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/ui.d.ts.map +1 -1
  31. package/dist/ui.js +4 -2
  32. package/dist/ui.js.map +1 -1
  33. package/dist/voice.d.ts +127 -0
  34. package/dist/voice.d.ts.map +1 -0
  35. package/package.json +16 -14
  36. package/dist/chunks/ChatService-BRsE5HmY.js.map +0 -1
@@ -2,30 +2,30 @@ import { ObjectRegistry, SmrtCollection, SmrtObject, crossPackageRef, field, for
2
2
  import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy";
3
3
  import { createHash } from "node:crypto";
4
4
  //#region \0rolldown/runtime.js
5
- var __defProp$6 = Object.defineProperty;
5
+ var __defProp$7 = Object.defineProperty;
6
6
  var __exportAll = (all, no_symbols) => {
7
7
  let target = {};
8
- for (var name in all) __defProp$6(target, name, {
8
+ for (var name in all) __defProp$7(target, name, {
9
9
  get: all[name],
10
10
  enumerable: true
11
11
  });
12
- if (!no_symbols) __defProp$6(target, Symbol.toStringTag, { value: "Module" });
12
+ if (!no_symbols) __defProp$7(target, Symbol.toStringTag, { value: "Module" });
13
13
  return target;
14
14
  };
15
15
  //#endregion
16
16
  //#region src/models/AgentSession.ts
17
- var __defProp$5 = Object.defineProperty;
18
- var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
19
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp$5(obj, key, {
17
+ var __defProp$6 = Object.defineProperty;
18
+ var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
19
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp$6(obj, key, {
20
20
  enumerable: true,
21
21
  configurable: true,
22
22
  writable: true,
23
23
  value
24
24
  }) : obj[key] = value;
25
- var __decorateClass$5 = (decorators, target, key, kind) => {
26
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
25
+ var __decorateClass$6 = (decorators, target, key, kind) => {
26
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
27
27
  for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
28
- if (kind && result) __defProp$5(target, key, result);
28
+ if (kind && result) __defProp$6(target, key, result);
29
29
  return result;
30
30
  };
31
31
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -152,22 +152,22 @@ var AgentSession = class extends SmrtObject {
152
152
  * require an exact match so distinct subjects get distinct sessions.
153
153
  */
154
154
  __publicField(AgentSession, "SESSION_KEY_CONTEXT_FIELD", "__sessionKey");
155
- __decorateClass$5([tenantId({ nullable: true })], AgentSession.prototype, "tenantId", 2);
156
- __decorateClass$5([field({ required: true })], AgentSession.prototype, "agentId", 2);
157
- __decorateClass$5([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], AgentSession.prototype, "participantProfileId", 2);
158
- __decorateClass$5([foreignKey("ChatRoom")], AgentSession.prototype, "chatRoomId", 2);
159
- __decorateClass$5([field({ required: true })], AgentSession.prototype, "status", 2);
160
- __decorateClass$5([field()], AgentSession.prototype, "allowedTools", 2);
161
- __decorateClass$5([field()], AgentSession.prototype, "sessionContext", 2);
162
- __decorateClass$5([field()], AgentSession.prototype, "systemPrompt", 2);
163
- __decorateClass$5([field()], AgentSession.prototype, "messageCount", 2);
164
- __decorateClass$5([field()], AgentSession.prototype, "totalTokensUsed", 2);
165
- __decorateClass$5([field()], AgentSession.prototype, "maxTokens", 2);
166
- __decorateClass$5([field()], AgentSession.prototype, "maxMessages", 2);
167
- __decorateClass$5([field()], AgentSession.prototype, "lastMessageAt", 2);
168
- __decorateClass$5([field()], AgentSession.prototype, "expiresAt", 2);
169
- __decorateClass$5([field()], AgentSession.prototype, "closedAt", 2);
170
- AgentSession = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt({
155
+ __decorateClass$6([tenantId({ nullable: true })], AgentSession.prototype, "tenantId", 2);
156
+ __decorateClass$6([field({ required: true })], AgentSession.prototype, "agentId", 2);
157
+ __decorateClass$6([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], AgentSession.prototype, "participantProfileId", 2);
158
+ __decorateClass$6([foreignKey("ChatRoom")], AgentSession.prototype, "chatRoomId", 2);
159
+ __decorateClass$6([field({ required: true })], AgentSession.prototype, "status", 2);
160
+ __decorateClass$6([field()], AgentSession.prototype, "allowedTools", 2);
161
+ __decorateClass$6([field()], AgentSession.prototype, "sessionContext", 2);
162
+ __decorateClass$6([field()], AgentSession.prototype, "systemPrompt", 2);
163
+ __decorateClass$6([field()], AgentSession.prototype, "messageCount", 2);
164
+ __decorateClass$6([field()], AgentSession.prototype, "totalTokensUsed", 2);
165
+ __decorateClass$6([field()], AgentSession.prototype, "maxTokens", 2);
166
+ __decorateClass$6([field()], AgentSession.prototype, "maxMessages", 2);
167
+ __decorateClass$6([field()], AgentSession.prototype, "lastMessageAt", 2);
168
+ __decorateClass$6([field()], AgentSession.prototype, "expiresAt", 2);
169
+ __decorateClass$6([field()], AgentSession.prototype, "closedAt", 2);
170
+ AgentSession = __decorateClass$6([TenantScoped({ mode: "optional" }), smrt({
171
171
  tableName: "agent_sessions",
172
172
  api: { include: ["list", "get"] },
173
173
  mcp: { include: ["list", "get"] },
@@ -175,12 +175,12 @@ AgentSession = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt({
175
175
  })], AgentSession);
176
176
  //#endregion
177
177
  //#region src/models/ChatMessage.ts
178
- var __defProp$4 = Object.defineProperty;
179
- var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
180
- var __decorateClass$4 = (decorators, target, key, kind) => {
181
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
178
+ var __defProp$5 = Object.defineProperty;
179
+ var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
180
+ var __decorateClass$5 = (decorators, target, key, kind) => {
181
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
182
182
  for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
183
- if (kind && result) __defProp$4(target, key, result);
183
+ if (kind && result) __defProp$5(target, key, result);
184
184
  return result;
185
185
  };
186
186
  var ChatMessage = class extends SmrtObject {
@@ -281,22 +281,22 @@ var ChatMessage = class extends SmrtObject {
281
281
  return `${text.slice(0, maxLength)}...`;
282
282
  }
283
283
  };
284
- __decorateClass$4([tenantId()], ChatMessage.prototype, "tenantId", 2);
285
- __decorateClass$4([foreignKey("ChatRoom", { required: true })], ChatMessage.prototype, "roomId", 2);
286
- __decorateClass$4([foreignKey("ChatThread")], ChatMessage.prototype, "threadId", 2);
287
- __decorateClass$4([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], ChatMessage.prototype, "senderProfileId", 2);
288
- __decorateClass$4([foreignKey("AgentSession")], ChatMessage.prototype, "agentSessionId", 2);
289
- __decorateClass$4([field()], ChatMessage.prototype, "content", 2);
290
- __decorateClass$4([field({ required: true })], ChatMessage.prototype, "messageType", 2);
291
- __decorateClass$4([field({ required: true })], ChatMessage.prototype, "role", 2);
292
- __decorateClass$4([field()], ChatMessage.prototype, "isEdited", 2);
293
- __decorateClass$4([field()], ChatMessage.prototype, "editedAt", 2);
294
- __decorateClass$4([field()], ChatMessage.prototype, "isDeleted", 2);
295
- __decorateClass$4([foreignKey("ChatMessage")], ChatMessage.prototype, "replyToMessageId", 2);
296
- __decorateClass$4([field()], ChatMessage.prototype, "metadata", 2);
297
- __decorateClass$4([field()], ChatMessage.prototype, "toolCallData", 2);
298
- __decorateClass$4([field()], ChatMessage.prototype, "attachments", 2);
299
- ChatMessage = __decorateClass$4([TenantScoped({ mode: "required" }), smrt({
284
+ __decorateClass$5([tenantId()], ChatMessage.prototype, "tenantId", 2);
285
+ __decorateClass$5([foreignKey("ChatRoom", { required: true })], ChatMessage.prototype, "roomId", 2);
286
+ __decorateClass$5([foreignKey("ChatThread")], ChatMessage.prototype, "threadId", 2);
287
+ __decorateClass$5([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], ChatMessage.prototype, "senderProfileId", 2);
288
+ __decorateClass$5([foreignKey("AgentSession")], ChatMessage.prototype, "agentSessionId", 2);
289
+ __decorateClass$5([field()], ChatMessage.prototype, "content", 2);
290
+ __decorateClass$5([field({ required: true })], ChatMessage.prototype, "messageType", 2);
291
+ __decorateClass$5([field({ required: true })], ChatMessage.prototype, "role", 2);
292
+ __decorateClass$5([field()], ChatMessage.prototype, "isEdited", 2);
293
+ __decorateClass$5([field()], ChatMessage.prototype, "editedAt", 2);
294
+ __decorateClass$5([field()], ChatMessage.prototype, "isDeleted", 2);
295
+ __decorateClass$5([foreignKey("ChatMessage")], ChatMessage.prototype, "replyToMessageId", 2);
296
+ __decorateClass$5([field()], ChatMessage.prototype, "metadata", 2);
297
+ __decorateClass$5([field()], ChatMessage.prototype, "toolCallData", 2);
298
+ __decorateClass$5([field()], ChatMessage.prototype, "attachments", 2);
299
+ ChatMessage = __decorateClass$5([TenantScoped({ mode: "required" }), smrt({
300
300
  tableName: "chat_messages",
301
301
  api: { include: ["list", "get"] },
302
302
  mcp: { include: ["list", "get"] },
@@ -304,12 +304,12 @@ ChatMessage = __decorateClass$4([TenantScoped({ mode: "required" }), smrt({
304
304
  })], ChatMessage);
305
305
  //#endregion
306
306
  //#region src/models/ChatParticipant.ts
307
- var __defProp$3 = Object.defineProperty;
308
- var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
309
- var __decorateClass$3 = (decorators, target, key, kind) => {
310
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
307
+ var __defProp$4 = Object.defineProperty;
308
+ var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
309
+ var __decorateClass$4 = (decorators, target, key, kind) => {
310
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
311
311
  for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
312
- if (kind && result) __defProp$3(target, key, result);
312
+ if (kind && result) __defProp$4(target, key, result);
313
313
  return result;
314
314
  };
315
315
  var ChatParticipant = class extends SmrtObject {
@@ -364,19 +364,19 @@ var ChatParticipant = class extends SmrtObject {
364
364
  await this.save();
365
365
  }
366
366
  };
367
- __decorateClass$3([tenantId()], ChatParticipant.prototype, "tenantId", 2);
368
- __decorateClass$3([foreignKey("ChatRoom", { required: true })], ChatParticipant.prototype, "roomId", 2);
369
- __decorateClass$3([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], ChatParticipant.prototype, "profileId", 2);
370
- __decorateClass$3([field({ required: true })], ChatParticipant.prototype, "role", 2);
371
- __decorateClass$3([field({ required: true })], ChatParticipant.prototype, "status", 2);
372
- __decorateClass$3([field({ required: true })], ChatParticipant.prototype, "onlineStatus", 2);
373
- __decorateClass$3([foreignKey("ChatMessage")], ChatParticipant.prototype, "lastReadMessageId", 2);
374
- __decorateClass$3([field()], ChatParticipant.prototype, "lastSeenAt", 2);
375
- __decorateClass$3([field()], ChatParticipant.prototype, "joinedAt", 2);
376
- __decorateClass$3([field()], ChatParticipant.prototype, "nickname", 2);
377
- __decorateClass$3([field()], ChatParticipant.prototype, "isMuted", 2);
378
- __decorateClass$3([field()], ChatParticipant.prototype, "isPinned", 2);
379
- ChatParticipant = __decorateClass$3([TenantScoped({ mode: "required" }), smrt({
367
+ __decorateClass$4([tenantId()], ChatParticipant.prototype, "tenantId", 2);
368
+ __decorateClass$4([foreignKey("ChatRoom", { required: true })], ChatParticipant.prototype, "roomId", 2);
369
+ __decorateClass$4([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], ChatParticipant.prototype, "profileId", 2);
370
+ __decorateClass$4([field({ required: true })], ChatParticipant.prototype, "role", 2);
371
+ __decorateClass$4([field({ required: true })], ChatParticipant.prototype, "status", 2);
372
+ __decorateClass$4([field({ required: true })], ChatParticipant.prototype, "onlineStatus", 2);
373
+ __decorateClass$4([foreignKey("ChatMessage")], ChatParticipant.prototype, "lastReadMessageId", 2);
374
+ __decorateClass$4([field()], ChatParticipant.prototype, "lastSeenAt", 2);
375
+ __decorateClass$4([field()], ChatParticipant.prototype, "joinedAt", 2);
376
+ __decorateClass$4([field()], ChatParticipant.prototype, "nickname", 2);
377
+ __decorateClass$4([field()], ChatParticipant.prototype, "isMuted", 2);
378
+ __decorateClass$4([field()], ChatParticipant.prototype, "isPinned", 2);
379
+ ChatParticipant = __decorateClass$4([TenantScoped({ mode: "required" }), smrt({
380
380
  tableName: "chat_participants",
381
381
  api: { include: ["list", "get"] },
382
382
  mcp: { include: ["list", "get"] },
@@ -384,12 +384,12 @@ ChatParticipant = __decorateClass$3([TenantScoped({ mode: "required" }), smrt({
384
384
  })], ChatParticipant);
385
385
  //#endregion
386
386
  //#region src/models/ChatReaction.ts
387
- var __defProp$2 = Object.defineProperty;
388
- var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
389
- var __decorateClass$2 = (decorators, target, key, kind) => {
390
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
387
+ var __defProp$3 = Object.defineProperty;
388
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
389
+ var __decorateClass$3 = (decorators, target, key, kind) => {
390
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
391
391
  for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
392
- if (kind && result) __defProp$2(target, key, result);
392
+ if (kind && result) __defProp$3(target, key, result);
393
393
  return result;
394
394
  };
395
395
  var ChatReaction = class extends SmrtObject {
@@ -405,11 +405,11 @@ var ChatReaction = class extends SmrtObject {
405
405
  if (options.emoji !== void 0) this.emoji = options.emoji;
406
406
  }
407
407
  };
408
- __decorateClass$2([tenantId()], ChatReaction.prototype, "tenantId", 2);
409
- __decorateClass$2([foreignKey("ChatMessage", { required: true })], ChatReaction.prototype, "messageId", 2);
410
- __decorateClass$2([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], ChatReaction.prototype, "profileId", 2);
411
- __decorateClass$2([field({ required: true })], ChatReaction.prototype, "emoji", 2);
412
- ChatReaction = __decorateClass$2([TenantScoped({ mode: "required" }), smrt({
408
+ __decorateClass$3([tenantId()], ChatReaction.prototype, "tenantId", 2);
409
+ __decorateClass$3([foreignKey("ChatMessage", { required: true })], ChatReaction.prototype, "messageId", 2);
410
+ __decorateClass$3([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], ChatReaction.prototype, "profileId", 2);
411
+ __decorateClass$3([field({ required: true })], ChatReaction.prototype, "emoji", 2);
412
+ ChatReaction = __decorateClass$3([TenantScoped({ mode: "required" }), smrt({
413
413
  tableName: "chat_reactions",
414
414
  api: { include: ["list"] },
415
415
  mcp: { include: ["list"] },
@@ -417,12 +417,12 @@ ChatReaction = __decorateClass$2([TenantScoped({ mode: "required" }), smrt({
417
417
  })], ChatReaction);
418
418
  //#endregion
419
419
  //#region src/models/ChatRoom.ts
420
- var __defProp$1 = Object.defineProperty;
421
- var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
422
- var __decorateClass$1 = (decorators, target, key, kind) => {
423
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
420
+ var __defProp$2 = Object.defineProperty;
421
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
422
+ var __decorateClass$2 = (decorators, target, key, kind) => {
423
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
424
424
  for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
425
- if (kind && result) __defProp$1(target, key, result);
425
+ if (kind && result) __defProp$2(target, key, result);
426
426
  return result;
427
427
  };
428
428
  var ChatRoom = class extends SmrtObject {
@@ -493,19 +493,19 @@ var ChatRoom = class extends SmrtObject {
493
493
  await this.save();
494
494
  }
495
495
  };
496
- __decorateClass$1([tenantId()], ChatRoom.prototype, "tenantId", 2);
497
- __decorateClass$1([field()], ChatRoom.prototype, "name", 2);
498
- __decorateClass$1([field()], ChatRoom.prototype, "description", 2);
499
- __decorateClass$1([field({ required: true })], ChatRoom.prototype, "roomType", 2);
500
- __decorateClass$1([field({ required: true })], ChatRoom.prototype, "status", 2);
501
- __decorateClass$1([field()], ChatRoom.prototype, "topic", 2);
502
- __decorateClass$1([field()], ChatRoom.prototype, "avatarUrl", 2);
503
- __decorateClass$1([field()], ChatRoom.prototype, "isArchived", 2);
504
- __decorateClass$1([field()], ChatRoom.prototype, "maxParticipants", 2);
505
- __decorateClass$1([field()], ChatRoom.prototype, "metadata", 2);
506
- __decorateClass$1([crossPackageRef("@happyvertical/smrt-profiles:Profile")], ChatRoom.prototype, "createdByProfileId", 2);
507
- __decorateClass$1([field()], ChatRoom.prototype, "lastMessageAt", 2);
508
- ChatRoom = __decorateClass$1([TenantScoped({ mode: "required" }), smrt({
496
+ __decorateClass$2([tenantId()], ChatRoom.prototype, "tenantId", 2);
497
+ __decorateClass$2([field()], ChatRoom.prototype, "name", 2);
498
+ __decorateClass$2([field()], ChatRoom.prototype, "description", 2);
499
+ __decorateClass$2([field({ required: true })], ChatRoom.prototype, "roomType", 2);
500
+ __decorateClass$2([field({ required: true })], ChatRoom.prototype, "status", 2);
501
+ __decorateClass$2([field()], ChatRoom.prototype, "topic", 2);
502
+ __decorateClass$2([field()], ChatRoom.prototype, "avatarUrl", 2);
503
+ __decorateClass$2([field()], ChatRoom.prototype, "isArchived", 2);
504
+ __decorateClass$2([field()], ChatRoom.prototype, "maxParticipants", 2);
505
+ __decorateClass$2([field()], ChatRoom.prototype, "metadata", 2);
506
+ __decorateClass$2([crossPackageRef("@happyvertical/smrt-profiles:Profile")], ChatRoom.prototype, "createdByProfileId", 2);
507
+ __decorateClass$2([field()], ChatRoom.prototype, "lastMessageAt", 2);
508
+ ChatRoom = __decorateClass$2([TenantScoped({ mode: "required" }), smrt({
509
509
  tableName: "chat_rooms",
510
510
  api: { include: ["list", "get"] },
511
511
  mcp: { include: ["list", "get"] },
@@ -513,12 +513,12 @@ ChatRoom = __decorateClass$1([TenantScoped({ mode: "required" }), smrt({
513
513
  })], ChatRoom);
514
514
  //#endregion
515
515
  //#region src/models/ChatThread.ts
516
- var __defProp = Object.defineProperty;
517
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
518
- var __decorateClass = (decorators, target, key, kind) => {
519
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
516
+ var __defProp$1 = Object.defineProperty;
517
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
518
+ var __decorateClass$1 = (decorators, target, key, kind) => {
519
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
520
520
  for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
521
- if (kind && result) __defProp(target, key, result);
521
+ if (kind && result) __defProp$1(target, key, result);
522
522
  return result;
523
523
  };
524
524
  var ChatThread = class extends SmrtObject {
@@ -550,21 +550,147 @@ var ChatThread = class extends SmrtObject {
550
550
  await this.save();
551
551
  }
552
552
  };
553
- __decorateClass([tenantId()], ChatThread.prototype, "tenantId", 2);
554
- __decorateClass([foreignKey("ChatRoom", { required: true })], ChatThread.prototype, "roomId", 2);
555
- __decorateClass([foreignKey("ChatMessage", { nullable: true })], ChatThread.prototype, "rootMessageId", 2);
556
- __decorateClass([field()], ChatThread.prototype, "title", 2);
557
- __decorateClass([field()], ChatThread.prototype, "isResolved", 2);
558
- __decorateClass([field()], ChatThread.prototype, "messageCount", 2);
559
- __decorateClass([field()], ChatThread.prototype, "lastMessageAt", 2);
560
- __decorateClass([field()], ChatThread.prototype, "participantCount", 2);
561
- ChatThread = __decorateClass([TenantScoped({ mode: "required" }), smrt({
553
+ __decorateClass$1([tenantId()], ChatThread.prototype, "tenantId", 2);
554
+ __decorateClass$1([foreignKey("ChatRoom", { required: true })], ChatThread.prototype, "roomId", 2);
555
+ __decorateClass$1([foreignKey("ChatMessage", { nullable: true })], ChatThread.prototype, "rootMessageId", 2);
556
+ __decorateClass$1([field()], ChatThread.prototype, "title", 2);
557
+ __decorateClass$1([field()], ChatThread.prototype, "isResolved", 2);
558
+ __decorateClass$1([field()], ChatThread.prototype, "messageCount", 2);
559
+ __decorateClass$1([field()], ChatThread.prototype, "lastMessageAt", 2);
560
+ __decorateClass$1([field()], ChatThread.prototype, "participantCount", 2);
561
+ ChatThread = __decorateClass$1([TenantScoped({ mode: "required" }), smrt({
562
562
  tableName: "chat_threads",
563
563
  api: { include: ["list", "get"] },
564
564
  mcp: { include: ["list", "get"] },
565
565
  cli: true
566
566
  })], ChatThread);
567
567
  //#endregion
568
+ //#region src/models/VoiceSession.ts
569
+ var __defProp = Object.defineProperty;
570
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
571
+ var __decorateClass = (decorators, target, key, kind) => {
572
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
573
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
574
+ if (kind && result) __defProp(target, key, result);
575
+ return result;
576
+ };
577
+ var VoiceSession = class extends SmrtObject {
578
+ tenantId = "";
579
+ gatewaySessionId = "";
580
+ actorProfileId = "";
581
+ actorUserId = null;
582
+ personaId = "";
583
+ agentSessionId = "";
584
+ chatRoomId = "";
585
+ threadId = null;
586
+ target = "smrt:chat";
587
+ status = "active";
588
+ expiresAt = new Date(Date.now() + 600 * 1e3);
589
+ lastTurnAt = null;
590
+ lastGatewayTurnId = null;
591
+ personaSnapshot = "{}";
592
+ metadata = "{}";
593
+ processedTurnIds = "[]";
594
+ constructor(options = {}) {
595
+ super(options);
596
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
597
+ if (options.gatewaySessionId !== void 0) this.gatewaySessionId = options.gatewaySessionId;
598
+ if (options.actorProfileId !== void 0) this.actorProfileId = options.actorProfileId;
599
+ if (options.actorUserId !== void 0) this.actorUserId = options.actorUserId;
600
+ if (options.personaId !== void 0) this.personaId = options.personaId;
601
+ if (options.agentSessionId !== void 0) this.agentSessionId = options.agentSessionId;
602
+ if (options.chatRoomId !== void 0) this.chatRoomId = options.chatRoomId;
603
+ if (options.threadId !== void 0) this.threadId = options.threadId;
604
+ if (options.target !== void 0) this.target = options.target;
605
+ if (options.status !== void 0) this.status = options.status;
606
+ if (options.expiresAt !== void 0) this.expiresAt = options.expiresAt;
607
+ if (options.lastTurnAt !== void 0) this.lastTurnAt = options.lastTurnAt;
608
+ if (options.lastGatewayTurnId !== void 0) this.lastGatewayTurnId = options.lastGatewayTurnId;
609
+ if (options.personaSnapshot !== void 0) this.personaSnapshot = typeof options.personaSnapshot === "string" ? options.personaSnapshot : JSON.stringify(options.personaSnapshot);
610
+ if (options.metadata !== void 0) this.metadata = typeof options.metadata === "string" ? options.metadata : JSON.stringify(options.metadata);
611
+ if (options.processedTurnIds !== void 0) this.processedTurnIds = typeof options.processedTurnIds === "string" ? options.processedTurnIds : JSON.stringify(options.processedTurnIds);
612
+ }
613
+ isActive(now = /* @__PURE__ */ new Date()) {
614
+ return this.status === "active" && now < this.expiresAt;
615
+ }
616
+ isExpired(now = /* @__PURE__ */ new Date()) {
617
+ return now >= this.expiresAt;
618
+ }
619
+ async expire() {
620
+ this.status = "expired";
621
+ await this.save();
622
+ }
623
+ async revoke() {
624
+ this.status = "revoked";
625
+ await this.save();
626
+ }
627
+ getPersonaSnapshot() {
628
+ try {
629
+ return JSON.parse(this.personaSnapshot);
630
+ } catch {
631
+ return {
632
+ id: this.personaId,
633
+ tenantId: this.tenantId,
634
+ runAsUserId: "",
635
+ allowedTools: []
636
+ };
637
+ }
638
+ }
639
+ setPersonaSnapshot(persona) {
640
+ this.personaSnapshot = JSON.stringify(persona);
641
+ }
642
+ getMetadata() {
643
+ try {
644
+ return JSON.parse(this.metadata);
645
+ } catch {
646
+ return {};
647
+ }
648
+ }
649
+ setMetadata(metadata) {
650
+ this.metadata = JSON.stringify(metadata);
651
+ }
652
+ getProcessedTurnIds() {
653
+ try {
654
+ const parsed = JSON.parse(this.processedTurnIds);
655
+ return Array.isArray(parsed) ? parsed.filter((id) => typeof id === "string") : [];
656
+ } catch {
657
+ return [];
658
+ }
659
+ }
660
+ hasProcessedTurn(turnId) {
661
+ return this.getProcessedTurnIds().includes(turnId);
662
+ }
663
+ recordGatewayTurn(turnId, maxRememberedTurns = 50) {
664
+ const ids = this.getProcessedTurnIds().filter((id) => id !== turnId);
665
+ ids.push(turnId);
666
+ this.processedTurnIds = JSON.stringify(ids.slice(-maxRememberedTurns));
667
+ this.lastGatewayTurnId = turnId;
668
+ this.lastTurnAt = /* @__PURE__ */ new Date();
669
+ }
670
+ };
671
+ __decorateClass([tenantId()], VoiceSession.prototype, "tenantId", 2);
672
+ __decorateClass([field({ required: true })], VoiceSession.prototype, "gatewaySessionId", 2);
673
+ __decorateClass([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], VoiceSession.prototype, "actorProfileId", 2);
674
+ __decorateClass([crossPackageRef("@happyvertical/smrt-users:User", { nullable: true })], VoiceSession.prototype, "actorUserId", 2);
675
+ __decorateClass([crossPackageRef("@happyvertical/smrt-personas:AgentPersona", { required: true })], VoiceSession.prototype, "personaId", 2);
676
+ __decorateClass([foreignKey("AgentSession", { required: true })], VoiceSession.prototype, "agentSessionId", 2);
677
+ __decorateClass([foreignKey("ChatRoom", { required: true })], VoiceSession.prototype, "chatRoomId", 2);
678
+ __decorateClass([foreignKey("ChatThread")], VoiceSession.prototype, "threadId", 2);
679
+ __decorateClass([field({ required: true })], VoiceSession.prototype, "target", 2);
680
+ __decorateClass([field({ required: true })], VoiceSession.prototype, "status", 2);
681
+ __decorateClass([field({ required: true })], VoiceSession.prototype, "expiresAt", 2);
682
+ __decorateClass([field()], VoiceSession.prototype, "lastTurnAt", 2);
683
+ __decorateClass([field()], VoiceSession.prototype, "lastGatewayTurnId", 2);
684
+ __decorateClass([field()], VoiceSession.prototype, "personaSnapshot", 2);
685
+ __decorateClass([field()], VoiceSession.prototype, "metadata", 2);
686
+ __decorateClass([field()], VoiceSession.prototype, "processedTurnIds", 2);
687
+ VoiceSession = __decorateClass([TenantScoped({ mode: "required" }), smrt({
688
+ tableName: "voice_sessions",
689
+ api: { include: ["list", "get"] },
690
+ mcp: { include: ["list", "get"] },
691
+ cli: true
692
+ })], VoiceSession);
693
+ //#endregion
568
694
  //#region src/collections/AgentSessionCollection.ts
569
695
  var AgentSessionCollection = class extends SmrtCollection {
570
696
  static _itemClass = AgentSession;
@@ -1070,6 +1196,34 @@ var ChatThreadCollection = class extends SmrtCollection {
1070
1196
  }
1071
1197
  };
1072
1198
  //#endregion
1199
+ //#region src/collections/VoiceSessionCollection.ts
1200
+ var VoiceSessionCollection = class extends SmrtCollection {
1201
+ static _itemClass = VoiceSession;
1202
+ async getActiveById(id, target = "smrt:chat") {
1203
+ const session = await this.get({
1204
+ id,
1205
+ target
1206
+ });
1207
+ if (!session?.isActive()) return null;
1208
+ return session;
1209
+ }
1210
+ async expireStale(olderThan = /* @__PURE__ */ new Date(), scope) {
1211
+ const where = {
1212
+ status: "active",
1213
+ "expiresAt <": olderThan
1214
+ };
1215
+ if (scope?.tenantId !== void 0) where.tenantId = scope.tenantId;
1216
+ if (scope?.target !== void 0) where.target = scope.target;
1217
+ const stale = await this.list({ where });
1218
+ let expired = 0;
1219
+ for (const session of stale) {
1220
+ await session.expire();
1221
+ expired++;
1222
+ }
1223
+ return expired;
1224
+ }
1225
+ };
1226
+ //#endregion
1073
1227
  //#region src/services/ChatService.ts
1074
1228
  var ChatService_exports = /* @__PURE__ */ __exportAll({
1075
1229
  ChatService: () => ChatService,
@@ -1083,13 +1237,15 @@ var ChatService = class ChatService {
1083
1237
  #threads;
1084
1238
  #agentSessions;
1085
1239
  #reactions;
1086
- constructor(rooms, messages, participants, threads, agentSessions, reactions) {
1240
+ #voiceSessions;
1241
+ constructor(rooms, messages, participants, threads, agentSessions, reactions, voiceSessions) {
1087
1242
  this.#rooms = rooms;
1088
1243
  this.#messages = messages;
1089
1244
  this.#participants = participants;
1090
1245
  this.#threads = threads;
1091
1246
  this.#agentSessions = agentSessions;
1092
1247
  this.#reactions = reactions;
1248
+ this.#voiceSessions = voiceSessions;
1093
1249
  }
1094
1250
  static async create(options) {
1095
1251
  ObjectRegistry.registerCollection("@happyvertical/smrt-chat:ChatRoom", ChatRoomCollection);
@@ -1098,13 +1254,15 @@ var ChatService = class ChatService {
1098
1254
  ObjectRegistry.registerCollection("@happyvertical/smrt-chat:ChatThread", ChatThreadCollection);
1099
1255
  ObjectRegistry.registerCollection("@happyvertical/smrt-chat:AgentSession", AgentSessionCollection);
1100
1256
  ObjectRegistry.registerCollection("@happyvertical/smrt-chat:ChatReaction", ChatReactionCollection);
1257
+ ObjectRegistry.registerCollection("@happyvertical/smrt-chat:VoiceSession", VoiceSessionCollection);
1101
1258
  const rooms = await ObjectRegistry.getCollection("@happyvertical/smrt-chat:ChatRoom", options);
1102
1259
  const messages = await ObjectRegistry.getCollection("@happyvertical/smrt-chat:ChatMessage", options);
1103
1260
  const participants = await ObjectRegistry.getCollection("@happyvertical/smrt-chat:ChatParticipant", options);
1104
1261
  const threads = await ObjectRegistry.getCollection("@happyvertical/smrt-chat:ChatThread", options);
1105
1262
  const agentSessions = await ObjectRegistry.getCollection("@happyvertical/smrt-chat:AgentSession", options);
1106
1263
  const reactions = await ObjectRegistry.getCollection("@happyvertical/smrt-chat:ChatReaction", options);
1107
- return new ChatService(rooms, messages, participants, threads, agentSessions, reactions);
1264
+ const voiceSessions = await ObjectRegistry.getCollection("@happyvertical/smrt-chat:VoiceSession", options);
1265
+ return new ChatService(rooms, messages, participants, threads, agentSessions, reactions, voiceSessions);
1108
1266
  }
1109
1267
  /** Initialize all underlying collections (table creation) */
1110
1268
  async initialize() {
@@ -1114,6 +1272,7 @@ var ChatService = class ChatService {
1114
1272
  await this.#threads.initialize();
1115
1273
  await this.#agentSessions.initialize();
1116
1274
  await this.#reactions.initialize();
1275
+ await this.#voiceSessions.initialize();
1117
1276
  }
1118
1277
  /**
1119
1278
  * Create a room and add the creating actor as owner (S5 #1392).
@@ -1753,6 +1912,6 @@ function sendAgentReply(service, params) {
1753
1912
  return ChatService[RUN_AGENT_REPLY](service, params);
1754
1913
  }
1755
1914
  //#endregion
1756
- export { ChatRoom as a, ChatMessage as c, ChatThread as i, AgentSession as l, ChatService_exports as n, ChatReaction as o, sendAgentReply as r, ChatParticipant as s, ChatService as t };
1915
+ export { VoiceSession as a, ChatReaction as c, AgentSession as d, VoiceSessionCollection as i, ChatParticipant as l, ChatService_exports as n, ChatThread as o, sendAgentReply as r, ChatRoom as s, ChatService as t, ChatMessage as u };
1757
1916
 
1758
- //# sourceMappingURL=ChatService-BRsE5HmY.js.map
1917
+ //# sourceMappingURL=ChatService-B9rJuwtb.js.map