@happyvertical/smrt-cli 0.51.23 → 0.51.25

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 (34) hide show
  1. package/AGENTS.md +1 -0
  2. package/README.md +1 -0
  3. package/dist/{ApiKey-BZmbOTnL-Bo7tbG1k.js → ApiKey-BZmbOTnL-BHFzurt7.js} +2 -2
  4. package/dist/ApiKeyCollection-Bfb_nw81-D8b3Nrg4.js +2 -0
  5. package/dist/AuditLogCollection-B1YonCAP-CpPE8zro.js +2 -0
  6. package/dist/{NostrIdentity-n70E0vck-G4M4P2GW.js → NostrIdentity-n70E0vck-Cga1lWU1.js} +3 -3
  7. package/dist/NostrIdentityCollection-Ca74dkaL-BKzq1O2N.js +2 -0
  8. package/dist/{OidcIdentity-K8V4u0CR-D3Zc7yju.js → OidcIdentity-K8V4u0CR-buvSdd8D.js} +2 -2
  9. package/dist/OidcIdentityCollection-gnrLoF08-BsEJX0w8.js +2 -0
  10. package/dist/ProfileAssetCollection-CmbeSgDi-CcjX8UeG.js +2 -0
  11. package/dist/{ProfileCollection-DTT4KNpQ-CFn9nEde.js → ProfileCollection-DTT4KNpQ-B2yHjF8e.js} +30 -653
  12. package/dist/ProfileMetadataCollection-DxX_BJKV-CqTZZ7O9.js +2 -0
  13. package/dist/{ProfileMetafieldCollection-CMKhVi2I-NPA4NfPL.js → ProfileMetafieldCollection-CMKhVi2I-BTguykyW.js} +1 -1
  14. package/dist/{ProfileRelationshipCollection-DUVgaIqf-BlH89282.js → ProfileRelationshipCollection-DUVgaIqf-CdOJCU07.js} +1 -1
  15. package/dist/{ProfileRelationshipTermCollection-DtA9OM23-D3KSY2OS.js → ProfileRelationshipTermCollection-DtA9OM23-ug8uUFUp.js} +1 -1
  16. package/dist/{ProfileRelationshipType-BRiRka6t-sguU4oDf.js → ProfileRelationshipType-BRiRka6t-B-lkyTB2.js} +1 -1
  17. package/dist/{ProfileRelationshipTypeCollection-BdXwd7Kf-DGHj5NYL.js → ProfileRelationshipTypeCollection-BdXwd7Kf-BUuZ3P72.js} +1 -1
  18. package/dist/{commands-CdijcyQl.js → commands-BVFlmHkE.js} +61 -1
  19. package/dist/dist-4XD0OZmB.js +1235 -0
  20. package/dist/dist-C-AYkaoT.js +813 -0
  21. package/dist/{dist-DPN8zVvb.js → dist-CaxtTrhT.js} +3 -3
  22. package/dist/{dist-Cm7M-US-.js → dist-VEFJWHIY.js} +25 -25
  23. package/dist/index.js +9 -9
  24. package/dist/{oidcProvisioningPrimitives-0-3n3D6f-2uN0TAcP.js → oidcProvisioningPrimitives-0-3n3D6f-DpuGh5Ac.js} +4 -4
  25. package/dist/resolveIdentity-BrJDCjYi-DrBA1wFo.js +2 -0
  26. package/package.json +9 -8
  27. package/dist/ApiKeyCollection-Bfb_nw81-CNAaLULe.js +0 -2
  28. package/dist/AuditLogCollection-B1YonCAP-yweHrz14.js +0 -2
  29. package/dist/NostrIdentityCollection-Ca74dkaL-aM_-cerc.js +0 -2
  30. package/dist/OidcIdentityCollection-gnrLoF08-B5y4FHI0.js +0 -2
  31. package/dist/ProfileAssetCollection-CmbeSgDi-mMSqxPLS.js +0 -2
  32. package/dist/ProfileMetadataCollection-DxX_BJKV-CXKXBRtU.js +0 -2
  33. package/dist/dist-B5ngi39H.js +0 -190
  34. package/dist/resolveIdentity-BrJDCjYi-CX_TCtNl.js +0 -2
@@ -1,634 +1,11 @@
1
- import { t as __exportAll$1 } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { n as __exportAll$2 } from "./NostrIdentity-n70E0vck-G4M4P2GW.js";
3
- import { a as getTenantId, i as queryWithGlobals, n as tenantId, r as queryGlobal, s as withSystemContext, t as TenantScoped } from "./dist-B5ngi39H.js";
4
- import { a as removeOwnedAssetFromCollection, i as getOwnedAssetsFromCollection, n as assertValidOwnedAssetRelationship, o as resolveOwnedAssetsById, r as assertValidOwnedAssetSortOrder, t as addOwnedAssetFromCollection } from "./dist-DPN8zVvb.js";
5
- import { ObjectRegistry, RuntimeError, SmrtCollection, SmrtObject, ValidationError, field, foreignKey, isAbortedTransactionError, oneToMany, smrt } from "@happyvertical/smrt-core";
6
- import { getPackageConfig } from "@happyvertical/smrt-config";
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { a as queryGlobal, c as withSystemContext, i as tenantId, n as resolvePrompt, o as queryWithGlobals, r as TenantScoped, t as definePrompt } from "./dist-C-AYkaoT.js";
3
+ import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-Cga1lWU1.js";
4
+ import { a as removeOwnedAssetFromCollection, i as getOwnedAssetsFromCollection, n as assertValidOwnedAssetRelationship, o as resolveOwnedAssetsById, r as assertValidOwnedAssetSortOrder, t as addOwnedAssetFromCollection } from "./dist-CaxtTrhT.js";
5
+ import { RuntimeError, SmrtCollection, SmrtObject, ValidationError, field, foreignKey, isAbortedTransactionError, oneToMany, smrt } from "@happyvertical/smrt-core";
7
6
  import { BackfillTableUnavailableError, BackfillTracker } from "@happyvertical/smrt-core/migrations";
