openloops 0.1.33 → 0.1.36
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/dist/clients/llm-client.d.ts +2 -0
- package/dist/clients/llm-client.js +15 -3
- package/dist/clients/llm-client.mjs +16 -4
- package/dist/clients/llm-error.d.ts +2 -1
- package/dist/clients/llm-error.js +10 -0
- package/dist/clients/llm-error.mjs +9 -0
- package/dist/common/base/base.entity.d.ts +2 -1
- package/dist/common/constants/harness.d.ts +3 -0
- package/dist/common/constants/harness.js +34 -0
- package/dist/common/constants/harness.mjs +9 -0
- package/dist/common/constants/index.d.ts +1 -0
- package/dist/common/constants/index.js +22 -0
- package/dist/common/constants/index.mjs +1 -0
- package/dist/guardrails/guard.d.ts +40 -0
- package/dist/guardrails/guard.js +65 -0
- package/dist/guardrails/guard.mjs +42 -0
- package/dist/guardrails/index.d.ts +2 -0
- package/dist/guardrails/index.js +41 -0
- package/dist/guardrails/index.mjs +6 -0
- package/dist/guardrails/input/block-card.d.ts +2 -0
- package/dist/guardrails/input/block-card.js +57 -0
- package/dist/guardrails/input/block-card.mjs +34 -0
- package/dist/guardrails/input/block-code.d.ts +2 -0
- package/dist/guardrails/input/block-code.js +37 -0
- package/dist/guardrails/input/block-code.mjs +14 -0
- package/dist/guardrails/input/block-email.d.ts +2 -0
- package/dist/guardrails/input/block-email.js +37 -0
- package/dist/guardrails/input/block-email.mjs +14 -0
- package/dist/guardrails/input/create-block-input-oversize.d.ts +2 -0
- package/dist/guardrails/input/create-block-input-oversize.js +38 -0
- package/dist/guardrails/input/create-block-input-oversize.mjs +15 -0
- package/dist/guardrails/input/diagnostic-sanity.d.ts +2 -0
- package/dist/guardrails/input/diagnostic-sanity.js +49 -0
- package/dist/guardrails/input/diagnostic-sanity.mjs +26 -0
- package/dist/guardrails/input/index.d.ts +3 -0
- package/dist/guardrails/input/index.js +26 -0
- package/dist/guardrails/input/index.mjs +3 -0
- package/dist/guardrails/input/input-check.d.ts +2 -0
- package/dist/guardrails/input/input-check.js +51 -0
- package/dist/guardrails/input/input-check.mjs +28 -0
- package/dist/harness/agent.d.ts +7 -0
- package/dist/harness/agent.js +62 -5
- package/dist/harness/agent.mjs +63 -6
- package/dist/loops/agi/loop.js +2 -3
- package/dist/loops/agi/loop.mjs +2 -3
- package/dist/services/chats/entities/chat-message.entity.d.ts +3 -1
- package/dist/services/chats/entities/chat-message.entity.js +7 -3
- package/dist/services/chats/entities/chat-message.entity.mjs +7 -3
- package/dist/services/chats/entities/chat.entity.d.ts +1 -1
- package/dist/services/chats/entities/chat.entity.js +5 -3
- package/dist/services/chats/entities/chat.entity.mjs +5 -3
- package/dist/services/chats/lambdas/update-chat/update-chat.use-case.js +5 -0
- package/dist/services/chats/lambdas/update-chat/update-chat.use-case.mjs +5 -0
- package/dist/services/tasks/entities/agent-task.entity.d.ts +4 -4
- package/dist/services/tasks/entities/agent-task.entity.js +7 -7
- package/dist/services/tasks/entities/agent-task.entity.mjs +7 -7
- package/dist/services/traces/entities/agent-trace-entry.entity.d.ts +3 -3
- package/package.json +9 -2
package/dist/loops/agi/loop.mjs
CHANGED
|
@@ -11,7 +11,6 @@ const MAX_SAME_TOOL = 6;
|
|
|
11
11
|
const MAX_ANSWER_REJECTIONS = 1;
|
|
12
12
|
const WARN_WORKSPACE_TURNS = 3;
|
|
13
13
|
const MAX_WORKSPACE_TURNS = 7;
|
|
14
|
-
const SUMMARY_CHARS = 400;
|
|
15
14
|
const BLOCK_DUPLICATES = false;
|
|
16
15
|
class AgiLoop extends AgentLoop {
|
|
17
16
|
get initialNode() {
|
|
@@ -102,7 +101,7 @@ class AgiLoop extends AgentLoop {
|
|
|
102
101
|
if (stopReason) {
|
|
103
102
|
const answer = task.forceAnswer(`I could not finish the task: ${stopReason}.`);
|
|
104
103
|
ctx.reply(answer);
|
|
105
|
-
task.summary = answer
|
|
104
|
+
task.summary = answer;
|
|
106
105
|
ctx.chat.failTask(task.id);
|
|
107
106
|
ctx.chat.state?.setStatus(AgentStatus.IDLE);
|
|
108
107
|
ctx.setNextNode(this.nodes.fast_responder);
|
|
@@ -140,7 +139,7 @@ class AgiLoop extends AgentLoop {
|
|
|
140
139
|
}
|
|
141
140
|
task.deliverAnswer();
|
|
142
141
|
ctx.reply(answer);
|
|
143
|
-
ctx.chat.completeTask(task.id, answer
|
|
142
|
+
ctx.chat.completeTask(task.id, answer);
|
|
144
143
|
ctx.chat.state?.setStatus(AgentStatus.IDLE);
|
|
145
144
|
ctx.setNextNode(this.nodes.fast_responder);
|
|
146
145
|
return;
|
|
@@ -5,15 +5,17 @@ export interface ChatMessageProps extends BaseEntityProps {
|
|
|
5
5
|
role?: Roles;
|
|
6
6
|
content?: string;
|
|
7
7
|
answerId?: string | ObjectId;
|
|
8
|
+
excludeFromContext?: boolean;
|
|
8
9
|
}
|
|
9
10
|
export declare class ChatMessage extends BaseEntity {
|
|
10
11
|
private readonly props;
|
|
11
12
|
role?: Roles | undefined;
|
|
12
13
|
content?: string | undefined;
|
|
13
14
|
answerId?: ObjectId | undefined;
|
|
15
|
+
excludeFromContext?: boolean | undefined;
|
|
14
16
|
static factory(message: ChatMessageProps): ChatMessage;
|
|
15
17
|
static fromJSON(props: ChatMessageProps): ChatMessage;
|
|
16
|
-
constructor(props: ChatMessageProps, role?: Roles | undefined, content?: string | undefined, answerId?: ObjectId | undefined);
|
|
18
|
+
constructor(props: ChatMessageProps, role?: Roles | undefined, content?: string | undefined, answerId?: ObjectId | undefined, excludeFromContext?: boolean | undefined);
|
|
17
19
|
toJSON(): ChatMessageProps;
|
|
18
20
|
}
|
|
19
21
|
export {};
|
|
@@ -24,17 +24,19 @@ module.exports = __toCommonJS(chat_message_entity_exports);
|
|
|
24
24
|
var import_mongodb = require("mongodb");
|
|
25
25
|
var import_base = require("../../../common/base/base.entity.js");
|
|
26
26
|
class ChatMessage extends import_base.BaseEntity {
|
|
27
|
-
constructor(props, role, content, answerId) {
|
|
27
|
+
constructor(props, role, content, answerId, excludeFromContext) {
|
|
28
28
|
super(props);
|
|
29
29
|
this.props = props;
|
|
30
30
|
this.role = role;
|
|
31
31
|
this.content = content;
|
|
32
32
|
this.answerId = answerId;
|
|
33
|
+
this.excludeFromContext = excludeFromContext;
|
|
33
34
|
}
|
|
34
35
|
props;
|
|
35
36
|
role;
|
|
36
37
|
content;
|
|
37
38
|
answerId;
|
|
39
|
+
excludeFromContext;
|
|
38
40
|
static factory(message) {
|
|
39
41
|
const messageId = message._id && import_mongodb.ObjectId.isValid(message._id) ? new import_mongodb.ObjectId(message._id) : new import_mongodb.ObjectId();
|
|
40
42
|
return ChatMessage.fromJSON({ ...message, _id: messageId });
|
|
@@ -44,7 +46,8 @@ class ChatMessage extends import_base.BaseEntity {
|
|
|
44
46
|
props,
|
|
45
47
|
props.role,
|
|
46
48
|
props.content,
|
|
47
|
-
import_base.BaseEntity.toObjectId(props.answerId)
|
|
49
|
+
import_base.BaseEntity.toObjectId(props.answerId),
|
|
50
|
+
props.excludeFromContext
|
|
48
51
|
);
|
|
49
52
|
}
|
|
50
53
|
toJSON() {
|
|
@@ -52,7 +55,8 @@ class ChatMessage extends import_base.BaseEntity {
|
|
|
52
55
|
...super.toJSON(),
|
|
53
56
|
role: this.role,
|
|
54
57
|
content: this.content,
|
|
55
|
-
answerId: this.answerId
|
|
58
|
+
answerId: this.answerId,
|
|
59
|
+
excludeFromContext: this.excludeFromContext || void 0
|
|
56
60
|
};
|
|
57
61
|
}
|
|
58
62
|
}
|
|
@@ -2,17 +2,19 @@ import "../../../chunk-CF3WOMB3.mjs";
|
|
|
2
2
|
import { ObjectId } from "mongodb";
|
|
3
3
|
import { BaseEntity } from "../../../common/base/base.entity.js";
|
|
4
4
|
class ChatMessage extends BaseEntity {
|
|
5
|
-
constructor(props, role, content, answerId) {
|
|
5
|
+
constructor(props, role, content, answerId, excludeFromContext) {
|
|
6
6
|
super(props);
|
|
7
7
|
this.props = props;
|
|
8
8
|
this.role = role;
|
|
9
9
|
this.content = content;
|
|
10
10
|
this.answerId = answerId;
|
|
11
|
+
this.excludeFromContext = excludeFromContext;
|
|
11
12
|
}
|
|
12
13
|
props;
|
|
13
14
|
role;
|
|
14
15
|
content;
|
|
15
16
|
answerId;
|
|
17
|
+
excludeFromContext;
|
|
16
18
|
static factory(message) {
|
|
17
19
|
const messageId = message._id && ObjectId.isValid(message._id) ? new ObjectId(message._id) : new ObjectId();
|
|
18
20
|
return ChatMessage.fromJSON({ ...message, _id: messageId });
|
|
@@ -22,7 +24,8 @@ class ChatMessage extends BaseEntity {
|
|
|
22
24
|
props,
|
|
23
25
|
props.role,
|
|
24
26
|
props.content,
|
|
25
|
-
BaseEntity.toObjectId(props.answerId)
|
|
27
|
+
BaseEntity.toObjectId(props.answerId),
|
|
28
|
+
props.excludeFromContext
|
|
26
29
|
);
|
|
27
30
|
}
|
|
28
31
|
toJSON() {
|
|
@@ -30,7 +33,8 @@ class ChatMessage extends BaseEntity {
|
|
|
30
33
|
...super.toJSON(),
|
|
31
34
|
role: this.role,
|
|
32
35
|
content: this.content,
|
|
33
|
-
answerId: this.answerId
|
|
36
|
+
answerId: this.answerId,
|
|
37
|
+
excludeFromContext: this.excludeFromContext || void 0
|
|
34
38
|
};
|
|
35
39
|
}
|
|
36
40
|
}
|
|
@@ -57,7 +57,7 @@ class Chat extends import_base.BaseEntity {
|
|
|
57
57
|
tasks = [];
|
|
58
58
|
pendingTraces = [];
|
|
59
59
|
get lastAnswer() {
|
|
60
|
-
return this.messages?.slice().reverse().find((message) => message.role === "assistant")?.content;
|
|
60
|
+
return this.messages?.slice().reverse().find((message) => message.role === "assistant" && !message.excludeFromContext)?.content;
|
|
61
61
|
}
|
|
62
62
|
get activeTask() {
|
|
63
63
|
if (!this.state?.activeTaskId) return void 0;
|
|
@@ -78,7 +78,7 @@ class Chat extends import_base.BaseEntity {
|
|
|
78
78
|
return created;
|
|
79
79
|
}
|
|
80
80
|
lastHistoryMessages(count = 6) {
|
|
81
|
-
return this.messages?.slice(-count, -1);
|
|
81
|
+
return this.messages?.filter((message) => !message.excludeFromContext).slice(-count, -1);
|
|
82
82
|
}
|
|
83
83
|
addTrace(entry) {
|
|
84
84
|
this.pendingTraces.push({
|
|
@@ -113,7 +113,7 @@ class Chat extends import_base.BaseEntity {
|
|
|
113
113
|
previousTaskId: opts?.continuesFrom,
|
|
114
114
|
loopName: this.settings?.loopName
|
|
115
115
|
});
|
|
116
|
-
newTask.threadId ??= newTask.
|
|
116
|
+
newTask.threadId ??= newTask._id;
|
|
117
117
|
this.tasks.push(newTask);
|
|
118
118
|
this.state?.setActiveTaskId(newTask.id);
|
|
119
119
|
return newTask;
|
|
@@ -143,12 +143,14 @@ class Chat extends import_base.BaseEntity {
|
|
|
143
143
|
clearActiveTaskIdIfMatches(task) {
|
|
144
144
|
if (task?.id === this.state?.activeTaskId) {
|
|
145
145
|
this.state?.setActiveTaskId(void 0);
|
|
146
|
+
this.unset(["state.activeTaskId"]);
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
switchLoop(loopName) {
|
|
149
150
|
if (this.settings?.loopName && this.settings.loopName !== loopName) {
|
|
150
151
|
this.activeTask?.pause();
|
|
151
152
|
this.state?.setActiveTaskId(void 0);
|
|
153
|
+
this.unset(["state.activeTaskId"]);
|
|
152
154
|
}
|
|
153
155
|
this.settings?.setLoopName(loopName);
|
|
154
156
|
}
|
|
@@ -35,7 +35,7 @@ class Chat extends BaseEntity {
|
|
|
35
35
|
tasks = [];
|
|
36
36
|
pendingTraces = [];
|
|
37
37
|
get lastAnswer() {
|
|
38
|
-
return this.messages?.slice().reverse().find((message) => message.role === "assistant")?.content;
|
|
38
|
+
return this.messages?.slice().reverse().find((message) => message.role === "assistant" && !message.excludeFromContext)?.content;
|
|
39
39
|
}
|
|
40
40
|
get activeTask() {
|
|
41
41
|
if (!this.state?.activeTaskId) return void 0;
|
|
@@ -56,7 +56,7 @@ class Chat extends BaseEntity {
|
|
|
56
56
|
return created;
|
|
57
57
|
}
|
|
58
58
|
lastHistoryMessages(count = 6) {
|
|
59
|
-
return this.messages?.slice(-count, -1);
|
|
59
|
+
return this.messages?.filter((message) => !message.excludeFromContext).slice(-count, -1);
|
|
60
60
|
}
|
|
61
61
|
addTrace(entry) {
|
|
62
62
|
this.pendingTraces.push({
|
|
@@ -91,7 +91,7 @@ class Chat extends BaseEntity {
|
|
|
91
91
|
previousTaskId: opts?.continuesFrom,
|
|
92
92
|
loopName: this.settings?.loopName
|
|
93
93
|
});
|
|
94
|
-
newTask.threadId ??= newTask.
|
|
94
|
+
newTask.threadId ??= newTask._id;
|
|
95
95
|
this.tasks.push(newTask);
|
|
96
96
|
this.state?.setActiveTaskId(newTask.id);
|
|
97
97
|
return newTask;
|
|
@@ -121,12 +121,14 @@ class Chat extends BaseEntity {
|
|
|
121
121
|
clearActiveTaskIdIfMatches(task) {
|
|
122
122
|
if (task?.id === this.state?.activeTaskId) {
|
|
123
123
|
this.state?.setActiveTaskId(void 0);
|
|
124
|
+
this.unset(["state.activeTaskId"]);
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
switchLoop(loopName) {
|
|
127
128
|
if (this.settings?.loopName && this.settings.loopName !== loopName) {
|
|
128
129
|
this.activeTask?.pause();
|
|
129
130
|
this.state?.setActiveTaskId(void 0);
|
|
131
|
+
this.unset(["state.activeTaskId"]);
|
|
130
132
|
}
|
|
131
133
|
this.settings?.setLoopName(loopName);
|
|
132
134
|
}
|
|
@@ -50,6 +50,11 @@ let UpdateChatUseCase = class extends import_base.BaseUseCase {
|
|
|
50
50
|
}
|
|
51
51
|
const chat = import_entities.Chat.fromJSON({ ...payload, _id: id });
|
|
52
52
|
chat.setUpdatedBy(currentUser);
|
|
53
|
+
if (payload.toUnset) {
|
|
54
|
+
const flat = chat.toFlatDocument();
|
|
55
|
+
const fields = Object.keys(payload.toUnset).filter((field) => flat[field] === void 0);
|
|
56
|
+
if (fields.length) chat.unset(fields);
|
|
57
|
+
}
|
|
53
58
|
const result = await this.chatRepository?.update(chat);
|
|
54
59
|
if (!result) {
|
|
55
60
|
throw new Error("Chat not found or update failed");
|
|
@@ -22,6 +22,11 @@ let UpdateChatUseCase = class extends BaseUseCase {
|
|
|
22
22
|
}
|
|
23
23
|
const chat = Chat.fromJSON({ ...payload, _id: id });
|
|
24
24
|
chat.setUpdatedBy(currentUser);
|
|
25
|
+
if (payload.toUnset) {
|
|
26
|
+
const flat = chat.toFlatDocument();
|
|
27
|
+
const fields = Object.keys(payload.toUnset).filter((field) => flat[field] === void 0);
|
|
28
|
+
if (fields.length) chat.unset(fields);
|
|
29
|
+
}
|
|
25
30
|
const result = await this.chatRepository?.update(chat);
|
|
26
31
|
if (!result) {
|
|
27
32
|
throw new Error("Chat not found or update failed");
|
|
@@ -17,7 +17,7 @@ export interface AgentTaskProps extends BaseEntityProps {
|
|
|
17
17
|
status?: TaskStatus;
|
|
18
18
|
goal?: string;
|
|
19
19
|
nextNode?: string;
|
|
20
|
-
threadId?: string;
|
|
20
|
+
threadId?: string | ObjectId;
|
|
21
21
|
previousTaskId?: string;
|
|
22
22
|
summary?: string;
|
|
23
23
|
loopName?: string;
|
|
@@ -85,7 +85,7 @@ export declare class AgentTask extends BaseEntity {
|
|
|
85
85
|
status?: TaskStatus | undefined;
|
|
86
86
|
goal?: string | undefined;
|
|
87
87
|
nextNode?: string | undefined;
|
|
88
|
-
threadId?:
|
|
88
|
+
threadId?: ObjectId | undefined;
|
|
89
89
|
previousTaskId?: string | undefined;
|
|
90
90
|
summary?: string | undefined;
|
|
91
91
|
loopName?: string | undefined;
|
|
@@ -102,7 +102,7 @@ export declare class AgentTask extends BaseEntity {
|
|
|
102
102
|
static collectRefs(value: any): CollectedRefs;
|
|
103
103
|
actions: AgentAction[];
|
|
104
104
|
hydrated: boolean;
|
|
105
|
-
constructor(props: AgentTaskProps, chatId?: ObjectId | undefined, status?: TaskStatus | undefined, goal?: string | undefined, nextNode?: string | undefined, threadId?:
|
|
105
|
+
constructor(props: AgentTaskProps, chatId?: ObjectId | undefined, status?: TaskStatus | undefined, goal?: string | undefined, nextNode?: string | undefined, threadId?: ObjectId | undefined, previousTaskId?: string | undefined, summary?: string | undefined, loopName?: string | undefined, planCount?: number, planOffset?: number, executedOffset?: number, scratch?: Record<string, any> | undefined, opening?: string | undefined, turns?: TurnRecord[], known?: Record<string, string> | undefined, schemas?: Record<string, ToolSchemaSummary> | undefined);
|
|
106
106
|
toJSON(): AgentTaskProps;
|
|
107
107
|
get id(): string;
|
|
108
108
|
get clearedFields(): Record<string, ''>;
|
|
@@ -149,9 +149,9 @@ export declare class AgentTask extends BaseEntity {
|
|
|
149
149
|
get discoveredToolNames(): string[];
|
|
150
150
|
get failedActions(): AgentAction[];
|
|
151
151
|
get executedActions(): AgentAction[];
|
|
152
|
-
get lastExecutedAction(): AgentAction | undefined;
|
|
153
152
|
get replanCount(): number;
|
|
154
153
|
get executedSinceOpen(): number;
|
|
154
|
+
get lastExecutedAction(): AgentAction | undefined;
|
|
155
155
|
executionHistory(maxChars?: number): {
|
|
156
156
|
ref: string;
|
|
157
157
|
tool: string | undefined;
|
|
@@ -262,7 +262,7 @@ class AgentTask extends import_base.BaseEntity {
|
|
|
262
262
|
props.status,
|
|
263
263
|
props.goal,
|
|
264
264
|
props.nextNode,
|
|
265
|
-
props.threadId,
|
|
265
|
+
import_base.BaseEntity.toObjectId(props.threadId),
|
|
266
266
|
props.previousTaskId,
|
|
267
267
|
props.summary,
|
|
268
268
|
props.loopName,
|
|
@@ -292,9 +292,9 @@ class AgentTask extends import_base.BaseEntity {
|
|
|
292
292
|
previousTaskId: this.previousTaskId,
|
|
293
293
|
summary: this.summary,
|
|
294
294
|
loopName: this.loopName,
|
|
295
|
-
planCount: this.planCount,
|
|
296
|
-
planOffset: this.planOffset,
|
|
297
|
-
executedOffset: this.executedOffset,
|
|
295
|
+
planCount: this.planCount || void 0,
|
|
296
|
+
planOffset: this.planOffset || void 0,
|
|
297
|
+
executedOffset: this.executedOffset || void 0,
|
|
298
298
|
scratch: this.scratch,
|
|
299
299
|
opening: this.opening,
|
|
300
300
|
turns: this.turns.length ? this.turns : void 0,
|
|
@@ -578,15 +578,15 @@ class AgentTask extends import_base.BaseEntity {
|
|
|
578
578
|
get executedActions() {
|
|
579
579
|
return this.actions.filter((a) => a.isTerminal);
|
|
580
580
|
}
|
|
581
|
-
get lastExecutedAction() {
|
|
582
|
-
return this.actions.slice().reverse().find((a) => a.isTerminal);
|
|
583
|
-
}
|
|
584
581
|
get replanCount() {
|
|
585
582
|
return Math.max(0, this.planCount - this.planOffset - 1);
|
|
586
583
|
}
|
|
587
584
|
get executedSinceOpen() {
|
|
588
585
|
return Math.max(0, this.executedActions.length - this.executedOffset);
|
|
589
586
|
}
|
|
587
|
+
get lastExecutedAction() {
|
|
588
|
+
return this.actions.slice().reverse().find((a) => a.isTerminal);
|
|
589
|
+
}
|
|
590
590
|
executionHistory(maxChars = 1500) {
|
|
591
591
|
return this.executedActions.map((a) => a.promptView(maxChars));
|
|
592
592
|
}
|
|
@@ -230,7 +230,7 @@ class AgentTask extends BaseEntity {
|
|
|
230
230
|
props.status,
|
|
231
231
|
props.goal,
|
|
232
232
|
props.nextNode,
|
|
233
|
-
props.threadId,
|
|
233
|
+
BaseEntity.toObjectId(props.threadId),
|
|
234
234
|
props.previousTaskId,
|
|
235
235
|
props.summary,
|
|
236
236
|
props.loopName,
|
|
@@ -260,9 +260,9 @@ class AgentTask extends BaseEntity {
|
|
|
260
260
|
previousTaskId: this.previousTaskId,
|
|
261
261
|
summary: this.summary,
|
|
262
262
|
loopName: this.loopName,
|
|
263
|
-
planCount: this.planCount,
|
|
264
|
-
planOffset: this.planOffset,
|
|
265
|
-
executedOffset: this.executedOffset,
|
|
263
|
+
planCount: this.planCount || void 0,
|
|
264
|
+
planOffset: this.planOffset || void 0,
|
|
265
|
+
executedOffset: this.executedOffset || void 0,
|
|
266
266
|
scratch: this.scratch,
|
|
267
267
|
opening: this.opening,
|
|
268
268
|
turns: this.turns.length ? this.turns : void 0,
|
|
@@ -546,15 +546,15 @@ class AgentTask extends BaseEntity {
|
|
|
546
546
|
get executedActions() {
|
|
547
547
|
return this.actions.filter((a) => a.isTerminal);
|
|
548
548
|
}
|
|
549
|
-
get lastExecutedAction() {
|
|
550
|
-
return this.actions.slice().reverse().find((a) => a.isTerminal);
|
|
551
|
-
}
|
|
552
549
|
get replanCount() {
|
|
553
550
|
return Math.max(0, this.planCount - this.planOffset - 1);
|
|
554
551
|
}
|
|
555
552
|
get executedSinceOpen() {
|
|
556
553
|
return Math.max(0, this.executedActions.length - this.executedOffset);
|
|
557
554
|
}
|
|
555
|
+
get lastExecutedAction() {
|
|
556
|
+
return this.actions.slice().reverse().find((a) => a.isTerminal);
|
|
557
|
+
}
|
|
558
558
|
executionHistory(maxChars = 1500) {
|
|
559
559
|
return this.executedActions.map((a) => a.promptView(maxChars));
|
|
560
560
|
}
|
|
@@ -8,7 +8,7 @@ export interface AgentTraceEntryProps extends BaseEntityProps {
|
|
|
8
8
|
timestamp?: Date | string;
|
|
9
9
|
answerId?: string | ObjectId;
|
|
10
10
|
messageId?: string | ObjectId;
|
|
11
|
-
kind?: 'skill' | 'node' | 'agent';
|
|
11
|
+
kind?: 'skill' | 'node' | 'agent' | 'guard';
|
|
12
12
|
iteration?: number;
|
|
13
13
|
durationMs?: number;
|
|
14
14
|
}
|
|
@@ -21,10 +21,10 @@ export declare class AgentTraceEntry extends BaseEntity {
|
|
|
21
21
|
timestamp?: Date | undefined;
|
|
22
22
|
answerId?: ObjectId | undefined;
|
|
23
23
|
messageId?: ObjectId | undefined;
|
|
24
|
-
kind?: "skill" | "node" | "agent" | undefined;
|
|
24
|
+
kind?: "skill" | "node" | "agent" | "guard" | undefined;
|
|
25
25
|
iteration?: number | undefined;
|
|
26
26
|
durationMs?: number | undefined;
|
|
27
27
|
static fromJSON(props: AgentTraceEntryProps): AgentTraceEntry;
|
|
28
|
-
constructor(props: AgentTraceEntryProps, chatId?: ObjectId | undefined, taskId?: ObjectId | undefined, node?: string | undefined, reasoning?: string | undefined, timestamp?: Date | undefined, answerId?: ObjectId | undefined, messageId?: ObjectId | undefined, kind?: "skill" | "node" | "agent" | undefined, iteration?: number | undefined, durationMs?: number | undefined);
|
|
28
|
+
constructor(props: AgentTraceEntryProps, chatId?: ObjectId | undefined, taskId?: ObjectId | undefined, node?: string | undefined, reasoning?: string | undefined, timestamp?: Date | undefined, answerId?: ObjectId | undefined, messageId?: ObjectId | undefined, kind?: "skill" | "node" | "agent" | "guard" | undefined, iteration?: number | undefined, durationMs?: number | undefined);
|
|
29
29
|
toJSON(): AgentTraceEntryProps;
|
|
30
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openloops",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.36",
|
|
4
4
|
"description": "Framework to build AI Agents",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jose Barcos",
|
|
@@ -43,6 +43,10 @@
|
|
|
43
43
|
"types": "./dist/loops/index.d.ts",
|
|
44
44
|
"default": "./dist/loops/index.js"
|
|
45
45
|
},
|
|
46
|
+
"./guardrails": {
|
|
47
|
+
"types": "./dist/guardrails/index.d.ts",
|
|
48
|
+
"default": "./dist/guardrails/index.js"
|
|
49
|
+
},
|
|
46
50
|
"./authentication": {
|
|
47
51
|
"types": "./dist/services/authentication/index.d.ts",
|
|
48
52
|
"default": "./dist/services/authentication/index.js"
|
|
@@ -72,7 +76,10 @@
|
|
|
72
76
|
"prepublishOnly": "yarn build",
|
|
73
77
|
"check-size": "npm pack --dry-run",
|
|
74
78
|
"release": "npm version patch && npm publish --access public",
|
|
75
|
-
"push": "git push --follow-tags"
|
|
79
|
+
"push": "git push --follow-tags",
|
|
80
|
+
"test": "jest",
|
|
81
|
+
"test:watch": "jest --watch",
|
|
82
|
+
"test:coverage": "jest --coverage"
|
|
76
83
|
},
|
|
77
84
|
"dependencies": {
|
|
78
85
|
"@earendil-works/pi-ai": "^1.0.4",
|