openloops 0.2.7 → 0.2.9

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 (44) hide show
  1. package/dist/db/index.d.ts +1 -0
  2. package/dist/db/index.js +22 -0
  3. package/dist/db/index.mjs +1 -0
  4. package/dist/db/indexes/agent-actions.d.ts +2 -0
  5. package/dist/db/indexes/agent-actions.js +30 -0
  6. package/dist/db/indexes/agent-actions.mjs +7 -0
  7. package/dist/db/indexes/agent-tasks.d.ts +2 -0
  8. package/dist/db/indexes/agent-tasks.js +30 -0
  9. package/dist/db/indexes/agent-tasks.mjs +7 -0
  10. package/dist/db/indexes/agent-traces.d.ts +2 -0
  11. package/dist/db/indexes/agent-traces.js +30 -0
  12. package/dist/db/indexes/agent-traces.mjs +7 -0
  13. package/dist/db/indexes/agentic-job-runs.d.ts +2 -0
  14. package/dist/db/indexes/agentic-job-runs.js +32 -0
  15. package/dist/db/indexes/agentic-job-runs.mjs +9 -0
  16. package/dist/db/indexes/agentic-jobs.d.ts +2 -0
  17. package/dist/db/indexes/agentic-jobs.js +31 -0
  18. package/dist/db/indexes/agentic-jobs.mjs +8 -0
  19. package/dist/db/indexes/chats.d.ts +2 -0
  20. package/dist/db/indexes/chats.js +30 -0
  21. package/dist/db/indexes/chats.mjs +7 -0
  22. package/dist/db/indexes/index.d.ts +3 -0
  23. package/dist/db/indexes/index.js +56 -0
  24. package/dist/db/indexes/index.mjs +32 -0
  25. package/dist/db/indexes/llm-calls.d.ts +2 -0
  26. package/dist/db/indexes/llm-calls.js +32 -0
  27. package/dist/db/indexes/llm-calls.mjs +9 -0
  28. package/dist/db/indexes/mcp-servers.d.ts +2 -0
  29. package/dist/db/indexes/mcp-servers.js +30 -0
  30. package/dist/db/indexes/mcp-servers.mjs +7 -0
  31. package/dist/db/indexes/workspace-items.d.ts +2 -0
  32. package/dist/db/indexes/workspace-items.js +30 -0
  33. package/dist/db/indexes/workspace-items.mjs +7 -0
  34. package/dist/harness/agent-state.d.ts +3 -0
  35. package/dist/harness/agent-state.js +6 -0
  36. package/dist/harness/agent-state.mjs +6 -0
  37. package/dist/harness/agent.d.ts +4 -0
  38. package/dist/harness/agent.js +17 -0
  39. package/dist/harness/agent.mjs +17 -0
  40. package/docs/agent.md +19 -0
  41. package/docs/agentic-jobs.md +1 -1
  42. package/docs/configuration.md +16 -0
  43. package/docs/integration-guide.md +2 -1
  44. package/package.json +5 -1
@@ -0,0 +1 @@
1
+ export * from './indexes';
@@ -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,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const agentActions: IndexDescription[];
@@ -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,7 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const agentActions = [
3
+ { key: { ownerId: 1, taskId: 1 } }
4
+ ];
5
+ export {
6
+ agentActions
7
+ };
@@ -0,0 +1,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const agentTasks: IndexDescription[];
@@ -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,7 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const agentTasks = [
3
+ { key: { ownerId: 1, chatId: 1 } }
4
+ ];
5
+ export {
6
+ agentTasks
7
+ };
@@ -0,0 +1,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const agentTraces: IndexDescription[];
@@ -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,7 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const agentTraces = [
3
+ { key: { ownerId: 1, chatId: 1 } }
4
+ ];
5
+ export {
6
+ agentTraces
7
+ };
@@ -0,0 +1,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const agenticJobRuns: IndexDescription[];
@@ -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,9 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const agenticJobRuns = [
3
+ { key: { jobId: 1, createdAt: -1 } },
4
+ { key: { ownerId: 1, createdAt: -1 } },
5
+ { key: { status: 1, createdAt: 1 } }
6
+ ];
7
+ export {
8
+ agenticJobRuns
9
+ };
@@ -0,0 +1,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const agenticJobs: IndexDescription[];
@@ -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,8 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const agenticJobs = [
3
+ { key: { enabled: 1, nextRunAt: 1 } },
4
+ { key: { ownerId: 1, createdAt: -1 } }
5
+ ];
6
+ export {
7
+ agenticJobs
8
+ };
@@ -0,0 +1,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const chats: IndexDescription[];
@@ -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,7 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const chats = [
3
+ { key: { ownerId: 1, updatedAt: -1 } }
4
+ ];
5
+ export {
6
+ chats
7
+ };
@@ -0,0 +1,3 @@
1
+ import { Db, IndexDescription } from 'mongodb';
2
+ export declare const indexes: Record<string, IndexDescription[]>;
3
+ export declare function ensureIndexes(db: Db): Promise<Record<string, string[]>>;
@@ -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,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const llmCalls: IndexDescription[];
@@ -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,9 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const llmCalls = [
3
+ { key: { ownerId: 1, createdAt: -1 } },
4
+ { key: { sessionId: 1 } },
5
+ { key: { answerId: 1 }, sparse: true }
6
+ ];
7
+ export {
8
+ llmCalls
9
+ };
@@ -0,0 +1,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const mcpServers: IndexDescription[];
@@ -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,7 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const mcpServers = [
3
+ { key: { ownerId: 1 } }
4
+ ];
5
+ export {
6
+ mcpServers
7
+ };
@@ -0,0 +1,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const workspaceItems: IndexDescription[];
@@ -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
+ });
@@ -0,0 +1,7 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const workspaceItems = [
3
+ { key: { ownerId: 1, chatId: 1 } }
4
+ ];
5
+ export {
6
+ workspaceItems
7
+ };
@@ -12,6 +12,7 @@ export interface AgentError {
12
12
  timestamp: Date;
13
13
  }
