casualos 3.4.0-alpha.14204808910 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +51 -1224
  2. package/package.json +4 -4
package/dist/cli.js CHANGED
@@ -17459,7 +17459,7 @@ var require_base64_js = __commonJS({
17459
17459
  "use strict";
17460
17460
  exports.byteLength = byteLength;
17461
17461
  exports.toByteArray = toByteArray15;
17462
- exports.fromByteArray = fromByteArray17;
17462
+ exports.fromByteArray = fromByteArray16;
17463
17463
  var lookup2 = [];
17464
17464
  var revLookup = [];
17465
17465
  var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
@@ -17530,7 +17530,7 @@ var require_base64_js = __commonJS({
17530
17530
  }
17531
17531
  return output.join("");
17532
17532
  }
17533
- function fromByteArray17(uint8) {
17533
+ function fromByteArray16(uint8) {
17534
17534
  var tmp;
17535
17535
  var len2 = uint8.length;
17536
17536
  var extraBytes = len2 % 3;
@@ -98081,7 +98081,7 @@ var trace = TraceAPI.getInstance();
98081
98081
  function hashLowEntropyPasswordWithSalt2(password, salt) {
98082
98082
  const tracer = trace.getTracer(
98083
98083
  "InstrumentedHashHelpers",
98084
- false ? void 0 : "v3.4.0-alpha.14204808910"
98084
+ false ? void 0 : "v3.4.0"
98085
98085
  );
98086
98086
  return tracer.startActiveSpan(
98087
98087
  "hashLowEntropyPasswordWithSalt",
@@ -98099,7 +98099,7 @@ function hashLowEntropyPasswordWithSalt2(password, salt) {
98099
98099
  function hashHighEntropyPasswordWithSalt2(password, salt) {
98100
98100
  const tracer = trace.getTracer(
98101
98101
  "InstrumentedHashHelpers",
98102
- false ? void 0 : "v3.4.0-alpha.14204808910"
98102
+ false ? void 0 : "v3.4.0"
98103
98103
  );
98104
98104
  return tracer.startActiveSpan(
98105
98105
  "hashHighEntropyPasswordWithSalt",
@@ -98117,7 +98117,7 @@ function hashHighEntropyPasswordWithSalt2(password, salt) {
98117
98117
  function verifyPasswordAgainstHashes2(password, salt, hashes) {
98118
98118
  const tracer = trace.getTracer(
98119
98119
  "InstrumentedHashHelpers",
98120
- false ? void 0 : "v3.4.0-alpha.14204808910"
98120
+ false ? void 0 : "v3.4.0"
98121
98121
  );
98122
98122
  return tracer.startActiveSpan(
98123
98123
  "verifyPasswordAgainstHashes",
@@ -105069,7 +105069,7 @@ var import_semantic_conventions = __toESM(require_src3());
105069
105069
  function traced(tracerName, options = {}, metricOptions = {}) {
105070
105070
  const tracer = trace.getTracer(
105071
105071
  tracerName,
105072
- false ? void 0 : "v3.4.0-alpha.14204808910"
105072
+ false ? void 0 : "v3.4.0"
105073
105073
  );
105074
105074
  return function(target, propertyKey, descriptor) {
105075
105075
  const originalMethod = descriptor.value;
@@ -105147,7 +105147,7 @@ function getHistogram(meter) {
105147
105147
  }
105148
105148
  return metrics.getMeter(
105149
105149
  meter.meter,
105150
- false ? void 0 : "v3.4.0-alpha.14204808910"
105150
+ false ? void 0 : "v3.4.0"
105151
105151
  ).createHistogram(meter.name, meter.options);
105152
105152
  }
105153
105153
  function getCounter(meter) {
@@ -105156,7 +105156,7 @@ function getCounter(meter) {
105156
105156
  }
105157
105157
  return metrics.getMeter(
105158
105158
  meter.meter,
105159
- false ? void 0 : "v3.4.0-alpha.14204808910"
105159
+ false ? void 0 : "v3.4.0"
105160
105160
  ).createCounter(meter.name, meter.options);
105161
105161
  }
105162
105162
  function traceHttpResponse(options = {}) {
@@ -108186,34 +108186,6 @@ function getHumeAiFeatures(config2, subscriptionStatus, subscriptionId, type, pe
108186
108186
  );
108187
108187
  return features.ai.hume ?? { allowed: false };
108188
108188
  }
108189
- function getSloydAiFeatures(config2, subscriptionStatus, subscriptionId, type, periodStartMs, periodEndMs, nowMs = Date.now()) {
108190
- const features = getSubscriptionFeatures(
108191
- config2,
108192
- subscriptionStatus,
108193
- subscriptionId,
108194
- type,
108195
- periodStartMs,
108196
- periodEndMs,
108197
- nowMs
108198
- );
108199
- return features.ai.sloyd ?? { allowed: false };
108200
- }
108201
- function getOpenAiFeatures(config2, subscriptionStatus, subscriptionId, type, periodStartMs, periodEndMs, nowMs = Date.now()) {
108202
- const features = getSubscriptionFeatures(
108203
- config2,
108204
- subscriptionStatus,
108205
- subscriptionId,
108206
- type,
108207
- periodStartMs,
108208
- periodEndMs,
108209
- nowMs
108210
- );
108211
- return features.ai.openai ?? {
108212
- realtime: {
108213
- allowed: false
108214
- }
108215
- };
108216
- }
108217
108189
  function getSubscriptionFeatures(config2, subscriptionStatus, subscriptionId, type, periodStartMs, periodEndMs, nowMs = Date.now()) {
108218
108190
  if (!config2) {
108219
108191
  return allowAllFeatures();
@@ -117291,7 +117263,7 @@ var RecordsServer = class {
117291
117263
  this._notificationsController = notificationsController;
117292
117264
  this._tracer = trace.getTracer(
117293
117265
  "RecordsServer",
117294
- false ? void 0 : "v3.4.0-alpha.14204808910"
117266
+ false ? void 0 : "v3.4.0"
117295
117267
  );
117296
117268
  this._procedures = this._createProcedures();
117297
117269
  this._setupRoutes();
@@ -119696,8 +119668,8 @@ var RecordsServer = class {
119696
119668
  return {
119697
119669
  success: true,
119698
119670
  ...metadata,
119699
- version: true ? "v3.4.0-alpha.14204808910" : void 0,
119700
- versionHash: true ? "9be199a7988c84a5f500913190be3c43e5ed1af4" : void 0
119671
+ version: true ? "v3.4.0" : void 0,
119672
+ versionHash: true ? "e6d88e1adf37ddf74e4b925b5a839b74b9832951" : void 0
119701
119673
  };
119702
119674
  })
119703
119675
  };
@@ -124025,1151 +123997,6 @@ __decorateClass([
124025
123997
  traced(TRACE_NAME11)
124026
123998
  ], RateLimitController.prototype, "checkRateLimit", 1);
124027
123999
 
124028
- // ../aux-records/AIController.ts
124029
- var import_base64_js14 = __toESM(require_base64_js());
124030
- var TRACE_NAME12 = "AIController";
124031
- var AIController = class {
124032
- constructor(configuration) {
124033
- if (configuration.chat) {
124034
- const chat = configuration.chat;
124035
- const options = chat.options;
124036
- this._chatProviders = chat.interfaces;
124037
- this._chatOptions = options;
124038
- this._allowedChatModels = new Map(
124039
- options.allowedChatModels.map(
124040
- (m2) => typeof m2 === "string" ? [m2, options.defaultModel] : [m2.model, m2.provider]
124041
- )
124042
- );
124043
- this._allowedChatSubscriptionTiers = typeof options.allowedChatSubscriptionTiers === "boolean" ? options.allowedChatSubscriptionTiers : new Set(options.allowedChatSubscriptionTiers);
124044
- }
124045
- if (configuration.generateSkybox) {
124046
- this._generateSkybox = configuration.generateSkybox.interface;
124047
- const options = configuration.generateSkybox.options;
124048
- this._allowedGenerateSkyboxSubscriptionTiers = typeof options.allowedSubscriptionTiers === "boolean" ? options.allowedSubscriptionTiers : new Set(options.allowedSubscriptionTiers);
124049
- }
124050
- if (configuration.images) {
124051
- this._imageProviders = configuration.images.interfaces;
124052
- const options = configuration.images.options;
124053
- this._imageOptions = options;
124054
- this._allowedImageSubscriptionTiers = typeof options.allowedSubscriptionTiers === "boolean" ? options.allowedSubscriptionTiers : new Set(options.allowedSubscriptionTiers);
124055
- this._allowedImageModels = /* @__PURE__ */ new Map();
124056
- for (let provider in options.allowedModels) {
124057
- for (let model of options.allowedModels[provider]) {
124058
- this._allowedImageModels.set(model, provider);
124059
- }
124060
- }
124061
- }
124062
- this._policies = configuration.policyController;
124063
- this._humeInterface = configuration.hume?.interface;
124064
- this._humeConfig = configuration.hume?.config;
124065
- this._sloydInterface = configuration.sloyd?.interface;
124066
- this._openAIRealtimeInterface = configuration.openai?.realtime?.interface;
124067
- this._metrics = configuration.metrics;
124068
- this._config = configuration.config;
124069
- this._policyStore = configuration.policies;
124070
- this._recordsStore = configuration.records;
124071
- }
124072
- async chat(request2) {
124073
- try {
124074
- if (!this._chatProviders) {
124075
- return {
124076
- success: false,
124077
- errorCode: "not_supported",
124078
- errorMessage: "This operation is not supported."
124079
- };
124080
- }
124081
- if (!request2.userId) {
124082
- return {
124083
- success: false,
124084
- errorCode: "not_logged_in",
124085
- errorMessage: "The user must be logged in. Please provide a sessionKey or a recordKey."
124086
- };
124087
- }
124088
- if (!this._matchesSubscriptionTiers(
124089
- request2.userSubscriptionTier,
124090
- this._allowedChatSubscriptionTiers
124091
- )) {
124092
- if (!request2.userSubscriptionTier) {
124093
- return {
124094
- success: false,
124095
- errorCode: "not_subscribed",
124096
- errorMessage: "The user must be subscribed in order to use this operation.",
124097
- allowedSubscriptionTiers: [
124098
- ...this._allowedChatSubscriptionTiers
124099
- ]
124100
- };
124101
- } else {
124102
- return {
124103
- success: false,
124104
- errorCode: "invalid_subscription_tier",
124105
- errorMessage: "This operation is not available to the user at their current subscription tier.",
124106
- allowedSubscriptionTiers: [
124107
- ...this._allowedChatSubscriptionTiers
124108
- ],
124109
- currentSubscriptionTier: request2.userSubscriptionTier
124110
- };
124111
- }
124112
- }
124113
- if (!!request2.model && !this._allowedChatModels.has(request2.model)) {
124114
- return {
124115
- success: false,
124116
- errorCode: "invalid_model",
124117
- errorMessage: `The given model is not allowed for chats.`
124118
- };
124119
- }
124120
- const model = request2.model ?? this._chatOptions.defaultModel;
124121
- const provider = this._allowedChatModels.get(request2.model) ?? this._chatOptions.defaultModelProvider;
124122
- const chat = this._chatProviders[provider];
124123
- if (!chat) {
124124
- console.error(
124125
- "[AIController] No chat provider found for model:",
124126
- model
124127
- );
124128
- return {
124129
- success: false,
124130
- errorCode: "not_supported",
124131
- errorMessage: "The given model is not supported."
124132
- };
124133
- } else {
124134
- console.log(
124135
- "[AIController] Using chat provider:",
124136
- provider,
124137
- "for model:",
124138
- model
124139
- );
124140
- }
124141
- const metrics3 = await this._metrics.getSubscriptionAiChatMetrics({
124142
- ownerId: request2.userId
124143
- });
124144
- const config2 = await this._config.getSubscriptionConfiguration();
124145
- const allowedFeatures = getSubscriptionFeatures(
124146
- config2,
124147
- metrics3.subscriptionStatus,
124148
- metrics3.subscriptionId,
124149
- "user"
124150
- );
124151
- if (!allowedFeatures.ai.chat.allowed) {
124152
- return {
124153
- success: false,
124154
- errorCode: "not_authorized",
124155
- errorMessage: "The subscription does not permit AI Chat features."
124156
- };
124157
- }
124158
- let maxTokens = void 0;
124159
- if (allowedFeatures.ai.chat.maxTokensPerPeriod) {
124160
- maxTokens = allowedFeatures.ai.chat.maxTokensPerPeriod - metrics3.totalTokensInCurrentPeriod;
124161
- }
124162
- if (maxTokens <= 0) {
124163
- return {
124164
- success: false,
124165
- errorCode: "subscription_limit_reached",
124166
- errorMessage: `The user has reached their limit for the current subscription period.`
124167
- };
124168
- }
124169
- if (allowedFeatures.ai.chat.maxTokensPerRequest) {
124170
- if (maxTokens) {
124171
- maxTokens = Math.min(
124172
- maxTokens,
124173
- allowedFeatures.ai.chat.maxTokensPerRequest
124174
- );
124175
- } else {
124176
- maxTokens = allowedFeatures.ai.chat.maxTokensPerRequest;
124177
- }
124178
- }
124179
- if (this._policyStore) {
124180
- const privacyFeatures = await this._policyStore.getUserPrivacyFeatures(
124181
- request2.userId
124182
- );
124183
- if (!privacyFeatures.allowAI) {
124184
- return {
124185
- success: false,
124186
- errorCode: "not_authorized",
124187
- errorMessage: "AI Access is not allowed"
124188
- };
124189
- }
124190
- }
124191
- if (allowedFeatures.ai.chat.allowedModels) {
124192
- const allowedModels = allowedFeatures.ai.chat.allowedModels;
124193
- if (!allowedModels.includes(model)) {
124194
- return {
124195
- success: false,
124196
- errorCode: "not_authorized",
124197
- errorMessage: "The subscription does not permit the given model for AI Chat features."
124198
- };
124199
- }
124200
- }
124201
- const result = await chat.chat({
124202
- messages: request2.messages,
124203
- model,
124204
- temperature: request2.temperature,
124205
- topP: request2.topP,
124206
- frequencyPenalty: request2.frequencyPenalty,
124207
- presencePenalty: request2.presencePenalty,
124208
- stopWords: request2.stopWords,
124209
- userId: request2.userId,
124210
- maxTokens
124211
- });
124212
- if (result.totalTokens > 0) {
124213
- const adjustedTokens = this._calculateTokenCost(result, model);
124214
- await this._metrics.recordChatMetrics({
124215
- userId: request2.userId,
124216
- createdAtMs: Date.now(),
124217
- tokens: adjustedTokens
124218
- });
124219
- }
124220
- return {
124221
- success: true,
124222
- choices: result.choices
124223
- };
124224
- } catch (err) {
124225
- const span = trace.getActiveSpan();
124226
- span?.recordException(err);
124227
- span?.setStatus({ code: SpanStatusCode.ERROR });
124228
- console.error("[AIController] Error handling chat request:", err);
124229
- return {
124230
- success: false,
124231
- errorCode: "server_error",
124232
- errorMessage: "A server error occurred."
124233
- };
124234
- }
124235
- }
124236
- _calculateTokenCost(result, model) {
124237
- const totalTokens = result.totalTokens;
124238
- const tokenModifierRatio = this._chatOptions.tokenModifierRatio;
124239
- const modifier = tokenModifierRatio[model] ?? 1;
124240
- const adjustedTokens = modifier * totalTokens;
124241
- return adjustedTokens;
124242
- }
124243
- async *chatStream(request2) {
124244
- try {
124245
- if (!this._chatProviders) {
124246
- return {
124247
- success: false,
124248
- errorCode: "not_supported",
124249
- errorMessage: "This operation is not supported."
124250
- };
124251
- }
124252
- if (!request2.userId) {
124253
- return {
124254
- success: false,
124255
- errorCode: "not_logged_in",
124256
- errorMessage: "The user must be logged in. Please provide a sessionKey or a recordKey."
124257
- };
124258
- }
124259
- if (!this._matchesSubscriptionTiers(
124260
- request2.userSubscriptionTier,
124261
- this._allowedChatSubscriptionTiers
124262
- )) {
124263
- if (!request2.userSubscriptionTier) {
124264
- return {
124265
- success: false,
124266
- errorCode: "not_subscribed",
124267
- errorMessage: "The user must be subscribed in order to use this operation.",
124268
- allowedSubscriptionTiers: [
124269
- ...this._allowedChatSubscriptionTiers
124270
- ]
124271
- };
124272
- } else {
124273
- return {
124274
- success: false,
124275
- errorCode: "invalid_subscription_tier",
124276
- errorMessage: "This operation is not available to the user at their current subscription tier.",
124277
- allowedSubscriptionTiers: [
124278
- ...this._allowedChatSubscriptionTiers
124279
- ],
124280
- currentSubscriptionTier: request2.userSubscriptionTier
124281
- };
124282
- }
124283
- }
124284
- if (!!request2.model && !this._allowedChatModels.has(request2.model)) {
124285
- return {
124286
- success: false,
124287
- errorCode: "invalid_model",
124288
- errorMessage: `The given model is not allowed for chats.`
124289
- };
124290
- }
124291
- const model = request2.model ?? this._chatOptions.defaultModel;
124292
- const provider = this._allowedChatModels.get(request2.model) ?? this._chatOptions.defaultModelProvider;
124293
- const chat = this._chatProviders[provider];
124294
- if (!chat) {
124295
- console.error(
124296
- "[AIController] No chat provider found for model:",
124297
- model
124298
- );
124299
- return {
124300
- success: false,
124301
- errorCode: "not_supported",
124302
- errorMessage: "The given model is not supported."
124303
- };
124304
- } else if (!chat.chatStream) {
124305
- console.error(
124306
- "[AIController] Chat provider does not support chatStream for model:",
124307
- model
124308
- );
124309
- return {
124310
- success: false,
124311
- errorCode: "not_supported",
124312
- errorMessage: "The given model does not support streaming."
124313
- };
124314
- } else {
124315
- console.log(
124316
- "[AIController] Using chat provider:",
124317
- provider,
124318
- "for model:",
124319
- model
124320
- );
124321
- }
124322
- const metrics3 = await this._metrics.getSubscriptionAiChatMetrics({
124323
- ownerId: request2.userId
124324
- });
124325
- const config2 = await this._config.getSubscriptionConfiguration();
124326
- const allowedFeatures = getSubscriptionFeatures(
124327
- config2,
124328
- metrics3.subscriptionStatus,
124329
- metrics3.subscriptionId,
124330
- "user"
124331
- );
124332
- if (!allowedFeatures.ai.chat.allowed) {
124333
- return {
124334
- success: false,
124335
- errorCode: "not_authorized",
124336
- errorMessage: "The subscription does not permit AI Chat features."
124337
- };
124338
- }
124339
- if (allowedFeatures.ai.chat.allowedModels) {
124340
- const allowedModels = allowedFeatures.ai.chat.allowedModels;
124341
- if (!allowedModels.includes(model)) {
124342
- return {
124343
- success: false,
124344
- errorCode: "not_authorized",
124345
- errorMessage: "The subscription does not permit the given model for AI Chat features."
124346
- };
124347
- }
124348
- }
124349
- let maxTokens = void 0;
124350
- if (allowedFeatures.ai.chat.maxTokensPerPeriod) {
124351
- maxTokens = allowedFeatures.ai.chat.maxTokensPerPeriod - metrics3.totalTokensInCurrentPeriod;
124352
- }
124353
- if (maxTokens <= 0) {
124354
- return {
124355
- success: false,
124356
- errorCode: "subscription_limit_reached",
124357
- errorMessage: `The user has reached their limit for the current subscription period.`
124358
- };
124359
- }
124360
- if (allowedFeatures.ai.chat.maxTokensPerRequest) {
124361
- if (maxTokens) {
124362
- maxTokens = Math.min(
124363
- maxTokens,
124364
- allowedFeatures.ai.chat.maxTokensPerRequest
124365
- );
124366
- } else {
124367
- maxTokens = allowedFeatures.ai.chat.maxTokensPerRequest;
124368
- }
124369
- }
124370
- if (this._policyStore) {
124371
- const privacyFeatures = await this._policyStore.getUserPrivacyFeatures(
124372
- request2.userId
124373
- );
124374
- if (!privacyFeatures.allowAI) {
124375
- return {
124376
- success: false,
124377
- errorCode: "not_authorized",
124378
- errorMessage: "AI Access is not allowed"
124379
- };
124380
- }
124381
- }
124382
- const result = chat.chatStream({
124383
- messages: request2.messages,
124384
- model,
124385
- temperature: request2.temperature,
124386
- topP: request2.topP,
124387
- frequencyPenalty: request2.frequencyPenalty,
124388
- presencePenalty: request2.presencePenalty,
124389
- stopWords: request2.stopWords,
124390
- userId: request2.userId,
124391
- maxTokens
124392
- });
124393
- for await (let chunk of result) {
124394
- if (chunk.totalTokens > 0) {
124395
- const adjustedTokens = this._calculateTokenCost(
124396
- chunk,
124397
- model
124398
- );
124399
- await this._metrics.recordChatMetrics({
124400
- userId: request2.userId,
124401
- createdAtMs: Date.now(),
124402
- tokens: adjustedTokens
124403
- });
124404
- }
124405
- yield {
124406
- choices: chunk.choices
124407
- };
124408
- }
124409
- return {
124410
- success: true
124411
- };
124412
- } catch (err) {
124413
- const span = trace.getActiveSpan();
124414
- span?.recordException(err);
124415
- span?.setStatus({ code: SpanStatusCode.ERROR });
124416
- console.error(
124417
- "[AIController] Error handling chat stream request:",
124418
- err
124419
- );
124420
- return {
124421
- success: false,
124422
- errorCode: "server_error",
124423
- errorMessage: "A server error occurred."
124424
- };
124425
- }
124426
- }
124427
- async generateSkybox(request2) {
124428
- try {
124429
- if (!this._generateSkybox) {
124430
- return {
124431
- success: false,
124432
- errorCode: "not_supported",
124433
- errorMessage: "This operation is not supported."
124434
- };
124435
- }
124436
- if (!request2.userId) {
124437
- return {
124438
- success: false,
124439
- errorCode: "not_logged_in",
124440
- errorMessage: "The user must be logged in. Please provide a sessionKey or a recordKey."
124441
- };
124442
- }
124443
- if (!this._matchesSubscriptionTiers(
124444
- request2.userSubscriptionTier,
124445
- this._allowedGenerateSkyboxSubscriptionTiers
124446
- )) {
124447
- if (!request2.userSubscriptionTier) {
124448
- return {
124449
- success: false,
124450
- errorCode: "not_subscribed",
124451
- errorMessage: "The user must be subscribed in order to use this operation.",
124452
- allowedSubscriptionTiers: [
124453
- ...this._allowedGenerateSkyboxSubscriptionTiers
124454
- ]
124455
- };
124456
- } else {
124457
- return {
124458
- success: false,
124459
- errorCode: "invalid_subscription_tier",
124460
- errorMessage: "This operation is not available to the user at their current subscription tier.",
124461
- allowedSubscriptionTiers: [
124462
- ...this._allowedGenerateSkyboxSubscriptionTiers
124463
- ],
124464
- currentSubscriptionTier: request2.userSubscriptionTier
124465
- };
124466
- }
124467
- }
124468
- const metrics3 = await this._metrics.getSubscriptionAiSkyboxMetrics({
124469
- ownerId: request2.userId
124470
- });
124471
- const config2 = await this._config.getSubscriptionConfiguration();
124472
- const allowedFeatures = getSubscriptionFeatures(
124473
- config2,
124474
- metrics3.subscriptionStatus,
124475
- metrics3.subscriptionId,
124476
- "user"
124477
- );
124478
- if (!allowedFeatures.ai.skyboxes.allowed) {
124479
- return {
124480
- success: false,
124481
- errorCode: "not_authorized",
124482
- errorMessage: "The subscription does not permit AI Skybox features."
124483
- };
124484
- }
124485
- if (allowedFeatures.ai.skyboxes.maxSkyboxesPerPeriod > 0 && metrics3.totalSkyboxesInCurrentPeriod + 1 > allowedFeatures.ai.skyboxes.maxSkyboxesPerPeriod) {
124486
- return {
124487
- success: false,
124488
- errorCode: "subscription_limit_reached",
124489
- errorMessage: `The user has reached their limit for the current subscription period.`
124490
- };
124491
- }
124492
- if (this._policyStore) {
124493
- const privacyFeatures = await this._policyStore.getUserPrivacyFeatures(
124494
- request2.userId
124495
- );
124496
- if (!privacyFeatures.allowAI) {
124497
- return {
124498
- success: false,
124499
- errorCode: "not_authorized",
124500
- errorMessage: "AI Access is not allowed"
124501
- };
124502
- }
124503
- }
124504
- const result = await this._generateSkybox.generateSkybox({
124505
- prompt: request2.prompt,
124506
- negativePrompt: request2.negativePrompt,
124507
- blockadeLabs: request2.blockadeLabs
124508
- });
124509
- if (result.success === true) {
124510
- await this._metrics.recordSkyboxMetrics({
124511
- userId: request2.userId,
124512
- createdAtMs: Date.now(),
124513
- skyboxes: 1
124514
- });
124515
- return {
124516
- success: true,
124517
- skyboxId: result.skyboxId
124518
- };
124519
- } else {
124520
- return result;
124521
- }
124522
- } catch (err) {
124523
- const span = trace.getActiveSpan();
124524
- span?.recordException(err);
124525
- span?.setStatus({ code: SpanStatusCode.ERROR });
124526
- console.error(
124527
- "[AIController] Error handling generate skybox request:",
124528
- err
124529
- );
124530
- return {
124531
- success: false,
124532
- errorCode: "server_error",
124533
- errorMessage: "A server error occurred."
124534
- };
124535
- }
124536
- }
124537
- async getSkybox(request2) {
124538
- try {
124539
- if (!this._generateSkybox) {
124540
- return {
124541
- success: false,
124542
- errorCode: "not_supported",
124543
- errorMessage: "This operation is not supported."
124544
- };
124545
- }
124546
- if (!request2.userId) {
124547
- return {
124548
- success: false,
124549
- errorCode: "not_logged_in",
124550
- errorMessage: "The user must be logged in. Please provide a sessionKey or a recordKey."
124551
- };
124552
- }
124553
- if (!this._matchesSubscriptionTiers(
124554
- request2.userSubscriptionTier,
124555
- this._allowedGenerateSkyboxSubscriptionTiers
124556
- )) {
124557
- if (!request2.userSubscriptionTier) {
124558
- return {
124559
- success: false,
124560
- errorCode: "not_subscribed",
124561
- errorMessage: "The user must be subscribed in order to use this operation.",
124562
- allowedSubscriptionTiers: [
124563
- ...this._allowedGenerateSkyboxSubscriptionTiers
124564
- ]
124565
- };
124566
- } else {
124567
- return {
124568
- success: false,
124569
- errorCode: "invalid_subscription_tier",
124570
- errorMessage: "This operation is not available to the user at their current subscription tier.",
124571
- allowedSubscriptionTiers: [
124572
- ...this._allowedGenerateSkyboxSubscriptionTiers
124573
- ],
124574
- currentSubscriptionTier: request2.userSubscriptionTier
124575
- };
124576
- }
124577
- }
124578
- if (this._policyStore) {
124579
- const privacyFeatures = await this._policyStore.getUserPrivacyFeatures(
124580
- request2.userId
124581
- );
124582
- if (!privacyFeatures.allowAI) {
124583
- return {
124584
- success: false,
124585
- errorCode: "not_authorized",
124586
- errorMessage: "AI Access is not allowed"
124587
- };
124588
- }
124589
- }
124590
- const result = await this._generateSkybox.getSkybox(
124591
- request2.skyboxId
124592
- );
124593
- if (result.success === true) {
124594
- return {
124595
- success: true,
124596
- status: result.status,
124597
- fileUrl: result.fileUrl,
124598
- thumbnailUrl: result.thumbnailUrl
124599
- };
124600
- } else {
124601
- return result;
124602
- }
124603
- } catch (err) {
124604
- const span = trace.getActiveSpan();
124605
- span?.recordException(err);
124606
- span?.setStatus({ code: SpanStatusCode.ERROR });
124607
- console.error(
124608
- "[AIController] Error handling get skybox request:",
124609
- err
124610
- );
124611
- return {
124612
- success: false,
124613
- errorCode: "server_error",
124614
- errorMessage: "A server error occurred."
124615
- };
124616
- }
124617
- }
124618
- async generateImage(request2) {
124619
- try {
124620
- if (!this._imageProviders) {
124621
- return {
124622
- success: false,
124623
- errorCode: "not_supported",
124624
- errorMessage: "This operation is not supported."
124625
- };
124626
- }
124627
- if (!request2.userId) {
124628
- return {
124629
- success: false,
124630
- errorCode: "not_logged_in",
124631
- errorMessage: "The user must be logged in. Please provide a sessionKey or a recordKey."
124632
- };
124633
- }
124634
- if (!this._matchesSubscriptionTiers(
124635
- request2.userSubscriptionTier,
124636
- this._allowedImageSubscriptionTiers
124637
- )) {
124638
- if (!request2.userSubscriptionTier) {
124639
- return {
124640
- success: false,
124641
- errorCode: "not_subscribed",
124642
- errorMessage: "The user must be subscribed in order to use this operation.",
124643
- allowedSubscriptionTiers: [
124644
- ...this._allowedImageSubscriptionTiers
124645
- ]
124646
- };
124647
- } else {
124648
- return {
124649
- success: false,
124650
- errorCode: "invalid_subscription_tier",
124651
- errorMessage: "This operation is not available to the user at their current subscription tier.",
124652
- allowedSubscriptionTiers: [
124653
- ...this._allowedImageSubscriptionTiers
124654
- ],
124655
- currentSubscriptionTier: request2.userSubscriptionTier
124656
- };
124657
- }
124658
- }
124659
- const model = request2.model ?? this._imageOptions.defaultModel;
124660
- if (!this._allowedImageModels.has(model)) {
124661
- return {
124662
- success: false,
124663
- errorCode: "invalid_model",
124664
- errorMessage: `The given model is not allowed for images.`
124665
- };
124666
- }
124667
- const providerId = this._allowedImageModels.get(model);
124668
- const provider = this._imageProviders[providerId];
124669
- if (!provider) {
124670
- return {
124671
- success: false,
124672
- errorCode: "invalid_model",
124673
- errorMessage: `The given model is not allowed for images.`
124674
- };
124675
- }
124676
- const width = Math.min(
124677
- request2.width ?? this._imageOptions.defaultWidth,
124678
- this._imageOptions.maxWidth
124679
- );
124680
- const height = Math.min(
124681
- request2.height ?? this._imageOptions.defaultHeight,
124682
- this._imageOptions.maxHeight
124683
- );
124684
- const numberOfImages = Math.min(
124685
- request2.numberOfImages ?? 1,
124686
- this._imageOptions.maxImages
124687
- );
124688
- const totalPixels = Math.max(width, height) * numberOfImages;
124689
- const metrics3 = await this._metrics.getSubscriptionAiImageMetrics({
124690
- ownerId: request2.userId
124691
- });
124692
- const config2 = await this._config.getSubscriptionConfiguration();
124693
- const allowedFeatures = getSubscriptionFeatures(
124694
- config2,
124695
- metrics3.subscriptionStatus,
124696
- metrics3.subscriptionId,
124697
- "user"
124698
- );
124699
- if (!allowedFeatures.ai.images.allowed) {
124700
- return {
124701
- success: false,
124702
- errorCode: "not_authorized",
124703
- errorMessage: "The subscription does not permit AI Image features."
124704
- };
124705
- }
124706
- if (allowedFeatures.ai.images.maxSquarePixelsPerRequest > 0 && totalPixels > allowedFeatures.ai.images.maxSquarePixelsPerRequest) {
124707
- return {
124708
- success: false,
124709
- errorCode: "subscription_limit_reached",
124710
- errorMessage: `The request exceeds allowed subscription limits.`
124711
- };
124712
- }
124713
- if (allowedFeatures.ai.images.maxSquarePixelsPerPeriod > 0 && totalPixels + metrics3.totalSquarePixelsInCurrentPeriod > allowedFeatures.ai.images.maxSquarePixelsPerPeriod) {
124714
- return {
124715
- success: false,
124716
- errorCode: "subscription_limit_reached",
124717
- errorMessage: `The user has reached their limit for the current subscription period.`
124718
- };
124719
- }
124720
- if (this._policyStore) {
124721
- const privacyFeatures = await this._policyStore.getUserPrivacyFeatures(
124722
- request2.userId
124723
- );
124724
- if (!privacyFeatures.allowAI) {
124725
- return {
124726
- success: false,
124727
- errorCode: "not_authorized",
124728
- errorMessage: "AI Access is not allowed"
124729
- };
124730
- }
124731
- }
124732
- const result = await provider.generateImage({
124733
- model,
124734
- prompt: request2.prompt,
124735
- negativePrompt: request2.negativePrompt,
124736
- width,
124737
- height,
124738
- numberOfImages,
124739
- seed: request2.seed,
124740
- steps: Math.min(
124741
- request2.steps ?? 30,
124742
- this._imageOptions.maxSteps
124743
- ),
124744
- cfgScale: request2.cfgScale,
124745
- sampler: request2.sampler,
124746
- clipGuidancePreset: request2.clipGuidancePreset,
124747
- stylePreset: request2.stylePreset,
124748
- userId: request2.userId
124749
- });
124750
- if (!result.success) {
124751
- return result;
124752
- }
124753
- await this._metrics.recordImageMetrics({
124754
- userId: request2.userId,
124755
- createdAtMs: Date.now(),
124756
- squarePixels: totalPixels
124757
- });
124758
- return {
124759
- success: true,
124760
- images: result.images
124761
- };
124762
- } catch (err) {
124763
- const span = trace.getActiveSpan();
124764
- span?.recordException(err);
124765
- span?.setStatus({ code: SpanStatusCode.ERROR });
124766
- console.error(
124767
- "[AIController] Error handling generate image request:",
124768
- err
124769
- );
124770
- return {
124771
- success: false,
124772
- errorCode: "server_error",
124773
- errorMessage: "A server error occurred."
124774
- };
124775
- }
124776
- }
124777
- async getHumeAccessToken(request2) {
124778
- try {
124779
- if (!this._humeInterface) {
124780
- return {
124781
- success: false,
124782
- errorCode: "not_supported",
124783
- errorMessage: "This operation is not supported."
124784
- };
124785
- }
124786
- if (!request2.userId) {
124787
- return {
124788
- success: false,
124789
- errorCode: "not_logged_in",
124790
- errorMessage: "The user must be logged in. Please provide a sessionKey."
124791
- };
124792
- }
124793
- const recordName = request2.recordName ?? request2.userId;
124794
- const context = await this._policies.constructAuthorizationContext({
124795
- recordKeyOrRecordName: recordName,
124796
- userId: request2.userId
124797
- });
124798
- if (context.success === false) {
124799
- return context;
124800
- }
124801
- const authResult = await this._policies.authorizeSubjectUsingContext(
124802
- context.context,
124803
- {
124804
- resourceKind: "ai.hume",
124805
- action: "create",
124806
- markers: null,
124807
- subjectId: request2.userId,
124808
- subjectType: "user"
124809
- }
124810
- );
124811
- if (authResult.success === false) {
124812
- return authResult;
124813
- }
124814
- let metricsFilter = {};
124815
- if (context.context.recordStudioId) {
124816
- metricsFilter.studioId = context.context.recordStudioId;
124817
- } else {
124818
- metricsFilter.ownerId = context.context.recordOwnerId;
124819
- }
124820
- const metrics3 = await this._metrics.getSubscriptionRecordMetrics(
124821
- metricsFilter
124822
- );
124823
- const config2 = await this._config.getSubscriptionConfiguration();
124824
- const features = getHumeAiFeatures(
124825
- config2,
124826
- metrics3.subscriptionStatus,
124827
- metrics3.subscriptionId,
124828
- context.context.recordStudioId ? "studio" : "user"
124829
- );
124830
- if (!features.allowed) {
124831
- return {
124832
- success: false,
124833
- errorCode: "not_authorized",
124834
- errorMessage: "The subscription does not permit Hume AI features."
124835
- };
124836
- }
124837
- let humeConfig;
124838
- if (context.context.recordStudioId) {
124839
- humeConfig = await this._recordsStore.getStudioHumeConfig(
124840
- context.context.recordStudioId
124841
- );
124842
- }
124843
- humeConfig ??= this._humeConfig;
124844
- if (!humeConfig) {
124845
- if (context.context.recordStudioId) {
124846
- return {
124847
- success: false,
124848
- errorCode: "invalid_request",
124849
- errorMessage: "The studio does not have a Hume configuration."
124850
- };
124851
- }
124852
- return {
124853
- success: false,
124854
- errorCode: "not_authorized",
124855
- errorMessage: "The subscription does not permit Hume AI features."
124856
- };
124857
- }
124858
- if (this._policyStore) {
124859
- const privacyFeatures = await this._policyStore.getUserPrivacyFeatures(
124860
- request2.userId
124861
- );
124862
- if (!privacyFeatures.allowAI) {
124863
- return {
124864
- success: false,
124865
- errorCode: "not_authorized",
124866
- errorMessage: "AI Access is not allowed"
124867
- };
124868
- }
124869
- }
124870
- const result = await this._humeInterface.getAccessToken({
124871
- apiKey: humeConfig.apiKey,
124872
- secretKey: humeConfig.secretKey
124873
- });
124874
- if (result.success) {
124875
- return {
124876
- success: true,
124877
- accessToken: result.accessToken,
124878
- expiresIn: result.expiresIn,
124879
- issuedAt: result.issuedAt,
124880
- tokenType: result.tokenType
124881
- };
124882
- } else {
124883
- return result;
124884
- }
124885
- } catch (err) {
124886
- const span = trace.getActiveSpan();
124887
- span?.recordException(err);
124888
- span?.setStatus({ code: SpanStatusCode.ERROR });
124889
- console.error(
124890
- "[AIController] Error handling get hume access token request:",
124891
- err
124892
- );
124893
- return {
124894
- success: false,
124895
- errorCode: "server_error",
124896
- errorMessage: "A server error occurred."
124897
- };
124898
- }
124899
- }
124900
- async sloydGenerateModel(request2) {
124901
- try {
124902
- if (!this._sloydInterface) {
124903
- return {
124904
- success: false,
124905
- errorCode: "not_supported",
124906
- errorMessage: "This operation is not supported."
124907
- };
124908
- }
124909
- if (!request2.userId) {
124910
- return {
124911
- success: false,
124912
- errorCode: "not_logged_in",
124913
- errorMessage: "The user must be logged in. Please provide a sessionKey."
124914
- };
124915
- }
124916
- const context = await this._policies.constructAuthorizationContext({
124917
- recordKeyOrRecordName: request2.recordName,
124918
- userId: request2.userId
124919
- });
124920
- if (context.success === false) {
124921
- return context;
124922
- }
124923
- const authResult = await this._policies.authorizeSubjectUsingContext(
124924
- context.context,
124925
- {
124926
- resourceKind: "ai.sloyd",
124927
- action: "create",
124928
- markers: null,
124929
- subjectId: request2.userId,
124930
- subjectType: "user"
124931
- }
124932
- );
124933
- if (authResult.success === false) {
124934
- return authResult;
124935
- }
124936
- let metricsFilter = {};
124937
- if (context.context.recordStudioId) {
124938
- metricsFilter.studioId = context.context.recordStudioId;
124939
- } else {
124940
- metricsFilter.ownerId = context.context.recordOwnerId;
124941
- }
124942
- const metrics3 = await this._metrics.getSubscriptionAiSloydMetrics(
124943
- metricsFilter
124944
- );
124945
- const config2 = await this._config.getSubscriptionConfiguration();
124946
- const features = getSloydAiFeatures(
124947
- config2,
124948
- metrics3.subscriptionStatus,
124949
- metrics3.subscriptionId,
124950
- context.context.recordStudioId ? "studio" : "user"
124951
- );
124952
- if (!features.allowed) {
124953
- return {
124954
- success: false,
124955
- errorCode: "not_authorized",
124956
- errorMessage: "The subscription does not permit Sloyd AI features."
124957
- };
124958
- }
124959
- console.log(
124960
- `[AIController] [sloydGenerateModel] [maxModelsPerPeriod: ${features.maxModelsPerPeriod} totalModelsInCurrentPeriod: ${metrics3.totalModelsInCurrentPeriod}]`
124961
- );
124962
- if (typeof features.maxModelsPerPeriod === "number" && metrics3.totalModelsInCurrentPeriod >= features.maxModelsPerPeriod) {
124963
- return {
124964
- success: false,
124965
- errorCode: "subscription_limit_reached",
124966
- errorMessage: `The request exceeds allowed subscription limits.`
124967
- };
124968
- }
124969
- if (this._policyStore) {
124970
- const privacyFeatures = await this._policyStore.getUserPrivacyFeatures(
124971
- request2.userId
124972
- );
124973
- if (!privacyFeatures.allowAI) {
124974
- return {
124975
- success: false,
124976
- errorCode: "not_authorized",
124977
- errorMessage: "AI Access is not allowed"
124978
- };
124979
- }
124980
- }
124981
- const result = await (request2.baseModelId ? this._sloydInterface.editModel({
124982
- prompt: request2.prompt,
124983
- modelMimeType: request2.outputMimeType,
124984
- levelOfDetail: request2.levelOfDetail,
124985
- thumbnailPreviewExportType: request2.thumbnail?.type,
124986
- thumbnailPreviewSizeX: request2.thumbnail?.width,
124987
- thumbnailPreviewSizeY: request2.thumbnail?.height,
124988
- interactionId: request2.baseModelId
124989
- }) : this._sloydInterface.createModel({
124990
- prompt: request2.prompt,
124991
- modelMimeType: request2.outputMimeType,
124992
- levelOfDetail: request2.levelOfDetail,
124993
- thumbnailPreviewExportType: request2.thumbnail?.type,
124994
- thumbnailPreviewSizeX: request2.thumbnail?.width,
124995
- thumbnailPreviewSizeY: request2.thumbnail?.height
124996
- }));
124997
- if (result.success === false) {
124998
- return result;
124999
- }
125000
- const response = {
125001
- success: true,
125002
- modelId: result.interactionId,
125003
- mimeType: request2.outputMimeType,
125004
- modelData: typeof result.modelData === "string" ? result.modelData : (0, import_base64_js14.fromByteArray)(result.modelData),
125005
- thumbnailBase64: result.previewImage
125006
- };
125007
- if ("name" in result && typeof result.name === "string") {
125008
- response.name = result.name;
125009
- response.confidence = result.confidenceScore;
125010
- }
125011
- await this._metrics.recordSloydMetrics({
125012
- userId: context.context.recordOwnerId ?? void 0,
125013
- studioId: context.context.recordStudioId ?? void 0,
125014
- modelId: response.modelId,
125015
- confidence: response.confidence,
125016
- mimeType: response.mimeType,
125017
- modelData: response.modelData,
125018
- name: response.name,
125019
- thumbnailBase64: response.thumbnailBase64,
125020
- createdAtMs: Date.now(),
125021
- baseModelId: request2.baseModelId,
125022
- modelsCreated: 1
125023
- });
125024
- return response;
125025
- } catch (err) {
125026
- console.error(
125027
- "[AIController] Error handling sloyd create model request:",
125028
- err
125029
- );
125030
- return {
125031
- success: false,
125032
- errorCode: "server_error",
125033
- errorMessage: "A server error occurred."
125034
- };
125035
- }
125036
- }
125037
- async createOpenAIRealtimeSessionToken(request2) {
125038
- try {
125039
- if (!this._openAIRealtimeInterface) {
125040
- return {
125041
- success: false,
125042
- errorCode: "not_supported",
125043
- errorMessage: "This operation is not supported."
125044
- };
125045
- }
125046
- if (!request2.userId) {
125047
- return {
125048
- success: false,
125049
- errorCode: "not_logged_in",
125050
- errorMessage: "The user must be logged in. Please provide a sessionKey."
125051
- };
125052
- }
125053
- const context = await this._policies.constructAuthorizationContext({
125054
- recordKeyOrRecordName: request2.recordName,
125055
- userId: request2.userId
125056
- });
125057
- if (context.success === false) {
125058
- return context;
125059
- }
125060
- const authResult = await this._policies.authorizeSubjectUsingContext(
125061
- context.context,
125062
- {
125063
- resourceKind: "ai.openai.realtime",
125064
- action: "create",
125065
- markers: null,
125066
- subjectId: request2.userId,
125067
- subjectType: "user"
125068
- }
125069
- );
125070
- if (authResult.success === false) {
125071
- return authResult;
125072
- }
125073
- let metricsFilter = {};
125074
- if (context.context.recordStudioId) {
125075
- metricsFilter.studioId = context.context.recordStudioId;
125076
- } else {
125077
- metricsFilter.ownerId = context.context.recordOwnerId;
125078
- }
125079
- const metrics3 = await this._metrics.getSubscriptionAiOpenAIRealtimeMetrics(
125080
- metricsFilter
125081
- );
125082
- const config2 = await this._config.getSubscriptionConfiguration();
125083
- const features = getOpenAiFeatures(
125084
- config2,
125085
- metrics3.subscriptionStatus,
125086
- metrics3.subscriptionId,
125087
- context.context.recordStudioId ? "studio" : "user"
125088
- );
125089
- if (!features.realtime.allowed) {
125090
- return {
125091
- success: false,
125092
- errorCode: "not_authorized",
125093
- errorMessage: "The subscription does not permit OpenAI Realtime features."
125094
- };
125095
- }
125096
- if (typeof features.realtime.maxSessionsPerPeriod === "number" && metrics3.totalSessionsInCurrentPeriod >= features.realtime.maxSessionsPerPeriod) {
125097
- return {
125098
- success: false,
125099
- errorCode: "subscription_limit_reached",
125100
- errorMessage: `The request exceeds allowed subscription limits.`
125101
- };
125102
- }
125103
- if (typeof features.realtime.allowedModels !== "undefined" && !features.realtime.allowedModels.includes(request2.request.model)) {
125104
- return {
125105
- success: false,
125106
- errorCode: "subscription_limit_reached",
125107
- errorMessage: "The subscription doesn't support the given model."
125108
- };
125109
- }
125110
- const tokenRequest = {
125111
- ...request2.request,
125112
- maxResponseOutputTokens: features.realtime.maxResponseOutputTokens ?? request2.request.maxResponseOutputTokens ?? void 0
125113
- };
125114
- const result = await this._openAIRealtimeInterface.createRealtimeSessionToken(
125115
- tokenRequest
125116
- );
125117
- if (result.success === false) {
125118
- return result;
125119
- }
125120
- await this._metrics.recordOpenAIRealtimeMetrics({
125121
- userId: context.context.recordOwnerId ?? void 0,
125122
- studioId: context.context.recordStudioId ?? void 0,
125123
- sessionId: result.sessionId,
125124
- createdAtMs: Date.now(),
125125
- request: tokenRequest
125126
- });
125127
- return {
125128
- success: true,
125129
- sessionId: result.sessionId,
125130
- clientSecret: result.clientSecret
125131
- };
125132
- } catch (err) {
125133
- console.error(
125134
- "[AIController] Error handling createOpenAIRealtimeSessionToken request:",
125135
- err
125136
- );
125137
- return {
125138
- success: false,
125139
- errorCode: "server_error",
125140
- errorMessage: "A server error occurred."
125141
- };
125142
- }
125143
- }
125144
- _matchesSubscriptionTiers(tier, allowedTiers) {
125145
- return allowedTiers === true || allowedTiers.has(tier);
125146
- }
125147
- };
125148
- __decorateClass([
125149
- traced(TRACE_NAME12)
125150
- ], AIController.prototype, "chat", 1);
125151
- __decorateClass([
125152
- traced(TRACE_NAME12)
125153
- ], AIController.prototype, "chatStream", 1);
125154
- __decorateClass([
125155
- traced(TRACE_NAME12)
125156
- ], AIController.prototype, "generateSkybox", 1);
125157
- __decorateClass([
125158
- traced(TRACE_NAME12)
125159
- ], AIController.prototype, "getSkybox", 1);
125160
- __decorateClass([
125161
- traced(TRACE_NAME12)
125162
- ], AIController.prototype, "generateImage", 1);
125163
- __decorateClass([
125164
- traced(TRACE_NAME12)
125165
- ], AIController.prototype, "getHumeAccessToken", 1);
125166
- __decorateClass([
125167
- traced(TRACE_NAME12)
125168
- ], AIController.prototype, "sloydGenerateModel", 1);
125169
- __decorateClass([
125170
- traced(TRACE_NAME12)
125171
- ], AIController.prototype, "createOpenAIRealtimeSessionToken", 1);
125172
-
125173
124000
  // ../../node_modules/.pnpm/openai@4.89.0_zod@3.22.4/node_modules/openai/internal/qs/formats.mjs
125174
124001
  var default_format = "RFC3986";
125175
124002
  var formatters = {
@@ -131187,7 +130014,7 @@ OpenAI.Responses = Responses;
131187
130014
  var openai_default = OpenAI;
131188
130015
 
131189
130016
  // ../aux-records/OpenAIChatInterface.ts
131190
- var TRACE_NAME13 = "OpenAIChatInterface";
130017
+ var TRACE_NAME12 = "OpenAIChatInterface";
131191
130018
  var SPAN_OPTIONS = {
131192
130019
  kind: SpanKind.CLIENT,
131193
130020
  attributes: {
@@ -131328,14 +130155,14 @@ var OpenAIChatInterface = class {
131328
130155
  }
131329
130156
  };
131330
130157
  __decorateClass([
131331
- traced(TRACE_NAME13, SPAN_OPTIONS)
130158
+ traced(TRACE_NAME12, SPAN_OPTIONS)
131332
130159
  ], OpenAIChatInterface.prototype, "chat", 1);
131333
130160
  __decorateClass([
131334
- traced(TRACE_NAME13, SPAN_OPTIONS)
130161
+ traced(TRACE_NAME12, SPAN_OPTIONS)
131335
130162
  ], OpenAIChatInterface.prototype, "chatStream", 1);
131336
130163
 
131337
130164
  // ../aux-records/BlockadeLabsGenerateSkyboxInterface.ts
131338
- var TRACE_NAME14 = "BlockadeLabsGenerateSkyboxInterface";
130165
+ var TRACE_NAME13 = "BlockadeLabsGenerateSkyboxInterface";
131339
130166
  var SPAN_OPTIONS2 = {
131340
130167
  kind: SpanKind.CLIENT,
131341
130168
  attributes: {
@@ -131433,17 +130260,17 @@ var BlockadeLabsGenerateSkyboxInterface = class {
131433
130260
  }
131434
130261
  };
131435
130262
  __decorateClass([
131436
- traced(TRACE_NAME14, SPAN_OPTIONS2)
130263
+ traced(TRACE_NAME13, SPAN_OPTIONS2)
131437
130264
  ], BlockadeLabsGenerateSkyboxInterface.prototype, "generateSkybox", 1);
131438
130265
  __decorateClass([
131439
- traced(TRACE_NAME14, SPAN_OPTIONS2)
130266
+ traced(TRACE_NAME13, SPAN_OPTIONS2)
131440
130267
  ], BlockadeLabsGenerateSkyboxInterface.prototype, "getSkybox", 1);
131441
130268
  function isFinished(status) {
131442
130269
  return status.status === "complete" || status.status === "abort" || status.status === "error";
131443
130270
  }
131444
130271
 
131445
130272
  // ../aux-records/OpenAIImageInterface.ts
131446
- var TRACE_NAME15 = "OpenAIImageInterface";
130273
+ var TRACE_NAME14 = "OpenAIImageInterface";
131447
130274
  var SPAN_OPTIONS3 = {
131448
130275
  kind: SpanKind.CLIENT,
131449
130276
  attributes: {
@@ -131511,12 +130338,12 @@ var OpenAIImageInterface = class {
131511
130338
  }
131512
130339
  };
131513
130340
  __decorateClass([
131514
- traced(TRACE_NAME15, SPAN_OPTIONS3)
130341
+ traced(TRACE_NAME14, SPAN_OPTIONS3)
131515
130342
  ], OpenAIImageInterface.prototype, "generateImage", 1);
131516
130343
 
131517
130344
  // ../aux-records/StabilityAIImageInterface.ts
131518
130345
  var import_lodash23 = __toESM(require_lodash());
131519
- var TRACE_NAME16 = "StabilityAIImageInterface";
130346
+ var TRACE_NAME15 = "StabilityAIImageInterface";
131520
130347
  var StabilityAIImageInterface = class {
131521
130348
  constructor(options) {
131522
130349
  this._options = options;
@@ -131726,16 +130553,16 @@ var StabilityAIImageInterface = class {
131726
130553
  }
131727
130554
  };
131728
130555
  __decorateClass([
131729
- traced(TRACE_NAME16)
130556
+ traced(TRACE_NAME15)
131730
130557
  ], StabilityAIImageInterface.prototype, "generateImage", 1);
131731
130558
  __decorateClass([
131732
- traced(TRACE_NAME16)
130559
+ traced(TRACE_NAME15)
131733
130560
  ], StabilityAIImageInterface.prototype, "_stableImageUltra", 1);
131734
130561
  __decorateClass([
131735
- traced(TRACE_NAME16)
130562
+ traced(TRACE_NAME15)
131736
130563
  ], StabilityAIImageInterface.prototype, "_stableImageCore", 1);
131737
130564
  __decorateClass([
131738
- traced(TRACE_NAME16)
130565
+ traced(TRACE_NAME15)
131739
130566
  ], StabilityAIImageInterface.prototype, "_sd3", 1);
131740
130567
  function getStableImageAspectRatio(width, height) {
131741
130568
  if (!width || !height) {
@@ -132575,7 +131402,7 @@ var GoogleGenerativeAI = class {
132575
131402
  };
132576
131403
 
132577
131404
  // ../aux-records/GoogleAIChatInterface.ts
132578
- var TRACE_NAME17 = "GoogleAIChatInterface";
131405
+ var TRACE_NAME16 = "GoogleAIChatInterface";
132579
131406
  var SPAN_OPTIONS4 = {
132580
131407
  kind: SpanKind.CLIENT,
132581
131408
  attributes: {
@@ -132755,10 +131582,10 @@ var GoogleAIChatInterface = class {
132755
131582
  }
132756
131583
  };
132757
131584
  __decorateClass([
132758
- traced(TRACE_NAME17, SPAN_OPTIONS4)
131585
+ traced(TRACE_NAME16, SPAN_OPTIONS4)
132759
131586
  ], GoogleAIChatInterface.prototype, "chat", 1);
132760
131587
  __decorateClass([
132761
- traced(TRACE_NAME17, SPAN_OPTIONS4)
131588
+ traced(TRACE_NAME16, SPAN_OPTIONS4)
132762
131589
  ], GoogleAIChatInterface.prototype, "chatStream", 1);
132763
131590
  function mapMessage(message2) {
132764
131591
  return {
@@ -134929,7 +133756,7 @@ var { AnthropicError: AnthropicError2, APIError: APIError3, APIConnectionError:
134929
133756
  var sdk_default = Anthropic;
134930
133757
 
134931
133758
  // ../aux-records/AnthropicAIChatInterface.ts
134932
- var TRACE_NAME18 = "AnthropicAIChatInterface";
133759
+ var TRACE_NAME17 = "AnthropicAIChatInterface";
134933
133760
  var SPAN_OPTIONS5 = {
134934
133761
  kind: SpanKind.CLIENT,
134935
133762
  attributes: {
@@ -135049,10 +133876,10 @@ var AnthropicAIChatInterface = class {
135049
133876
  }
135050
133877
  };
135051
133878
  __decorateClass([
135052
- traced(TRACE_NAME18, SPAN_OPTIONS5)
133879
+ traced(TRACE_NAME17, SPAN_OPTIONS5)
135053
133880
  ], AnthropicAIChatInterface.prototype, "chat", 1);
135054
133881
  __decorateClass([
135055
- traced(TRACE_NAME18, SPAN_OPTIONS5)
133882
+ traced(TRACE_NAME17, SPAN_OPTIONS5)
135056
133883
  ], AnthropicAIChatInterface.prototype, "chatStream", 1);
135057
133884
  function mapMessage2(message2) {
135058
133885
  return {
@@ -135099,7 +133926,7 @@ function mapOutputContent(content) {
135099
133926
  }
135100
133927
 
135101
133928
  // ../aux-records/AIOpenAIRealtimeInterface.ts
135102
- var TRACE_NAME19 = "OpenAIRealtimeInterface";
133929
+ var TRACE_NAME18 = "OpenAIRealtimeInterface";
135103
133930
  var OpenAIRealtimeInterface = class {
135104
133931
  constructor(options) {
135105
133932
  this._options = options;
@@ -135169,7 +133996,7 @@ var OpenAIRealtimeInterface = class {
135169
133996
  }
135170
133997
  };
135171
133998
  __decorateClass([
135172
- traced(TRACE_NAME19)
133999
+ traced(TRACE_NAME18)
135173
134000
  ], OpenAIRealtimeInterface.prototype, "createRealtimeSessionToken", 1);
135174
134001
 
135175
134002
  // ../aux-records/MemoryStore.ts
@@ -135179,7 +134006,7 @@ var import_lodash24 = __toESM(require_lodash());
135179
134006
  var import_lodash25 = __toESM(require_lodash());
135180
134007
 
135181
134008
  // ../aux-records/CachingConfigStore.ts
135182
- var TRACE_NAME20 = "CachingConfigStore";
134009
+ var TRACE_NAME19 = "CachingConfigStore";
135183
134010
  var CachingConfigStore = class {
135184
134011
  /**
135185
134012
  * Creates a new CachingConfigStore.
@@ -135235,17 +134062,17 @@ var CachingConfigStore = class {
135235
134062
  }
135236
134063
  };
135237
134064
  __decorateClass([
135238
- traced(TRACE_NAME20)
134065
+ traced(TRACE_NAME19)
135239
134066
  ], CachingConfigStore.prototype, "getSubscriptionConfiguration", 1);
135240
134067
  __decorateClass([
135241
- traced(TRACE_NAME20)
134068
+ traced(TRACE_NAME19)
135242
134069
  ], CachingConfigStore.prototype, "getPrivoConfiguration", 1);
135243
134070
  __decorateClass([
135244
- traced(TRACE_NAME20)
134071
+ traced(TRACE_NAME19)
135245
134072
  ], CachingConfigStore.prototype, "getModerationConfig", 1);
135246
134073
 
135247
134074
  // ../aux-records/ModerationController.ts
135248
- var TRACE_NAME21 = "ModerationController";
134075
+ var TRACE_NAME20 = "ModerationController";
135249
134076
  var ModerationController = class {
135250
134077
  constructor(store, config2, messenger, jobProvider) {
135251
134078
  this._store = store;
@@ -135479,13 +134306,13 @@ var ModerationController = class {
135479
134306
  }
135480
134307
  };
135481
134308
  __decorateClass([
135482
- traced(TRACE_NAME21)
134309
+ traced(TRACE_NAME20)
135483
134310
  ], ModerationController.prototype, "reportInst", 1);
135484
134311
  __decorateClass([
135485
- traced(TRACE_NAME21)
134312
+ traced(TRACE_NAME20)
135486
134313
  ], ModerationController.prototype, "scheduleModerationScans", 1);
135487
134314
  __decorateClass([
135488
- traced(TRACE_NAME21)
134315
+ traced(TRACE_NAME20)
135489
134316
  ], ModerationController.prototype, "scanFile", 1);
135490
134317
 
135491
134318
  // ../aux-records/ModerationConfiguration.ts
@@ -136415,7 +135242,7 @@ var import_node_util8 = require("node:util");
136415
135242
  var generate2 = (0, import_node_util8.promisify)(import_node_crypto13.generateKeyPair);
136416
135243
 
136417
135244
  // ../aux-records/LoomController.ts
136418
- var TRACE_NAME22 = "LoomController";
135245
+ var TRACE_NAME21 = "LoomController";
136419
135246
  var LoomController = class {
136420
135247
  constructor(options) {
136421
135248
  this._policies = options.policies;
@@ -136500,7 +135327,7 @@ var LoomController = class {
136500
135327
  }
136501
135328
  };
136502
135329
  __decorateClass([
136503
- traced(TRACE_NAME22)
135330
+ traced(TRACE_NAME21)
136504
135331
  ], LoomController.prototype, "getToken", 1);
136505
135332
 
136506
135333
  // ../aux-records/PrivoConfiguration.ts
@@ -137139,12 +135966,12 @@ var WEBHOOK_STATE_SCHEMA = z.discriminatedUnion("type", [
137139
135966
  var import_hash6 = __toESM(require_hash());
137140
135967
 
137141
135968
  // ../crypto/utils.ts
137142
- var import_base64_js15 = __toESM(require_base64_js());
135969
+ var import_base64_js14 = __toESM(require_base64_js());
137143
135970
 
137144
135971
  // ../crypto/HashHelpers.ts
137145
135972
  var import_hash5 = __toESM(require_hash());
137146
135973
  var import_tweetnacl6 = __toESM(require_nacl_fast());
137147
- var import_base64_js16 = __toESM(require_base64_js());
135974
+ var import_base64_js15 = __toESM(require_base64_js());
137148
135975
  function getHash(obj) {
137149
135976
  const json = fast_json_stable_stringify_default(obj);
137150
135977
  let sha = (0, import_hash5.sha256)();
@@ -137154,10 +135981,10 @@ function getHash(obj) {
137154
135981
 
137155
135982
  // ../crypto/Signatures.ts
137156
135983
  var import_tweetnacl7 = __toESM(require_nacl_fast());
137157
- var import_base64_js17 = __toESM(require_base64_js());
135984
+ var import_base64_js16 = __toESM(require_base64_js());
137158
135985
 
137159
135986
  // ../aux-records/webhooks/WebhookRecordsController.ts
137160
- var TRACE_NAME23 = "WebhookRecordsController";
135987
+ var TRACE_NAME22 = "WebhookRecordsController";
137161
135988
  var WebhookRecordsController = class extends CrudRecordsController {
137162
135989
  constructor(config2) {
137163
135990
  super({
@@ -137657,16 +136484,16 @@ var WebhookRecordsController = class extends CrudRecordsController {
137657
136484
  }
137658
136485
  };
137659
136486
  __decorateClass([
137660
- traced(TRACE_NAME23)
136487
+ traced(TRACE_NAME22)
137661
136488
  ], WebhookRecordsController.prototype, "handleWebhook", 1);
137662
136489
  __decorateClass([
137663
- traced(TRACE_NAME23)
136490
+ traced(TRACE_NAME22)
137664
136491
  ], WebhookRecordsController.prototype, "listWebhookRuns", 1);
137665
136492
  __decorateClass([
137666
- traced(TRACE_NAME23)
136493
+ traced(TRACE_NAME22)
137667
136494
  ], WebhookRecordsController.prototype, "getWebhookRun", 1);
137668
136495
  __decorateClass([
137669
- traced(TRACE_NAME23)
136496
+ traced(TRACE_NAME22)
137670
136497
  ], WebhookRecordsController.prototype, "_checkSubscriptionMetrics", 1);
137671
136498
 
137672
136499
  // ../aux-records/webhooks/MemoryWebhookRecordsStore.ts
@@ -149898,7 +148725,7 @@ var config = new Conf({
149898
148725
  projectName: "casualos-cli"
149899
148726
  });
149900
148727
  var program2 = new Command();
149901
- program2.name("casualos").description("A CLI for CasualOS").version("v3.4.0-alpha.14204808910").option(
148728
+ program2.name("casualos").description("A CLI for CasualOS").version("v3.4.0").option(
149902
148729
  "-e, --endpoint <url>",
149903
148730
  "The endpoint to use for queries. Can be used to override the current endpoint."
149904
148731
  );