openloops 0.1.29 → 0.1.31
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 +1 -1
- package/dist/agent/agent-loop.d.ts +3 -1
- package/dist/agent/agent.d.ts +2 -7
- package/dist/agent/agent.js +3 -0
- package/dist/agent/agent.mjs +3 -0
- package/dist/clients/llm-client.d.ts +1 -1
- package/dist/clients/llm-client.js +5 -3
- package/dist/clients/llm-client.mjs +5 -3
- package/dist/services/chats/entities/chat-settings.entity.d.ts +4 -1
- package/dist/services/chats/entities/chat-settings.entity.js +8 -1
- package/dist/services/chats/entities/chat-settings.entity.mjs +8 -1
- package/dist/services/llmcalls/entities/llmcall.entity.d.ts +1 -1
- package/dist/skills/skill.d.ts +2 -0
- package/dist/skills/skill.js +3 -1
- package/dist/skills/skill.mjs +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ You know the pattern: before you write a single line of what your agent actually
|
|
|
67
67
|
- **Production-grade tool execution.** Retries on failed steps, confirmation prompts before destructive actions, and graceful resume after a crash are all built into the runtime.
|
|
68
68
|
- **Native MCP support.** Connect any MCP server and its tools become regular tools instantly. No adapter package, no manual schema mapping.
|
|
69
69
|
- **Sub-agent orchestration.** An agent can launch and coordinate other agents to split up a problem. Full guide coming soon.
|
|
70
|
-
- **Any LLM provider, including local ones.** Built on [`@
|
|
70
|
+
- **Any LLM provider, including local ones.** Built on [`@earendil-works/pi-ai`](https://www.npmjs.com/package/@earendil-works/pi-ai), so OpenAI, Anthropic, and self-hosted models (e.g. via Ollama) all work the same way.
|
|
71
71
|
- **Observability without ceremony.** Sentry and Langfuse are built in. Set the environment variables and they turn on, no SDK wiring required.
|
|
72
72
|
- **A loop marketplace.** Don't write a customer-support agent from scratch. Install one.
|
|
73
73
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CurrentUser, CurrentSession } from '../common/base/index.js';
|
|
2
2
|
import { Logger } from '../common/logger/index.js';
|
|
3
3
|
import { Chat } from '../services/chats/entities/chat.entity.js';
|
|
4
|
+
import { ChatSettingsProps } from '../services/chats/entities/chat-settings.entity.js';
|
|
4
5
|
import { AgentTask } from '../services/chats/entities/agent-task.entity.js';
|
|
5
6
|
import { Tool, BaseParams } from '../tools/tool.js';
|
|
6
7
|
import { SkillRunOptions } from '../skills/skill.js';
|
|
@@ -9,6 +10,7 @@ export interface RunContext {
|
|
|
9
10
|
identity?: AgentIdentity;
|
|
10
11
|
task?: AgentTask;
|
|
11
12
|
chat: Chat;
|
|
13
|
+
chatOptions?: ChatSettingsProps;
|
|
12
14
|
currentUser: CurrentUser;
|
|
13
15
|
currentSession?: CurrentSession;
|
|
14
16
|
currentMessage: string;
|
|
@@ -19,7 +21,7 @@ export interface RunContext {
|
|
|
19
21
|
limit?: number;
|
|
20
22
|
}) => ScoredTool[];
|
|
21
23
|
baseParams: BaseParams;
|
|
22
|
-
skillParams: Pick<SkillRunOptions, 'sessionId' | 'answerId' | 'userMessage' | 'currentUser' | 'currentSession' | 'chat'>;
|
|
24
|
+
skillParams: Pick<SkillRunOptions, 'provider' | 'modelName' | 'sessionId' | 'answerId' | 'userMessage' | 'currentUser' | 'currentSession' | 'chat'>;
|
|
23
25
|
reply: (content: string) => void;
|
|
24
26
|
setNextNode: (node?: string | AgentLoopNode) => void;
|
|
25
27
|
logger: Logger;
|
package/dist/agent/agent.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import 'reflect-metadata';
|
|
|
2
2
|
import { CurrentUser, CurrentSession } from '../common/base/index.js';
|
|
3
3
|
import { McpServer } from '../services/mcp-servers/entities/index.js';
|
|
4
4
|
import { Chat } from '../services/chats/entities/chat.entity.js';
|
|
5
|
+
import { ChatSettingsProps } from '../services/chats/entities/chat-settings.entity.js';
|
|
5
6
|
import { Tool } from '../tools/tool.js';
|
|
6
7
|
import { AgentLoop } from './agent-loop';
|
|
7
8
|
export declare const AGENT_ERROR_CODES: {
|
|
@@ -22,12 +23,6 @@ interface ChatInput {
|
|
|
22
23
|
chatId?: string;
|
|
23
24
|
messageId?: string;
|
|
24
25
|
}
|
|
25
|
-
interface ChatOptions {
|
|
26
|
-
loopName?: string;
|
|
27
|
-
modelName?: 'string';
|
|
28
|
-
isPrivateSession?: boolean;
|
|
29
|
-
notifyOnCompletion?: boolean;
|
|
30
|
-
}
|
|
31
26
|
type HookType = 'pre_execution' | 'post_execution';
|
|
32
27
|
export declare class Agent {
|
|
33
28
|
private readonly updateChatUseCase;
|
|
@@ -57,7 +52,7 @@ export declare class Agent {
|
|
|
57
52
|
get lastAssistantAnswer(): string | undefined;
|
|
58
53
|
run(props: {
|
|
59
54
|
input: ChatInput;
|
|
60
|
-
options?:
|
|
55
|
+
options?: ChatSettingsProps;
|
|
61
56
|
currentUser: CurrentUser;
|
|
62
57
|
currentSession?: CurrentSession;
|
|
63
58
|
}): Promise<{
|
package/dist/agent/agent.js
CHANGED
|
@@ -287,6 +287,7 @@ class Agent {
|
|
|
287
287
|
identity: this._identity,
|
|
288
288
|
task: this.currentChat.activeTask,
|
|
289
289
|
chat: this.currentChat,
|
|
290
|
+
chatOptions: this.chatOptions,
|
|
290
291
|
currentUser: this.currentUser,
|
|
291
292
|
currentSession: this.currentSession,
|
|
292
293
|
currentMessage: this.currentMessage,
|
|
@@ -299,6 +300,8 @@ class Agent {
|
|
|
299
300
|
answerId: this.answerId
|
|
300
301
|
},
|
|
301
302
|
skillParams: {
|
|
303
|
+
provider: this.chatOptions?.modelProvider,
|
|
304
|
+
modelName: this.chatOptions?.modelName,
|
|
302
305
|
sessionId,
|
|
303
306
|
answerId: this.answerId,
|
|
304
307
|
userMessage: this.currentMessage,
|
package/dist/agent/agent.mjs
CHANGED
|
@@ -264,6 +264,7 @@ class Agent {
|
|
|
264
264
|
identity: this._identity,
|
|
265
265
|
task: this.currentChat.activeTask,
|
|
266
266
|
chat: this.currentChat,
|
|
267
|
+
chatOptions: this.chatOptions,
|
|
267
268
|
currentUser: this.currentUser,
|
|
268
269
|
currentSession: this.currentSession,
|
|
269
270
|
currentMessage: this.currentMessage,
|
|
@@ -276,6 +277,8 @@ class Agent {
|
|
|
276
277
|
answerId: this.answerId
|
|
277
278
|
},
|
|
278
279
|
skillParams: {
|
|
280
|
+
provider: this.chatOptions?.modelProvider,
|
|
281
|
+
modelName: this.chatOptions?.modelName,
|
|
279
282
|
sessionId,
|
|
280
283
|
answerId: this.answerId,
|
|
281
284
|
userMessage: this.currentMessage,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KnownProvider, Message, AssistantMessage } from '@
|
|
1
|
+
import type { KnownProvider, Message, AssistantMessage } from '@earendil-works/pi-ai';
|
|
2
2
|
import { CurrentUser } from '../common/base/index.js';
|
|
3
3
|
export declare class LLMClient {
|
|
4
4
|
private readonly logger;
|
|
@@ -54,7 +54,8 @@ class LLMClient {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
async complete(params) {
|
|
57
|
-
const {
|
|
57
|
+
const { builtinModels } = await import("@earendil-works/pi-ai/providers/all");
|
|
58
|
+
const models = builtinModels();
|
|
58
59
|
const {
|
|
59
60
|
origin,
|
|
60
61
|
sessionId,
|
|
@@ -66,7 +67,8 @@ class LLMClient {
|
|
|
66
67
|
modelName = "gpt-4o-mini",
|
|
67
68
|
temperature = 0.7
|
|
68
69
|
} = params ?? {};
|
|
69
|
-
const model = getModel(provider, modelName);
|
|
70
|
+
const model = models.getModel(provider, modelName);
|
|
71
|
+
if (!model) throw new Error("[LLM Client] model not found");
|
|
70
72
|
const context = {
|
|
71
73
|
systemPrompt,
|
|
72
74
|
messages
|
|
@@ -95,7 +97,7 @@ class LLMClient {
|
|
|
95
97
|
input: context
|
|
96
98
|
});
|
|
97
99
|
try {
|
|
98
|
-
const response = await complete(model, context, {
|
|
100
|
+
const response = await models.complete(model, context, {
|
|
99
101
|
temperature
|
|
100
102
|
});
|
|
101
103
|
generation?.end({
|
|
@@ -22,7 +22,8 @@ class LLMClient {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
async complete(params) {
|
|
25
|
-
const {
|
|
25
|
+
const { builtinModels } = await import("@earendil-works/pi-ai/providers/all");
|
|
26
|
+
const models = builtinModels();
|
|
26
27
|
const {
|
|
27
28
|
origin,
|
|
28
29
|
sessionId,
|
|
@@ -34,7 +35,8 @@ class LLMClient {
|
|
|
34
35
|
modelName = "gpt-4o-mini",
|
|
35
36
|
temperature = 0.7
|
|
36
37
|
} = params ?? {};
|
|
37
|
-
const model = getModel(provider, modelName);
|
|
38
|
+
const model = models.getModel(provider, modelName);
|
|
39
|
+
if (!model) throw new Error("[LLM Client] model not found");
|
|
38
40
|
const context = {
|
|
39
41
|
systemPrompt,
|
|
40
42
|
messages
|
|
@@ -63,7 +65,7 @@ class LLMClient {
|
|
|
63
65
|
input: context
|
|
64
66
|
});
|
|
65
67
|
try {
|
|
66
|
-
const response = await complete(model, context, {
|
|
68
|
+
const response = await models.complete(model, context, {
|
|
67
69
|
temperature
|
|
68
70
|
});
|
|
69
71
|
generation?.end({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export interface ChatSettingsProps {
|
|
2
2
|
notifyOnCompletion?: boolean;
|
|
3
3
|
isPrivateSession?: boolean;
|
|
4
|
+
modelProvider?: string;
|
|
4
5
|
modelName?: string;
|
|
5
6
|
loopName?: string;
|
|
6
7
|
}
|
|
@@ -8,12 +9,14 @@ export declare class ChatSettings {
|
|
|
8
9
|
private readonly props;
|
|
9
10
|
notifyOnCompletion?: boolean | undefined;
|
|
10
11
|
isPrivateSession?: boolean | undefined;
|
|
12
|
+
modelProvider?: string | undefined;
|
|
11
13
|
modelName?: string | undefined;
|
|
12
14
|
loopName?: string | undefined;
|
|
13
|
-
constructor(props: ChatSettingsProps, notifyOnCompletion?: boolean | undefined, isPrivateSession?: boolean | undefined, modelName?: string | undefined, loopName?: string | undefined);
|
|
15
|
+
constructor(props: ChatSettingsProps, notifyOnCompletion?: boolean | undefined, isPrivateSession?: boolean | undefined, modelProvider?: string | undefined, modelName?: string | undefined, loopName?: string | undefined);
|
|
14
16
|
static fromJSON(props: ChatSettingsProps): ChatSettings;
|
|
15
17
|
toJSON(): ChatSettingsProps;
|
|
16
18
|
setLoopName(loopName: string): void;
|
|
19
|
+
setModelProvider(modelProvider: string): void;
|
|
17
20
|
setModelName(modelName: string): void;
|
|
18
21
|
setNotifyOnCompletion(notifyOnCompletion: boolean): void;
|
|
19
22
|
setIsPrivateSession(isPrivateSession: boolean): void;
|
|
@@ -22,16 +22,18 @@ __export(chat_settings_entity_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(chat_settings_entity_exports);
|
|
24
24
|
class ChatSettings {
|
|
25
|
-
constructor(props, notifyOnCompletion, isPrivateSession, modelName, loopName) {
|
|
25
|
+
constructor(props, notifyOnCompletion, isPrivateSession, modelProvider, modelName, loopName) {
|
|
26
26
|
this.props = props;
|
|
27
27
|
this.notifyOnCompletion = notifyOnCompletion;
|
|
28
28
|
this.isPrivateSession = isPrivateSession;
|
|
29
|
+
this.modelProvider = modelProvider;
|
|
29
30
|
this.modelName = modelName;
|
|
30
31
|
this.loopName = loopName;
|
|
31
32
|
}
|
|
32
33
|
props;
|
|
33
34
|
notifyOnCompletion;
|
|
34
35
|
isPrivateSession;
|
|
36
|
+
modelProvider;
|
|
35
37
|
modelName;
|
|
36
38
|
loopName;
|
|
37
39
|
static fromJSON(props) {
|
|
@@ -39,6 +41,7 @@ class ChatSettings {
|
|
|
39
41
|
props,
|
|
40
42
|
props.notifyOnCompletion,
|
|
41
43
|
props.isPrivateSession,
|
|
44
|
+
props.modelProvider,
|
|
42
45
|
props.modelName,
|
|
43
46
|
props.loopName
|
|
44
47
|
);
|
|
@@ -47,6 +50,7 @@ class ChatSettings {
|
|
|
47
50
|
return {
|
|
48
51
|
notifyOnCompletion: this.notifyOnCompletion,
|
|
49
52
|
isPrivateSession: this.isPrivateSession,
|
|
53
|
+
modelProvider: this.modelProvider,
|
|
50
54
|
modelName: this.modelName,
|
|
51
55
|
loopName: this.loopName
|
|
52
56
|
};
|
|
@@ -54,6 +58,9 @@ class ChatSettings {
|
|
|
54
58
|
setLoopName(loopName) {
|
|
55
59
|
this.loopName = loopName;
|
|
56
60
|
}
|
|
61
|
+
setModelProvider(modelProvider) {
|
|
62
|
+
this.modelProvider = modelProvider;
|
|
63
|
+
}
|
|
57
64
|
setModelName(modelName) {
|
|
58
65
|
this.modelName = modelName;
|
|
59
66
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import "../../../chunk-CF3WOMB3.mjs";
|
|
2
2
|
class ChatSettings {
|
|
3
|
-
constructor(props, notifyOnCompletion, isPrivateSession, modelName, loopName) {
|
|
3
|
+
constructor(props, notifyOnCompletion, isPrivateSession, modelProvider, modelName, loopName) {
|
|
4
4
|
this.props = props;
|
|
5
5
|
this.notifyOnCompletion = notifyOnCompletion;
|
|
6
6
|
this.isPrivateSession = isPrivateSession;
|
|
7
|
+
this.modelProvider = modelProvider;
|
|
7
8
|
this.modelName = modelName;
|
|
8
9
|
this.loopName = loopName;
|
|
9
10
|
}
|
|
10
11
|
props;
|
|
11
12
|
notifyOnCompletion;
|
|
12
13
|
isPrivateSession;
|
|
14
|
+
modelProvider;
|
|
13
15
|
modelName;
|
|
14
16
|
loopName;
|
|
15
17
|
static fromJSON(props) {
|
|
@@ -17,6 +19,7 @@ class ChatSettings {
|
|
|
17
19
|
props,
|
|
18
20
|
props.notifyOnCompletion,
|
|
19
21
|
props.isPrivateSession,
|
|
22
|
+
props.modelProvider,
|
|
20
23
|
props.modelName,
|
|
21
24
|
props.loopName
|
|
22
25
|
);
|
|
@@ -25,6 +28,7 @@ class ChatSettings {
|
|
|
25
28
|
return {
|
|
26
29
|
notifyOnCompletion: this.notifyOnCompletion,
|
|
27
30
|
isPrivateSession: this.isPrivateSession,
|
|
31
|
+
modelProvider: this.modelProvider,
|
|
28
32
|
modelName: this.modelName,
|
|
29
33
|
loopName: this.loopName
|
|
30
34
|
};
|
|
@@ -32,6 +36,9 @@ class ChatSettings {
|
|
|
32
36
|
setLoopName(loopName) {
|
|
33
37
|
this.loopName = loopName;
|
|
34
38
|
}
|
|
39
|
+
setModelProvider(modelProvider) {
|
|
40
|
+
this.modelProvider = modelProvider;
|
|
41
|
+
}
|
|
35
42
|
setModelName(modelName) {
|
|
36
43
|
this.modelName = modelName;
|
|
37
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ObjectId } from 'mongodb';
|
|
2
|
-
import type { AssistantMessage } from '@
|
|
2
|
+
import type { AssistantMessage } from '@earendil-works/pi-ai';
|
|
3
3
|
import { BaseEntity, BaseEntityProps } from '../../../common/base/base.entity.js';
|
|
4
4
|
export interface LLMCallProps extends BaseEntityProps {
|
|
5
5
|
origin?: string;
|
package/dist/skills/skill.d.ts
CHANGED
package/dist/skills/skill.js
CHANGED
|
@@ -38,7 +38,7 @@ class Skill {
|
|
|
38
38
|
this.systemInstructions = props.systemInstructions;
|
|
39
39
|
}
|
|
40
40
|
async run(options) {
|
|
41
|
-
const { sessionId, answerId, userMessage, currentUser, currentSession, contextInjection = {}, input = {}, chat } = options;
|
|
41
|
+
const { provider, modelName, sessionId, answerId, userMessage, currentUser, currentSession, contextInjection = {}, input = {}, chat } = options;
|
|
42
42
|
try {
|
|
43
43
|
const llmClient = import_tsyringe.container.resolve(import_llm_client.LLMClient);
|
|
44
44
|
const currentCountryCode = currentSession?.location?.country;
|
|
@@ -88,6 +88,8 @@ class Skill {
|
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
const response = await llmClient.complete({
|
|
91
|
+
provider,
|
|
92
|
+
modelName,
|
|
91
93
|
sessionId,
|
|
92
94
|
answerId,
|
|
93
95
|
origin: this.name,
|
package/dist/skills/skill.mjs
CHANGED
|
@@ -16,7 +16,7 @@ class Skill {
|
|
|
16
16
|
this.systemInstructions = props.systemInstructions;
|
|
17
17
|
}
|
|
18
18
|
async run(options) {
|
|
19
|
-
const { sessionId, answerId, userMessage, currentUser, currentSession, contextInjection = {}, input = {}, chat } = options;
|
|
19
|
+
const { provider, modelName, sessionId, answerId, userMessage, currentUser, currentSession, contextInjection = {}, input = {}, chat } = options;
|
|
20
20
|
try {
|
|
21
21
|
const llmClient = container.resolve(LLMClient);
|
|
22
22
|
const currentCountryCode = currentSession?.location?.country;
|
|
@@ -66,6 +66,8 @@ class Skill {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
const response = await llmClient.complete({
|
|
69
|
+
provider,
|
|
70
|
+
modelName,
|
|
69
71
|
sessionId,
|
|
70
72
|
answerId,
|
|
71
73
|
origin: this.name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openloops",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"description": "Framework to build AI Agents",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jose Barcos",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"push": "git push --follow-tags"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@
|
|
78
|
+
"@earendil-works/pi-ai": "^1.0.4",
|
|
79
79
|
"@modelcontextprotocol/sdk": "^1.30.1",
|
|
80
80
|
"@sentry/node": "^11.0.0",
|
|
81
81
|
"axios": "^1.20.0",
|