8
- //#region ../prompts/dist/index.js
9
- var __defProp$1$1 = Object.defineProperty;
10
- var __exportAll = (all, no_symbols) => {
11
- let target = {};
12
- for (var name in all) __defProp$1$1(target, name, {
13
- get: all[name],
14
- enumerable: true
15
- });
16
- if (!no_symbols) __defProp$1$1(target, Symbol.toStringTag, { value: "Module" });
17
- return target;
18
- };
19
- ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-prompts\",\"packageVersion\":\"0.51.23\",\"objects\":{\"@happyvertical/smrt-prompts:PromptOverrideCollection\":{\"name\":\"promptoverridecollection\",\"className\":\"PromptOverrideCollection\",\"qualifiedName\":\"@happyvertical/smrt-prompts:PromptOverrideCollection\",\"collection\":\"promptoverrides\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/prompts/src/collections/PromptOverrideCollection.ts\",\"packageName\":\"@happyvertical/smrt-prompts\",\"fields\":{},\"methods\":{\"getAppOverride\":{\"name\":\"getAppOverride\",\"async\":true,\"parameters\":[{\"name\":\"key\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"string\"]}],\"returnType\":\"Promise<PromptOverride | null>\",\"isStatic\":false,\"isPublic\":true},\"getTenantOverride\":{\"name\":\"getTenantOverride\",\"async\":true,\"parameters\":[{\"name\":\"key\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"string\"]}],\"returnType\":\"Promise<PromptOverride | null>\",\"isStatic\":false,\"isPublic\":true},\"getResolutionLayers\":{\"name\":\"getResolutionLayers\",\"async\":true,\"parameters\":[{\"name\":\"key\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string | null\",\"optional\":true,\"unionBranches\":[{\"type\":\"string\"},{\"type\":\"null\"}]},{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"string\"]}],\"returnType\":\"Promise<object>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"_smrt_prompt_overrides\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"PromptOverride\",\"exportName\":\"PromptOverrideCollection\",\"collectionExportName\":\"PromptOverrideCollectionCollection\",\"schema\":{\"tableName\":\"_smrt_prompt_overrides\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_prompt_overrides\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"key\\\" TEXT NOT NULL DEFAULT '',\\n \\\"tenant_id\\\" TEXT,\\n \\\"template\\\" TEXT,\\n \\\"profile\\\" TEXT,\\n \\\"model\\\" TEXT,\\n \\\"params\\\" TEXT\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"key\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"tenant_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"template\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"profile\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"model\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"params\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"_smrt_prompt_overrides_key_context_idx\",\"columns\":[\"key\",\"context\"],\"unique\":true},{\"name\":\"_smrt_prompt_overrides_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"_smrt_prompt_overrides_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"6f475427\"},\"importPath\":\"@happyvertical/smrt-prompts\"},\"@happyvertical/smrt-prompts:PromptOverride\":{\"name\":\"promptoverride\",\"className\":\"PromptOverride\",\"qualifiedName\":\"@happyvertical/smrt-prompts:PromptOverride\",\"collection\":\"promptoverrides\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/prompts/src/models/PromptOverride.ts\",\"packageName\":\"@happyvertical/smrt-prompts\",\"fields\":{\"key\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"template\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"profile\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"model\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"params\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}}},\"methods\":{\"getParams\":{\"name\":\"getParams\",\"async\":false,\"parameters\":[],\"returnType\":\"PromptParams\",\"isStatic\":false,\"isPublic\":true},\"setParams\":{\"name\":\"setParams\",\"async\":false,\"parameters\":[{\"name\":\"params\",\"type\":\"PromptParams | null\",\"optional\":false,\"unionBranches\":[{\"type\":\"PromptParams\"},{\"type\":\"null\"}]}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"toPromptLayer\":{\"name\":\"toPromptLayer\",\"async\":false,\"parameters\":[],\"returnType\":\"PromptLayer\",\"isStatic\":false,\"isPublic\":true},\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"isStatic\":false,\"isPublic\":true},\"delete\":{\"name\":\"delete\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"_smrt_prompt_overrides\",\"conflictColumns\":[\"key\",\"context\"],\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"cli\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"],\"exclude\":[\"getParams\",\"setParams\",\"toPromptLayer\"]},\"mcp\":{\"include\":[]}},\"extends\":\"SmrtObject\",\"exportName\":\"PromptOverride\",\"collectionExportName\":\"PromptOverrideCollection\",\"validationRules\":[{\"field\":\"key\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"_smrt_prompt_overrides\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_prompt_overrides\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"key\\\" TEXT NOT NULL DEFAULT '',\\n \\\"tenant_id\\\" TEXT,\\n \\\"template\\\" TEXT,\\n \\\"profile\\\" TEXT,\\n \\\"model\\\" TEXT,\\n \\\"params\\\" TEXT\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"key\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"tenant_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"template\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"profile\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"model\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"params\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"_smrt_prompt_overrides_key_context_idx\",\"columns\":[\"key\",\"context\"],\"unique\":true},{\"name\":\"_smrt_prompt_overrides_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"_smrt_prompt_overrides_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"6f475427\"},\"importPath\":\"@happyvertical/smrt-prompts\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-tenancy\"]}"));
20
- var PROMPT_CACHE_TTL_MS = 3e4;
21
- var promptCache = /* @__PURE__ */ new Map();
22
- var cacheGenerations = /* @__PURE__ */ new Map();
23
- var nextGeneration = 1;
24
- var clearedThrough = 0;
25
- var dbInstanceIds = /* @__PURE__ */ new WeakMap();
26
- var nextDbId = 1;
27
- function getDbNamespace(db) {
28
- if (!db) return "no-db";
29
- if (typeof db === "string") return `db:${db}`;
30
- if (typeof db === "object") {
31
- const dbObject = db;
32
- if (typeof dbObject.query === "function") {
33
- if (!dbInstanceIds.has(dbObject)) dbInstanceIds.set(dbObject, `db-instance:${nextDbId++}`);
34
- const namespace = dbInstanceIds.get(dbObject);
35
- if (namespace) return namespace;
36
- return "db-instance:unknown";
37
- }
38
- try {
39
- return `db-config:${JSON.stringify(dbObject)}`;
40
- } catch {
41
- return "db-config:opaque";
42
- }
43
- }
44
- return "db:unknown";
45
- }
46
- function buildCacheKey(key, tenantId, db) {
47
- return `${getDbNamespace(db)}::${key}::${tenantId ?? "app"}`;
48
- }
49
- function buildGenerationKey(key, db) {
50
- return `${getDbNamespace(db)}::${key}`;
51
- }
52
- function bumpGeneration(key, db) {
53
- cacheGenerations.set(buildGenerationKey(key, db), nextGeneration++);
54
- }
55
- function getCachedPromptBase(key, tenantId, db) {
56
- const cacheKey = buildCacheKey(key, tenantId, db);
57
- const cached = promptCache.get(cacheKey);
58
- if (!cached) return null;
59
- if (cached.expiresAt <= Date.now()) {
60
- promptCache.delete(cacheKey);
61
- return null;
62
- }
63
- return cached.value;
64
- }
65
- function getPromptCacheGeneration(key, db) {
66
- const generation = cacheGenerations.get(buildGenerationKey(key, db)) ?? 0;
67
- return generation > clearedThrough ? generation : clearedThrough;
68
- }
69
- function setCachedPromptBase(key, tenantId, db, value, loadedAtGeneration) {
70
- if (getPromptCacheGeneration(key, db) !== loadedAtGeneration) return;
71
- promptCache.set(buildCacheKey(key, tenantId, db), {
72
- expiresAt: Date.now() + PROMPT_CACHE_TTL_MS,
73
- value
74
- });
75
- }
76
- function invalidatePromptCache(key, tenantId, db) {
77
- const dbNamespace = getDbNamespace(db);
78
- bumpGeneration(key, db);
79
- if (tenantId !== null && tenantId !== void 0) {
80
- promptCache.delete(buildCacheKey(key, tenantId, db));
81
- return;
82
- }
83
- const keyPrefix = `${dbNamespace}::${key}::`;
84
- for (const cacheKey of promptCache.keys()) if (cacheKey.startsWith(keyPrefix)) promptCache.delete(cacheKey);
85
- }
86
- var DEFAULT_EDITABLE = {
87
- template: false,
88
- profile: false,
89
- model: false,
90
- params: false
91
- };
92
- var TOP_LEVEL_RESERVED_KEYS = /* @__PURE__ */ new Set([
93
- "key",
94
- "editable",
95
- "template",
96
- "ai",
97
- "profile",
98
- "provider",
99
- "model",
100
- "params",
101
- "temperature",
102
- "maxTokens"
103
- ]);
104
- var AI_RESERVED_KEYS = /* @__PURE__ */ new Set([
105
- "profile",
106
- "provider",
107
- "model",
108
- "params",
109
- "temperature",
110
- "maxTokens"
111
- ]);
112
- var AI_ROUTING_PARAM_KEYS = /* @__PURE__ */ new Set([
113
- "profile",
114
- "provider",
115
- "type",
116
- "model",
117
- "defaultModel"
118
- ]);
119
- function isPlainObject(value) {
120
- return !!value && typeof value === "object" && !Array.isArray(value);
121
- }
122
- function normalizeEditableConfig(editable) {
123
- return {
124
- template: editable?.template ?? DEFAULT_EDITABLE.template,
125
- profile: editable?.profile ?? DEFAULT_EDITABLE.profile,
126
- model: editable?.model ?? DEFAULT_EDITABLE.model,
127
- params: editable?.params ?? DEFAULT_EDITABLE.params
128
- };
129
- }
130
- function extractPromptParams(source, reservedKeys) {
131
- const params = {};
132
- if (isPlainObject(source.params)) Object.assign(params, sanitizePromptParams(source.params));
133
- if ("temperature" in source && source.temperature !== void 0) params.temperature = source.temperature;
134
- if ("maxTokens" in source && source.maxTokens !== void 0) params.maxTokens = source.maxTokens;
135
- for (const [key, value] of Object.entries(source)) {
136
- if (reservedKeys.has(key) || value === void 0) continue;
137
- assignPromptParam(params, key, value);
138
- }
139
- return params;
140
- }
141
- function assignPromptParam(params, key, value) {
142
- if (AI_ROUTING_PARAM_KEYS.has(key) || value === void 0) return;
143
- params[key] = value;
144
- }
145
- function sanitizePromptParams(params) {
146
- const sanitized = {};
147
- if (!params) return sanitized;
148
- for (const [key, value] of Object.entries(params)) assignPromptParam(sanitized, key, value);
149
- return sanitized;
150
- }
151
- function mergePromptParams(...paramLayers) {
152
- const merged = {};
153
- for (const layer of paramLayers) {
154
- if (!layer) continue;
155
- for (const [key, value] of Object.entries(layer)) assignPromptParam(merged, key, value);
156
- }
157
- return merged;
158
- }
159
- function normalizeAIInput(ai) {
160
- if (!isPlainObject(ai)) return { params: {} };
161
- const profile = typeof ai.profile === "string" || ai.profile === null ? ai.profile : void 0;
162
- const model = typeof ai.model === "string" || ai.model === null ? ai.model : void 0;
163
- return {
164
- profile: profile ?? void 0,
165
- model: model ?? void 0,
166
- params: extractPromptParams(ai, AI_RESERVED_KEYS)
167
- };
168
- }
169
- function normalizePromptDefinitionInput(input) {
170
- return {
171
- key: input.key,
172
- template: input.template,
173
- ai: normalizeAIInput(input.ai),
174
- editable: normalizeEditableConfig(input.editable)
175
- };
176
- }
177
- function normalizePromptLayer(input) {
178
- if (!isPlainObject(input)) return {};
179
- const nestedAi = isPlainObject(input.ai) ? normalizeAIInput(input.ai) : { params: {} };
180
- const topLevelParams = extractPromptParams(input, TOP_LEVEL_RESERVED_KEYS);
181
- return {
182
- template: input.template === void 0 ? void 0 : input.template === null ? null : String(input.template),
183
- profile: input.profile === void 0 ? nestedAi.profile : input.profile === null ? null : String(input.profile),
184
- model: input.model === void 0 ? nestedAi.model : input.model === null ? null : String(input.model),
185
- params: mergePromptParams(topLevelParams, nestedAi.params)
186
- };
187
- }
188
- function mergePromptLayers(...layers) {
189
- let template = "";
190
- let profile;
191
- let model;
192
- let params = {};
193
- for (const layer of layers) {
194
- if (!layer) continue;
195
- if (layer.template !== void 0 && layer.template !== null) template = layer.template;
196
- if (layer.profile !== void 0 && layer.profile !== null) profile = layer.profile;
197
- if (layer.model !== void 0 && layer.model !== null) model = layer.model;
198
- if (layer.params !== void 0 && layer.params !== null) params = mergePromptParams(params, layer.params);
199
- }
200
- return {
201
- template,
202
- ai: {
203
- profile,
204
- model,
205
- params
206
- }
207
- };
208
- }
209
- function normalizeProfileConfig(profile) {
210
- const params = extractPromptParams(isPlainObject(profile) ? profile : {}, /* @__PURE__ */ new Set(["provider", "model"]));
211
- return {
212
- provider: String(profile.provider),
213
- model: String(profile.model),
214
- params
215
- };
216
- }
217
- function validateProfileName(profileName, config) {
218
- if (profileName.trim() === "") throw new Error("Prompt profile names cannot be empty");
219
- const allowedProfileNames = config.allowedProfileNames;
220
- if (Array.isArray(allowedProfileNames) && !allowedProfileNames.includes(profileName)) throw new Error(`Prompt profile "${profileName}" is not in the allowed profile list`);
221
- if (!config.profiles?.[profileName]) throw new Error(`Prompt profile "${profileName}" is not configured`);
222
- }
223
- function validateModelName(modelName, config) {
224
- if (modelName.trim() === "") throw new Error("Prompt model overrides cannot be empty");
225
- const allowedModels = config.allowedModels;
226
- if (Array.isArray(allowedModels) && !allowedModels.includes(modelName)) throw new Error(`Prompt model "${modelName}" is not in the allowed model list`);
227
- }
228
- function buildResolvedAI(ai, config) {
229
- let provider;
230
- let model = ai.model;
231
- let params = ai.params;
232
- if (ai.profile) {
233
- validateProfileName(ai.profile, config);
234
- const configuredProfile = config.profiles?.[ai.profile];
235
- if (!configuredProfile) throw new Error(`Prompt profile "${ai.profile}" is not configured`);
236
- const profileConfig = normalizeProfileConfig(configuredProfile);
237
- provider = profileConfig.provider;
238
- model = model ?? profileConfig.model;
239
- params = mergePromptParams(profileConfig.params, params);
240
- }
241
- if (ai.model) validateModelName(ai.model, config);
242
- if (ai.model && !ai.profile) throw new Error("Direct prompt model overrides require an effective prompt profile");
243
- if (model && !ai.model && config.allowedModels) validateModelName(model, config);
244
- const resolved = {
245
- ...params,
246
- profile: ai.profile,
247
- provider,
248
- model,
249
- ...config.allowedModels ? { allowedModels: [...config.allowedModels] } : {},
250
- params
251
- };
252
- if (typeof params.temperature === "number") resolved.temperature = params.temperature;
253
- if (typeof params.maxTokens === "number") resolved.maxTokens = params.maxTokens;
254
- return resolved;
255
- }
256
- function renderPromptTemplate(template, variables) {
257
- if (!variables || Object.keys(variables).length === 0) return template;
258
- return template.replace(/\{([^{}]+)\}/g, (_match, rawKey) => {
259
- const value = variables[rawKey.trim()];
260
- if (value === void 0 || value === null) return "";
261
- if (value instanceof Date) return value.toISOString();
262
- if (Array.isArray(value) || isPlainObject(value)) try {
263
- return JSON.stringify(value);
264
- } catch {
265
- return "";
266
- }
267
- return String(value);
268
- });
269
- }
270
- function parsePromptParams(raw) {
271
- if (!raw) return {};
272
- try {
273
- const parsed = JSON.parse(raw);
274
- return isPlainObject(parsed) ? sanitizePromptParams(parsed) : {};
275
- } catch {
276
- return {};
277
- }
278
- }
279
- function serializePromptParams(params) {
280
- if (params === null || params === void 0) return null;
281
- return JSON.stringify(sanitizePromptParams(params));
282
- }
283
- function getRegistry() {
284
- if (!globalThis.__smrtPromptRegistry) globalThis.__smrtPromptRegistry = /* @__PURE__ */ new Map();
285
- return globalThis.__smrtPromptRegistry;
286
- }
287
- function stableStringify(value) {
288
- if (Array.isArray(value)) return `[${value.map((item) => stableStringify(item)).join(",")}]`;
289
- if (value && typeof value === "object") return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${JSON.stringify(key)}:${stableStringify(item)}`).join(",")}}`;
290
- return JSON.stringify(value);
291
- }
292
- var PromptRegistry = {
293
- register(input) {
294
- if (!input.key || input.key.trim() === "") throw new Error("Prompt definitions require a non-empty key");
295
- const definition = normalizePromptDefinitionInput(input);
296
- const registry = getRegistry();
297
- const existing = registry.get(definition.key);
298
- if (existing) {
299
- if (stableStringify(existing) !== stableStringify(definition)) throw new Error(`Prompt "${definition.key}" is already registered with a different definition`);
300
- return existing;
301
- }
302
- registry.set(definition.key, definition);
303
- return definition;
304
- },
305
- get(key) {
306
- return getRegistry().get(key);
307
- },
308
- has(key) {
309
- return getRegistry().has(key);
310
- },
311
- getAll() {
312
- return Array.from(getRegistry().values());
313
- },
314
- clear() {
315
- getRegistry().clear();
316
- }
317
- };
318
- function definePrompt(input) {
319
- return PromptRegistry.register(input);
320
- }
321
- var __defProp$3 = Object.defineProperty;
322
- var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
323
- var __decorateClass$3 = (decorators, target, key, kind) => {
324
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
325
- for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
326
- if (kind && result) __defProp$3(target, key, result);
327
- return result;
328
- };
329
- function getPromptConfig$1() {
330
- return getPackageConfig("prompts", {
331
- profiles: {},
332
- prompts: {}
333
- });
334
- }
335
- var PromptOverride = class extends SmrtObject {
336
- key = "";
337
- tenantId = null;
338
- template = null;
339
- profile = null;
340
- model = null;
341
- params = null;
342
- constructor(options = {}) {
343
- super(options);
344
- if (options.key !== void 0) this.key = options.key;
345
- if (options.tenantId !== void 0) this.tenantId = options.tenantId;
346
- if (options.template !== void 0) this.template = options.template;
347
- if (options.profile !== void 0) this.profile = options.profile;
348
- if (options.model !== void 0) this.model = options.model;
349
- if (options.params !== void 0) if (typeof options.params === "string" || options.params === null) this.params = options.params;
350
- else this.params = serializePromptParams(options.params);
351
- }
352
- getParams() {
353
- return parsePromptParams(this.params);
354
- }
355
- setParams(params) {
356
- this.params = serializePromptParams(params);
357
- }
358
- toPromptLayer() {
359
- return {
360
- template: this.template,
361
- profile: this.profile,
362
- model: this.model,
363
- params: this.params === null ? null : this.getParams()
364
- };
365
- }
366
- async save() {
367
- const previousIdentity = await this.getPersistedIdentity();
368
- this.normalizeParamsForPersistence();
369
- await this.validatePromptOverride();
370
- this.context = this.tenantId ?? "__app__";
371
- const identityChanged = previousIdentity && (previousIdentity.key !== this.key || previousIdentity.tenantId !== this.tenantId);
372
- const result = identityChanged && previousIdentity ? await this.saveAfterIdentityChange() : await super.save();
373
- if (identityChanged && previousIdentity) invalidatePromptCache(previousIdentity.key, previousIdentity.tenantId, this.db);
374
- invalidatePromptCache(this.key, this.tenantId, this.db);
375
- return result;
376
- }
377
- async saveAfterIdentityChange() {
378
- if (typeof this.db.beginTransaction === "function") return this.saveAfterIdentityChangeInTransaction();
379
- return this.saveAfterIdentityChangeWithDeferredDelete();
380
- }
381
- async saveAfterIdentityChangeInTransaction() {
382
- const originalDb = this._db;
383
- const originalOptionsDb = this.options.db;
384
- const tx = await this.db.beginTransaction?.();
385
- if (!tx) return this.saveAfterIdentityChangeWithDeferredDelete();
386
- try {
387
- this._db = tx;
388
- this.options.db = tx;
389
- await super.delete();
390
- const result = await super.save();
391
- await tx.commit();
392
- return result;
393
- } catch (error) {
394
- try {
395
- await tx.rollback();
396
- } catch {}
397
- throw error;
398
- } finally {
399
- this._db = originalDb;
400
- this.options.db = originalOptionsDb;
401
- }
402
- }
403
- async saveAfterIdentityChangeWithDeferredDelete() {
404
- const previousId = this.id;
405
- if (!previousId) return super.save();
406
- const replacementId = crypto.randomUUID();
407
- let replacementSaved = false;
408
- this.id = replacementId;
409
- try {
410
- const result = await super.save();
411
- replacementSaved = true;
412
- await this.db.delete(this.tableName, { id: previousId });
413
- return result;
414
- } catch (error) {
415
- if (replacementSaved) try {
416
- await this.db.delete(this.tableName, { id: replacementId });
417
- } catch {}
418
- this.id = previousId;
419
- throw error;
420
- }
421
- }
422
- async delete() {
423
- const key = this.key;
424
- const tenantId = this.tenantId;
425
- await super.delete();
426
- invalidatePromptCache(key, tenantId, this.db);
427
- }
428
- async validatePromptOverride() {
429
- if (!this.key || this.key.trim() === "") throw new Error("PromptOverride.key is required");
430
- const definition = PromptRegistry.get(this.key);
431
- if (!definition) throw new Error(`Unknown prompt key "${this.key}"`);
432
- const config = getPromptConfig$1();
433
- const editable = definition.editable;
434
- if (this.template !== null && !editable.template) throw new Error(`Prompt "${this.key}" does not allow template overrides`);
435
- if (this.profile !== null && !editable.profile) throw new Error(`Prompt "${this.key}" does not allow profile overrides`);
436
- if (this.model !== null && !editable.model) throw new Error(`Prompt "${this.key}" does not allow model overrides`);
437
- if (this.params !== null && !editable.params) throw new Error(`Prompt "${this.key}" does not allow params overrides`);
438
- if (this.params !== null) try {
439
- const parsed = JSON.parse(this.params);
440
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("Prompt params must be a JSON object");
441
- } catch (error) {
442
- throw new Error(`Prompt "${this.key}" has invalid params JSON: ${error instanceof Error ? error.message : String(error)}`);
443
- }
444
- if (this.profile !== null) validateProfileName(this.profile, config);
445
- if (this.model !== null) validateModelName(this.model, config);
446
- const lowerLayers = await this.getLowerPrecedenceLayers();
447
- const currentLayer = this.toPromptLayer();
448
- const merged = mergePromptLayers(...lowerLayers, currentLayer);
449
- if (currentLayer.model && !merged.ai.profile) throw new Error(`Prompt "${this.key}" model overrides require an effective prompt profile`);
450
- }
451
- async getLowerPrecedenceLayers() {
452
- const definition = PromptRegistry.get(this.key);
453
- const config = getPromptConfig$1();
454
- const layers = [];
455
- if (definition) layers.push({
456
- template: definition.template,
457
- profile: definition.ai.profile ?? null,
458
- model: definition.ai.model ?? null,
459
- params: definition.ai.params
460
- });
461
- layers.push(normalizePromptLayer(config.prompts?.[this.key]));
462
- const { PromptOverrideCollection } = await Promise.resolve().then(() => PromptOverrideCollection_exports);
463
- const collection = await PromptOverrideCollection.create({ db: this.options.db ?? this.options.persistence });
464
- if (this.tenantId) {
465
- const appOverride = await collection.getAppOverride(this.key, { excludeId: this.id ?? void 0 });
466
- if (appOverride) layers.push(appOverride.toPromptLayer());
467
- }
468
- return layers;
469
- }
470
- normalizeParamsForPersistence() {
471
- const rawParams = this.params;
472
- if (rawParams === null || rawParams === void 0) {
473
- this.params = null;
474
- return;
475
- }
476
- if (typeof rawParams === "string") {
477
- this.params = rawParams;
478
- return;
479
- }
480
- if (typeof rawParams === "object" && !Array.isArray(rawParams)) {
481
- this.params = serializePromptParams(rawParams);
482
- return;
483
- }
484
- throw new Error(`Prompt "${this.key}" params must be a JSON object or JSON string`);
485
- }
486
- async getPersistedIdentity() {
487
- if (!this.id) return null;
488
- const existing = await this.db.get(this.tableName, { id: this.id });
489
- if (!existing) return null;
490
- return {
491
- key: String(existing.key ?? this.key),
492
- tenantId: existing.tenantId !== void 0 ? existing.tenantId : existing.tenant_id ?? null
493
- };
494
- }
495
- };
496
- __decorateClass$3([field({ required: true })], PromptOverride.prototype, "key", 2);
497
- __decorateClass$3([field({
498
- type: "text",
499
- nullable: true
500
- })], PromptOverride.prototype, "tenantId", 2);
501
- __decorateClass$3([field({
502
- type: "text",
503
- nullable: true
504
- })], PromptOverride.prototype, "template", 2);
505
- __decorateClass$3([field({
506
- type: "text",
507
- nullable: true
508
- })], PromptOverride.prototype, "profile", 2);
509
- __decorateClass$3([field({
510
- type: "text",
511
- nullable: true
512
- })], PromptOverride.prototype, "model", 2);
513
- __decorateClass$3([field({
514
- type: "text",
515
- nullable: true
516
- })], PromptOverride.prototype, "params", 2);
517
- PromptOverride = __decorateClass$3([smrt({
518
- tableName: "_smrt_prompt_overrides",
519
- conflictColumns: ["key", "context"],
520
- api: { include: [
521
- "list",
522
- "get",
523
- "create",
524
- "update",
525
- "delete"
526
- ] },
527
- cli: {
528
- include: [
529
- "list",
530
- "get",
531
- "create",
532
- "update",
533
- "delete"
534
- ],
535
- exclude: [
536
- "getParams",
537
- "setParams",
538
- "toPromptLayer"
539
- ]
540
- },
541
- mcp: { include: [] }
542
- })], PromptOverride);
543
- var PromptOverrideCollection_exports = /* @__PURE__ */ __exportAll({ PromptOverrideCollection: () => PromptOverrideCollection });
544
- var PromptOverrideCollection = class extends SmrtCollection {
545
- static _itemClass = PromptOverride;
546
- excludeOverrideId(items, excludeId) {
547
- return items.filter((item) => excludeId ? item.id !== excludeId : true);
548
- }
549
- async getAppOverride(key, options = {}) {
550
- const items = await this.list({ where: {
551
- key,
552
- tenantId: null
553
- } });
554
- return this.excludeOverrideId(items, options.excludeId)[0] ?? null;
555
- }
556
- async getTenantOverride(key, tenantId, options = {}) {
557
- const items = await this.list({ where: {
558
- key,
559
- tenantId
560
- } });
561
- return this.excludeOverrideId(items, options.excludeId)[0] ?? null;
562
- }
563
- async getResolutionLayers(key, tenantId, options = {}) {
564
- const [app, tenant] = await Promise.all([this.getAppOverride(key, options), tenantId != null ? this.getTenantOverride(key, tenantId, options) : Promise.resolve(null)]);
565
- return {
566
- app,
567
- tenant
568
- };
569
- }
570
- };
571
- function getPromptConfig() {
572
- return getPackageConfig("prompts", {
573
- profiles: {},
574
- prompts: {}
575
- });
576
- }
577
- async function loadPromptBase(key, options) {
578
- const definition = PromptRegistry.get(key);
579
- if (!definition) throw new Error(`Unknown prompt key "${key}"`);
580
- const tenantId = options.tenantId !== void 0 ? options.tenantId : getTenantId() ?? null;
581
- let collection = null;
582
- let cacheDb = options.db;
583
- if (options.db) {
584
- const initializedCollection = await PromptOverrideCollection.create({ db: options.db });
585
- collection = initializedCollection;
586
- cacheDb = initializedCollection.db;
587
- }
588
- const cached = getCachedPromptBase(key, tenantId, cacheDb);
589
- if (cached) return cached;
590
- const loadedAtGeneration = getPromptCacheGeneration(key, cacheDb);
591
- const config = getPromptConfig();
592
- const layers = [{
593
- template: definition.template,
594
- profile: definition.ai.profile ?? null,
595
- model: definition.ai.model ?? null,
596
- params: definition.ai.params
597
- }, normalizePromptLayer(config.prompts?.[key])];
598
- if (collection) {
599
- const stored = await collection.getResolutionLayers(key, tenantId);
600
- if (stored.app) layers.push(stored.app.toPromptLayer());
601
- if (stored.tenant) layers.push(stored.tenant.toPromptLayer());
602
- }
603
- const merged = mergePromptLayers(...layers);
604
- const value = {
605
- key,
606
- template: merged.template,
607
- ai: merged.ai
608
- };
609
- setCachedPromptBase(key, tenantId, cacheDb, value, loadedAtGeneration);
610
- return value;
611
- }
612
- async function resolvePrompt(key, options = {}) {
613
- const config = getPromptConfig();
614
- const base = await loadPromptBase(key, options);
615
- const runtimeOverride = normalizePromptLayer(options.override);
616
- const merged = mergePromptLayers({
617
- template: base.template,
618
- profile: base.ai.profile ?? null,
619
- model: base.ai.model ?? null,
620
- params: base.ai.params
621
- }, runtimeOverride);
622
- return {
623
- key,
624
- template: merged.template,
625
- text: renderPromptTemplate(merged.template, options.variables),
626
- ai: buildResolvedAI(merged.ai, config)
627
- };
628
- }
629
- //#endregion
630
7
  //#region ../profiles/dist/chunks/ProfileCollection-DTT4KNpQ.js
