openloops 0.4.2 → 0.4.5

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to `openloops` are written here, newest first. The format follows [Keep a Changelog](https://keepachangelog.com) and the versions follow [semantic versioning](https://semver.org), where a minor version can still break the API while the package is in beta. Changes before 0.4.0 are not recorded here, see the commits and the tags.
4
4
 
5
+ ## 0.4.4
6
+
7
+ ### Fixed
8
+
9
+ - Claude models on Amazon Bedrock failed with `temperature may only be set to 1 when thinking is enabled`. The temperature is no longer sent to them when thinking is on. The rules live in `src/clients/llm/sampling-rules.ts`, one entry per provider and model, so another model that rejects the temperature is one more line.
10
+ - A provider error saying the temperature "may only" take some value is now seen as a rejected sampling parameter, so the existing retry without temperature also covers it.
11
+
12
+ ## 0.4.3
13
+
14
+ ### Added
15
+
16
+ - `search` in `listChatsByUser`: returns only the chats with a message whose content contains the text, ignoring case. The text is escaped, so it is matched literally and not as a regular expression.
17
+ - `escapeRegex` helper in `src/common/helpers`, now used by `listChatsByUser`, `searchWorkspaceItems` and the tool ranking instead of three copies of the same escape.
18
+
5
19
  ## 0.4.2
6
20
 
7
21
  ### Added
@@ -39,6 +39,7 @@ var import_llmcalls = require("../../services/llmcalls/index.js");
39
39
  var import_pi_ai_adapter = require("./pi-ai-adapter");
40
40
  var import_number_setting = require("../../common/utils/number-setting.js");
41
41
  var import_model_resolution = require("./model-resolution");
42
+ var import_sampling_rules = require("./sampling-rules");
42
43
  var import_llm_error = require("./llm-error");
43
44
  const DEFAULT_TEMPERATURE = 0.7;
44
45
  const MAX_RETRIES = 4;
@@ -99,15 +100,16 @@ class LLMClient {
99
100
  const resolvedChoice = toolChoice === "required" ? REQUIRED_TOOL_CHOICE[model.api] : toolChoice;
100
101
  if (toolChoice === "required" && !resolvedChoice) throw new Error(`[LLM Client] forced tool choice is not supported for api ${model.api}`);
101
102
  const context = (0, import_pi_ai_adapter.toPiContext)({ messages, tools }, model);
103
+ const reasoning = thinking && thinking !== "off" ? thinking : void 0;
104
+ const ruleOmitsTemperature = (0, import_sampling_rules.omitsTemperature)(provider, modelName, Boolean(reasoning));
102
105
  const send = (omitTemperature) => this.withDeadline(thinking === "high" ? this.callTimeoutMs * HIGH_THINKING_TIMEOUT_FACTOR : this.callTimeoutMs, (signal) => {
103
- const options = { ...omitTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
104
- const reasoning = thinking && thinking !== "off" ? thinking : void 0;
106
+ const options = { ...omitTemperature || ruleOmitsTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
105
107
  return resolvedChoice || thinking ? models.completeSimple(model, context, { ...options, ...resolvedChoice ? { toolChoice: resolvedChoice } : {}, ...reasoning ? { reasoning } : {} }) : models.complete(model, context, options);
106
108
  });
107
109
  const raw = await this.traced(
108
110
  { origin, sessionId, answerId, currentUser, modelName, provider, temperature },
109
111
  context,
110
- () => this.withoutRejectedTemperature(`${provider}/${modelName}`, send)
112
+ () => this.withoutRejectedTemperature({ provider, model: modelName, thinking: Boolean(reasoning) }, send)
111
113
  );
112
114
  if (raw.stopReason === "error" || raw.stopReason === "aborted") {
113
115
  throw import_llm_error.LLMError.fromProvider(raw.errorMessage ?? `request ${raw.stopReason}`);
@@ -155,12 +157,13 @@ class LLMClient {
155
157
  clearTimeout(timer);
156
158
  }
157
159
  }
158
- async withoutRejectedTemperature(key, send) {
160
+ async withoutRejectedTemperature(call, send) {
161
+ const key = `${call.provider}/${call.model}`;
159
162
  const known = LLMClient.modelsWithoutTemperature.has(key);
160
163
  const response = await this.waitingOnRateLimit(() => send(known));
161
164
  if (known || response.stopReason !== "error" || !(0, import_llm_error.rejectsSamplingParameter)(response.errorMessage)) return response;
162
165
  LLMClient.modelsWithoutTemperature.add(key);
163
- this.logger.warn({ model: key, error: response.errorMessage }, "[LLM Service] The model rejected the temperature setting, retrying without it");
166
+ this.logger.warn({ ...call, error: response.errorMessage }, "[LLM Service] The model rejected the temperature setting, retrying without it. Add a rule in sampling-rules.ts to avoid this retry");
164
167
  return this.waitingOnRateLimit(() => send(true));
165
168
  }
166
169
  async waitingOnRateLimit(run) {
@@ -7,6 +7,7 @@ import { createLLMCall } from "../../services/llmcalls/index.js";
7
7
  import { toPiContext, fromPiMessage } from "./pi-ai-adapter";
8
8
  import { numberSetting } from "../../common/utils/number-setting.js";
9
9
  import { resolveModel, toModelRef } from "./model-resolution";
10
+ import { omitsTemperature } from "./sampling-rules";
10
11
  import { LLMError, retryDelayMs, rejectsSamplingParameter } from "./llm-error";
11
12
  const DEFAULT_TEMPERATURE = 0.7;
12
13
  const MAX_RETRIES = 4;
@@ -67,15 +68,16 @@ class LLMClient {
67
68
  const resolvedChoice = toolChoice === "required" ? REQUIRED_TOOL_CHOICE[model.api] : toolChoice;
68
69
  if (toolChoice === "required" && !resolvedChoice) throw new Error(`[LLM Client] forced tool choice is not supported for api ${model.api}`);
69
70
  const context = toPiContext({ messages, tools }, model);
71
+ const reasoning = thinking && thinking !== "off" ? thinking : void 0;
72
+ const ruleOmitsTemperature = omitsTemperature(provider, modelName, Boolean(reasoning));
70
73
  const send = (omitTemperature) => this.withDeadline(thinking === "high" ? this.callTimeoutMs * HIGH_THINKING_TIMEOUT_FACTOR : this.callTimeoutMs, (signal) => {
71
- const options = { ...omitTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
72
- const reasoning = thinking && thinking !== "off" ? thinking : void 0;
74
+ const options = { ...omitTemperature || ruleOmitsTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
73
75
  return resolvedChoice || thinking ? models.completeSimple(model, context, { ...options, ...resolvedChoice ? { toolChoice: resolvedChoice } : {}, ...reasoning ? { reasoning } : {} }) : models.complete(model, context, options);
74
76
  });
75
77
  const raw = await this.traced(
76
78
  { origin, sessionId, answerId, currentUser, modelName, provider, temperature },
77
79
  context,
78
- () => this.withoutRejectedTemperature(`${provider}/${modelName}`, send)
80
+ () => this.withoutRejectedTemperature({ provider, model: modelName, thinking: Boolean(reasoning) }, send)
79
81
  );
80
82
  if (raw.stopReason === "error" || raw.stopReason === "aborted") {
81
83
  throw LLMError.fromProvider(raw.errorMessage ?? `request ${raw.stopReason}`);
@@ -123,12 +125,13 @@ class LLMClient {
123
125
  clearTimeout(timer);
124
126
  }
125
127
  }
126
- async withoutRejectedTemperature(key, send) {
128
+ async withoutRejectedTemperature(call, send) {
129
+ const key = `${call.provider}/${call.model}`;
127
130
  const known = LLMClient.modelsWithoutTemperature.has(key);
128
131
  const response = await this.waitingOnRateLimit(() => send(known));
129
132
  if (known || response.stopReason !== "error" || !rejectsSamplingParameter(response.errorMessage)) return response;
130
133
  LLMClient.modelsWithoutTemperature.add(key);
131
- this.logger.warn({ model: key, error: response.errorMessage }, "[LLM Service] The model rejected the temperature setting, retrying without it");
134
+ this.logger.warn({ ...call, error: response.errorMessage }, "[LLM Service] The model rejected the temperature setting, retrying without it. Add a rule in sampling-rules.ts to avoid this retry");
132
135
  return this.waitingOnRateLimit(() => send(true));
133
136
  }
134
137
  async waitingOnRateLimit(run) {
@@ -41,7 +41,7 @@ const RETRYABLE = {
41
41
  };
42
42
  const MAX_WAIT_MS = 6e4;
43
43
  const SAMPLING_PARAMETER = /\b(?:temperature|top_p|top_k)\b/i;
44
- const REJECTION = /unsupported|not supported|does not support|doesn't support|deprecated|not allowed|only the default|no longer|removed|cannot be|can't be|must be|invalid/i;
44
+ const REJECTION = /unsupported|not supported|does not support|doesn't support|deprecated|not allowed|only the default|may only|no longer|removed|cannot be|can't be|must be|invalid/i;
45
45
  class LLMError extends Error {
46
46
  code;
47
47
  isRetryable;
@@ -17,7 +17,7 @@ const RETRYABLE = {
17
17
  };
18
18
  const MAX_WAIT_MS = 6e4;
19
19
  const SAMPLING_PARAMETER = /\b(?:temperature|top_p|top_k)\b/i;
20
- const REJECTION = /unsupported|not supported|does not support|doesn't support|deprecated|not allowed|only the default|no longer|removed|cannot be|can't be|must be|invalid/i;
20
+ const REJECTION = /unsupported|not supported|does not support|doesn't support|deprecated|not allowed|only the default|may only|no longer|removed|cannot be|can't be|must be|invalid/i;
21
21
  class LLMError extends Error {
22
22
  code;
23
23
  isRetryable;
@@ -0,0 +1 @@
1
+ export declare function omitsTemperature(provider: string, model: string, thinking: boolean): boolean;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var sampling_rules_exports = {};
20
+ __export(sampling_rules_exports, {
21
+ omitsTemperature: () => omitsTemperature
22
+ });
23
+ module.exports = __toCommonJS(sampling_rules_exports);
24
+ const NO_TEMPERATURE = [
25
+ { provider: "amazon-bedrock", model: /claude/, withThinking: true }
26
+ ];
27
+ function omitsTemperature(provider, model, thinking) {
28
+ return NO_TEMPERATURE.some((rule) => rule.provider === provider && (!rule.model || rule.model.test(model)) && (!rule.withThinking || thinking));
29
+ }
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ omitsTemperature
33
+ });
@@ -0,0 +1,10 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const NO_TEMPERATURE = [
3
+ { provider: "amazon-bedrock", model: /claude/, withThinking: true }
4
+ ];
5
+ function omitsTemperature(provider, model, thinking) {
6
+ return NO_TEMPERATURE.some((rule) => rule.provider === provider && (!rule.model || rule.model.test(model)) && (!rule.withThinking || thinking));
7
+ }
8
+ export {
9
+ omitsTemperature
10
+ };
@@ -0,0 +1 @@
1
+ export declare function escapeRegex(input?: string): string;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var escape_regex_exports = {};
20
+ __export(escape_regex_exports, {
21
+ escapeRegex: () => escapeRegex
22
+ });
23
+ module.exports = __toCommonJS(escape_regex_exports);
24
+ function escapeRegex(input = "") {
25
+ return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
26
+ }
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ escapeRegex
30
+ });
@@ -0,0 +1,7 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ function escapeRegex(input = "") {
3
+ return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4
+ }
5
+ export {
6
+ escapeRegex
7
+ };
@@ -1,2 +1,3 @@
1
+ export * from './escape-regex';
1
2
  export * from './extract-json-from-text';
2
3
  export * from './sanitize-string';
@@ -15,10 +15,12 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
16
  var helpers_exports = {};
17
17
  module.exports = __toCommonJS(helpers_exports);
18
+ __reExport(helpers_exports, require("./escape-regex"), module.exports);
18
19
  __reExport(helpers_exports, require("./extract-json-from-text"), module.exports);
19
20
  __reExport(helpers_exports, require("./sanitize-string"), module.exports);
20
21
  // Annotate the CommonJS export names for ESM import in node:
21
22
  0 && (module.exports = {
23
+ ...require("./escape-regex"),
22
24
  ...require("./extract-json-from-text"),
23
25
  ...require("./sanitize-string")
24
26
  });
@@ -1,2 +1,3 @@
1
+ export * from "./escape-regex";
1
2
  export * from "./extract-json-from-text";
2
3
  export * from "./sanitize-string";
@@ -21,9 +21,7 @@ __export(rank_tools_by_keywords_exports, {
21
21
  rankToolsByKeywords: () => rankToolsByKeywords
22
22
  });
23
23
  module.exports = __toCommonJS(rank_tools_by_keywords_exports);
24
- function escapeRegExp(text) {
25
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
26
- }
24
+ var import_helpers = require("../../common/helpers/index.js");
27
25
  function rankToolsByKeywords(keywords, tools, minScoreThreshold = 0.1) {
28
26
  const NAME_WEIGHT_MULTIPLIER = 2.5;
29
27
  const DESCRIPTION_WEIGHT_MULTIPLIER = 1;
@@ -36,7 +34,7 @@ function rankToolsByKeywords(keywords, tools, minScoreThreshold = 0.1) {
36
34
  for (const { keyword, weight } of keywords) {
37
35
  if (!keyword || weight <= 0) continue;
38
36
  const cleanKeyword = keyword.trim();
39
- const escapedKeyword = escapeRegExp(cleanKeyword);
37
+ const escapedKeyword = (0, import_helpers.escapeRegex)(cleanKeyword);
40
38
  const regex = new RegExp(`\\b${escapedKeyword}\\b`, "gi");
41
39
  const nameMatches = (normalizedName.match(regex) || []).length;
42
40
  const descMatches = (normalizedDescription.match(regex) || []).length;
@@ -1,7 +1,5 @@
1
1
  import "../../chunk-CF3WOMB3.mjs";
2
- function escapeRegExp(text) {
3
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4
- }
2
+ import { escapeRegex } from "../../common/helpers/index.js";
5
3
  function rankToolsByKeywords(keywords, tools, minScoreThreshold = 0.1) {
6
4
  const NAME_WEIGHT_MULTIPLIER = 2.5;
7
5
  const DESCRIPTION_WEIGHT_MULTIPLIER = 1;
@@ -14,7 +12,7 @@ function rankToolsByKeywords(keywords, tools, minScoreThreshold = 0.1) {
14
12
  for (const { keyword, weight } of keywords) {
15
13
  if (!keyword || weight <= 0) continue;
16
14
  const cleanKeyword = keyword.trim();
17
- const escapedKeyword = escapeRegExp(cleanKeyword);
15
+ const escapedKeyword = escapeRegex(cleanKeyword);
18
16
  const regex = new RegExp(`\\b${escapedKeyword}\\b`, "gi");
19
17
  const nameMatches = (normalizedName.match(regex) || []).length;
20
18
  const descMatches = (normalizedDescription.match(regex) || []).length;
@@ -5,6 +5,7 @@ import { ChatProps, ExecutionMode } from '../entities';
5
5
  export interface Params extends BaseUseCaseParams {
6
6
  filters?: Partial<ChatProps>;
7
7
  executionMode?: ExecutionMode;
8
+ search?: string;
8
9
  options?: QueryOptions;
9
10
  }
10
11
  export interface Output extends BaseUseCaseOutput {
@@ -32,6 +32,7 @@ __export(list_chats_by_user_use_case_exports, {
32
32
  module.exports = __toCommonJS(list_chats_by_user_use_case_exports);
33
33
  var import_tsyringe = require("tsyringe");
34
34
  var import_mongodb = require("mongodb");
35
+ var import_helpers = require("../../../common/helpers/index.js");
35
36
  var import_base = require("../../../common/base/base.use-case.js");
36
37
  var import_repositories2 = require("../repositories");
37
38
  let ListChatsByUserUseCase = class extends import_base.BaseUseCase {
@@ -41,13 +42,15 @@ let ListChatsByUserUseCase = class extends import_base.BaseUseCase {
41
42
  }
42
43
  chatRepository;
43
44
  async execute(params) {
44
- const { options, executionMode, currentUser } = params;
45
+ const { options, executionMode, search, currentUser } = params;
45
46
  const { page = 1, limit: pageSize = 10 } = options || {};
47
+ const term = (0, import_helpers.escapeRegex)(search?.trim());
46
48
  const result = await this.chatRepository?._.findManyPaginated({
47
49
  where: {
48
50
  ownerId: new import_mongodb.ObjectId(currentUser?.userId),
49
51
  ...executionMode === "autonomous" ? { "settings.executionMode": "autonomous" } : {},
50
- ...executionMode === "interactive" ? { "settings.executionMode": { $ne: "autonomous" } } : {}
52
+ ...executionMode === "interactive" ? { "settings.executionMode": { $ne: "autonomous" } } : {},
53
+ ...term ? { "messages.content": { $regex: term, $options: "i" } } : {}
51
54
  },
52
55
  options: { page, limit: pageSize, sortBy: { updatedAt: -1 } }
53
56
  });
@@ -4,6 +4,7 @@ import {
4
4
  } from "../../../chunk-CF3WOMB3.mjs";
5
5
  import { autoInjectable, inject } from "tsyringe";
6
6
  import { ObjectId } from "mongodb";
7
+ import { escapeRegex } from "../../../common/helpers/index.js";
7
8
  import { BaseUseCase } from "../../../common/base/base.use-case.js";
8
9
  import { ChatRepository } from "../repositories";
9
10
  let ListChatsByUserUseCase = class extends BaseUseCase {
@@ -13,13 +14,15 @@ let ListChatsByUserUseCase = class extends BaseUseCase {
13
14
  }
14
15
  chatRepository;
15
16
  async execute(params) {
16
- const { options, executionMode, currentUser } = params;
17
+ const { options, executionMode, search, currentUser } = params;
17
18
  const { page = 1, limit: pageSize = 10 } = options || {};
19
+ const term = escapeRegex(search?.trim());
18
20
  const result = await this.chatRepository?._.findManyPaginated({
19
21
  where: {
20
22
  ownerId: new ObjectId(currentUser?.userId),
21
23
  ...executionMode === "autonomous" ? { "settings.executionMode": "autonomous" } : {},
22
- ...executionMode === "interactive" ? { "settings.executionMode": { $ne: "autonomous" } } : {}
24
+ ...executionMode === "interactive" ? { "settings.executionMode": { $ne: "autonomous" } } : {},
25
+ ...term ? { "messages.content": { $regex: term, $options: "i" } } : {}
23
26
  },
24
27
  options: { page, limit: pageSize, sortBy: { updatedAt: -1 } }
25
28
  });
@@ -31,6 +31,7 @@ __export(search_workspace_items_use_case_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(search_workspace_items_use_case_exports);
33
33
  var import_tsyringe = require("tsyringe");
34
+ var import_helpers = require("../../../common/helpers/index.js");
34
35
  var import_base = require("../../../common/base/base.use-case.js");
35
36
  var import_base2 = require("../../../common/base/base.entity.js");
36
37
  var import_repositories2 = require("../repositories");
@@ -46,8 +47,7 @@ let SearchWorkspaceItemsUseCase = class extends import_base.BaseUseCase {
46
47
  if (!chatId) throw new Error("chatId is required");
47
48
  if (!query?.trim()) throw new Error("query is required");
48
49
  if (!currentUser) this.throwError403();
49
- const escaped = query.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
50
- const pattern = { $regex: escaped, $options: "i" };
50
+ const pattern = { $regex: (0, import_helpers.escapeRegex)(query.trim()), $options: "i" };
51
51
  const where = {
52
52
  ownerId: import_base2.BaseEntity.toObjectId(currentUser?.userId),
53
53
  chatId: import_base2.BaseEntity.toObjectId(chatId),
@@ -3,6 +3,7 @@ import {
3
3
  __decorateParam
4
4
  } from "../../../chunk-CF3WOMB3.mjs";
5
5
  import { autoInjectable, inject } from "tsyringe";
6
+ import { escapeRegex } from "../../../common/helpers/index.js";
6
7
  import { BaseUseCase } from "../../../common/base/base.use-case.js";
7
8
  import { BaseEntity } from "../../../common/base/base.entity.js";
8
9
  import { WorkspaceItemRepository } from "../repositories";
@@ -18,8 +19,7 @@ let SearchWorkspaceItemsUseCase = class extends BaseUseCase {
18
19
  if (!chatId) throw new Error("chatId is required");
19
20
  if (!query?.trim()) throw new Error("query is required");
20
21
  if (!currentUser) this.throwError403();
21
- const escaped = query.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
22
- const pattern = { $regex: escaped, $options: "i" };
22
+ const pattern = { $regex: escapeRegex(query.trim()), $options: "i" };
23
23
  const where = {
24
24
  ownerId: BaseEntity.toObjectId(currentUser?.userId),
25
25
  chatId: BaseEntity.toObjectId(chatId),
package/docs/chats.md CHANGED
@@ -53,6 +53,12 @@ const interactive = await listChatsByUser({ executionMode: 'interactive', curren
53
53
 
54
54
  `executionMode` is optional. `autonomous` returns the chats that were created by an autonomous run and `interactive` returns the rest, including the chats saved before the mode existed. Combine it with `state.status` to show the autonomous runs that need attention: `awaiting_user_confirmation` or `awaiting_user_input` mean the run is paused until the user answers in the chat, and `failed` means it failed.
55
55
 
56
+ ```typescript
57
+ const found = await listChatsByUser({ search: 'netflix', currentUser })
58
+ ```
59
+
60
+ `search` is optional. It returns the chats with at least one message whose content contains the text, ignoring case, in the same order and with the same pagination. The text is matched literally, so characters such as `(` or `.` have no special meaning. It reads the messages without an index, which is fine for the chats of one user. An empty text is ignored.
61
+
56
62
  ## Getting one chat
57
63
 
58
64
  ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openloops",
3
- "version": "0.4.2",
3
+ "version": "0.4.5",
4
4
  "description": "Open source harness for AI agents: a TypeScript runtime with persistence, tools, MCP trust, approvals and autonomous automations, where the loop is pluggable",
5
5
  "author": {
6
6
  "name": "Jose Barcos",