openloops 0.3.1 → 0.3.4
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/common/base/base.entity.d.ts +1 -1
- package/dist/common/base/base.entity.js +3 -4
- package/dist/common/base/base.entity.mjs +3 -4
- package/dist/harness/agent-state.d.ts +1 -3
- package/dist/harness/agent-state.js +1 -6
- package/dist/harness/agent-state.mjs +1 -6
- package/dist/harness/agent.js +0 -4
- package/dist/harness/agent.mjs +0 -4
- package/dist/loops/agi/loop.js +3 -6
- package/dist/loops/agi/loop.mjs +3 -6
- package/dist/loops/agi/skills/reasoning-engine.js +3 -3
- package/dist/loops/agi/skills/reasoning-engine.mjs +3 -3
- package/dist/loops/shared/skills/fast-responder.js +2 -2
- package/dist/loops/shared/skills/fast-responder.mjs +2 -2
- package/dist/services/users/use-cases/create-user.use-case.d.ts +1 -0
- package/dist/services/users/use-cases/create-user.use-case.js +2 -2
- package/dist/services/users/use-cases/create-user.use-case.mjs +2 -2
- package/docs/agent.md +1 -1
- package/docs/loops.md +1 -1
- package/docs/users.md +9 -1
- package/examples/users/create-user.ts +5 -3
- package/package.json +1 -1
|
@@ -44,7 +44,7 @@ export declare class BaseEntity {
|
|
|
44
44
|
setDefaults(): void;
|
|
45
45
|
setId(id: string | ObjectId): void;
|
|
46
46
|
setOwner(currentUser?: CurrentUser): void;
|
|
47
|
-
setCreatedBy(currentUser?: CurrentUser): void;
|
|
47
|
+
setCreatedBy(currentUser?: CurrentUser, sanitize?: boolean): void;
|
|
48
48
|
setUpdatedBy(currentUser?: CurrentUser): void;
|
|
49
49
|
setDeletedBy(currentUser?: CurrentUser): void;
|
|
50
50
|
setArchivedBy(currentUser?: CurrentUser): void;
|
|
@@ -111,11 +111,10 @@ const _BaseEntity = class _BaseEntity {
|
|
|
111
111
|
if (!currentUser) return;
|
|
112
112
|
this.ownerId = _BaseEntity.toObjectId(currentUser.userId);
|
|
113
113
|
}
|
|
114
|
-
setCreatedBy(currentUser) {
|
|
115
|
-
if (
|
|
116
|
-
this.sanitize(currentUser);
|
|
114
|
+
setCreatedBy(currentUser, sanitize = true) {
|
|
115
|
+
if (sanitize) this.sanitize(currentUser);
|
|
117
116
|
this.createdAt = /* @__PURE__ */ new Date();
|
|
118
|
-
this.createdBy = _BaseEntity.toObjectId(currentUser
|
|
117
|
+
this.createdBy = _BaseEntity.toObjectId(currentUser?.userId);
|
|
119
118
|
this.setDefaults();
|
|
120
119
|
}
|
|
121
120
|
setUpdatedBy(currentUser) {
|
|
@@ -83,11 +83,10 @@ const _BaseEntity = class _BaseEntity {
|
|
|
83
83
|
if (!currentUser) return;
|
|
84
84
|
this.ownerId = _BaseEntity.toObjectId(currentUser.userId);
|
|
85
85
|
}
|
|
86
|
-
setCreatedBy(currentUser) {
|
|
87
|
-
if (
|
|
88
|
-
this.sanitize(currentUser);
|
|
86
|
+
setCreatedBy(currentUser, sanitize = true) {
|
|
87
|
+
if (sanitize) this.sanitize(currentUser);
|
|
89
88
|
this.createdAt = /* @__PURE__ */ new Date();
|
|
90
|
-
this.createdBy = _BaseEntity.toObjectId(currentUser
|
|
89
|
+
this.createdBy = _BaseEntity.toObjectId(currentUser?.userId);
|
|
91
90
|
this.setDefaults();
|
|
92
91
|
}
|
|
93
92
|
setUpdatedBy(currentUser) {
|
|
@@ -29,14 +29,12 @@ export declare class AgentState {
|
|
|
29
29
|
stopRequested?: boolean | undefined;
|
|
30
30
|
currentActivity?: CurrentActivity | undefined;
|
|
31
31
|
private activityListener?;
|
|
32
|
-
private activityFromModel;
|
|
33
32
|
static fromJSON(props?: AgentStateProps): AgentState;
|
|
34
33
|
constructor(status?: AgentStatus | undefined, language?: string | undefined, lastError?: AgentError | undefined, activeTaskId?: string | undefined, stopRequested?: boolean | undefined, currentActivity?: CurrentActivity | undefined);
|
|
35
34
|
toJSON(): AgentStateProps;
|
|
36
35
|
setLanguage(language?: string): void;
|
|
37
36
|
onActivityChange(listener?: ActivityListener): void;
|
|
38
|
-
|
|
39
|
-
setCurrentActivity(currentActivity: CurrentActivity, source?: 'system' | 'model'): void;
|
|
37
|
+
setCurrentActivity(currentActivity: CurrentActivity): void;
|
|
40
38
|
setStatus(status: AgentStatus): void;
|
|
41
39
|
setActiveTaskId(taskId?: string): void;
|
|
42
40
|
setLastError(lastError?: AgentError): void;
|
|
@@ -46,7 +46,6 @@ class AgentState {
|
|
|
46
46
|
stopRequested;
|
|
47
47
|
currentActivity;
|
|
48
48
|
activityListener;
|
|
49
|
-
activityFromModel = false;
|
|
50
49
|
static fromJSON(props = {}) {
|
|
51
50
|
return new AgentState(
|
|
52
51
|
props.status,
|
|
@@ -71,13 +70,9 @@ class AgentState {
|
|
|
71
70
|
onActivityChange(listener) {
|
|
72
71
|
this.activityListener = listener;
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
return this.activityFromModel;
|
|
76
|
-
}
|
|
77
|
-
setCurrentActivity(currentActivity, source = "system") {
|
|
73
|
+
setCurrentActivity(currentActivity) {
|
|
78
74
|
const changed = this.currentActivity !== currentActivity;
|
|
79
75
|
this.currentActivity = currentActivity;
|
|
80
|
-
this.activityFromModel = source === "model";
|
|
81
76
|
if (changed) this.activityListener?.(currentActivity);
|
|
82
77
|
}
|
|
83
78
|
setStatus(status) {
|
|
@@ -23,7 +23,6 @@ class AgentState {
|
|
|
23
23
|
stopRequested;
|
|
24
24
|
currentActivity;
|
|
25
25
|
activityListener;
|
|
26
|
-
activityFromModel = false;
|
|
27
26
|
static fromJSON(props = {}) {
|
|
28
27
|
return new AgentState(
|
|
29
28
|
props.status,
|
|
@@ -48,13 +47,9 @@ class AgentState {
|
|
|
48
47
|
onActivityChange(listener) {
|
|
49
48
|
this.activityListener = listener;
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
return this.activityFromModel;
|
|
53
|
-
}
|
|
54
|
-
setCurrentActivity(currentActivity, source = "system") {
|
|
50
|
+
setCurrentActivity(currentActivity) {
|
|
55
51
|
const changed = this.currentActivity !== currentActivity;
|
|
56
52
|
this.currentActivity = currentActivity;
|
|
57
|
-
this.activityFromModel = source === "model";
|
|
58
53
|
if (changed) this.activityListener?.(currentActivity);
|
|
59
54
|
}
|
|
60
55
|
setStatus(status) {
|
package/dist/harness/agent.js
CHANGED
|
@@ -263,7 +263,6 @@ class Agent {
|
|
|
263
263
|
if (this.chatOptions?.loopName) this.currentChat.settings?.setLoopName(this.chatOptions.loopName);
|
|
264
264
|
this.awaitingConfirmation = this.currentChat.state?.status === import_agent_state.AgentStatus.AWAITING_USER_CONFIRMATION;
|
|
265
265
|
this.currentChat.state?.setStatus(import_agent_state.AgentStatus.PROCESSING);
|
|
266
|
-
this.currentChat.state?.setCurrentActivity("Starting...");
|
|
267
266
|
await this.persist({ resetStop: true });
|
|
268
267
|
if (!await this.runInputGuards(userMessage)) return false;
|
|
269
268
|
for (const hook of this._preHooks) {
|
|
@@ -306,7 +305,6 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
306
305
|
}
|
|
307
306
|
async finishBlocked() {
|
|
308
307
|
this.currentChat.state?.setStatus(this.awaitingConfirmation ? import_agent_state.AgentStatus.AWAITING_USER_CONFIRMATION : import_agent_state.AgentStatus.IDLE);
|
|
309
|
-
this.currentChat.state?.setCurrentActivity("stopped");
|
|
310
308
|
await this.persist();
|
|
311
309
|
await this.disconnectMcpServers();
|
|
312
310
|
}
|
|
@@ -372,14 +370,12 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
372
370
|
for (const hook of this._postHooks) {
|
|
373
371
|
await hook();
|
|
374
372
|
}
|
|
375
|
-
this.currentChat.state?.setCurrentActivity("stopped");
|
|
376
373
|
await this.persist();
|
|
377
374
|
await this.disconnectMcpServers();
|
|
378
375
|
}
|
|
379
376
|
async failRun(message, llmError) {
|
|
380
377
|
try {
|
|
381
378
|
this.currentChat.state?.setStatus(import_agent_state.AgentStatus.FAILED);
|
|
382
|
-
this.currentChat.state?.setCurrentActivity("stopped");
|
|
383
379
|
this.currentChat.state?.setLastError({ code: llmError?.code ?? AGENT_ERROR_CODES.RUN_FAILED, message, isRetryable: llmError?.isRetryable ?? true, timestamp: /* @__PURE__ */ new Date() });
|
|
384
380
|
this.currentChat.addTrace({ node: "agent", kind: "agent", reasoning: `Run failed: ${message}` });
|
|
385
381
|
this.currentChat.failTask();
|
package/dist/harness/agent.mjs
CHANGED
|
@@ -248,7 +248,6 @@ class Agent {
|
|
|
248
248
|
if (this.chatOptions?.loopName) this.currentChat.settings?.setLoopName(this.chatOptions.loopName);
|
|
249
249
|
this.awaitingConfirmation = this.currentChat.state?.status === AgentStatus.AWAITING_USER_CONFIRMATION;
|
|
250
250
|
this.currentChat.state?.setStatus(AgentStatus.PROCESSING);
|
|
251
|
-
this.currentChat.state?.setCurrentActivity("Starting...");
|
|
252
251
|
await this.persist({ resetStop: true });
|
|
253
252
|
if (!await this.runInputGuards(userMessage)) return false;
|
|
254
253
|
for (const hook of this._preHooks) {
|
|
@@ -291,7 +290,6 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
291
290
|
}
|
|
292
291
|
async finishBlocked() {
|
|
293
292
|
this.currentChat.state?.setStatus(this.awaitingConfirmation ? AgentStatus.AWAITING_USER_CONFIRMATION : AgentStatus.IDLE);
|
|
294
|
-
this.currentChat.state?.setCurrentActivity("stopped");
|
|
295
293
|
await this.persist();
|
|
296
294
|
await this.disconnectMcpServers();
|
|
297
295
|
}
|
|
@@ -357,14 +355,12 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
357
355
|
for (const hook of this._postHooks) {
|
|
358
356
|
await hook();
|
|
359
357
|
}
|
|
360
|
-
this.currentChat.state?.setCurrentActivity("stopped");
|
|
361
358
|
await this.persist();
|
|
362
359
|
await this.disconnectMcpServers();
|
|
363
360
|
}
|
|
364
361
|
async failRun(message, llmError) {
|
|
365
362
|
try {
|
|
366
363
|
this.currentChat.state?.setStatus(AgentStatus.FAILED);
|
|
367
|
-
this.currentChat.state?.setCurrentActivity("stopped");
|
|
368
364
|
this.currentChat.state?.setLastError({ code: llmError?.code ?? AGENT_ERROR_CODES.RUN_FAILED, message, isRetryable: llmError?.isRetryable ?? true, timestamp: /* @__PURE__ */ new Date() });
|
|
369
365
|
this.currentChat.addTrace({ node: "agent", kind: "agent", reasoning: `Run failed: ${message}` });
|
|
370
366
|
this.currentChat.failTask();
|
package/dist/loops/agi/loop.js
CHANGED
|
@@ -50,7 +50,7 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
50
50
|
return "agi";
|
|
51
51
|
}
|
|
52
52
|
get version() {
|
|
53
|
-
return "1.8.
|
|
53
|
+
return "1.8.4";
|
|
54
54
|
}
|
|
55
55
|
get author() {
|
|
56
56
|
return {
|
|
@@ -72,7 +72,6 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
72
72
|
harness.setNextNode(this.nodes.reasoning_engine);
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
ctx.chat.state?.setCurrentActivity("Analyzing requirement...");
|
|
76
75
|
const chat_history = ctx.chat.lastHistoryMessages();
|
|
77
76
|
const agentIdentity = ctx.identity;
|
|
78
77
|
const result = await import_skills.fastResponder.run({
|
|
@@ -85,7 +84,7 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
85
84
|
ctx.chat.state?.setLanguage(result.detected_language);
|
|
86
85
|
if (!result.can_answer) {
|
|
87
86
|
const activity = (0, import_activity.cleanActivity)(result.activity);
|
|
88
|
-
if (activity) ctx.chat.state?.setCurrentActivity(activity
|
|
87
|
+
if (activity) ctx.chat.state?.setCurrentActivity(activity);
|
|
89
88
|
harness.setNextNode(this.nodes.reasoning_engine);
|
|
90
89
|
} else {
|
|
91
90
|
ctx.chat.state?.setStatus(import_harness.AgentStatus.IDLE);
|
|
@@ -94,7 +93,6 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
async reasoningEngine(ctx, harness) {
|
|
97
|
-
if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity("Thinking...");
|
|
98
96
|
const task = ctx.task ?? ctx.chat.createTask(ctx.currentMessage);
|
|
99
97
|
task.answerQuestion(ctx.currentMessage);
|
|
100
98
|
const streak = task.sameToolStreak;
|
|
@@ -128,7 +126,7 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
128
126
|
if (/^[a-z]{2}$/.test(language)) ctx.chat.state?.setLanguage(language);
|
|
129
127
|
const { rawText, ...callInfo } = result.callInfo;
|
|
130
128
|
const activity = (0, import_activity.cleanActivity)(result.activity);
|
|
131
|
-
if (activity) ctx.chat.state?.setCurrentActivity(activity
|
|
129
|
+
if (activity) ctx.chat.state?.setCurrentActivity(activity);
|
|
132
130
|
task.addTurn({ ...result, activity }, {
|
|
133
131
|
author: "reasoning_engine",
|
|
134
132
|
declaredTools: catalog.tools.map((tool) => tool.name),
|
|
@@ -153,7 +151,6 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
153
151
|
const blocked = ready.filter((action) => harness.requiresApproval(action));
|
|
154
152
|
const runnable = ready.filter((action) => !blocked.includes(action));
|
|
155
153
|
if (runnable.length) {
|
|
156
|
-
if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity(`Running ${runnable.map((action) => action.name).join(", ")}...`);
|
|
157
154
|
await Promise.all(runnable.map((action) => harness.runAction(action, { blockDuplicates: BLOCK_DUPLICATES })));
|
|
158
155
|
}
|
|
159
156
|
if (blocked.length) {
|
package/dist/loops/agi/loop.mjs
CHANGED
|
@@ -28,7 +28,7 @@ class AgiLoop extends AgentLoop {
|
|
|
28
28
|
return "agi";
|
|
29
29
|
}
|
|
30
30
|
get version() {
|
|
31
|
-
return "1.8.
|
|
31
|
+
return "1.8.4";
|
|
32
32
|
}
|
|
33
33
|
get author() {
|
|
34
34
|
return {
|
|
@@ -50,7 +50,6 @@ class AgiLoop extends AgentLoop {
|
|
|
50
50
|
harness.setNextNode(this.nodes.reasoning_engine);
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
ctx.chat.state?.setCurrentActivity("Analyzing requirement...");
|
|
54
53
|
const chat_history = ctx.chat.lastHistoryMessages();
|
|
55
54
|
const agentIdentity = ctx.identity;
|
|
56
55
|
const result = await fastResponder.run({
|
|
@@ -63,7 +62,7 @@ class AgiLoop extends AgentLoop {
|
|
|
63
62
|
ctx.chat.state?.setLanguage(result.detected_language);
|
|
64
63
|
if (!result.can_answer) {
|
|
65
64
|
const activity = cleanActivity(result.activity);
|
|
66
|
-
if (activity) ctx.chat.state?.setCurrentActivity(activity
|
|
65
|
+
if (activity) ctx.chat.state?.setCurrentActivity(activity);
|
|
67
66
|
harness.setNextNode(this.nodes.reasoning_engine);
|
|
68
67
|
} else {
|
|
69
68
|
ctx.chat.state?.setStatus(AgentStatus.IDLE);
|
|
@@ -72,7 +71,6 @@ class AgiLoop extends AgentLoop {
|
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
async reasoningEngine(ctx, harness) {
|
|
75
|
-
if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity("Thinking...");
|
|
76
74
|
const task = ctx.task ?? ctx.chat.createTask(ctx.currentMessage);
|
|
77
75
|
task.answerQuestion(ctx.currentMessage);
|
|
78
76
|
const streak = task.sameToolStreak;
|
|
@@ -106,7 +104,7 @@ class AgiLoop extends AgentLoop {
|
|
|
106
104
|
if (/^[a-z]{2}$/.test(language)) ctx.chat.state?.setLanguage(language);
|
|
107
105
|
const { rawText, ...callInfo } = result.callInfo;
|
|
108
106
|
const activity = cleanActivity(result.activity);
|
|
109
|
-
if (activity) ctx.chat.state?.setCurrentActivity(activity
|
|
107
|
+
if (activity) ctx.chat.state?.setCurrentActivity(activity);
|
|
110
108
|
task.addTurn({ ...result, activity }, {
|
|
111
109
|
author: "reasoning_engine",
|
|
112
110
|
declaredTools: catalog.tools.map((tool) => tool.name),
|
|
@@ -131,7 +129,6 @@ class AgiLoop extends AgentLoop {
|
|
|
131
129
|
const blocked = ready.filter((action) => harness.requiresApproval(action));
|
|
132
130
|
const runnable = ready.filter((action) => !blocked.includes(action));
|
|
133
131
|
if (runnable.length) {
|
|
134
|
-
if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity(`Running ${runnable.map((action) => action.name).join(", ")}...`);
|
|
135
132
|
await Promise.all(runnable.map((action) => harness.runAction(action, { blockDuplicates: BLOCK_DUPLICATES })));
|
|
136
133
|
}
|
|
137
134
|
if (blocked.length) {
|
|
@@ -25,7 +25,7 @@ var import_skill = require("../../../skills/skill.js");
|
|
|
25
25
|
var import_shared_rules = require("../../../skills/shared/shared-rules.js");
|
|
26
26
|
const reasoningEngine = new import_skill.Skill({
|
|
27
27
|
name: "reasoning_engine",
|
|
28
|
-
version: "2.5.
|
|
28
|
+
version: "2.5.2",
|
|
29
29
|
description: "Continuous reasoning cycle of the agent: reads the situation or the results of its last actions, rewrites its working state and decides the next actions, including the final answer.",
|
|
30
30
|
temperature: 0.3,
|
|
31
31
|
systemRole: true,
|
|
@@ -34,12 +34,12 @@ const reasoningEngine = new import_skill.Skill({
|
|
|
34
34
|
goal: "Fulfil the user's request (INPUT.user_message) by working in cycles: think, act, observe and continue from where you left off, until you can give a final answer with the respond action.",
|
|
35
35
|
role: "You are the mind of an autonomous agent. The agent has a body, the runtime that hosts you (the harness), and you are what thinks and decides. Your body gives you hands, eyes, ears, a voice and a memory: it runs the actions you ask for, shows you their results as OBSERVATIONS, keeps your working state between cycles and delivers your answers to the user. You never execute anything yourself; everything you want to do in the world is an action that your body performs for you. Some of your tools are part of your body: search_tools (your eyes, to find external tools, present in your tool list only when the catalog is too large to list), read_context and save_context (a desk where you keep and reread data), ask_user (to pause and ask the person something) and respond (your voice, to give the final answer). Other tools are instruments of the outside world, such as apps, APIs and MCP servers, and their names carry the server as a prefix, like 'server__tool'; that prefix is part of the name and is always written. You work in cycles. In each cycle you receive the situation (the user's request the first time, then the results of your last actions), you think, you rewrite your state and you answer with your next actions. You never lose the thread: your previous reasoning and state come back to you in every cycle, so you continue from where you left off instead of starting over.",
|
|
36
36
|
logic_rules: [
|
|
37
|
-
"OUTPUT_FORMAT: Every response is a single JSON object with the fields 'reasoning', 'language', 'state'
|
|
37
|
+
"OUTPUT_FORMAT: Every response is a single JSON object with the fields 'reasoning', 'language', 'state', 'actions' (never empty) and 'activity' (see ACTIVITY), and optionally 'learned'. Nothing outside that JSON.",
|
|
38
38
|
"REASONING: Explain in a few sentences why you decide these actions now: what you learned from the last results, what is missing, and why these actions move you forward. It is kept for audit and debugging.",
|
|
39
39
|
"STATE: Your state is your working memory and the harness returns it to you in the next cycle. Rewrite it completely in every response, carrying forward what still matters. Use these keys, each a short text: 'objective' (what the user wants, in your own words), 'progress' (what is done and learned so far, citing refs), 'tried' (what you attempted that failed or gave nothing, so you never repeat it), 'expecting' (what you expect these actions to return) and 'next' (what you will do once you have it).",
|
|
40
40
|
`LEARNED: 'learned' is an optional list of {"key": "...", "value": "..."} with the facts you will need in later cycles and must not lose: entities with their exact identifiers (for example the customer or document the user chose, and its id), schemas of tools you will call, and decisions of the user. Add only what is new. The harness keeps it and returns all of it in HARNESS.known in every cycle, so you do not need to copy it into the state. Before an action that targets an entity, use the one in HARNESS.known, and never replace it with a different one unless the user asks. Before calling a tool, take its argument names from HARNESS.schemas when it is listed there.`,
|
|
41
41
|
`ACTIONS: 'actions' is a list of objects like {"tool": "<exact tool name>", "arguments": {...}}. The tool must be one of the names in your tool list. Copy the name character by character, including the server prefix of external tools (like 'server__tool'), which is part of the name. The only thing you may drop is a leading 'functions.'. The arguments must match its schema. You cannot call tools natively: you only ask for them through actions. Independent actions in the same response run in parallel; dependent ones go in later responses. Never invent tool names or arguments.`,
|
|
42
|
-
"ACTIVITY: 'activity'
|
|
42
|
+
"ACTIVITY: Always write 'activity'. It is shown to the user while the actions you ask for run and while you think about their results, until your next response. Write one short sentence of at most 60 characters: a verb in the progressive form followed by what is being looked up or done, taken from the user's request. It must be in the language of 'language' and of the message of the user, never in the language of these instructions. Never mention tool names, ids, refs or technical terms, never include amounts or personal data, and do not promise a result. The only exception is when your actions just deliver the final answer: then leave it out.",
|
|
43
43
|
"NEVER_EMPTY: 'actions' always has at least one action. 'reasoning' and 'state' are never shown to the user, so writing there that you will answer or summarize delivers nothing. As soon as you have what you need, your action is 'respond' with the complete final answer, written in that same response.",
|
|
44
44
|
`LOOP: After your actions run, the next message you receive is {"OBSERVATIONS": [...]} with one entry per action (ref, tool, status, output or error). Continue from there. You finish the task only with a 'respond' action, which delivers your final answer; use it alone or with actions whose results you no longer need.`,
|
|
45
45
|
"HARNESS_NOTICES: A message may contain a 'HARNESS' key with notices from your body, such as the remaining budget, a warning, a stop reason, 'known' (the facts kept for you, including the answers of the user) or 'schemas' (the arguments of the tools you have already seen). Obey them.",
|
|
@@ -3,7 +3,7 @@ import { Skill } from "../../../skills/skill.js";
|
|
|
3
3
|
import { FORMATTING, LATEX_FORMATTING, CITATION_FORMATTING } from "../../../skills/shared/shared-rules.js";
|
|
4
4
|
const reasoningEngine = new Skill({
|
|
5
5
|
name: "reasoning_engine",
|
|
6
|
-
version: "2.5.
|
|
6
|
+
version: "2.5.2",
|
|
7
7
|
description: "Continuous reasoning cycle of the agent: reads the situation or the results of its last actions, rewrites its working state and decides the next actions, including the final answer.",
|
|
8
8
|
temperature: 0.3,
|
|
9
9
|
systemRole: true,
|
|
@@ -12,12 +12,12 @@ const reasoningEngine = new Skill({
|
|
|
12
12
|
goal: "Fulfil the user's request (INPUT.user_message) by working in cycles: think, act, observe and continue from where you left off, until you can give a final answer with the respond action.",
|
|
13
13
|
role: "You are the mind of an autonomous agent. The agent has a body, the runtime that hosts you (the harness), and you are what thinks and decides. Your body gives you hands, eyes, ears, a voice and a memory: it runs the actions you ask for, shows you their results as OBSERVATIONS, keeps your working state between cycles and delivers your answers to the user. You never execute anything yourself; everything you want to do in the world is an action that your body performs for you. Some of your tools are part of your body: search_tools (your eyes, to find external tools, present in your tool list only when the catalog is too large to list), read_context and save_context (a desk where you keep and reread data), ask_user (to pause and ask the person something) and respond (your voice, to give the final answer). Other tools are instruments of the outside world, such as apps, APIs and MCP servers, and their names carry the server as a prefix, like 'server__tool'; that prefix is part of the name and is always written. You work in cycles. In each cycle you receive the situation (the user's request the first time, then the results of your last actions), you think, you rewrite your state and you answer with your next actions. You never lose the thread: your previous reasoning and state come back to you in every cycle, so you continue from where you left off instead of starting over.",
|
|
14
14
|
logic_rules: [
|
|
15
|
-
"OUTPUT_FORMAT: Every response is a single JSON object with the fields 'reasoning', 'language', 'state'
|
|
15
|
+
"OUTPUT_FORMAT: Every response is a single JSON object with the fields 'reasoning', 'language', 'state', 'actions' (never empty) and 'activity' (see ACTIVITY), and optionally 'learned'. Nothing outside that JSON.",
|
|
16
16
|
"REASONING: Explain in a few sentences why you decide these actions now: what you learned from the last results, what is missing, and why these actions move you forward. It is kept for audit and debugging.",
|
|
17
17
|
"STATE: Your state is your working memory and the harness returns it to you in the next cycle. Rewrite it completely in every response, carrying forward what still matters. Use these keys, each a short text: 'objective' (what the user wants, in your own words), 'progress' (what is done and learned so far, citing refs), 'tried' (what you attempted that failed or gave nothing, so you never repeat it), 'expecting' (what you expect these actions to return) and 'next' (what you will do once you have it).",
|
|
18
18
|
`LEARNED: 'learned' is an optional list of {"key": "...", "value": "..."} with the facts you will need in later cycles and must not lose: entities with their exact identifiers (for example the customer or document the user chose, and its id), schemas of tools you will call, and decisions of the user. Add only what is new. The harness keeps it and returns all of it in HARNESS.known in every cycle, so you do not need to copy it into the state. Before an action that targets an entity, use the one in HARNESS.known, and never replace it with a different one unless the user asks. Before calling a tool, take its argument names from HARNESS.schemas when it is listed there.`,
|
|
19
19
|
`ACTIONS: 'actions' is a list of objects like {"tool": "<exact tool name>", "arguments": {...}}. The tool must be one of the names in your tool list. Copy the name character by character, including the server prefix of external tools (like 'server__tool'), which is part of the name. The only thing you may drop is a leading 'functions.'. The arguments must match its schema. You cannot call tools natively: you only ask for them through actions. Independent actions in the same response run in parallel; dependent ones go in later responses. Never invent tool names or arguments.`,
|
|
20
|
-
"ACTIVITY: 'activity'
|
|
20
|
+
"ACTIVITY: Always write 'activity'. It is shown to the user while the actions you ask for run and while you think about their results, until your next response. Write one short sentence of at most 60 characters: a verb in the progressive form followed by what is being looked up or done, taken from the user's request. It must be in the language of 'language' and of the message of the user, never in the language of these instructions. Never mention tool names, ids, refs or technical terms, never include amounts or personal data, and do not promise a result. The only exception is when your actions just deliver the final answer: then leave it out.",
|
|
21
21
|
"NEVER_EMPTY: 'actions' always has at least one action. 'reasoning' and 'state' are never shown to the user, so writing there that you will answer or summarize delivers nothing. As soon as you have what you need, your action is 'respond' with the complete final answer, written in that same response.",
|
|
22
22
|
`LOOP: After your actions run, the next message you receive is {"OBSERVATIONS": [...]} with one entry per action (ref, tool, status, output or error). Continue from there. You finish the task only with a 'respond' action, which delivers your final answer; use it alone or with actions whose results you no longer need.`,
|
|
23
23
|
"HARNESS_NOTICES: A message may contain a 'HARNESS' key with notices from your body, such as the remaining budget, a warning, a stop reason, 'known' (the facts kept for you, including the answers of the user) or 'schemas' (the arguments of the tools you have already seen). Obey them.",
|
|
@@ -25,7 +25,7 @@ var import_skill = require("../../../skills/skill.js");
|
|
|
25
25
|
var import_shared_rules = require("../../../skills/shared/shared-rules.js");
|
|
26
26
|
const fastResponder = new import_skill.Skill({
|
|
27
27
|
name: "fast_responder",
|
|
28
|
-
version: "2.4.
|
|
28
|
+
version: "2.4.2",
|
|
29
29
|
description: "Handles general conversations and multipurpose user assistance.",
|
|
30
30
|
temperature: 0.7,
|
|
31
31
|
thinking: "low",
|
|
@@ -42,7 +42,7 @@ const fastResponder = new import_skill.Skill({
|
|
|
42
42
|
"LANGUAGE_DETECTION: Identify the language of the CURRENT user message in INPUT.user_message, or follow any explicit request to answer in a specific language (e.g., 'responde en espa\xF1ol', 'reply in English'). Base this decision ONLY on the actual text the user just typed. CONTEXT.user_details.preferred_language reflects the app's configured display language, NOT what the user is typing right now \u2014 it MUST NEVER influence this detection, even when it disagrees with the message's actual language. Always generate the 'answer' field in that detected or requested language, and set 'detected_language' in the output to its 2-letter ISO 639-1 code (e.g., 'es', 'en', 'fr').",
|
|
43
43
|
"MEMORY_AND_PERSONAL_DATA_CHECK: Do NOT assume, pretend, or hallucinate remembering past events, meetings, notes, or specific user context. If the user asks about something mentioned in the past (e.g., 'recuerdas la reuni\xF3n...?', 'qu\xE9 te dije de...?'), set 'can_answer' to false UNLESS the exact details are explicitly provided inside 'context_injection'. Never fake memory.",
|
|
44
44
|
"CAPABILITY_CHECK: Set 'can_answer' to false if: 1) The query involves creating, registering, updating, or deleting data or non-text resources (e.g., expenses, records, reminders, calendar entries), 2) The query refers to personal memory, past events, meetings, or stored notes not present in 'context_injection', 3) The query requires specialized skills or tools (e.g., searching databases, calendar lookup, external integrations), 4) The query requires live internet access (news, weather, live data), 5) The query is a correction, rejection, or negative feedback regarding a previously executed task or tool response (e.g., 'no era esa fecha', 'te equivocaste', 'busca otra opci\xF3n', 'eso no sirvi\xF3'). When 'can_answer' is false, leave 'answer' minimal or empty for the fallback engine.",
|
|
45
|
-
"ACTIVITY: When 'can_answer' is false, write in 'activity' one short sentence
|
|
45
|
+
"ACTIVITY: When 'can_answer' is false, always write in 'activity' one short sentence of at most 60 characters: a verb in the present or progressive form followed by what you will look up or do, taken from the user's request. It must be in 'detected_language' and match the language of the message of the user, never the language of these instructions. Never mention tool names or technical terms, never include amounts or personal data, and do not promise a result. Leave it empty when 'can_answer' is true.",
|
|
46
46
|
"REASONING: Always generate the 'reasoning' field with a short explanation in English of the decision-making process, regardless of whether 'can_answer' is true or false.",
|
|
47
47
|
import_shared_rules.FORMATTING,
|
|
48
48
|
import_shared_rules.LATEX_FORMATTING,
|
|
@@ -3,7 +3,7 @@ import { Skill } from "../../../skills/skill.js";
|
|
|
3
3
|
import { FORMATTING, LATEX_FORMATTING, CITATION_FORMATTING, POLICY_RESTRICTIONS } from "../../../skills/shared/shared-rules.js";
|
|
4
4
|
const fastResponder = new Skill({
|
|
5
5
|
name: "fast_responder",
|
|
6
|
-
version: "2.4.
|
|
6
|
+
version: "2.4.2",
|
|
7
7
|
description: "Handles general conversations and multipurpose user assistance.",
|
|
8
8
|
temperature: 0.7,
|
|
9
9
|
thinking: "low",
|
|
@@ -20,7 +20,7 @@ const fastResponder = new Skill({
|
|
|
20
20
|
"LANGUAGE_DETECTION: Identify the language of the CURRENT user message in INPUT.user_message, or follow any explicit request to answer in a specific language (e.g., 'responde en espa\xF1ol', 'reply in English'). Base this decision ONLY on the actual text the user just typed. CONTEXT.user_details.preferred_language reflects the app's configured display language, NOT what the user is typing right now \u2014 it MUST NEVER influence this detection, even when it disagrees with the message's actual language. Always generate the 'answer' field in that detected or requested language, and set 'detected_language' in the output to its 2-letter ISO 639-1 code (e.g., 'es', 'en', 'fr').",
|
|
21
21
|
"MEMORY_AND_PERSONAL_DATA_CHECK: Do NOT assume, pretend, or hallucinate remembering past events, meetings, notes, or specific user context. If the user asks about something mentioned in the past (e.g., 'recuerdas la reuni\xF3n...?', 'qu\xE9 te dije de...?'), set 'can_answer' to false UNLESS the exact details are explicitly provided inside 'context_injection'. Never fake memory.",
|
|
22
22
|
"CAPABILITY_CHECK: Set 'can_answer' to false if: 1) The query involves creating, registering, updating, or deleting data or non-text resources (e.g., expenses, records, reminders, calendar entries), 2) The query refers to personal memory, past events, meetings, or stored notes not present in 'context_injection', 3) The query requires specialized skills or tools (e.g., searching databases, calendar lookup, external integrations), 4) The query requires live internet access (news, weather, live data), 5) The query is a correction, rejection, or negative feedback regarding a previously executed task or tool response (e.g., 'no era esa fecha', 'te equivocaste', 'busca otra opci\xF3n', 'eso no sirvi\xF3'). When 'can_answer' is false, leave 'answer' minimal or empty for the fallback engine.",
|
|
23
|
-
"ACTIVITY: When 'can_answer' is false, write in 'activity' one short sentence
|
|
23
|
+
"ACTIVITY: When 'can_answer' is false, always write in 'activity' one short sentence of at most 60 characters: a verb in the present or progressive form followed by what you will look up or do, taken from the user's request. It must be in 'detected_language' and match the language of the message of the user, never the language of these instructions. Never mention tool names or technical terms, never include amounts or personal data, and do not promise a result. Leave it empty when 'can_answer' is true.",
|
|
24
24
|
"REASONING: Always generate the 'reasoning' field with a short explanation in English of the decision-making process, regardless of whether 'can_answer' is true or false.",
|
|
25
25
|
FORMATTING,
|
|
26
26
|
LATEX_FORMATTING,
|
|
@@ -42,12 +42,12 @@ let CreateUserUseCase = class extends import_base.BaseUseCase {
|
|
|
42
42
|
}
|
|
43
43
|
userRepository;
|
|
44
44
|
async execute(params) {
|
|
45
|
-
const { payload, currentUser } = params;
|
|
45
|
+
const { payload, currentUser, sanitize } = params;
|
|
46
46
|
if (!payload?.email) throw new Error("[Create User] email param is required");
|
|
47
47
|
if (!payload?.password) throw new Error("[Create User] password param is required");
|
|
48
48
|
const model = payload.preferences ? await (0, import_default_model.readDefaultModel)(payload.preferences) : void 0;
|
|
49
49
|
const user = await import_entities.User.create({ ...payload, ...payload.preferences ? { preferences: model.preferences } : {} });
|
|
50
|
-
user.setCreatedBy(currentUser);
|
|
50
|
+
user.setCreatedBy(currentUser, sanitize);
|
|
51
51
|
await this.userRepository?.create(user);
|
|
52
52
|
const { password, ...rest } = user.toJSON();
|
|
53
53
|
return { data: rest };
|
|
@@ -14,12 +14,12 @@ let CreateUserUseCase = class extends BaseUseCase {
|
|
|
14
14
|
}
|
|
15
15
|
userRepository;
|
|
16
16
|
async execute(params) {
|
|
17
|
-
const { payload, currentUser } = params;
|
|
17
|
+
const { payload, currentUser, sanitize } = params;
|
|
18
18
|
if (!payload?.email) throw new Error("[Create User] email param is required");
|
|
19
19
|
if (!payload?.password) throw new Error("[Create User] password param is required");
|
|
20
20
|
const model = payload.preferences ? await readDefaultModel(payload.preferences) : void 0;
|
|
21
21
|
const user = await User.create({ ...payload, ...payload.preferences ? { preferences: model.preferences } : {} });
|
|
22
|
-
user.setCreatedBy(currentUser);
|
|
22
|
+
user.setCreatedBy(currentUser, sanitize);
|
|
23
23
|
await this.userRepository?.create(user);
|
|
24
24
|
const { password, ...rest } = user.toJSON();
|
|
25
25
|
return { data: rest };
|
package/docs/agent.md
CHANGED
|
@@ -198,7 +198,7 @@ await agent.run({ input: { chatId, message }, currentUser })
|
|
|
198
198
|
stop()
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
-
The listener receives every change of the activity of the run while it is in progress
|
|
201
|
+
The listener receives every change of the activity of the run while it is in progress. It gets no start or end marker: the run is over when `agent.run()` resolves. This is the only place where the real activity is available: since 0.3.0 it is not saved with the chat, and `state.currentActivity` is deprecated (see [chats](chats.md#statecurrentactivity-is-deprecated)). It does not receive a value that repeats the previous one. With `AgiLoop` the value is a short sentence written by the model in the language of the conversation, such as `Buscando tus gastos de vuelos de agosto`, shown from the answer that asked for the actions until the next answer. When the model gives none, the listener hears nothing and the client keeps what it shows. See [loops](loops.md#agiloop).
|
|
202
202
|
|
|
203
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
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.
|
package/docs/loops.md
CHANGED
|
@@ -17,7 +17,7 @@ import { AgiLoop } from 'openloops/loops'
|
|
|
17
17
|
| `reasoning_engine` | Reads the situation or the results of the last actions, rewrites its working state, decides the next actions, reports the language of the conversation and says in one sentence what is happening until its next answer. |
|
|
18
18
|
| `action_engine` | Runs the actions the reasoning engine asked for, asks the user for confirmation when needed, delivers the final answer. |
|
|
19
19
|
|
|
20
|
-
The sentences of both nodes are what [`agent.onActivity`](agent.md#activity-updates) tells, written in the language of the conversation, so a client can show what the agent is doing
|
|
20
|
+
The sentences of both nodes are what [`agent.onActivity`](agent.md#activity-updates) tells, written in the language of the conversation, so a client can show what the agent is doing. The loop never invents one: when a node leaves it out or writes something unusable (not a text, empty, `running`, `stopped`), the listener hears nothing and the last one the model gave stays, also when the answer of a turn is not valid and the model has to try again. The text is cleaned of markup and line breaks and cut at 80 characters, and each one is kept in the turn that produced it (`turns[].activity`) to audit what the user saw.
|
|
21
21
|
|
|
22
22
|
The loop works within a budget per task (20 reasoning turns and 40 tool calls) and stops with an honest answer when the model repeats itself, keeps only reading notes, or runs out of budget. It also rejects final answers that cite identifiers that never appeared in a result or in the user's words.
|
|
23
23
|
|
package/docs/users.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
`openloops` includes its own user management, so you don't need to build a parallel system just to have an identity to hand the `Agent`.
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
|
-
import { createUser, getUserById, updateUser, deleteUser, ListUsersByProps } from 'openloops/users'
|
|
6
|
+
import { createUser, getUserById, updateUser, deleteUser, ListUsersByProps, UserRole } from 'openloops/users'
|
|
7
7
|
import { CurrentUser } from 'openloops/base'
|
|
8
8
|
```
|
|
9
9
|
|
|
@@ -28,12 +28,20 @@ const result = await createUser({
|
|
|
28
28
|
lastName: 'Barcos',
|
|
29
29
|
email: 'jose@openloops.xyz',
|
|
30
30
|
password: 'a-real-password',
|
|
31
|
+
role: UserRole.USER,
|
|
31
32
|
},
|
|
33
|
+
sanitize: false,
|
|
32
34
|
})
|
|
33
35
|
```
|
|
34
36
|
|
|
35
37
|
`email` and `password` are required. Passwords are hashed before being stored and are never returned.
|
|
36
38
|
|
|
39
|
+
### `sanitize`
|
|
40
|
+
|
|
41
|
+
By default `createUser` removes the fields only admins can set, such as `role`, unless the `currentUser` is an admin. This is what protects you from someone escalating privileges through the payload.
|
|
42
|
+
|
|
43
|
+
If you send `role`, pass `sanitize: false`, otherwise it is discarded. Do it only when your code builds the payload itself, with the fields you choose. Never pass the raw body of a request from an API.
|
|
44
|
+
|
|
37
45
|
## Getting a user
|
|
38
46
|
|
|
39
47
|
```typescript
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createUser } from 'openloops/users'
|
|
1
|
+
import { createUser, UserRole } from 'openloops/users'
|
|
2
2
|
import { Logger } from 'openloops/common'
|
|
3
3
|
|
|
4
4
|
async function createUserExample () {
|
|
@@ -9,8 +9,10 @@ async function createUserExample () {
|
|
|
9
9
|
firstName: 'Jose',
|
|
10
10
|
lastName: 'Barcos',
|
|
11
11
|
email: 'jose@openloops.xyz',
|
|
12
|
-
password: 'openloops!'
|
|
13
|
-
|
|
12
|
+
password: 'openloops!',
|
|
13
|
+
role: UserRole.USER
|
|
14
|
+
},
|
|
15
|
+
sanitize: false
|
|
14
16
|
})
|
|
15
17
|
|
|
16
18
|
logger.info(result, '[Demo] Created user:')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openloops",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
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",
|