631
- var ProfileCollection_DTT4KNpQ_exports = /* @__PURE__ */ __exportAll$1({
8
+ var ProfileCollection_DTT4KNpQ_exports = /* @__PURE__ */ __exportAll({
632
9
  _: () => smrtProfilesGenerateBioPrompt,
633
10
  a: () => Profile,
634
11
  d: () => isOidcProvisioningRaceConflict,
@@ -669,7 +46,7 @@ function promptMessageOptions(ai) {
669
46
  ...typeof ai.maxTokens === "number" ? { maxTokens: ai.maxTokens } : {}
670
47
  };
671
48
  }
672
- var ProfileType_exports = /* @__PURE__ */ __exportAll$2({ ProfileType: () => ProfileType });
49
+ var ProfileType_exports = /* @__PURE__ */ __exportAll$1({ ProfileType: () => ProfileType });
673
50
  var __defProp$2 = Object.defineProperty;
674
51
  var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
675
52
  var __decorateClass$2 = (decorators, target, key, kind) => {
@@ -1051,8 +428,8 @@ var Profile = class extends SmrtObject {
1051
428
  * @param value - The value to set
1052
429
  */
1053
430
  async addMetadata(metafieldSlug, value) {
1054
- const { ProfileMetafieldCollection } = await import("./ProfileMetafieldCollection-CMKhVi2I-NPA4NfPL.js").then((n) => n.n);
1055
- const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DxX_BJKV-CXKXBRtU.js").then((n) => n.n);
431
+ const { ProfileMetafieldCollection } = await import("./ProfileMetafieldCollection-CMKhVi2I-BTguykyW.js").then((n) => n.n);
432
+ const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DxX_BJKV-CqTZZ7O9.js").then((n) => n.n);
1056
433
  const metafield = await (await ProfileMetafieldCollection.create(this.options)).getBySlug(metafieldSlug);
1057
434
  if (!metafield) throw new Error(`Metafield '${metafieldSlug}' not found`);
1058
435
  await metafield.validateValue(value);
@@ -1083,7 +460,7 @@ var Profile = class extends SmrtObject {
1083
460
  * @returns Object with metafield slugs as keys
1084
461
  */
1085
462
  async getMetadata() {
1086
- const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DxX_BJKV-CXKXBRtU.js").then((n) => n.n);
463
+ const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DxX_BJKV-CqTZZ7O9.js").then((n) => n.n);
1087
464
  return await (await ProfileMetadataCollection.create(this.options)).getMetadataObject(this.id);
1088
465
  }
1089
466
  /**
@@ -1100,8 +477,8 @@ var Profile = class extends SmrtObject {
1100
477
  * @param metafieldSlug - The slug of the metafield to remove
1101
478
  */
1102
479
  async removeMetadata(metafieldSlug) {
1103
- const { ProfileMetafieldCollection } = await import("./ProfileMetafieldCollection-CMKhVi2I-NPA4NfPL.js").then((n) => n.n);
1104
- const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DxX_BJKV-CXKXBRtU.js").then((n) => n.n);
480
+ const { ProfileMetafieldCollection } = await import("./ProfileMetafieldCollection-CMKhVi2I-BTguykyW.js").then((n) => n.n);
481
+ const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DxX_BJKV-CqTZZ7O9.js").then((n) => n.n);
1105
482
  const metafield = await (await ProfileMetafieldCollection.create(this.options)).getBySlug(metafieldSlug);
1106
483
  if (!metafield) throw new Error(`Metafield '${metafieldSlug}' not found`);
1107
484
  const existing = await (await ProfileMetadataCollection.create(this.options)).list({
@@ -1114,7 +491,7 @@ var Profile = class extends SmrtObject {
1114
491
  if (existing.length > 0) await existing[0].delete();
1115
492
  }
1116
493
  async getProfileAssetCollection() {
1117
- const { ProfileAssetCollection } = await import("./ProfileAssetCollection-CmbeSgDi-mMSqxPLS.js").then((n) => n.n);
494
+ const { ProfileAssetCollection } = await import("./ProfileAssetCollection-CmbeSgDi-CcjX8UeG.js").then((n) => n.n);
1118
495
  return ProfileAssetCollection.create({ db: this.db });
1119
496
  }
1120
497
  async getAssets(relationship) {
@@ -1144,9 +521,9 @@ var Profile = class extends SmrtObject {
1144
521
  * @param contextProfile - Optional context profile for tertiary relationships
1145
522
  */
1146
523
  async addRelationship(toProfile, relationshipSlug, contextProfile) {
1147
- const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-DGHj5NYL.js").then((n) => n.n);
1148
- const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-BlH89282.js").then((n) => n.n);
1149
- const { ProfileRelationshipType } = await import("./ProfileRelationshipType-BRiRka6t-sguU4oDf.js").then((n) => n.n).then((n) => n.n);
524
+ const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-BUuZ3P72.js").then((n) => n.n);
525
+ const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-CdOJCU07.js").then((n) => n.n);
526
+ const { ProfileRelationshipType } = await import("./ProfileRelationshipType-BRiRka6t-B-lkyTB2.js").then((n) => n.n).then((n) => n.n);
1150
527
  const relationshipType = await (await ProfileRelationshipTypeCollection.create(this.options)).getBySlug(relationshipSlug);
1151
528
  if (!relationshipType) throw new Error(`Relationship type '${relationshipSlug}' not found`);
1152
529
  const relationshipCollection = await ProfileRelationshipCollection.create(this.options);
@@ -1170,8 +547,8 @@ var Profile = class extends SmrtObject {
1170
547
  * @returns Array of ProfileRelationship instances
1171
548
  */
1172
549
  async getRelationships(options) {
1173
- const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-BlH89282.js").then((n) => n.n);
1174
- const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-DGHj5NYL.js").then((n) => n.n);
550
+ const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-CdOJCU07.js").then((n) => n.n);
551
+ const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-BUuZ3P72.js").then((n) => n.n);
1175
552
  const relationshipCollection = await ProfileRelationshipCollection.create(this.options);
1176
553
  const direction = options?.direction || "all";
1177
554
  let typeId;
@@ -1214,8 +591,8 @@ var Profile = class extends SmrtObject {
1214
591
  * @param relationshipSlug - The type of relationship to remove
1215
592
  */
1216
593
  async removeRelationship(toProfile, relationshipSlug) {
1217
- const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-DGHj5NYL.js").then((n) => n.n);
1218
- const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-BlH89282.js").then((n) => n.n);
594
+ const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-BUuZ3P72.js").then((n) => n.n);
595
+ const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-CdOJCU07.js").then((n) => n.n);
1219
596
  const relationshipType = await (await ProfileRelationshipTypeCollection.create(this.options)).getBySlug(relationshipSlug);
1220
597
  if (!relationshipType) throw new Error(`Relationship type '${relationshipSlug}' not found`);
1221
598
  const relationshipCollection = await ProfileRelationshipCollection.create(this.options);
@@ -1308,7 +685,7 @@ var Profile = class extends SmrtObject {
1308
685
  * @returns Array of API keys
1309
686
  */
1310
687
  async getApiKeys() {
1311
- const { ApiKeyCollection } = await import("./ApiKeyCollection-Bfb_nw81-CNAaLULe.js").then((n) => n.n);
688
+ const { ApiKeyCollection } = await import("./ApiKeyCollection-Bfb_nw81-D8b3Nrg4.js").then((n) => n.n);
1312
689
  return await (await ApiKeyCollection.create(this.options)).findByProfile(this.id);
1313
690
  }
1314
691
  /**
@@ -1317,7 +694,7 @@ var Profile = class extends SmrtObject {
1317
694
  * @returns Array of active API keys
1318
695
  */
1319
696
  async getActiveApiKeys() {
1320
- const { ApiKeyCollection } = await import("./ApiKeyCollection-Bfb_nw81-CNAaLULe.js").then((n) => n.n);
697
+ const { ApiKeyCollection } = await import("./ApiKeyCollection-Bfb_nw81-D8b3Nrg4.js").then((n) => n.n);
1321
698
  return await (await ApiKeyCollection.create(this.options)).findActiveByProfile(this.id);
1322
699
  }
1323
700
  /**
@@ -1327,7 +704,7 @@ var Profile = class extends SmrtObject {
1327
704
  * @returns The generated key (plaintext) and ApiKey record
1328
705
  */
1329
706
  async generateApiKey(options) {
1330
- const { ApiKey } = await import("./ApiKey-BZmbOTnL-Bo7tbG1k.js").then((n) => n.n).then((n) => n.n);
707
+ const { ApiKey } = await import("./ApiKey-BZmbOTnL-BHFzurt7.js").then((n) => n.n).then((n) => n.n);
1331
708
  return await ApiKey.generate(this, {
1332
709
  ...options,
1333
710
  db: this.options?.db
@@ -1339,7 +716,7 @@ var Profile = class extends SmrtObject {
1339
716
  * @returns Array of OIDC identity records
1340
717
  */
1341
718
  async getOidcIdentities() {
1342
- const { OidcIdentityCollection } = await import("./OidcIdentityCollection-gnrLoF08-B5y4FHI0.js").then((n) => n.r);
719
+ const { OidcIdentityCollection } = await import("./OidcIdentityCollection-gnrLoF08-BsEJX0w8.js").then((n) => n.r);
1343
720
  return await (await OidcIdentityCollection.create(this.options)).findByProfile(this.id);
1344
721
  }
1345
722
  /**
@@ -1352,7 +729,7 @@ var Profile = class extends SmrtObject {
1352
729
  * type, but refuses to create or rebind authority.
1353
730
  */
1354
731
  async linkOidcIdentity(oidcData) {
1355
- const { OidcIdentityCollection } = await import("./OidcIdentityCollection-gnrLoF08-B5y4FHI0.js").then((n) => n.r);
732
+ const { OidcIdentityCollection } = await import("./OidcIdentityCollection-gnrLoF08-BsEJX0w8.js").then((n) => n.r);
1356
733
  return await (await OidcIdentityCollection.create(this.options)).linkToProfile(this, oidcData);
1357
734
  }
1358
735
  /**
@@ -1361,7 +738,7 @@ var Profile = class extends SmrtObject {
1361
738
  * @returns Array of Nostr identity records
1362
739
  */
1363
740
  async getNostrIdentities() {
1364
- const { NostrIdentityCollection } = await import("./NostrIdentityCollection-Ca74dkaL-aM_-cerc.js").then((n) => n.n);
741
+ const { NostrIdentityCollection } = await import("./NostrIdentityCollection-Ca74dkaL-BKzq1O2N.js").then((n) => n.n);
1365
742
  return await (await NostrIdentityCollection.create(this.options)).findByProfile(this.id);
1366
743
  }
1367
744
  /**
@@ -1371,7 +748,7 @@ var Profile = class extends SmrtObject {
1371
748
  * @returns The linked Nostr identity record
1372
749
  */
1373
750
  async linkNostrIdentity(nostrData) {
1374
- const { NostrIdentityCollection } = await import("./NostrIdentityCollection-Ca74dkaL-aM_-cerc.js").then((n) => n.n);
751
+ const { NostrIdentityCollection } = await import("./NostrIdentityCollection-Ca74dkaL-BKzq1O2N.js").then((n) => n.n);
1375
752
  return await (await NostrIdentityCollection.create(this.options)).linkToProfile(this, nostrData);
1376
753
  }
1377
754
  /**
@@ -1381,7 +758,7 @@ var Profile = class extends SmrtObject {
1381
758
  * @returns Array of audit log entries
1382
759
  */
1383
760
  async getAuditLogs(limit = 50) {
1384
- const { AuditLogCollection } = await import("./AuditLogCollection-B1YonCAP-yweHrz14.js").then((n) => n.n);
761
+ const { AuditLogCollection } = await import("./AuditLogCollection-B1YonCAP-CpPE8zro.js").then((n) => n.n);
1385
762
  return await (await AuditLogCollection.create(this.options)).getRecentActivity(this.id, limit);
1386
763
  }
1387
764
  /**
@@ -1391,7 +768,7 @@ var Profile = class extends SmrtObject {
1391
768
  * @returns The created audit log entry
1392
769
  */
1393
770
  async recordAction(options) {
1394
- const { AuditLogCollection } = await import("./AuditLogCollection-B1YonCAP-yweHrz14.js").then((n) => n.n);
771
+ const { AuditLogCollection } = await import("./AuditLogCollection-B1YonCAP-CpPE8zro.js").then((n) => n.n);
1395
772
  return await (await AuditLogCollection.create(this.options)).record({
1396
773
  profile: this,
1397
774
  ...options
@@ -1430,7 +807,7 @@ Profile = __decorateClass([TenantScoped({ mode: "optional" }), smrt({
1430
807
  var OidcProfileEmailReservationCollection = class extends SmrtCollection {
1431
808
  static _itemClass = OidcProfileEmailReservation;
1432
809
  };
1433
- var ProfileCollection_exports = /* @__PURE__ */ __exportAll$2({
810
+ var ProfileCollection_exports = /* @__PURE__ */ __exportAll$1({
1434
811
  CanonicalPersonProfileError: () => CanonicalPersonProfileError,
1435
812
  ProfileCollection: () => ProfileCollection
1436
813
  });