openloops 0.2.6 → 0.2.8
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/README.md +3 -0
- package/dist/common/repositories/mongo-db.client.js +3 -0
- package/dist/common/repositories/mongo-db.client.mjs +3 -0
- package/dist/db/index.d.ts +1 -0
- package/dist/db/index.js +22 -0
- package/dist/db/index.mjs +1 -0
- package/dist/db/indexes/agent-actions.d.ts +2 -0
- package/dist/db/indexes/agent-actions.js +30 -0
- package/dist/db/indexes/agent-actions.mjs +7 -0
- package/dist/db/indexes/agent-tasks.d.ts +2 -0
- package/dist/db/indexes/agent-tasks.js +30 -0
- package/dist/db/indexes/agent-tasks.mjs +7 -0
- package/dist/db/indexes/agent-traces.d.ts +2 -0
- package/dist/db/indexes/agent-traces.js +30 -0
- package/dist/db/indexes/agent-traces.mjs +7 -0
- package/dist/db/indexes/agentic-job-runs.d.ts +2 -0
- package/dist/db/indexes/agentic-job-runs.js +32 -0
- package/dist/db/indexes/agentic-job-runs.mjs +9 -0
- package/dist/db/indexes/agentic-jobs.d.ts +2 -0
- package/dist/db/indexes/agentic-jobs.js +31 -0
- package/dist/db/indexes/agentic-jobs.mjs +8 -0
- package/dist/db/indexes/chats.d.ts +2 -0
- package/dist/db/indexes/chats.js +30 -0
- package/dist/db/indexes/chats.mjs +7 -0
- package/dist/db/indexes/index.d.ts +3 -0
- package/dist/db/indexes/index.js +56 -0
- package/dist/db/indexes/index.mjs +32 -0
- package/dist/db/indexes/llm-calls.d.ts +2 -0
- package/dist/db/indexes/llm-calls.js +32 -0
- package/dist/db/indexes/llm-calls.mjs +9 -0
- package/dist/db/indexes/mcp-servers.d.ts +2 -0
- package/dist/db/indexes/mcp-servers.js +30 -0
- package/dist/db/indexes/mcp-servers.mjs +7 -0
- package/dist/db/indexes/workspace-items.d.ts +2 -0
- package/dist/db/indexes/workspace-items.js +30 -0
- package/dist/db/indexes/workspace-items.mjs +7 -0
- package/docs/agentic-jobs.md +1 -1
- package/docs/configuration.md +17 -0
- package/docs/integration-guide.md +2 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -224,6 +224,9 @@ AGENTIC_JOBS_LEASE_MS=
|
|
|
224
224
|
LLM_CALL_TIMEOUT_MS=
|
|
225
225
|
MCP_TOOL_TIMEOUT_MS=
|
|
226
226
|
|
|
227
|
+
# Optional, most MongoDB connections per process (default 3)
|
|
228
|
+
OPENLOOPS_MONGO_MAX_POOL_SIZE=
|
|
229
|
+
|
|
227
230
|
# Optional, see "Observability" below
|
|
228
231
|
SENTRY_DSN=
|
|
229
232
|
LANGFUSE_SECRET_KEY=
|
|
@@ -33,6 +33,9 @@ class MongoClient {
|
|
|
33
33
|
constructor(uri, options) {
|
|
34
34
|
if (!uri) throw new Error("[Mongo Client]: uri parameter is required");
|
|
35
35
|
this.client = new import_mongodb.MongoClient(uri, {
|
|
36
|
+
maxPoolSize: Number(import_secret_manager.secretManager.get("OPENLOOPS_MONGO_MAX_POOL_SIZE")) || 3,
|
|
37
|
+
minPoolSize: 0,
|
|
38
|
+
maxIdleTimeMS: 1e4,
|
|
36
39
|
...options,
|
|
37
40
|
connectTimeoutMS: 5e3,
|
|
38
41
|
serverSelectionTimeoutMS: 5e3
|
|
@@ -12,6 +12,9 @@ class MongoClient {
|
|
|
12
12
|
constructor(uri, options) {
|
|
13
13
|
if (!uri) throw new Error("[Mongo Client]: uri parameter is required");
|
|
14
14
|
this.client = new BaseMongoCLient(uri, {
|
|
15
|
+
maxPoolSize: Number(secretManager.get("OPENLOOPS_MONGO_MAX_POOL_SIZE")) || 3,
|
|
16
|
+
minPoolSize: 0,
|
|
17
|
+
maxIdleTimeMS: 1e4,
|
|
15
18
|
...options,
|
|
16
19
|
connectTimeoutMS: 5e3,
|
|
17
20
|
serverSelectionTimeoutMS: 5e3
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './indexes';
|
package/dist/db/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var db_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(db_exports);
|
|
18
|
+
__reExport(db_exports, require("./indexes"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./indexes")
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./indexes";
|
|
@@ -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 agent_actions_exports = {};
|
|
20
|
+
__export(agent_actions_exports, {
|
|
21
|
+
agentActions: () => agentActions
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(agent_actions_exports);
|
|
24
|
+
const agentActions = [
|
|
25
|
+
{ key: { ownerId: 1, taskId: 1 } }
|
|
26
|
+
];
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
agentActions
|
|
30
|
+
});
|
|
@@ -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 agent_tasks_exports = {};
|
|
20
|
+
__export(agent_tasks_exports, {
|
|
21
|
+
agentTasks: () => agentTasks
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(agent_tasks_exports);
|
|
24
|
+
const agentTasks = [
|
|
25
|
+
{ key: { ownerId: 1, chatId: 1 } }
|
|
26
|
+
];
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
agentTasks
|
|
30
|
+
});
|
|
@@ -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 agent_traces_exports = {};
|
|
20
|
+
__export(agent_traces_exports, {
|
|
21
|
+
agentTraces: () => agentTraces
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(agent_traces_exports);
|
|
24
|
+
const agentTraces = [
|
|
25
|
+
{ key: { ownerId: 1, chatId: 1 } }
|
|
26
|
+
];
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
agentTraces
|
|
30
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
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 agentic_job_runs_exports = {};
|
|
20
|
+
__export(agentic_job_runs_exports, {
|
|
21
|
+
agenticJobRuns: () => agenticJobRuns
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(agentic_job_runs_exports);
|
|
24
|
+
const agenticJobRuns = [
|
|
25
|
+
{ key: { jobId: 1, createdAt: -1 } },
|
|
26
|
+
{ key: { ownerId: 1, createdAt: -1 } },
|
|
27
|
+
{ key: { status: 1, createdAt: 1 } }
|
|
28
|
+
];
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
agenticJobRuns
|
|
32
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
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 agentic_jobs_exports = {};
|
|
20
|
+
__export(agentic_jobs_exports, {
|
|
21
|
+
agenticJobs: () => agenticJobs
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(agentic_jobs_exports);
|
|
24
|
+
const agenticJobs = [
|
|
25
|
+
{ key: { enabled: 1, nextRunAt: 1 } },
|
|
26
|
+
{ key: { ownerId: 1, createdAt: -1 } }
|
|
27
|
+
];
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
agenticJobs
|
|
31
|
+
});
|
|
@@ -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 chats_exports = {};
|
|
20
|
+
__export(chats_exports, {
|
|
21
|
+
chats: () => chats
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(chats_exports);
|
|
24
|
+
const chats = [
|
|
25
|
+
{ key: { ownerId: 1, updatedAt: -1 } }
|
|
26
|
+
];
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
chats
|
|
30
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
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 indexes_exports = {};
|
|
20
|
+
__export(indexes_exports, {
|
|
21
|
+
ensureIndexes: () => ensureIndexes,
|
|
22
|
+
indexes: () => indexes
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(indexes_exports);
|
|
25
|
+
var import_llm_calls = require("./llm-calls");
|
|
26
|
+
var import_chats = require("./chats");
|
|
27
|
+
var import_agent_tasks = require("./agent-tasks");
|
|
28
|
+
var import_agent_actions = require("./agent-actions");
|
|
29
|
+
var import_agent_traces = require("./agent-traces");
|
|
30
|
+
var import_workspace_items = require("./workspace-items");
|
|
31
|
+
var import_mcp_servers = require("./mcp-servers");
|
|
32
|
+
var import_agentic_jobs = require("./agentic-jobs");
|
|
33
|
+
var import_agentic_job_runs = require("./agentic-job-runs");
|
|
34
|
+
const indexes = {
|
|
35
|
+
llm_calls: import_llm_calls.llmCalls,
|
|
36
|
+
chats: import_chats.chats,
|
|
37
|
+
agent_tasks: import_agent_tasks.agentTasks,
|
|
38
|
+
agent_actions: import_agent_actions.agentActions,
|
|
39
|
+
agent_traces: import_agent_traces.agentTraces,
|
|
40
|
+
workspace_items: import_workspace_items.workspaceItems,
|
|
41
|
+
mcp_servers: import_mcp_servers.mcpServers,
|
|
42
|
+
agentic_jobs: import_agentic_jobs.agenticJobs,
|
|
43
|
+
agentic_job_runs: import_agentic_job_runs.agenticJobRuns
|
|
44
|
+
};
|
|
45
|
+
async function ensureIndexes(db) {
|
|
46
|
+
const created = {};
|
|
47
|
+
for (const [name, definitions] of Object.entries(indexes)) {
|
|
48
|
+
created[name] = await db.collection(name).createIndexes(definitions);
|
|
49
|
+
}
|
|
50
|
+
return created;
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
ensureIndexes,
|
|
55
|
+
indexes
|
|
56
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import "../../chunk-CF3WOMB3.mjs";
|
|
2
|
+
import { llmCalls } from "./llm-calls";
|
|
3
|
+
import { chats } from "./chats";
|
|
4
|
+
import { agentTasks } from "./agent-tasks";
|
|
5
|
+
import { agentActions } from "./agent-actions";
|
|
6
|
+
import { agentTraces } from "./agent-traces";
|
|
7
|
+
import { workspaceItems } from "./workspace-items";
|
|
8
|
+
import { mcpServers } from "./mcp-servers";
|
|
9
|
+
import { agenticJobs } from "./agentic-jobs";
|
|
10
|
+
import { agenticJobRuns } from "./agentic-job-runs";
|
|
11
|
+
const indexes = {
|
|
12
|
+
llm_calls: llmCalls,
|
|
13
|
+
chats,
|
|
14
|
+
agent_tasks: agentTasks,
|
|
15
|
+
agent_actions: agentActions,
|
|
16
|
+
agent_traces: agentTraces,
|
|
17
|
+
workspace_items: workspaceItems,
|
|
18
|
+
mcp_servers: mcpServers,
|
|
19
|
+
agentic_jobs: agenticJobs,
|
|
20
|
+
agentic_job_runs: agenticJobRuns
|
|
21
|
+
};
|
|
22
|
+
async function ensureIndexes(db) {
|
|
23
|
+
const created = {};
|
|
24
|
+
for (const [name, definitions] of Object.entries(indexes)) {
|
|
25
|
+
created[name] = await db.collection(name).createIndexes(definitions);
|
|
26
|
+
}
|
|
27
|
+
return created;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
ensureIndexes,
|
|
31
|
+
indexes
|
|
32
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
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 llm_calls_exports = {};
|
|
20
|
+
__export(llm_calls_exports, {
|
|
21
|
+
llmCalls: () => llmCalls
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(llm_calls_exports);
|
|
24
|
+
const llmCalls = [
|
|
25
|
+
{ key: { ownerId: 1, createdAt: -1 } },
|
|
26
|
+
{ key: { sessionId: 1 } },
|
|
27
|
+
{ key: { answerId: 1 }, sparse: true }
|
|
28
|
+
];
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
llmCalls
|
|
32
|
+
});
|
|
@@ -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 mcp_servers_exports = {};
|
|
20
|
+
__export(mcp_servers_exports, {
|
|
21
|
+
mcpServers: () => mcpServers
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(mcp_servers_exports);
|
|
24
|
+
const mcpServers = [
|
|
25
|
+
{ key: { ownerId: 1 } }
|
|
26
|
+
];
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
mcpServers
|
|
30
|
+
});
|
|
@@ -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 workspace_items_exports = {};
|
|
20
|
+
__export(workspace_items_exports, {
|
|
21
|
+
workspaceItems: () => workspaceItems
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(workspace_items_exports);
|
|
24
|
+
const workspaceItems = [
|
|
25
|
+
{ key: { ownerId: 1, chatId: 1 } }
|
|
26
|
+
];
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
workspaceItems
|
|
30
|
+
});
|
package/docs/agentic-jobs.md
CHANGED
|
@@ -207,7 +207,7 @@ Someone answers a paused run in the chat, outside the runner. The runner checks
|
|
|
207
207
|
|
|
208
208
|
## Indexes
|
|
209
209
|
|
|
210
|
-
The collections are `agentic_jobs` and `agentic_job_runs`.
|
|
210
|
+
The collections are `agentic_jobs` and `agentic_job_runs`. `ensureIndexes` from `openloops/db` creates the indexes of the queries of the runner and of the lists (see [configuration](configuration.md#indexes)). They are:
|
|
211
211
|
|
|
212
212
|
- `agentic_jobs`: `{ enabled: 1, nextRunAt: 1 }` and `{ ownerId: 1, createdAt: -1 }`.
|
|
213
213
|
- `agentic_job_runs`: `{ jobId: 1, createdAt: -1 }`, `{ ownerId: 1, createdAt: -1 }` and `{ status: 1, createdAt: 1 }`.
|
package/docs/configuration.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
| --- | --- | --- |
|
|
7
7
|
| `OPENLOOPS_DB_URI` | yes | MongoDB connection string. |
|
|
8
8
|
| `OPENLOOPS_DB_NAME` | no | Database name. Defaults to `openloops`. |
|
|
9
|
+
| `OPENLOOPS_MONGO_MAX_POOL_SIZE` | no | Most connections each process keeps open to MongoDB. Defaults to `3`, which suits serverless functions, where every instance handles one request at a time. Raise it for a long-running server. |
|
|
9
10
|
| `SECRET_MANAGER_KEY` | yes | Key used to decrypt values that start with `ENC:`. The library throws when it loads without it. |
|
|
10
11
|
| `ANTHROPIC_API_KEY` | for the default model | API key of the default provider, `anthropic`. |
|
|
11
12
|
| `OPENAI_API_KEY`, `GEMINI_API_KEY` | for those providers | API keys of the other providers you choose per chat. |
|
|
@@ -78,6 +79,22 @@ The provider and the model go together: sending only one of them is an error. Th
|
|
|
78
79
|
|
|
79
80
|
The model call goes through a single client that retries, cancels and repeats an attempt that does not answer in time, waits when the provider asks to slow down, drops a temperature setting the model rejects and turns provider errors into messages that are safe to show to the user.
|
|
80
81
|
|
|
82
|
+
## Indexes
|
|
83
|
+
|
|
84
|
+
The collections of the package are queried by owner, chat, task and date, so they need indexes. Without them every query reads the whole collection. Create them once per deployment, and again after upgrading the package, with the helper that lists them all:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { MongoClient } from 'mongodb'
|
|
88
|
+
import { ensureIndexes } from 'openloops/db'
|
|
89
|
+
|
|
90
|
+
const client = new MongoClient(process.env.OPENLOOPS_DB_URI as string)
|
|
91
|
+
await client.connect()
|
|
92
|
+
console.log(await ensureIndexes(client.db(process.env.OPENLOOPS_DB_NAME || 'openloops')))
|
|
93
|
+
await client.close()
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
It covers `llm_calls`, `chats`, `agent_tasks`, `agent_actions`, `agent_traces`, `workspace_items`, `mcp_servers`, `agentic_jobs` and `agentic_job_runs`. It is safe to run again: an index that already exists is left as it is. Collections of your own application are not included.
|
|
97
|
+
|
|
81
98
|
## What is recorded
|
|
82
99
|
|
|
83
100
|
- Every LLM call, with its response, tokens and cost. See [usage](usage.md).
|
|
@@ -115,7 +115,7 @@ runner.start()
|
|
|
115
115
|
|
|
116
116
|
- It is safe to start the worker in several instances: a due job is taken by one of them.
|
|
117
117
|
- Stop it with `runner.stop()` when the process receives `SIGTERM`.
|
|
118
|
-
- Create the indexes listed in [agentic jobs](agentic-jobs.md#indexes).
|
|
118
|
+
- Create the indexes with `ensureIndexes` from `openloops/db`, see [configuration](configuration.md#indexes). The ones of the jobs are listed in [agentic jobs](agentic-jobs.md#indexes).
|
|
119
119
|
- A job that needs the user (a destructive tool, an unapproved server, a question) pauses its run, and the user answers in the chat of that run. Show those runs, which you can list with `listAgenticJobRunsByUser({ status: 'paused' })`.
|
|
120
120
|
|
|
121
121
|
## Security checklist
|
|
@@ -136,3 +136,4 @@ runner.start()
|
|
|
136
136
|
- Treating `error` as an exception that is thrown. It is returned.
|
|
137
137
|
- Forgetting that a run in `awaiting_user_confirmation` is waiting for the next message of the user, and that the next message is the answer.
|
|
138
138
|
- Starting the scheduled jobs worker without creating its indexes.
|
|
139
|
+
- Running the package on a real database without calling `ensureIndexes`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openloops",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Open source harness for AI agents: a TypeScript runtime with persistence, tools, MCP trust, approvals and autonomous jobs, where the loop is pluggable",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jose Barcos",
|
|
@@ -70,6 +70,10 @@
|
|
|
70
70
|
"./users": {
|
|
71
71
|
"types": "./dist/services/users/index.d.ts",
|
|
72
72
|
"default": "./dist/services/users/index.js"
|
|
73
|
+
},
|
|
74
|
+
"./db": {
|
|
75
|
+
"types": "./dist/db/index.d.ts",
|
|
76
|
+
"default": "./dist/db/index.js"
|
|
73
77
|
}
|
|
74
78
|
},
|
|
75
79
|
"files": [
|