@happyvertical/smrt-chat 0.51.32 → 0.51.34

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.
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-chat",
5
- "packageVersion": "0.51.32",
5
+ "packageVersion": "0.51.34",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-chat:AgentSessionCollection": {
8
8
  "name": "agentsessioncollection",
@@ -1,5 +1,5 @@
1
1
  import { SmrtObject } from '@happyvertical/smrt-core';
2
- import { AgentSessionOptions, AgentSessionStatus } from '../types.js';
2
+ import type { AgentSessionOptions, AgentSessionStatus } from '../types.js';
3
3
  /**
4
4
  * Agent conversation session. Internal model — sessions must be created via
5
5
  * {@link ChatService.createAgentSession} and their security-relevant config
@@ -1,5 +1,5 @@
1
1
  import { SmrtObject } from '@happyvertical/smrt-core';
2
- import { ChatMessageOptions, ChatMessageRole, ChatMessageType } from '../types.js';
2
+ import type { ChatMessageOptions, ChatMessageRole, ChatMessageType } from '../types.js';
3
3
  /**
4
4
  * Chat message. Internal model — all mutations must go through the
5
5
  * membership-checked {@link ChatService} (S5 #1392). The generated CRUD surface
@@ -1,5 +1,5 @@
1
1
  import { SmrtObject } from '@happyvertical/smrt-core';
2
- import { ChatParticipantOptions, ChatParticipantRole, ChatParticipantStatus, OnlineStatus } from '../types.js';
2
+ import type { ChatParticipantOptions, ChatParticipantRole, ChatParticipantStatus, OnlineStatus } from '../types.js';
3
3
  /**
4
4
  * Room membership row. Internal model — membership must be established and
5
5
  * mutated only through the membership/owner-checked {@link ChatService}
@@ -1,5 +1,5 @@
1
1
  import { SmrtObject } from '@happyvertical/smrt-core';
2
- import { ChatReactionOptions } from '../types.js';
2
+ import type { ChatReactionOptions } from '../types.js';
3
3
  /**
4
4
  * Message reaction. Internal model — reactions must be added/removed only
5
5
  * through the membership-checked {@link ChatService} (S5 #1392). The generated
@@ -1,5 +1,5 @@
1
1
  import { SmrtObject } from '@happyvertical/smrt-core';
2
- import { ChatRoomOptions, ChatRoomStatus, ChatRoomType } from '../types.js';
2
+ import type { ChatRoomOptions, ChatRoomStatus, ChatRoomType } from '../types.js';
3
3
  type ChatRoomMetadata = Record<string, unknown>;
4
4
  /**
5
5
  * Chat room supporting public channels, private groups, DMs, and agent conversations.
@@ -1,5 +1,5 @@
1
1
  import { SmrtObject } from '@happyvertical/smrt-core';
2
- import { ChatThreadOptions } from '../types.js';
2
+ import type { ChatThreadOptions } from '../types.js';
3
3
  /**
4
4
  * Conversation thread. Internal model — threads must be created/mutated only
5
5
  * through the membership-checked {@link ChatService} (S5 #1392). The generated
@@ -1,5 +1,5 @@
1
1
  import { SmrtObject } from '@happyvertical/smrt-core';
2
- import { VoiceGatewayTurnOptions, VoiceGatewayTurnStatus } from '../types.js';
2
+ import type { VoiceGatewayTurnOptions, VoiceGatewayTurnStatus } from '../types.js';
3
3
  /**
4
4
  * Durable reservation for a gateway turn. The natural key makes `turn_id`
5
5
  * replay checks concurrency-safe before transcript messages are written.
@@ -1,6 +1,6 @@
1
1
  import { SmrtObject } from '@happyvertical/smrt-core';
2
- import { ConversationPersona } from '../persona-conversation.js';
3
- import { VoiceSessionOptions, VoiceSessionStatus } from '../types.js';
2
+ import type { ConversationPersona } from '../persona-conversation.js';
3
+ import type { VoiceSessionOptions, VoiceSessionStatus } from '../types.js';
4
4
  /**
5
5
  * Short-lived binding proving a voice gateway turn belongs to an authenticated
6
6
  * SMRT actor, persona, and chat session. Internal model: creation and turn
@@ -1,9 +1,28 @@
1
- import { AIInterface, AIMessage } from '@happyvertical/ai';
2
- import { PrincipalAuditSink, PrincipalBinding, PrincipalTool } from '@happyvertical/smrt-agents';
3
- import { LearningMemoryRecord, LearningSemanticSearch, SmrtClassOptions } from '@happyvertical/smrt-core';
4
- import { AgentSession } from './models/AgentSession.js';
5
- import { ChatMessage } from './models/ChatMessage.js';
6
- import { ManifestTool, ToolLoopResult } from './tool-loop.js';
1
+ /**
2
+ * Persona-bound conversation — the bridge from an {@link AgentSession} (a
3
+ * conversation) to an `AgentPersona`/`TenantAgent` (a tenant-scoped, principal-
4
+ * bound behavioural profile) (L3 of the learning-agents epic, #1891).
5
+ *
6
+ * This is the new, acyclic `chat → personas` edge. A conversation bound this way
7
+ * runs under the persona's **principal** (its `runAsUserId`, via
8
+ * {@link runToolLoop} → `executeAsPrincipal`), offers only the persona's
9
+ * **tools** (its `allowedTools`, narrowing the manifest operation surface),
10
+ * speaks with the persona's **instructions**, and draws on its **recalled
11
+ * learning memory** — so the assistant behaves like it knows the tenant's job.
12
+ *
13
+ * The persona's `allowedTools` is mirrored onto the `AgentSession` so the chat
14
+ * layer's own fail-closed tool gate (S5 #1392) agrees with the loop's — one
15
+ * allow-list, enforced at both the loop's side door and the message-authoring
16
+ * seam.
17
+ *
18
+ * @module
19
+ */
20
+ import type { AIInterface, AIMessage } from '@happyvertical/ai';
21
+ import type { PrincipalAuditSink, PrincipalBinding, PrincipalTool } from '@happyvertical/smrt-agents';
22
+ import type { LearningMemoryRecord, LearningSemanticSearch, SmrtClassOptions } from '@happyvertical/smrt-core';
23
+ import type { AgentSession } from './models/AgentSession.js';
24
+ import type { ChatMessage } from './models/ChatMessage.js';
25
+ import { type ManifestTool, type ToolLoopResult } from './tool-loop.js';
7
26
  /**
8
27
  * The structural persona shape the conversation binding needs. Both a
9
28
  * `ResolvedPersona` (from `PersonaResolver.resolve()`) and a raw `AgentPersona`
@@ -1,8 +1,8 @@
1
- import { SmrtObjectOptions } from '@happyvertical/smrt-core';
2
- import { AgentSession } from '../models/AgentSession.js';
3
- import { ChatMessage } from '../models/ChatMessage.js';
4
- import { ChatThread } from '../models/ChatThread.js';
5
- import { ChatMessageType, ChatParticipantRole, ChatRoomStatus, ChatRoomType } from '../types.js';
1
+ import { type SmrtObjectOptions } from '@happyvertical/smrt-core';
2
+ import type { AgentSession } from '../models/AgentSession.js';
3
+ import type { ChatMessage } from '../models/ChatMessage.js';
4
+ import type { ChatThread } from '../models/ChatThread.js';
5
+ import type { ChatMessageType, ChatParticipantRole, ChatRoomStatus, ChatRoomType } from '../types.js';
6
6
  /**
7
7
  * Parameters for emitting an agent-authored (assistant/tool) message. Used only
8
8
  * by the internal {@link sendAgentReply} bridge below — NOT a public surface.
@@ -65,7 +65,7 @@ export declare class ChatService {
65
65
  actorProfileId: string;
66
66
  description?: string;
67
67
  topic?: string;
68
- }): Promise<import('../index.js').ChatRoom>;
68
+ }): Promise<import("../index.js").ChatRoom>;
69
69
  /**
70
70
  * Send a USER message to a room as the authenticated caller (S5 #1392).
71
71
  *
@@ -126,7 +126,7 @@ export declare class ChatService {
126
126
  actorProfileId: string;
127
127
  profileId: string;
128
128
  role?: ChatParticipantRole;
129
- }): Promise<import('../index.js').ChatParticipant>;
129
+ }): Promise<import("../index.js").ChatParticipant>;
130
130
  /**
131
131
  * Remove (soft-leave) a participant from a room (S5 #1392).
132
132
  *
@@ -156,7 +156,7 @@ export declare class ChatService {
156
156
  topic?: string;
157
157
  avatarUrl?: string;
158
158
  status?: ChatRoomStatus;
159
- }): Promise<import('../index.js').ChatRoom>;
159
+ }): Promise<import("../index.js").ChatRoom>;
160
160
  /**
161
161
  * Add a reaction to a message as the authenticated caller (S5 #1392).
162
162
  *
@@ -171,7 +171,7 @@ export declare class ChatService {
171
171
  messageId: string;
172
172
  actorProfileId: string;
173
173
  emoji: string;
174
- }): Promise<import('../index.js').ChatReaction>;
174
+ }): Promise<import("../index.js").ChatReaction>;
175
175
  /**
176
176
  * Remove the caller's own reaction from a message (S5 #1392).
177
177
  *
@@ -198,7 +198,7 @@ export declare class ChatService {
198
198
  actorProfileId: string;
199
199
  profileId1: string;
200
200
  profileId2: string;
201
- }): Promise<import('../index.js').ChatRoom>;
201
+ }): Promise<import("../index.js").ChatRoom>;
202
202
  /**
203
203
  * Create an agent conversation session with a linked chat room (S5 #1392).
204
204
  *
@@ -243,7 +243,7 @@ export declare class ChatService {
243
243
  agentProfileId?: string | null;
244
244
  }): Promise<{
245
245
  session: AgentSession;
246
- room: import('../index.js').ChatRoom;
246
+ room: import("../index.js").ChatRoom;
247
247
  }>;
248
248
  /**
249
249
  * Send a USER message within an agent session (S5 #1392).
@@ -290,7 +290,7 @@ export declare class ChatService {
290
290
  * exist; throws when the actor is not an active participant. `tenantId` is
291
291
  * required so the lookup and the membership gate are always tenant-scoped.
292
292
  */