14
14
  type CurrentActivity = 'running' | 'stopped' | (string & {});
15
+ export type ActivityListener = (activity: string) => void;
15
16
  export interface AgentStateProps {
16
17
  status?: AgentStatus;
17
18
  language?: string;
@@ -27,10 +28,12 @@ export declare class AgentState {
27
28
  activeTaskId?: string | undefined;
28
29
  stopRequested?: boolean | undefined;
29
30
  currentActivity?: CurrentActivity | undefined;
31
+ private activityListener?;
30
32
  static fromJSON(props?: AgentStateProps): AgentState;
31
33
  constructor(status?: AgentStatus | undefined, language?: string | undefined, lastError?: AgentError | undefined, activeTaskId?: string | undefined, stopRequested?: boolean | undefined, currentActivity?: CurrentActivity | undefined);
32
34
  toJSON(): AgentStateProps;
33
35
  setLanguage(language?: string): void;
36
+ onActivityChange(listener?: ActivityListener): void;
34
37
  setCurrentActivity(currentActivity: CurrentActivity): void;
35
38
  setStatus(status: AgentStatus): void;
36
39
  setActiveTaskId(taskId?: string): void;
@@ -45,6 +45,7 @@ class AgentState {
45
45
  activeTaskId;
46
46
  stopRequested;
47
47
  currentActivity;
48
+ activityListener;
48
49
  static fromJSON(props = {}) {
49
50
  return new AgentState(
50
51
  props.status,
@@ -68,8 +69,13 @@ class AgentState {
68
69
  setLanguage(language) {
69
70
  if (language) this.language = language;
70
71
  }
72
+ onActivityChange(listener) {
73
+ this.activityListener = listener;
74
+ }
71
75
  setCurrentActivity(currentActivity) {
76
+ const changed = this.currentActivity !== currentActivity;
72
77
  this.currentActivity = currentActivity;
78
+ if (changed) this.activityListener?.(currentActivity);
73
79
  }
74
80
  setStatus(status) {
75
81
  this.status = status;
@@ -22,6 +22,7 @@ class AgentState {
22
22
  activeTaskId;
23
23
  stopRequested;
24
24
  currentActivity;
25
+ activityListener;
25
26
  static fromJSON(props = {}) {
26
27
  return new AgentState(
27
28
  props.status,
@@ -45,8 +46,13 @@ class AgentState {
45
46
  setLanguage(language) {
46
47
  if (language) this.language = language;
47
48
  }
49
+ onActivityChange(listener) {
50
+ this.activityListener = listener;
51
+ }
48
52
  setCurrentActivity(currentActivity) {
53
+ const changed = this.currentActivity !== currentActivity;
49
54
  this.currentActivity = currentActivity;
55
+ if (changed) this.activityListener?.(currentActivity);
50
56
  }
51
57
  setStatus(status) {
52
58
  this.status = status;
@@ -6,6 +6,7 @@ import { ChatSettingsProps } from '../services/chats/entities/chat-settings.enti
6
6
  import { Tool } from '../tools/tool.js';
7
7
  import { Guard } from '../guardrails/guard.js';
8
8
  import { AgentLoop } from './agent-loop';
9
+ import { ActivityListener } from './agent-state';
9
10
  export interface InternalMcp {
10
11
  name: string;
11
12
  url: string;
@@ -58,6 +59,7 @@ export declare class Agent {
58
59
  private mcpListingFailed;
59
60
  private _preHooks;
60
61
  private _postHooks;
62
+ private _activityListeners;
61
63
  private _guards;
62
64
  private awaitingConfirmation;
63
65
  private currentChat;
@@ -101,6 +103,8 @@ export declare class Agent {
101
103
  addTool(tool: Tool): void;
102
104
  addInternalMcp(mcp: InternalMcp): void;
103
105
  addHook(type: HookType, fn: Function): void;
106
+ onActivity(listener: ActivityListener): () => void;
107
+ private emitActivity;
104
108
  addGuard(guard: Guard): void;
105
109
  private preRunner;
106
110
  private runInputGuards;
@@ -76,6 +76,7 @@ class Agent {
76
76
  mcpListingFailed = false;
77
77
  _preHooks = [];
78
78
  _postHooks = [];
79
+ _activityListeners = [];
79
80
  _guards = [];
80
81
  awaitingConfirmation = false;
81
82
  currentChat;
@@ -206,6 +207,21 @@ class Agent {
206
207
  if (type === "pre_execution") this._preHooks.push(fn);
207
208
  if (type === "post_execution") this._postHooks.push(fn);
208
209
  }
210
+ onActivity(listener) {
211
+ this._activityListeners.push(listener);
212
+ return () => {
213
+ this._activityListeners = this._activityListeners.filter((candidate) => candidate !== listener);
214
+ };
215
+ }
216
+ emitActivity(activity) {
217
+ for (const listener of this._activityListeners) {
218
+ try {
219
+ listener(activity);
220
+ } catch (error) {
221
+ this.logger.warn({ error: error?.message ?? error }, "[AGENT] An activity listener failed");
222
+ }
223
+ }
224
+ }
209
225
  addGuard(guard) {
210
226
  this._guards.push(guard);
211
227
  }
@@ -227,6 +243,7 @@ class Agent {
227
243
  this.currentChat.switchLoop(this._loop.name);
228
244
  await this.loadTasks();
229
245
  }
246
+ this.currentChat.state?.onActivityChange((activity) => this.emitActivity(activity));
230
247
  const userMessage = this.currentChat.pushMessage({
231
248
  role: "user",
232
249
  content: this.currentMessage,
@@ -61,6 +61,7 @@ class Agent {
61
61
  mcpListingFailed = false;
62
62
  _preHooks = [];
63
63
  _postHooks = [];
64
+ _activityListeners = [];
64
65
  _guards = [];
65
66
  awaitingConfirmation = false;
66
67
  currentChat;
@@ -191,6 +192,21 @@ class Agent {
191
192
  if (type === "pre_execution") this._preHooks.push(fn);
192
193
  if (type === "post_execution") this._postHooks.push(fn);
193
194
  }
195
+ onActivity(listener) {
196
+ this._activityListeners.push(listener);
197
+ return () => {
198
+ this._activityListeners = this._activityListeners.filter((candidate) => candidate !== listener);
199
+ };
200
+ }
201
+ emitActivity(activity) {
202
+ for (const listener of this._activityListeners) {
203
+ try {
204
+ listener(activity);
205
+ } catch (error) {
206
+ this.logger.warn({ error: error?.message ?? error }, "[AGENT] An activity listener failed");
207
+ }
208
+ }
209
+ }
194
210
  addGuard(guard) {
195
211
  this._guards.push(guard);
196
212
  }
@@ -212,6 +228,7 @@ class Agent {
212
228
  this.currentChat.switchLoop(this._loop.name);
213
229
  await this.loadTasks();
214
230
  }
231
+ this.currentChat.state?.onActivityChange((activity) => this.emitActivity(activity));
215
232
  const userMessage = this.currentChat.pushMessage({
216
233
  role: "user",
217
234
  content: this.currentMessage,
package/docs/agent.md CHANGED
@@ -186,6 +186,25 @@ agent.addHook('post_execution', async () => {
186
186
 
187
187
  Hooks do not run when a guard blocks the message, because the loop never starts.
188
188
 
189
+ ## Activity updates
190
+
191
+ ```typescript
192
+ const stop = agent.onActivity(activity => {
193
+ stream.write(`event: activity\ndata: ${JSON.stringify({ activity })}\n\n`)
194
+ })
195
+
196
+ await agent.run({ input: { chatId, message }, currentUser })
197
+
198
+ stop()
199
+ ```
200
+
201
+ The listener receives every change of `state.currentActivity` while the run is in progress, such as `Starting...`, `Thinking...` or `Running search...`, and a last `stopped` when the run ends. It does not receive a value that repeats the previous one.
202
+
203
+ - The listener belongs to that `Agent` instance and to the chat of its current run. Nothing is shared between instances, so concurrent runs in the same process, even of different users, never hear each other. As always, create one `Agent` per run and do not share it between concurrent requests.
204
+ - It is called synchronously from the loop, so keep it fast and do not await inside it. An error thrown by a listener is logged and ignored, the run goes on and the other listeners still run.
205
+ - `onActivity` returns a function that removes the listener.
206
+ - Past values are not replayed. If a client connects late or loses its connection, read `state.currentActivity` of the chat, which is saved with it.
207
+
189
208
  ## Stopping a running turn
190
209
 
191
210
  ```typescript
@@ -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`. For the queries of the runner and of the lists, create these indexes:
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 }`.
@@ -79,6 +79,22 @@ The provider and the model go together: sending only one of them is an error. Th
79
79
 
80
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.
81
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
+
82
98
  ## What is recorded
83
99
 
84
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.7",
3
+ "version": "0.2.9",
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": [