@resolveio/server-lib 22.0.14 → 22.0.16

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.
@@ -73,6 +73,7 @@ export declare function buildDisplayTable(docs: any[], options?: {
73
73
  includeGroupFromId?: boolean;
74
74
  }): AiAssistantDisplayTable;
75
75
  export declare function formatDisplayTableMarkdown(display: AiAssistantDisplayTable): string;
76
+ export declare function normalizeAssistantNowExprPlaceholders(value: any): any;
76
77
  export declare function rewriteMatchExpressionsToExpr(match: any): any;
77
78
  export declare function stripQueryFieldPathsDeep(query: any, fieldsToStrip: string[]): any;
78
79
  export declare function stripScopedFieldsFromPipeline(pipeline: any[], fieldsToStrip: string[]): any[];
@@ -114,6 +114,7 @@ exports.serializeMongoValue = serializeMongoValue;
114
114
  exports.flattenForTable = flattenForTable;
115
115
  exports.buildDisplayTable = buildDisplayTable;
116
116
  exports.formatDisplayTableMarkdown = formatDisplayTableMarkdown;
117
+ exports.normalizeAssistantNowExprPlaceholders = normalizeAssistantNowExprPlaceholders;
117
118
  exports.rewriteMatchExpressionsToExpr = rewriteMatchExpressionsToExpr;
118
119
  exports.stripQueryFieldPathsDeep = stripQueryFieldPathsDeep;
119
120
  exports.stripScopedFieldsFromPipeline = stripScopedFieldsFromPipeline;
@@ -1591,7 +1592,10 @@ function executeAiAssistantCodexRun(payload, context) {
1591
1592
  workingDirectory: workspaceRoot,
1592
1593
  sandboxMode: 'read-only',
1593
1594
  skipGitRepoCheck: true,
1594
- modelReasoningEffort: resolveCodexThoughtLevel(),
1595
+ modelReasoningEffort: resolveCodexThoughtLevel({
1596
+ message: message,
1597
+ attachmentText: attachmentData.promptText
1598
+ }),
1595
1599
  networkAccessEnabled: false,
1596
1600
  webSearchMode: 'disabled',
1597
1601
  webSearchEnabled: false,
@@ -6076,6 +6080,45 @@ function normalizeAssistantNowExprOperand(value) {
6076
6080
  },
6077
6081
  _a;
6078
6082
  }