293
- getRoomForMember(roomId: string, actorProfileId: string, tenantId: string): Promise<import('../index.js').ChatRoom | null>;
293
+ getRoomForMember(roomId: string, actorProfileId: string, tenantId: string): Promise<import("../index.js").ChatRoom | null>;
294
294
  /**
295
295
  * Tenant-bound read of a single agent session (S5 #1392).
296
296
  *
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-chat",
6
- "packageVersion": "0.51.32",
6
+ "packageVersion": "0.51.34",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "df19b82e749e812f77fb166768cbd6e6cfea438b55ce83f99495a0378ce8c461",
11
- "packageJson": "2a09a5e1938a9617b75a27315ca4893ec5527048e6d82f3108905ec86921057e",
10
+ "manifest": "6dec0b9c1cb43c363ae8c1f76970e6170220c3982ae9477ae1e75eb009dc3ae5",
11
+ "packageJson": "53a6d64d8bf3a04a095d51e6656e48dec283f5e3d5b95c1a026788410e354525",
12
12
  "agents": "e76478900c3e8a013895d69d5a544b4a9280bcda18e3b69104da27938da2706e",
13
13
  "moduleDoc:agents/dev-workbench.md": "69b6f827d25c8aeb0e7516c90303af23948803213b5d34bc334c1e3376c83a16",
14
14
  "agentSurface:src/routes/chat-dev.intents.ts": "ff8f7c19c7eb6e841a08f03c97773c53092ed208004666bfed372bd1ad456b35"
@@ -48,7 +48,7 @@
48
48
  "fast-glob": "^3.3.3",
49
49
  "svelte": "^5.57.1",
50
50
  "svelte-check": "^4.7.6",
51
- "typescript": "5.9.3",
51
+ "typescript": "6.0.3",
52
52
  "vite": "8.1.4",
53
53
  "vitest": "4.1.10"
54
54
  },
@@ -1,7 +1,45 @@
1
- import { AIInterface, AIMessage, AITool, ChatOptions } from '@happyvertical/ai';
2
- import { PrincipalAuditSink, PrincipalBinding, PrincipalRun, PrincipalTool } from '@happyvertical/smrt-agents';
3
- import { SmrtClassOptions } from '@happyvertical/smrt-core';
4
- import { PermissionDefinition } from '@happyvertical/smrt-users';
1
+ /**
2
+ * ToolLoop — a bounded `tool_call → observe → respond` agentic loop over the
3
+ * SMRT manifest operation surface (L3 of the learning-agents epic, #1891).
4
+ *
5
+ * The universe of tools is **closed**: every tool is a manifest operation of an
6
+ * installed SMRT package — an object's CRUD or *public custom action*, each a
7
+ * `(collection, action)` in the manifest-derived permission catalog
8
+ * ({@link PermissionCatalogService}). The loop invokes them **in-process
9
+ * ("side door")** — no HTTP/MCP round-trip — inside the persona's
10
+ * session-permission context ({@link executeAsPrincipal}), so tenant isolation
11
+ * and per-operation authority (Postgres RLS, or the catalog assert when RLS is
12
+ * off) apply through any door.
13
+ *
14
+ * Two independent gates make the loop fail-closed:
15
+ *
16
+ * 1. **Offer gate** — the available tools are exactly the manifest operations
17
+ * filtered by the persona's `allowedTools`. A tool outside the allow-list is
18
+ * never offered to the model, and a hallucinated tool name is rejected
19
+ * without execution.
20
+ * 2. **Execution gate** — every executed tool additionally re-asserts the
21
+ * fail-closed allow-list ({@link PrincipalRun.assertToolAllowed}) and the
22
+ * catalog permission for its `(collection, action)`
23
+ * ({@link PrincipalRun.assertOperation}), so even a bug in the offer gate
24
+ * cannot run an un-permitted operation.
25
+ *
26
+ * The loop is bounded by a max-steps ceiling: after `maxSteps` tool-executing
27
+ * rounds it disables tools for one final completion, guaranteeing termination
28
+ * with a text answer.
29
+ *
30
+ * Beyond manifest operations, the loop accepts a small set of **extra tools**
31
+ * ({@link ToolLoopOptions.extraTools}) — non-CRUD `PrincipalTool`s such as the
32
+ * agent-orchestration `invoke-agent` tool (#1892). Each is gated by the *same*
33
+ * fail-closed allow-list (the caller only passes an allow-listed tool, and the
34
+ * tool's `execute` re-asserts `assertToolAllowed`), so the closed-universe,
35
+ * fail-closed property holds for them too.
36
+ *
37
+ * @module
38
+ */
39
+ import type { AIInterface, AIMessage, AITool, ChatOptions } from '@happyvertical/ai';
40
+ import { type PrincipalAuditSink, type PrincipalBinding, type PrincipalRun, type PrincipalTool } from '@happyvertical/smrt-agents';
41
+ import { type SmrtClassOptions } from '@happyvertical/smrt-core';
42
+ import { type PermissionDefinition } from '@happyvertical/smrt-users';
5
43
  /** Default ceiling on tool-executing rounds before the loop force-terminates. */
