@happyvertical/smrt-personas 0.38.18

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,311 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "generatedAt": "2026-07-09T01:22:04.866Z",
4
+ "packageName": "@happyvertical/smrt-personas",
5
+ "packageVersion": "0.38.18",
6
+ "sourceManifestPath": "dist/manifest.json",
7
+ "agentDocPath": "AGENTS.md",
8
+ "sourceHashes": {
9
+ "manifest": "096dbac08a846b0a0c9c3eff123d85bd9b47c9638db3e5ff4354ef0f60642b6b",
10
+ "packageJson": "b06371e5956e3d28275e5fcf417aa9c32b0ed89ab0cd9691b9e354dd63e70391",
11
+ "agents": "ef998dbc563d3d2905c694cd77a99576a6fd2d16d10f675014dbbe9aec1cbf5f"
12
+ },
13
+ "exports": [
14
+ ".",
15
+ "./manifest",
16
+ "./manifest.json"
17
+ ],
18
+ "dependencies": {
19
+ "@happyvertical/smrt-agents": "workspace:*",
20
+ "@happyvertical/smrt-core": "workspace:*",
21
+ "@happyvertical/smrt-tenancy": "workspace:*",
22
+ "@happyvertical/smrt-vitest": "workspace:*",
23
+ "@types/node": "24.13.2",
24
+ "typescript": "^5.9.3",
25
+ "vite": "^8.1.3",
26
+ "vitest": "^4.1.9"
27
+ },
28
+ "smrtDependencies": [
29
+ "@happyvertical/smrt-agents",
30
+ "@happyvertical/smrt-core",
31
+ "@happyvertical/smrt-tenancy",
32
+ "@happyvertical/smrt-vitest"
33
+ ],
34
+ "sdkDependencies": [],
35
+ "tags": [],
36
+ "risks": [],
37
+ "objects": [
38
+ {
39
+ "name": "AgentPersona",
40
+ "qualifiedName": "@happyvertical/smrt-personas:AgentPersona",
41
+ "collection": "agentpersonas",
42
+ "tableName": "agent_personas",
43
+ "packageName": "@happyvertical/smrt-personas",
44
+ "extends": "SmrtObject",
45
+ "fields": [
46
+ {
47
+ "name": "tenantId",
48
+ "type": "text",
49
+ "required": true,
50
+ "columnType": "UUID"
51
+ },
52
+ {
53
+ "name": "agentClass",
54
+ "type": "text",
55
+ "required": false,
56
+ "columnType": "TEXT"
57
+ },
58
+ {
59
+ "name": "name",
60
+ "type": "text",
61
+ "required": false,
62
+ "columnType": "TEXT"
63
+ },
64
+ {
65
+ "name": "contextType",
66
+ "type": "text",
67
+ "required": false,
68
+ "columnType": "TEXT"
69
+ },
70
+ {
71
+ "name": "contextId",
72
+ "type": "text",
73
+ "required": false,
74
+ "columnType": "TEXT"
75
+ },
76
+ {
77
+ "name": "instructions",
78
+ "type": "text",
79
+ "required": false,
80
+ "columnType": "TEXT"
81
+ },
82
+ {
83
+ "name": "allowedTools",
84
+ "type": "text",
85
+ "required": false,
86
+ "columnType": "TEXT"
87
+ },
88
+ {
89
+ "name": "runAsUserId",
90
+ "type": "crossPackageRef",
91
+ "required": true,
92
+ "related": "@happyvertical/smrt-users:User",
93
+ "columnType": "UUID"
94
+ },
95
+ {
96
+ "name": "actsAsProfileId",
97
+ "type": "crossPackageRef",
98
+ "required": false,
99
+ "related": "@happyvertical/smrt-profiles:Profile",
100
+ "columnType": "UUID"
101
+ },
102
+ {
103
+ "name": "memoryScope",
104
+ "type": "text",
105
+ "required": false,
106
+ "columnType": "TEXT"
107
+ },
108
+ {
109
+ "name": "priority",
110
+ "type": "integer",
111
+ "required": false,
112
+ "columnType": "INTEGER"
113
+ },
114
+ {
115
+ "name": "enabled",
116
+ "type": "boolean",
117
+ "required": false,
118
+ "columnType": "BOOLEAN"
119
+ }
120
+ ],
121
+ "relationships": [
122
+ {
123
+ "name": "runAsUserId",
124
+ "type": "crossPackageRef",
125
+ "required": true,
126
+ "related": "@happyvertical/smrt-users:User",
127
+ "columnType": "UUID"
128
+ },
129
+ {
130
+ "name": "actsAsProfileId",
131
+ "type": "crossPackageRef",
132
+ "required": false,
133
+ "related": "@happyvertical/smrt-profiles:Profile",
134
+ "columnType": "UUID"
135
+ }
136
+ ],
137
+ "methods": [
138
+ "getAllowedTools",
139
+ "setAllowedTools"
140
+ ],
141
+ "surfaces": [
142
+ {
143
+ "kind": "api",
144
+ "name": "agentpersonas.list",
145
+ "operation": "list",
146
+ "objectName": "@happyvertical/smrt-personas:AgentPersona",
147
+ "path": "/agentpersonas",
148
+ "method": "GET"
149
+ },
150
+ {
151
+ "kind": "api",
152
+ "name": "agentpersonas.get",
153
+ "operation": "get",
154
+ "objectName": "@happyvertical/smrt-personas:AgentPersona",
155
+ "path": "/agentpersonas/[id]",
156
+ "method": "GET"
157
+ },
158
+ {
159
+ "kind": "api",
160
+ "name": "agentpersonas.create",
161
+ "operation": "create",
162
+ "objectName": "@happyvertical/smrt-personas:AgentPersona",
163
+ "path": "/agentpersonas",
164
+ "method": "POST"
165
+ },
166
+ {
167
+ "kind": "api",
168
+ "name": "agentpersonas.update",
169
+ "operation": "update",
170
+ "objectName": "@happyvertical/smrt-personas:AgentPersona",
171
+ "path": "/agentpersonas/[id]",
172
+ "method": "PATCH"
173
+ },
174
+ {
175
+ "kind": "api",
176
+ "name": "agentpersonas.delete",
177
+ "operation": "delete",
178
+ "objectName": "@happyvertical/smrt-personas:AgentPersona",
179
+ "path": "/agentpersonas/[id]",
180
+ "method": "DELETE"
181
+ },
182
+ {
183
+ "kind": "cli",
184
+ "name": "agentpersona_list",
185
+ "operation": "list",
186
+ "objectName": "@happyvertical/smrt-personas:AgentPersona"
187
+ },
188
+ {
189
+ "kind": "cli",
190
+ "name": "agentpersona_get",
191
+ "operation": "get",
192
+ "objectName": "@happyvertical/smrt-personas:AgentPersona"
193
+ },
194
+ {
195
+ "kind": "mcp",
196
+ "name": "agentpersona_list",
197
+ "operation": "list",
198
+ "objectName": "@happyvertical/smrt-personas:AgentPersona"
199
+ },
200
+ {
201
+ "kind": "mcp",
202
+ "name": "agentpersona_get",
203
+ "operation": "get",
204
+ "objectName": "@happyvertical/smrt-personas:AgentPersona"
205
+ }
206
+ ],
207
+ "relationshipFeatures": [
208
+ "crossPackageRef",
209
+ "uuidColumns"
210
+ ],
211
+ "tags": [],
212
+ "risks": []
213
+ },
214
+ {
215
+ "name": "AgentPersonaCollection",
216
+ "qualifiedName": "@happyvertical/smrt-personas:AgentPersonaCollection",
217
+ "collection": "agentpersonas",
218
+ "tableName": "agent_personas",
219
+ "packageName": "@happyvertical/smrt-personas",
220
+ "extends": "SmrtCollection",
221
+ "fields": [],
222
+ "relationships": [],
223
+ "methods": [
224
+ "byTenantAndClass",
225
+ "findActive"
226
+ ],
227
+ "surfaces": [],
228
+ "relationshipFeatures": [
229
+ "uuidColumns"
230
+ ],
231
+ "tags": [],
232
+ "risks": []
233
+ }
234
+ ],
235
+ "surfaces": [
236
+ {
237
+ "kind": "api",
238
+ "name": "agentpersonas.list",
239
+ "operation": "list",
240
+ "objectName": "@happyvertical/smrt-personas:AgentPersona",
241
+ "path": "/agentpersonas",
242
+ "method": "GET"
243
+ },
244
+ {
245
+ "kind": "api",
246
+ "name": "agentpersonas.get",
247
+ "operation": "get",
248
+ "objectName": "@happyvertical/smrt-personas:AgentPersona",
249
+ "path": "/agentpersonas/[id]",
250
+ "method": "GET"
251
+ },
252
+ {
253
+ "kind": "api",
254
+ "name": "agentpersonas.create",
255
+ "operation": "create",
256
+ "objectName": "@happyvertical/smrt-personas:AgentPersona",
257
+ "path": "/agentpersonas",
258
+ "method": "POST"
259
+ },
260
+ {
261
+ "kind": "api",
262
+ "name": "agentpersonas.update",
263
+ "operation": "update",
264
+ "objectName": "@happyvertical/smrt-personas:AgentPersona",
265
+ "path": "/agentpersonas/[id]",
266
+ "method": "PATCH"
267
+ },
268
+ {
269
+ "kind": "api",
270
+ "name": "agentpersonas.delete",
271
+ "operation": "delete",
272
+ "objectName": "@happyvertical/smrt-personas:AgentPersona",
273
+ "path": "/agentpersonas/[id]",
274
+ "method": "DELETE"
275
+ },
276
+ {
277
+ "kind": "cli",
278
+ "name": "agentpersona_list",
279
+ "operation": "list",
280
+ "objectName": "@happyvertical/smrt-personas:AgentPersona"
281
+ },
282
+ {
283
+ "kind": "cli",
284
+ "name": "agentpersona_get",
285
+ "operation": "get",
286
+ "objectName": "@happyvertical/smrt-personas:AgentPersona"
287
+ },
288
+ {
289
+ "kind": "mcp",
290
+ "name": "agentpersona_list",
291
+ "operation": "list",
292
+ "objectName": "@happyvertical/smrt-personas:AgentPersona"
293
+ },
294
+ {
295
+ "kind": "mcp",
296
+ "name": "agentpersona_get",
297
+ "operation": "get",
298
+ "objectName": "@happyvertical/smrt-personas:AgentPersona"
299
+ }
300
+ ],
301
+ "prompts": [],
302
+ "relationshipsV2": {
303
+ "foreignKeyFields": 0,
304
+ "crossPackageRefFields": 2,
305
+ "junctionCollections": 0,
306
+ "hierarchicalObjects": 0,
307
+ "polymorphicAssociations": 0,
308
+ "uuidColumns": 5
309
+ },
310
+ "agentDoc": "# @happyvertical/smrt-personas\n\nTenant-owned, context-scoped agent personas and their resolution. Layers over\n`@happyvertical/smrt-agents`' `TenantAgent` availability/ceiling gate to decide\n*how* an agent behaves for a given tenant and context (its `TenantAgent` binding\ndecides *whether* it runs and caps its capabilities).\n\nThis is the L2 foundation of the \"learning agents\" epic (#1885). Foundation\nonly: `AgentPersona` + `PersonaResolver`. `ExecuteAsPrincipal`, feedback, the\nreflection runner, and multi-instance routing are separate issues\n(#1888/#1889/#1890).\n\n## Models\n\n- **AgentPersona** (`@TenantScoped({ mode: 'required' })`, table `agent_personas`):\n a behavioral profile for one agent class within one tenant. Many per\n `(tenant, agentClass)`; unique on `(tenant_id, agent_class, name)` via\n `conflictColumns`. Fields:\n - `agentClass` — canonical qualified agent type (e.g.\n `@happyvertical/smrt-agents:Praeco`); stored canonical so it lines up with\n `TenantAgent.agentClass`.\n - `name` — persona name, unique per `(tenant, agentClass)`.\n - `contextType` / `contextId` — optional scoping. No `contextType` = a\n tenant-wide default; `contextType` only = type-scoped; both = exact context.\n - `instructions` — system prompt layered onto the agent.\n - `allowedTools` — JSON array of tool ids stored as a string; use\n `getAllowedTools()` / `setAllowedTools()` (tolerant `try/catch` parse).\n - `runAsUserId` — `@crossPackageRef('@happyvertical/smrt-users:User')`, the\n principal the persona runs as.\n - `actsAsProfileId` — optional `@crossPackageRef('@happyvertical/smrt-profiles:Profile')`,\n a `Bot` identity for audit/attribution.\n - `memoryScope` — memory/reflection partition key (empty → resolver-derived).\n - `priority` — integer; higher wins among personas that apply at the same\n tenant level.\n - `enabled` — boolean; only enabled personas are resolved.\n\n## Collection\n\n`AgentPersonaCollection`:\n\n- `byTenantAndClass(tenantId, agentClass)` — all personas for the pair\n (canonicalized), ordered by descending priority then name.\n- `findActive(tenantId, agentClass, context?)` — enabled personas applicable to\n a context, same ordering.\n\n## PersonaResolver\n\n`resolve(tenantId, agentClass, context, options) → ResolvedPersona` layers,\nbottom to top: **manifest defaults → `TenantAgent` gate/ceiling → AgentPersona**.\n\n- **Hierarchy inheritance** mirrors `TenantAgentCollection.resolveForTenant`:\n walks the requesting tenant then its ancestors (`options.getAncestorIds`,\n nearest first). The nearest level with any applicable persona wins (a closer\n level shadows a farther one).\n- **Selection within a level**: most context-specific first\n (exact > type-scoped > tenant-wide), then highest `priority`, then name.\n- **Ceiling**: `options.availability` (a `PersonaAvailabilityGate`) gates\n availability and intersects the resolved `allowedTools`. Build one from a\n `ResolvedAgentAvailability` with `availabilityFromResolvedAgent()`.\n- **Default fallback**: when no persona applies, returns a defined default\n (`source: 'default'`, `name: 'default'`) from manifest defaults + the gate.\n\nBecause the walk reads personas across tenants, `resolve()` is intended for a\nsystem/admin path where cross-tenant reads are allowed — not inside a strict\nper-tenant interceptor context (same expectation as `resolveForTenant`).\n\n## Dependencies\n\nLeaf package (acyclic by construction — nothing depends back on it):\n\n- Runtime: `@happyvertical/smrt-core`, `@happyvertical/smrt-tenancy`,\n `@happyvertical/smrt-agents` (the `TenantAgent` type it bridges).\n- `runAsUserId` / `actsAsProfileId` reference `@happyvertical/smrt-users` and\n `@happyvertical/smrt-profiles` via `@crossPackageRef` string ids only — no\n package edge (keeps the DAG minimal). No inter-`smrt-*` `peerDependencies`.\n\n## Gotchas\n\n- **`conflictColumns` replaces the default `(slug, context)` unique index** — the\n unique key is `(tenant_id, agent_class, name)`, so same-named personas across\n tenants are allowed and tenant isolation is preserved.\n- **`allowedTools` is text, not `type: 'json'`** — stored as a JSON string and\n read through the helpers, so it never auto-hydrates to an object.\n- **Resolver runs outside strict tenant context** — it deliberately crosses\n tenants to walk the hierarchy.\n"
311
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@happyvertical/smrt-personas",
3
+ "version": "0.38.18",
4
+ "description": "Tenant-owned, context-scoped agent personas and resolution for the SMRT framework",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "CLAUDE.md",
11
+ "AGENTS.md"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./manifest": "./dist/manifest.json",
19
+ "./manifest.json": "./dist/manifest.json"
20
+ },
21
+ "dependencies": {
22
+ "@happyvertical/smrt-agents": "0.38.18",
23
+ "@happyvertical/smrt-tenancy": "0.38.18",
24
+ "@happyvertical/smrt-core": "0.38.18"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "24.13.2",
28
+ "typescript": "^5.9.3",
29
+ "vite": "^8.1.3",
30
+ "vitest": "^4.1.9",
31
+ "@happyvertical/smrt-vitest": "0.38.18"
32
+ },
33
+ "keywords": [
34
+ "smrt",
35
+ "agents",
36
+ "personas",
37
+ "multi-tenant",
38
+ "resolution"
39
+ ],
40
+ "author": "HappyVertical",
41
+ "license": "MIT",
42
+ "publishConfig": {
43
+ "registry": "https://registry.npmjs.org",
44
+ "access": "public"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/happyvertical/smrt.git",
49
+ "directory": "packages/personas"
50
+ },
51
+ "scripts": {
52
+ "build": "vite build --mode library",
53
+ "build:watch": "vite build --mode library --watch",
54
+ "clean": "rm -rf dist",
55
+ "dev": "vite dev",
56
+ "test": "vitest run",
57
+ "test:watch": "vitest",
58
+ "typecheck": "tsc --noEmit -p tsconfig.json",
59
+ "verify:pack": "node ../../scripts/verify-package-types-exports.js ."
60
+ }
61
+ }