6083
+ function normalizeAssistantDateArithmeticArgs(expression) {
6084
+ if (!expression || typeof expression !== 'object' || Array.isArray(expression)) {
6085
+ return expression;
6086
+ }
6087
+ if (expression instanceof Date || expression instanceof RegExp || isMongoObjectId(expression)) {
6088
+ return expression;
6089
+ }
6090
+ var normalizeOperatorArgs = function (operator) {
6091
+ if (!Object.prototype.hasOwnProperty.call(expression, operator)) {
6092
+ return;
6093
+ }
6094
+ var rawArgs = expression[operator];
6095
+ if (!rawArgs || typeof rawArgs !== 'object' || Array.isArray(rawArgs)) {
6096
+ return;
6097
+ }
6098
+ if (rawArgs instanceof Date || rawArgs instanceof RegExp || isMongoObjectId(rawArgs)) {
6099
+ return;
6100
+ }
6101
+ var nextArgs = __assign({}, rawArgs);
6102
+ if (!Object.prototype.hasOwnProperty.call(nextArgs, 'startDate')) {
6103
+ if (Object.prototype.hasOwnProperty.call(nextArgs, 'date')) {
6104
+ nextArgs.startDate = nextArgs.date;
6105
+ }
6106
+ else if (Object.prototype.hasOwnProperty.call(nextArgs, 'start')) {
6107
+ nextArgs.startDate = nextArgs.start;
6108
+ }
6109
+ }
6110
+ if (Object.prototype.hasOwnProperty.call(nextArgs, 'date')) {
6111
+ delete nextArgs.date;
6112
+ }
6113
+ if (Object.prototype.hasOwnProperty.call(nextArgs, 'start')) {
6114
+ delete nextArgs.start;
6115
+ }
6116
+ expression[operator] = nextArgs;
6117
+ };
6118
+ normalizeOperatorArgs('$dateAdd');
6119
+ normalizeOperatorArgs('$dateSubtract');
6120
+ return expression;
6121
+ }
6079
6122
  function normalizeAssistantNowExprPlaceholdersDeep(value) {
6080
6123
  if (Array.isArray(value)) {
6081
6124
  return value.map(function (entry) { return normalizeAssistantNowExprPlaceholdersDeep(entry); });
@@ -6093,7 +6136,10 @@ function normalizeAssistantNowExprPlaceholdersDeep(value) {
6093
6136
  Object.keys(value).forEach(function (key) {
6094
6137
  result[key] = normalizeAssistantNowExprPlaceholdersDeep(value[key]);
6095
6138
  });
6096
- return result;
6139
+ return normalizeAssistantDateArithmeticArgs(result);
6140
+ }
6141
+ function normalizeAssistantNowExprPlaceholders(value) {
6142
+ return normalizeAssistantNowExprPlaceholdersDeep(value);
6097
6143
  }
6098
6144
  function isMatchExpressionOperand(value) {
6099
6145
  if (typeof value === 'string') {
@@ -9210,7 +9256,62 @@ function resolveCodexFallbackModels(config, primaryModel) {
9210
9256
  }
9211
9257
  return models;
9212
9258
  }
9213
- function resolveCodexThoughtLevel() {
9259
+ var CODEX_THOUGHT_LEVEL_VALUES = ['minimal', 'low', 'medium', 'high', 'xhigh'];
9260
+ function normalizeCodexThoughtLevel(value) {
9261
+ var normalized = normalizeOptionalString(value).toLowerCase();
9262
+ if (!normalized) {
9263
+ return undefined;
9264
+ }
9265
+ if (CODEX_THOUGHT_LEVEL_VALUES.includes(normalized)) {
9266
+ return normalized;
9267
+ }
9268
+ return undefined;
9269
+ }
9270
+ function resolveConfiguredCodexAutoThoughtLevel(kind) {
9271
+ var config = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
9272
+ var levelKey = kind === 'simple' ? 'SIMPLE' : 'COMPLEX';
9273
+ var fallbackLevel = kind === 'simple' ? 'medium' : 'high';
9274
+ var configured = normalizeCodexThoughtLevel(config["AI_ASSISTANT_CODEX_".concat(levelKey, "_THOUGHT_LEVEL")]
9275
+ || process.env["AI_ASSISTANT_CODEX_".concat(levelKey, "_THOUGHT_LEVEL")]
9276
+ || config["AI_TERMINAL_CODEX_".concat(levelKey, "_THOUGHT_LEVEL")]
9277
+ || process.env["AI_TERMINAL_CODEX_".concat(levelKey, "_THOUGHT_LEVEL")]
9278
+ || config["AI_DASHBOARD_CODEX_".concat(levelKey, "_THOUGHT_LEVEL")]
9279
+ || process.env["AI_DASHBOARD_CODEX_".concat(levelKey, "_THOUGHT_LEVEL")]);
9280
+ return configured || fallbackLevel;
9281
+ }
9282
+ function resolveAutoCodexThoughtLevel(params) {
9283
+ var combinedText = [
9284
+ normalizeOptionalString(params === null || params === void 0 ? void 0 : params.message),
9285
+ normalizeOptionalString(params === null || params === void 0 ? void 0 : params.attachmentText)
9286
+ ].filter(Boolean).join('\n').toLowerCase();
9287
+ var simpleLevel = resolveConfiguredCodexAutoThoughtLevel('simple');
9288
+ var complexLevel = resolveConfiguredCodexAutoThoughtLevel('complex');
9289
+ if (!combinedText) {
9290
+ return simpleLevel;
9291
+ }
9292
+ var bugOrIssuePatterns = [
9293
+ /\bbug\b/i,
9294
+ /\bissue\b/i,
9295
+ /\berror\b/i,
9296
+ /\bexception\b/i,
9297
+ /\bfail(?:ed|ing|ure)?\b/i,
9298
+ /\bbroken\b/i,
9299
+ /\bnot\s+working\b/i,
9300
+ /\bdoesn['’]t\s+work\b/i,
9301
+ /\bwhy\s+is\s+this\s+happening\b/i,
9302
+ /\broot\s+cause\b/i,
9303
+ /\bregression\b/i,
9304
+ /\bdebug\b/i,
9305
+ /\binvestigat(?:e|ion)\b/i,
9306
+ /\bfix\b/i,
9307
+ /\bcrash(?:ed|ing)?\b/i,
9308
+ /\btimeout\b/i,
9309
+ /\bwrong\b/i,
9310
+ /\bincorrect\b/i
9311
+ ];
9312
+ return bugOrIssuePatterns.some(function (pattern) { return pattern.test(combinedText); }) ? complexLevel : simpleLevel;
9313
+ }
9314
+ function resolveCodexThoughtLevel(params) {
9214
9315
  var config = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
9215
9316
  var raw = normalizeOptionalString(config['AI_ASSISTANT_CODEX_THOUGHT_LEVEL']
9216
9317
  || process.env.AI_ASSISTANT_CODEX_THOUGHT_LEVEL
@@ -9219,10 +9320,14 @@ function resolveCodexThoughtLevel() {
9219
9320
  || config['AI_DASHBOARD_CODEX_THOUGHT_LEVEL']
9220
9321
  || process.env.AI_DASHBOARD_CODEX_THOUGHT_LEVEL);
9221
9322
  var normalized = (raw || '').trim().toLowerCase();
9222
- if (normalized === 'minimal' || normalized === 'low' || normalized === 'medium' || normalized === 'high' || normalized === 'xhigh') {
9223
- return normalized;
9323
+ var explicitLevel = normalizeCodexThoughtLevel(normalized);
9324
+ if (explicitLevel) {
9325
+ return explicitLevel;
9326
+ }
9327
+ if (normalized === 'auto' || !normalized) {
9328
+ return resolveAutoCodexThoughtLevel(params);
9224
9329
  }
9225
- return 'low';
9330
+ return 'medium';
9226
9331
  }
9227
9332
  function resolveCodexSettings(options) {
9228
9333
  var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};