openloops 0.7.6 → 0.8.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.
- package/CHANGELOG.md +53 -11
- package/dist/clients/llm/llm-error.d.ts +1 -1
- package/dist/clients/llm/llm-error.js +12 -0
- package/dist/clients/llm/llm-error.mjs +12 -0
- package/dist/common/helpers/index.d.ts +1 -0
- package/dist/common/helpers/index.js +3 -1
- package/dist/common/helpers/index.mjs +1 -0
- package/dist/common/helpers/sanitize-string.js +5 -15
- package/dist/common/helpers/sanitize-string.mjs +5 -5
- package/dist/common/helpers/strip-blocks.d.ts +1 -0
- package/dist/common/helpers/strip-blocks.js +45 -0
- package/dist/common/helpers/strip-blocks.mjs +21 -0
- package/dist/common/logger/pino.js +12 -3
- package/dist/common/logger/pino.mjs +12 -3
- package/dist/db/index.d.ts +1 -0
- package/dist/db/index.js +3 -1
- package/dist/db/index.mjs +1 -0
- package/dist/db/migrations/chat-titles.d.ts +10 -0
- package/dist/db/migrations/chat-titles.js +55 -0
- package/dist/db/migrations/chat-titles.mjs +31 -0
- package/dist/harness/agent-state.d.ts +0 -1
- package/dist/loops/agi/loop.js +4 -2
- package/dist/loops/agi/loop.mjs +4 -2
- package/dist/loops/shared/skills/fast-responder.d.ts +1 -0
- package/dist/loops/shared/skills/fast-responder.js +4 -2
- package/dist/loops/shared/skills/fast-responder.mjs +4 -2
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts +2 -1
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.js +2 -2
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +2 -2
- package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +1 -0
- package/dist/services/automations/use-cases/sync-automation-run.use-case.js +6 -2
- package/dist/services/automations/use-cases/sync-automation-run.use-case.mjs +5 -2
- package/dist/services/chats/entities/chat.entity.d.ts +3 -0
- package/dist/services/chats/entities/chat.entity.js +8 -0
- package/dist/services/chats/entities/chat.entity.mjs +8 -0
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.js +1 -5
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +1 -5
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.d.ts +2 -1
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.js +3 -2
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +3 -2
- package/dist/services/chats/utils/title.d.ts +2 -0
- package/dist/services/chats/utils/title.js +35 -0
- package/dist/services/chats/utils/title.mjs +10 -0
- package/dist/tools/core/fetch-url/html-to-text.js +3 -20
- package/dist/tools/core/fetch-url/html-to-text.mjs +3 -20
- package/docs/README.md +1 -1
- package/docs/agent.md +18 -3
- package/docs/automations.md +3 -3
- package/docs/chats.md +41 -8
- package/docs/configuration.md +1 -1
- package/docs/integration-guide.md +2 -2
- package/docs/llms.txt +1 -1
- package/docs/loops.md +1 -1
- package/examples/chats/search-chats.ts +30 -0
- package/package.json +7 -8
- package/dist/services/chats/utils/deprecated-activity.d.ts +0 -1
- package/dist/services/chats/utils/deprecated-activity.js +0 -60
- package/dist/services/chats/utils/deprecated-activity.mjs +0 -36
package/docs/llms.txt
CHANGED
|
@@ -14,7 +14,7 @@ Start with the integration guide, then read only the pages you need. All pages a
|
|
|
14
14
|
|
|
15
15
|
- [The Agent](agent.md): options, running a turn, statuses, confirmations, autonomous mode
|
|
16
16
|
- [Configuration](configuration.md): environment variables, default model, timeouts
|
|
17
|
-
- [Chats](chats.md): the chat record, message source, listing and deleting
|
|
17
|
+
- [Chats](chats.md): the chat record, its title, message source, listing, searching and deleting, and the migration to 0.8.0
|
|
18
18
|
|
|
19
19
|
## Shape the agent
|
|
20
20
|
|
package/docs/loops.md
CHANGED
|
@@ -13,7 +13,7 @@ import { AgiLoop } from 'openloops/loops'
|
|
|
13
13
|
|
|
14
14
|
| Node | What it does |
|
|
15
15
|
| --- | --- |
|
|
16
|
-
| `fast_responder` | Initial node. Answers directly when no tools or memory are needed, and when it cannot, says in one sentence what the agent will do. It is skipped in an autonomous run. |
|
|
16
|
+
| `fast_responder` | Initial node. Answers directly when no tools or memory are needed, and when it cannot, says in one sentence what the agent will do. It also writes the [title](chats.md#the-title) of a chat that has none. It is skipped in an autonomous run. |
|
|
17
17
|
| `reasoning_engine` | Reads the situation or the results of the last actions, rewrites its working state, decides the next actions, reports the language of the conversation and says in one sentence what is happening until its next answer. |
|
|
18
18
|
| `action_engine` | Runs the actions the reasoning engine asked for, asks the user for confirmation when needed, delivers the final answer. |
|
|
19
19
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Logger } from 'openloops/common'
|
|
2
|
+
import { CurrentUser } from 'openloops/base'
|
|
3
|
+
import { getChatById, listChatsByUser } from 'openloops/chats'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Searches the history of the user. `search` looks in the title and in the messages, and `select` returns only what a list needs,
|
|
7
|
+
* so the messages do not travel. Once the user picks a chat, it is loaded complete.
|
|
8
|
+
*/
|
|
9
|
+
async function searchChats () {
|
|
10
|
+
const logger = new Logger()
|
|
11
|
+
const currentUser = await CurrentUser.asyncFromDB('6ab56894eb20887d1ef7942c')
|
|
12
|
+
|
|
13
|
+
const history = await listChatsByUser({
|
|
14
|
+
search: 'netflix',
|
|
15
|
+
select: { title: 1, updatedAt: 1 },
|
|
16
|
+
options: { page: 1, limit: 10 },
|
|
17
|
+
currentUser,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
logger.info(history.items.map(chat => ({ id: chat._id, title: chat.title ?? 'Untitled', updatedAt: chat.updatedAt })), '[Demo] History')
|
|
21
|
+
|
|
22
|
+
const picked = history.items[0]?._id
|
|
23
|
+
if (!picked) return
|
|
24
|
+
|
|
25
|
+
const chat = await getChatById({ id: String(picked), currentUser })
|
|
26
|
+
|
|
27
|
+
logger.info(chat?.messages, '[Demo] Messages')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
searchChats()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openloops",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
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",
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
"test:watch": "jest --watch",
|
|
97
97
|
"test:coverage": "jest --coverage",
|
|
98
98
|
"migrate:automations": "ts-node scripts/migrate-automations.ts",
|
|
99
|
+
"migrate:chat-titles": "ts-node scripts/migrate-chat-titles.ts",
|
|
99
100
|
"eval": "ts-node --project evals/tsconfig.json evals/run.ts",
|
|
100
101
|
"eval:models": "ts-node --project evals/tsconfig.json evals/run.ts models",
|
|
101
102
|
"eval:skills": "ts-node --project evals/tsconfig.json evals/run.ts skills",
|
|
@@ -106,9 +107,9 @@
|
|
|
106
107
|
"eval:list": "ts-node --project evals/tsconfig.json evals/run.ts list"
|
|
107
108
|
},
|
|
108
109
|
"dependencies": {
|
|
109
|
-
"@earendil-works/pi-ai": "^1.
|
|
110
|
+
"@earendil-works/pi-ai": "^1.5.0",
|
|
110
111
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
111
|
-
"@sentry/node": "^11.
|
|
112
|
+
"@sentry/node": "^11.11.0",
|
|
112
113
|
"bcryptjs": "^3.0.3",
|
|
113
114
|
"croner": "^11.0.0",
|
|
114
115
|
"cryptr": "^6.4.0",
|
|
@@ -117,17 +118,15 @@
|
|
|
117
118
|
"jsonwebtoken": "^9.0.3",
|
|
118
119
|
"langfuse": "^3.39.2",
|
|
119
120
|
"mongodb": "^7.8.0",
|
|
120
|
-
"pino": "^10.4.0"
|
|
121
|
-
"pino-pretty": "^13.2.0",
|
|
122
|
-
"sanitize-html": "^2.18.1"
|
|
121
|
+
"pino": "^10.4.0"
|
|
123
122
|
},
|
|
124
123
|
"devDependencies": {
|
|
125
124
|
"@types/jest": "^30.0.0",
|
|
126
125
|
"@types/node": "^26.6.6",
|
|
127
|
-
"@types/sanitize-html": "^2.16.2",
|
|
128
126
|
"jest": "^30.5.2",
|
|
127
|
+
"pino-pretty": "^13.2.0",
|
|
129
128
|
"ts-jest": "^29.4.15",
|
|
130
|
-
"tsc-alias": "^1.9.
|
|
129
|
+
"tsc-alias": "^1.9.10",
|
|
131
130
|
"tsconfig-paths": "^4.2.0",
|
|
132
131
|
"tsup": "^9.0.0",
|
|
133
132
|
"typescript": "^6.0.3"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function deprecatedActivity(chatId: string, now?: number): string;
|
|
@@ -1,60 +0,0 @@
|
|
|
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 deprecated_activity_exports = {};
|
|
20
|
-
__export(deprecated_activity_exports, {
|
|
21
|
-
deprecatedActivity: () => deprecatedActivity
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(deprecated_activity_exports);
|
|
24
|
-
const WORDS = [
|
|
25
|
-
"Thinking",
|
|
26
|
-
"Computing",
|
|
27
|
-
"Pondering",
|
|
28
|
-
"Analyzing",
|
|
29
|
-
"Crunching",
|
|
30
|
-
"Reviewing",
|
|
31
|
-
"Checking",
|
|
32
|
-
"Working on it",
|
|
33
|
-
"Reasoning",
|
|
34
|
-
"Digging in",
|
|
35
|
-
"Gathering",
|
|
36
|
-
"Sorting",
|
|
37
|
-
"Calculating",
|
|
38
|
-
"Connecting the dots",
|
|
39
|
-
"Exploring",
|
|
40
|
-
"Piecing it together",
|
|
41
|
-
"Figuring it out",
|
|
42
|
-
"Untangling",
|
|
43
|
-
"Weighing options",
|
|
44
|
-
"Cooking"
|
|
45
|
-
];
|
|
46
|
-
const WINDOW_IN_MS = 4e3;
|
|
47
|
-
function hash(text) {
|
|
48
|
-
let value = 5381;
|
|
49
|
-
for (const character of text) value = (value << 5) + value + character.charCodeAt(0) >>> 0;
|
|
50
|
-
return value;
|
|
51
|
-
}
|
|
52
|
-
function deprecatedActivity(chatId, now = Date.now()) {
|
|
53
|
-
const window = Math.floor(now / WINDOW_IN_MS);
|
|
54
|
-
const index = hash(`${chatId}:${window}`) % WORDS.length;
|
|
55
|
-
return `${WORDS[index]}...`;
|
|
56
|
-
}
|
|
57
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
-
0 && (module.exports = {
|
|
59
|
-
deprecatedActivity
|
|
60
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const WORDS = [
|
|
2
|
-
"Thinking",
|
|
3
|
-
"Computing",
|
|
4
|
-
"Pondering",
|
|
5
|
-
"Analyzing",
|
|
6
|
-
"Crunching",
|
|
7
|
-
"Reviewing",
|
|
8
|
-
"Checking",
|
|
9
|
-
"Working on it",
|
|
10
|
-
"Reasoning",
|
|
11
|
-
"Digging in",
|
|
12
|
-
"Gathering",
|
|
13
|
-
"Sorting",
|
|
14
|
-
"Calculating",
|
|
15
|
-
"Connecting the dots",
|
|
16
|
-
"Exploring",
|
|
17
|
-
"Piecing it together",
|
|
18
|
-
"Figuring it out",
|
|
19
|
-
"Untangling",
|
|
20
|
-
"Weighing options",
|
|
21
|
-
"Cooking"
|
|
22
|
-
];
|
|
23
|
-
const WINDOW_IN_MS = 4e3;
|
|
24
|
-
function hash(text) {
|
|
25
|
-
let value = 5381;
|
|
26
|
-
for (const character of text) value = (value << 5) + value + character.charCodeAt(0) >>> 0;
|
|
27
|
-
return value;
|
|
28
|
-
}
|
|
29
|
-
function deprecatedActivity(chatId, now = Date.now()) {
|
|
30
|
-
const window = Math.floor(now / WINDOW_IN_MS);
|
|
31
|
-
const index = hash(`${chatId}:${window}`) % WORDS.length;
|
|
32
|
-
return `${WORDS[index]}...`;
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
deprecatedActivity
|
|
36
|
-
};
|