6
44
  export declare const DEFAULT_MAX_STEPS = 8;
7
45
  /**
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SmrtObjectOptions } from '@happyvertical/smrt-core';
1
+ import type { SmrtObjectOptions } from '@happyvertical/smrt-core';
2
2
  export type ChatRoomType = 'public' | 'private' | 'dm' | 'agent';
3
3
  export type ChatRoomStatus = 'active' | 'archived' | 'deleted';
4
4
  export type ChatParticipantRole = 'owner' | 'admin' | 'member' | 'viewer';
package/dist/ui.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ModuleUISlot, SmrtModuleMeta } from '@happyvertical/smrt-types';
1
+ import type { ModuleUISlot, SmrtModuleMeta } from '@happyvertical/smrt-types';
2
2
  export declare const CHAT_UI_SLOTS: Record<string, ModuleUISlot>;
3
3
  export declare const CHAT_MODULE_META: SmrtModuleMeta;
4
4
  //# sourceMappingURL=ui.d.ts.map
package/dist/voice.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { AIInterface } from '@happyvertical/ai';
2
- import { PrincipalAuditSink } from '@happyvertical/smrt-agents';
3
- import { SmrtClassOptions } from '@happyvertical/smrt-core';
4
- import { VoiceSession } from './models/VoiceSession.js';
5
- import { ConversationPersona, PersonaRecallOptions } from './persona-conversation.js';
6
- import { ChatService } from './services/index.js';
1
+ import type { AIInterface } from '@happyvertical/ai';
2
+ import type { PrincipalAuditSink } from '@happyvertical/smrt-agents';
3
+ import { type SmrtClassOptions } from '@happyvertical/smrt-core';
4
+ import type { VoiceSession } from './models/VoiceSession.js';
5
+ import { type ConversationPersona, type PersonaRecallOptions } from './persona-conversation.js';
6
+ import type { ChatService } from './services/index.js';
7
7
  export declare const SMRT_CHAT_VOICE_TARGET = "smrt:chat";
8
8
  export declare const MAX_VOICE_GATEWAY_TEXT_LENGTH = 12000;
9
9
  export interface VoiceGatewayTurnMetadata {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-chat",
3
- "version": "0.51.32",
3
+ "version": "0.51.34",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "Chat rooms, DMs, threads, and agent conversations for the SMRT framework",
6
6
  "type": "module",
@@ -71,14 +71,14 @@
71
71
  },
72
72
  "dependencies": {
73
73
  "@happyvertical/ai": "^0.94.1",
74
- "@happyvertical/smrt-agents": "0.51.32",
75
- "@happyvertical/smrt-core": "0.51.32",
76
- "@happyvertical/smrt-personas": "0.51.32",
77
- "@happyvertical/smrt-profiles": "0.51.32",
78
- "@happyvertical/smrt-tenancy": "0.51.32",
79
- "@happyvertical/smrt-types": "0.51.32",
80
- "@happyvertical/smrt-ui": "0.51.32",
81
- "@happyvertical/smrt-users": "0.51.32",
74
+ "@happyvertical/smrt-agents": "0.51.34",
75
+ "@happyvertical/smrt-core": "0.51.34",
76
+ "@happyvertical/smrt-personas": "0.51.34",
77
+ "@happyvertical/smrt-profiles": "0.51.34",
78
+ "@happyvertical/smrt-tenancy": "0.51.34",
79
+ "@happyvertical/smrt-types": "0.51.34",
80
+ "@happyvertical/smrt-ui": "0.51.34",
81
+ "@happyvertical/smrt-users": "0.51.34",
82
82
  "@happyvertical/sql": "^0.94.1"
83
83
  },
84
84
  "peerDependencies": {
@@ -90,9 +90,9 @@
90
90
  }
91
91
  },
92
92
  "devDependencies": {
93
- "@happyvertical/smrt-playground": "0.51.32",
94
- "@happyvertical/smrt-vitest": "0.51.32",
95
- "@happyvertical/smrt-web": "0.51.32",
93
+ "@happyvertical/smrt-playground": "0.51.34",
94
+ "@happyvertical/smrt-vitest": "0.51.34",
95
+ "@happyvertical/smrt-web": "0.51.34",
96
96
  "@mlc-ai/web-llm": "^0.2.85",
97
97
  "bitgpu": "0.19.1",
98
98
  "@sveltejs/kit": "2.69.1",
@@ -102,7 +102,7 @@
102
102
  "fast-glob": "^3.3.3",
103
103
  "svelte": "^5.57.1",
104
104
  "svelte-check": "^4.7.6",
105
- "typescript": "5.9.3",
105
+ "typescript": "6.0.3",
106
106
  "vite": "8.1.4",
107
107
  "vitest": "4.1.10"
108
108
  },