openloops 0.1.39 → 0.2.1
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 +40 -4
- package/dist/clients/index.d.ts +2 -2
- package/dist/clients/index.js +4 -4
- package/dist/clients/index.mjs +2 -2
- package/dist/clients/llm/index.d.ts +1 -0
- package/dist/{loops/plan-execute → clients/llm}/index.js +4 -4
- package/dist/clients/llm/index.mjs +1 -0
- package/dist/clients/{llm-client.d.ts → llm/llm-client.d.ts} +3 -14
- package/dist/clients/{llm-client.js → llm/llm-client.js} +14 -37
- package/dist/clients/{llm-client.mjs → llm/llm-client.mjs} +15 -38
- package/dist/clients/{llm-error.mjs → llm/llm-error.mjs} +1 -1
- package/dist/clients/{llm-types.d.ts → llm/llm-types.d.ts} +1 -1
- package/dist/clients/llm/model-resolution.d.ts +20 -0
- package/dist/clients/llm/model-resolution.js +83 -0
- package/dist/clients/llm/model-resolution.mjs +46 -0
- package/dist/clients/{pi-ai-adapter.mjs → llm/pi-ai-adapter.mjs} +1 -1
- package/dist/clients/serper/index.d.ts +1 -0
- package/dist/clients/serper/index.js +22 -0
- package/dist/clients/serper/index.mjs +1 -0
- package/dist/clients/{serper-client.js → serper/serper-client.js} +2 -2
- package/dist/clients/{serper-client.mjs → serper/serper-client.mjs} +3 -3
- package/dist/harness/agent-loop.d.ts +0 -1
- package/dist/harness/agent.d.ts +6 -1
- package/dist/harness/agent.js +21 -13
- package/dist/harness/agent.mjs +21 -13
- package/dist/harness/native-tools.d.ts +1 -1
- package/dist/{loops/shared → harness}/skills/approval-request.d.ts +1 -1
- package/dist/{loops/shared → harness}/skills/approval-request.js +1 -1
- package/dist/{loops/shared → harness}/skills/approval-request.mjs +2 -2
- package/dist/{loops/shared → harness}/skills/autonomous-answer.d.ts +1 -1
- package/dist/{loops/shared → harness}/skills/autonomous-answer.js +1 -1
- package/dist/{loops/shared → harness}/skills/autonomous-answer.mjs +2 -2
- package/dist/{loops/shared → harness}/skills/confirmation-gate.d.ts +1 -1
- package/dist/{loops/shared → harness}/skills/confirmation-gate.js +1 -1
- package/dist/{loops/shared → harness}/skills/confirmation-gate.mjs +2 -2
- package/dist/harness/skills/index.d.ts +4 -0
- package/dist/{loops/plan-execute → harness}/skills/index.js +8 -8
- package/dist/harness/skills/index.mjs +4 -0
- package/dist/{loops/shared → harness}/skills/mcp-change-review.d.ts +1 -1
- package/dist/{loops/shared → harness}/skills/mcp-change-review.js +1 -1
- package/dist/{loops/shared → harness}/skills/mcp-change-review.mjs +2 -2
- package/dist/harness/tool-catalog.d.ts +1 -1
- package/dist/loops/index.d.ts +0 -1
- package/dist/loops/index.js +0 -2
- package/dist/loops/index.mjs +0 -1
- package/dist/loops/shared/skills/index.d.ts +0 -4
- package/dist/loops/shared/skills/index.js +1 -9
- package/dist/loops/shared/skills/index.mjs +0 -4
- package/dist/services/chats/entities/chat.entity.d.ts +0 -5
- package/dist/services/chats/entities/chat.entity.js +0 -10
- package/dist/services/chats/entities/chat.entity.mjs +0 -10
- package/dist/services/llmcalls/module.d.ts +4 -2
- package/dist/services/llmcalls/module.js +13 -6
- package/dist/services/llmcalls/module.mjs +11 -5
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.d.ts +14 -0
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.js +62 -0
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.mjs +33 -0
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.d.ts +14 -0
- package/dist/services/llmcalls/use-cases/{get-llm-usage.use-case.js → get-llm-usage-by-message.use-case.js} +18 -37
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.mjs +33 -0
- package/dist/services/llmcalls/utils/usage-totals.d.ts +20 -0
- package/dist/services/llmcalls/utils/usage-totals.js +31 -0
- package/dist/services/llmcalls/utils/usage-totals.mjs +29 -0
- package/dist/services/tasks/entities/agent-task.entity.d.ts +2 -24
- package/dist/services/tasks/entities/agent-task.entity.js +2 -75
- package/dist/services/tasks/entities/agent-task.entity.mjs +2 -75
- package/dist/services/users/entities/user-default-model.d.ts +11 -0
- package/dist/services/users/entities/user-default-model.js +42 -0
- package/dist/services/users/entities/user-default-model.mjs +19 -0
- package/dist/services/users/entities/user-preferences.d.ts +4 -1
- package/dist/services/users/entities/user-preferences.js +8 -3
- package/dist/services/users/entities/user-preferences.mjs +8 -3
- package/dist/services/users/use-cases/create-user.use-case.js +3 -1
- package/dist/services/users/use-cases/create-user.use-case.mjs +3 -1
- package/dist/services/users/use-cases/update-user.use-case.js +4 -1
- package/dist/services/users/use-cases/update-user.use-case.mjs +4 -1
- package/dist/services/users/utils/default-model.d.ts +6 -0
- package/dist/services/users/utils/default-model.js +38 -0
- package/dist/services/users/utils/default-model.mjs +15 -0
- package/dist/skills/call-modes.d.ts +1 -1
- package/dist/skills/skill.d.ts +1 -1
- package/dist/skills/skill.js +1 -1
- package/dist/skills/skill.mjs +1 -1
- package/dist/tools/core/web-search/web-search.tool.js +1 -1
- package/dist/tools/core/web-search/web-search.tool.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/agent.md +4 -3
- package/docs/agentic-jobs.md +1 -1
- package/docs/assets/harness-car.svg +79 -0
- package/docs/chats.md +1 -1
- package/docs/configuration.md +18 -4
- package/docs/harness.md +12 -1
- package/docs/integration-guide.md +2 -2
- package/docs/llms.txt +1 -1
- package/docs/loops.md +4 -15
- package/docs/usage.md +19 -14
- package/docs/users.md +23 -0
- package/examples/run-agent/run-agent-with-fallback-model.ts +25 -0
- package/examples/usage/get-chat-usage.ts +8 -10
- package/examples/usage/get-message-usage.ts +5 -7
- package/examples/users/set-default-model.ts +36 -0
- package/package.json +1 -4
- package/dist/loops/plan-execute/index.d.ts +0 -1
- package/dist/loops/plan-execute/index.mjs +0 -1
- package/dist/loops/plan-execute/loop.d.ts +0 -26
- package/dist/loops/plan-execute/loop.js +0 -267
- package/dist/loops/plan-execute/loop.mjs +0 -249
- package/dist/loops/plan-execute/skills/action-planner.d.ts +0 -35
- package/dist/loops/plan-execute/skills/action-planner.js +0 -71
- package/dist/loops/plan-execute/skills/action-planner.mjs +0 -48
- package/dist/loops/plan-execute/skills/final-responder.d.ts +0 -7
- package/dist/loops/plan-execute/skills/final-responder.js +0 -58
- package/dist/loops/plan-execute/skills/final-responder.mjs +0 -35
- package/dist/loops/plan-execute/skills/index.d.ts +0 -4
- package/dist/loops/plan-execute/skills/index.mjs +0 -4
- package/dist/loops/plan-execute/skills/state-observer.d.ts +0 -10
- package/dist/loops/plan-execute/skills/state-observer.js +0 -61
- package/dist/loops/plan-execute/skills/state-observer.mjs +0 -38
- package/dist/loops/plan-execute/skills/strategy-engine.d.ts +0 -11
- package/dist/loops/plan-execute/skills/strategy-engine.js +0 -61
- package/dist/loops/plan-execute/skills/strategy-engine.mjs +0 -38
- package/dist/services/llmcalls/use-cases/get-llm-usage.use-case.d.ts +0 -24
- package/dist/services/llmcalls/use-cases/get-llm-usage.use-case.mjs +0 -51
- package/dist/skills/skill-runner.d.ts +0 -30
- package/dist/skills/skill-runner.js +0 -121
- package/dist/skills/skill-runner.mjs +0 -92
- /package/dist/clients/{llm-error.d.ts → llm/llm-error.d.ts} +0 -0
- /package/dist/clients/{llm-error.js → llm/llm-error.js} +0 -0
- /package/dist/clients/{llm-types.js → llm/llm-types.js} +0 -0
- /package/dist/clients/{llm-types.mjs → llm/llm-types.mjs} +0 -0
- /package/dist/clients/{pi-ai-adapter.d.ts → llm/pi-ai-adapter.d.ts} +0 -0
- /package/dist/clients/{pi-ai-adapter.js → llm/pi-ai-adapter.js} +0 -0
- /package/dist/clients/{serper-client.d.ts → serper/serper-client.d.ts} +0 -0
package/dist/harness/agent.js
CHANGED
|
@@ -34,7 +34,7 @@ var import_agent_action = require("../services/tasks/entities/agent-action.entit
|
|
|
34
34
|
var import_traces = require("../services/traces/index.js");
|
|
35
35
|
var import_tool = require("../tools/tool.js");
|
|
36
36
|
var import_constants = require("../common/constants/index.js");
|
|
37
|
-
var import_skills = require("
|
|
37
|
+
var import_skills = require("./skills");
|
|
38
38
|
var import_input_check = require("../guardrails/input/input-check.js");
|
|
39
39
|
var import_create_block_input_oversize = require("../guardrails/input/create-block-input-oversize.js");
|
|
40
40
|
var import_mcp_servers = require("../services/mcp-servers/index.js");
|
|
@@ -44,7 +44,8 @@ var import_workspace = require("./workspace");
|
|
|
44
44
|
var import_tool_pipeline = require("./tool-pipeline");
|
|
45
45
|
var import_native_tools = require("./native-tools");
|
|
46
46
|
var import_tool_catalog = require("./tool-catalog");
|
|
47
|
-
var import_llm_error = require("../clients/llm-error.js");
|
|
47
|
+
var import_llm_error = require("../clients/llm/llm-error.js");
|
|
48
|
+
var import_model_resolution = require("../clients/llm/model-resolution.js");
|
|
48
49
|
const MCP_CONNECT_RETRY_DELAYS_MS = [1e3, 2e3];
|
|
49
50
|
const MCP_DESCRIPTION_CHARS = 300;
|
|
50
51
|
const MAX_AUTOMATIC_ANSWERS = 3;
|
|
@@ -62,6 +63,8 @@ class Agent {
|
|
|
62
63
|
_identity;
|
|
63
64
|
maxIterations;
|
|
64
65
|
strictMode;
|
|
66
|
+
fallbackModel;
|
|
67
|
+
model;
|
|
65
68
|
_tools;
|
|
66
69
|
_mcps = [];
|
|
67
70
|
mcpListing;
|
|
@@ -111,6 +114,10 @@ class Agent {
|
|
|
111
114
|
this._identity = agentOptions.identity;
|
|
112
115
|
this.maxIterations = agentOptions.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
113
116
|
this.strictMode = agentOptions.strictMode ?? false;
|
|
117
|
+
if (agentOptions.fallbackModel) {
|
|
118
|
+
this.fallbackModel = (0, import_model_resolution.toModelRef)(agentOptions.fallbackModel);
|
|
119
|
+
if (!this.fallbackModel) throw new Error("[AGENT] fallbackModel needs a provider and a model");
|
|
120
|
+
}
|
|
114
121
|
this.addGuard((0, import_create_block_input_oversize.createBlockInputOversize)(agentOptions.maxInputLength ?? import_constants.DEFAULT_MAX_INPUT_LENGTH));
|
|
115
122
|
this.addGuard(import_input_check.inputCheck);
|
|
116
123
|
for (const guard of agentOptions.guards ?? []) this.addGuard(guard);
|
|
@@ -156,6 +163,8 @@ class Agent {
|
|
|
156
163
|
this.currentSession = currentSession;
|
|
157
164
|
this.currentMessage = message;
|
|
158
165
|
this.chatOptions = options;
|
|
166
|
+
this.model = void 0;
|
|
167
|
+
if (Boolean(options?.modelProvider) !== Boolean(options?.modelName)) throw new Error("[AGENT] Set both modelProvider and modelName, or neither");
|
|
159
168
|
this.answerId = new import_mongodb.ObjectId().toString();
|
|
160
169
|
const proceed = await this.preRunner(chatId);
|
|
161
170
|
if (proceed) {
|
|
@@ -213,8 +222,14 @@ class Agent {
|
|
|
213
222
|
this.userMessageId = userMessage._id?.toString();
|
|
214
223
|
if (this.chatOptions?.notifyOnCompletion) this.currentChat.settings?.setNotifyOnCompletion(true);
|
|
215
224
|
if (this.chatOptions?.isPrivateSession) this.currentChat.settings?.setIsPrivateSession(true);
|
|
216
|
-
|
|
217
|
-
|
|
225
|
+
this.model = (0, import_model_resolution.resolveModel)({
|
|
226
|
+
run: (0, import_model_resolution.toModelRef)({ provider: this.chatOptions?.modelProvider, model: this.chatOptions?.modelName }),
|
|
227
|
+
chat: (0, import_model_resolution.toModelRef)({ provider: this.currentChat.settings?.modelProvider, model: this.currentChat.settings?.modelName }),
|
|
228
|
+
user: (0, import_model_resolution.toModelRef)(this.currentUser?.preferences?.defaultModel),
|
|
229
|
+
agent: this.fallbackModel
|
|
230
|
+
});
|
|
231
|
+
this.currentChat.settings?.setModelProvider(this.model.provider);
|
|
232
|
+
this.currentChat.settings?.setModelName(this.model.model);
|
|
218
233
|
if (this.chatOptions?.loopName) this.currentChat.settings?.setLoopName(this.chatOptions.loopName);
|
|
219
234
|
this.awaitingConfirmation = this.currentChat.state?.status === import_agent_state.AgentStatus.AWAITING_USER_CONFIRMATION;
|
|
220
235
|
this.currentChat.state?.setStatus(import_agent_state.AgentStatus.PROCESSING);
|
|
@@ -768,12 +783,6 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
768
783
|
if (!task) throw new Error("[AGENT] There is no active task to run the action in");
|
|
769
784
|
return this.getPipeline().run(task, action, opts);
|
|
770
785
|
}
|
|
771
|
-
async reopenTask(taskId) {
|
|
772
|
-
const task = this.currentChat.getTask(taskId);
|
|
773
|
-
if (!task) return void 0;
|
|
774
|
-
await this.hydrateTask(task);
|
|
775
|
-
return this.currentChat.reopenTask(taskId);
|
|
776
|
-
}
|
|
777
786
|
buildRunContext() {
|
|
778
787
|
const sessionId = this.currentChat._id?.toString() ?? "";
|
|
779
788
|
const agent = this;
|
|
@@ -791,8 +800,8 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
791
800
|
},
|
|
792
801
|
baseParams: this.baseParams,
|
|
793
802
|
skillParams: {
|
|
794
|
-
provider: this.
|
|
795
|
-
modelName: this.
|
|
803
|
+
provider: this.model?.provider,
|
|
804
|
+
modelName: this.model?.model,
|
|
796
805
|
sessionId,
|
|
797
806
|
answerId: this.answerId,
|
|
798
807
|
userMessage: this.currentMessage,
|
|
@@ -821,7 +830,6 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
821
830
|
runAction: (action, opts) => this.runAction(action, opts),
|
|
822
831
|
requiresApproval: (action) => this.getPipeline().requiresApproval(action),
|
|
823
832
|
requestApproval: (actions, opts) => this.requestApproval(actions, opts.resumeAt),
|
|
824
|
-
reopenTask: (taskId) => this.reopenTask(taskId),
|
|
825
833
|
reply: (content) => this.reply(content, { source: "model" }),
|
|
826
834
|
setNextNode: (node) => {
|
|
827
835
|
const resolved = this.resolveNodeName(node);
|
package/dist/harness/agent.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import { AgentAction } from "../services/tasks/entities/agent-action.entity.js";
|
|
|
19
19
|
import { createAgentTraces } from "../services/traces/index.js";
|
|
20
20
|
import { Tool } from "../tools/tool.js";
|
|
21
21
|
import { DEFAULT_MAX_INPUT_LENGTH, GUARD_FAILURE_REPLY } from "../common/constants/index.js";
|
|
22
|
-
import { approvalRequest, confirmationGate, mcpChangeReview, autonomousAnswer } from "
|
|
22
|
+
import { approvalRequest, confirmationGate, mcpChangeReview, autonomousAnswer } from "./skills";
|
|
23
23
|
import { inputCheck } from "../guardrails/input/input-check.js";
|
|
24
24
|
import { createBlockInputOversize } from "../guardrails/input/create-block-input-oversize.js";
|
|
25
25
|
import { listAllMcpServersByUser, verifyMcpServerConnection, decideMcpServerTrust } from "../services/mcp-servers/index.js";
|
|
@@ -29,7 +29,8 @@ import { AgentWorkspace } from "./workspace";
|
|
|
29
29
|
import { ToolPipeline } from "./tool-pipeline";
|
|
30
30
|
import { NATIVE_TOOLS } from "./native-tools";
|
|
31
31
|
import { buildToolCatalog, isDeclarable, needsSearch } from "./tool-catalog";
|
|
32
|
-
import { LLMError } from "../clients/llm-error.js";
|
|
32
|
+
import { LLMError } from "../clients/llm/llm-error.js";
|
|
33
|
+
import { resolveModel, toModelRef } from "../clients/llm/model-resolution.js";
|
|
33
34
|
const MCP_CONNECT_RETRY_DELAYS_MS = [1e3, 2e3];
|
|
34
35
|
const MCP_DESCRIPTION_CHARS = 300;
|
|
35
36
|
const MAX_AUTOMATIC_ANSWERS = 3;
|
|
@@ -47,6 +48,8 @@ class Agent {
|
|
|
47
48
|
_identity;
|
|
48
49
|
maxIterations;
|
|
49
50
|
strictMode;
|
|
51
|
+
fallbackModel;
|
|
52
|
+
model;
|
|
50
53
|
_tools;
|
|
51
54
|
_mcps = [];
|
|
52
55
|
mcpListing;
|
|
@@ -96,6 +99,10 @@ class Agent {
|
|
|
96
99
|
this._identity = agentOptions.identity;
|
|
97
100
|
this.maxIterations = agentOptions.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
98
101
|
this.strictMode = agentOptions.strictMode ?? false;
|
|
102
|
+
if (agentOptions.fallbackModel) {
|
|
103
|
+
this.fallbackModel = toModelRef(agentOptions.fallbackModel);
|
|
104
|
+
if (!this.fallbackModel) throw new Error("[AGENT] fallbackModel needs a provider and a model");
|
|
105
|
+
}
|
|
99
106
|
this.addGuard(createBlockInputOversize(agentOptions.maxInputLength ?? DEFAULT_MAX_INPUT_LENGTH));
|
|
100
107
|
this.addGuard(inputCheck);
|
|
101
108
|
for (const guard of agentOptions.guards ?? []) this.addGuard(guard);
|
|
@@ -141,6 +148,8 @@ class Agent {
|
|
|
141
148
|
this.currentSession = currentSession;
|
|
142
149
|
this.currentMessage = message;
|
|
143
150
|
this.chatOptions = options;
|
|
151
|
+
this.model = void 0;
|
|
152
|
+
if (Boolean(options?.modelProvider) !== Boolean(options?.modelName)) throw new Error("[AGENT] Set both modelProvider and modelName, or neither");
|
|
144
153
|
this.answerId = new ObjectId().toString();
|
|
145
154
|
const proceed = await this.preRunner(chatId);
|
|
146
155
|
if (proceed) {
|
|
@@ -198,8 +207,14 @@ class Agent {
|
|
|
198
207
|
this.userMessageId = userMessage._id?.toString();
|
|
199
208
|
if (this.chatOptions?.notifyOnCompletion) this.currentChat.settings?.setNotifyOnCompletion(true);
|
|
200
209
|
if (this.chatOptions?.isPrivateSession) this.currentChat.settings?.setIsPrivateSession(true);
|
|
201
|
-
|
|
202
|
-
|
|
210
|
+
this.model = resolveModel({
|
|
211
|
+
run: toModelRef({ provider: this.chatOptions?.modelProvider, model: this.chatOptions?.modelName }),
|
|
212
|
+
chat: toModelRef({ provider: this.currentChat.settings?.modelProvider, model: this.currentChat.settings?.modelName }),
|
|
213
|
+
user: toModelRef(this.currentUser?.preferences?.defaultModel),
|
|
214
|
+
agent: this.fallbackModel
|
|
215
|
+
});
|
|
216
|
+
this.currentChat.settings?.setModelProvider(this.model.provider);
|
|
217
|
+
this.currentChat.settings?.setModelName(this.model.model);
|
|
203
218
|
if (this.chatOptions?.loopName) this.currentChat.settings?.setLoopName(this.chatOptions.loopName);
|
|
204
219
|
this.awaitingConfirmation = this.currentChat.state?.status === AgentStatus.AWAITING_USER_CONFIRMATION;
|
|
205
220
|
this.currentChat.state?.setStatus(AgentStatus.PROCESSING);
|
|
@@ -753,12 +768,6 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
753
768
|
if (!task) throw new Error("[AGENT] There is no active task to run the action in");
|
|
754
769
|
return this.getPipeline().run(task, action, opts);
|
|
755
770
|
}
|
|
756
|
-
async reopenTask(taskId) {
|
|
757
|
-
const task = this.currentChat.getTask(taskId);
|
|
758
|
-
if (!task) return void 0;
|
|
759
|
-
await this.hydrateTask(task);
|
|
760
|
-
return this.currentChat.reopenTask(taskId);
|
|
761
|
-
}
|
|
762
771
|
buildRunContext() {
|
|
763
772
|
const sessionId = this.currentChat._id?.toString() ?? "";
|
|
764
773
|
const agent = this;
|
|
@@ -776,8 +785,8 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
776
785
|
},
|
|
777
786
|
baseParams: this.baseParams,
|
|
778
787
|
skillParams: {
|
|
779
|
-
provider: this.
|
|
780
|
-
modelName: this.
|
|
788
|
+
provider: this.model?.provider,
|
|
789
|
+
modelName: this.model?.model,
|
|
781
790
|
sessionId,
|
|
782
791
|
answerId: this.answerId,
|
|
783
792
|
userMessage: this.currentMessage,
|
|
@@ -806,7 +815,6 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
806
815
|
runAction: (action, opts) => this.runAction(action, opts),
|
|
807
816
|
requiresApproval: (action) => this.getPipeline().requiresApproval(action),
|
|
808
817
|
requestApproval: (actions, opts) => this.requestApproval(actions, opts.resumeAt),
|
|
809
|
-
reopenTask: (taskId) => this.reopenTask(taskId),
|
|
810
818
|
reply: (content) => this.reply(content, { source: "model" }),
|
|
811
819
|
setNextNode: (node) => {
|
|
812
820
|
const resolved = this.resolveNodeName(node);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LLMToolDefinition } from '../clients/llm-types.js';
|
|
1
|
+
import { LLMToolDefinition } from '../clients/llm/llm-types.js';
|
|
2
2
|
import { AgentTask } from '../services/tasks/entities/agent-task.entity.js';
|
|
3
3
|
import { AgentAction } from '../services/tasks/entities/agent-action.entity.js';
|
|
4
4
|
import { WeightedKeyword, ScoredTool } from './utils/rank-tools-by-keywords';
|
|
@@ -21,7 +21,7 @@ __export(approval_request_exports, {
|
|
|
21
21
|
approvalRequest: () => approvalRequest
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(approval_request_exports);
|
|
24
|
-
var import_skill = require("
|
|
24
|
+
var import_skill = require("../../skills/skill.js");
|
|
25
25
|
const approvalRequest = new import_skill.Skill({
|
|
26
26
|
name: "approval_request",
|
|
27
27
|
version: "1.0.0",
|
|
@@ -21,7 +21,7 @@ __export(autonomous_answer_exports, {
|
|
|
21
21
|
autonomousAnswer: () => autonomousAnswer
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(autonomous_answer_exports);
|
|
24
|
-
var import_skill = require("
|
|
24
|
+
var import_skill = require("../../skills/skill.js");
|
|
25
25
|
const autonomousAnswer = new import_skill.Skill({
|
|
26
26
|
name: "autonomous_answer",
|
|
27
27
|
version: "1.0.0",
|
|
@@ -21,7 +21,7 @@ __export(confirmation_gate_exports, {
|
|
|
21
21
|
confirmationGate: () => confirmationGate
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(confirmation_gate_exports);
|
|
24
|
-
var import_skill = require("
|
|
24
|
+
var import_skill = require("../../skills/skill.js");
|
|
25
25
|
const confirmationGate = new import_skill.Skill({
|
|
26
26
|
name: "confirmation_gate",
|
|
27
27
|
version: "1.0.0",
|
|
@@ -15,14 +15,14 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var skills_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(skills_exports);
|
|
18
|
-
__reExport(skills_exports, require("./
|
|
19
|
-
__reExport(skills_exports, require("./
|
|
20
|
-
__reExport(skills_exports, require("./
|
|
21
|
-
__reExport(skills_exports, require("./
|
|
18
|
+
__reExport(skills_exports, require("./approval-request"), module.exports);
|
|
19
|
+
__reExport(skills_exports, require("./confirmation-gate"), module.exports);
|
|
20
|
+
__reExport(skills_exports, require("./mcp-change-review"), module.exports);
|
|
21
|
+
__reExport(skills_exports, require("./autonomous-answer"), module.exports);
|
|
22
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23
23
|
0 && (module.exports = {
|
|
24
|
-
...require("./
|
|
25
|
-
...require("./
|
|
26
|
-
...require("./
|
|
27
|
-
...require("./
|
|
24
|
+
...require("./approval-request"),
|
|
25
|
+
...require("./confirmation-gate"),
|
|
26
|
+
...require("./mcp-change-review"),
|
|
27
|
+
...require("./autonomous-answer")
|
|
28
28
|
});
|
|
@@ -21,7 +21,7 @@ __export(mcp_change_review_exports, {
|
|
|
21
21
|
mcpChangeReview: () => mcpChangeReview
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(mcp_change_review_exports);
|
|
24
|
-
var import_skill = require("
|
|
24
|
+
var import_skill = require("../../skills/skill.js");
|
|
25
25
|
const mcpChangeReview = new import_skill.Skill({
|
|
26
26
|
name: "mcp_change_review",
|
|
27
27
|
version: "1.0.0",
|
package/dist/loops/index.d.ts
CHANGED
package/dist/loops/index.js
CHANGED
|
@@ -15,12 +15,10 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var loops_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(loops_exports);
|
|
18
|
-
__reExport(loops_exports, require("./plan-execute"), module.exports);
|
|
19
18
|
__reExport(loops_exports, require("./shared"), module.exports);
|
|
20
19
|
__reExport(loops_exports, require("./agi"), module.exports);
|
|
21
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
21
|
0 && (module.exports = {
|
|
23
|
-
...require("./plan-execute"),
|
|
24
22
|
...require("./shared"),
|
|
25
23
|
...require("./agi")
|
|
26
24
|
});
|
package/dist/loops/index.mjs
CHANGED
|
@@ -15,16 +15,8 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var skills_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(skills_exports);
|
|
18
|
-
__reExport(skills_exports, require("./approval-request"), module.exports);
|
|
19
|
-
__reExport(skills_exports, require("./confirmation-gate"), module.exports);
|
|
20
18
|
__reExport(skills_exports, require("./fast-responder"), module.exports);
|
|
21
|
-
__reExport(skills_exports, require("./mcp-change-review"), module.exports);
|
|
22
|
-
__reExport(skills_exports, require("./autonomous-answer"), module.exports);
|
|
23
19
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24
20
|
0 && (module.exports = {
|
|
25
|
-
...require("./
|
|
26
|
-
...require("./confirmation-gate"),
|
|
27
|
-
...require("./fast-responder"),
|
|
28
|
-
...require("./mcp-change-review"),
|
|
29
|
-
...require("./autonomous-answer")
|
|
21
|
+
...require("./fast-responder")
|
|
30
22
|
});
|
|
@@ -32,10 +32,6 @@ export declare class Chat extends BaseEntity {
|
|
|
32
32
|
toJSON(): ChatProps;
|
|
33
33
|
pushMessage(message: ChatMessageProps): ChatMessage;
|
|
34
34
|
lastHistoryMessages(count?: number): ChatMessage[] | undefined;
|
|
35
|
-
lastHistoryTurns(count?: number): {
|
|
36
|
-
role: 'user' | 'assistant';
|
|
37
|
-
content: string;
|
|
38
|
-
}[];
|
|
39
35
|
addTrace(entry: Omit<AgentTrace, 'timestamp'>): void;
|
|
40
36
|
drainTraces(): AgentTrace[];
|
|
41
37
|
setAgentState(contextState: AgentStateProps): void;
|
|
@@ -44,7 +40,6 @@ export declare class Chat extends BaseEntity {
|
|
|
44
40
|
createTask(goal: string, opts?: {
|
|
45
41
|
continuesFrom?: string;
|
|
46
42
|
}): AgentTask;
|
|
47
|
-
reopenTask(taskId: string): AgentTask | undefined;
|
|
48
43
|
completeTask(taskId?: string, summary?: string): void;
|
|
49
44
|
failTask(taskId?: string): void;
|
|
50
45
|
cancelTask(taskId?: string): void;
|
|
@@ -80,9 +80,6 @@ class Chat extends import_base.BaseEntity {
|
|
|
80
80
|
lastHistoryMessages(count = 6) {
|
|
81
81
|
return this.messages?.filter((message) => !message.excludeFromContext).slice(-count, -1);
|
|
82
82
|
}
|
|
83
|
-
lastHistoryTurns(count = 6) {
|
|
84
|
-
return (this.lastHistoryMessages(count) ?? []).filter((message) => (message.role === "user" || message.role === "assistant") && message.content).map((message) => ({ role: message.role, content: message.content }));
|
|
85
|
-
}
|
|
86
83
|
addTrace(entry) {
|
|
87
84
|
this.pendingTraces.push({
|
|
88
85
|
...entry,
|
|
@@ -121,13 +118,6 @@ class Chat extends import_base.BaseEntity {
|
|
|
121
118
|
this.state?.setActiveTaskId(newTask.id);
|
|
122
119
|
return newTask;
|
|
123
120
|
}
|
|
124
|
-
reopenTask(taskId) {
|
|
125
|
-
const task = this.getTask(taskId);
|
|
126
|
-
if (!task) return void 0;
|
|
127
|
-
task.reopen();
|
|
128
|
-
this.state?.setActiveTaskId(task.id);
|
|
129
|
-
return task;
|
|
130
|
-
}
|
|
131
121
|
completeTask(taskId, summary) {
|
|
132
122
|
const task = taskId ? this.getTask(taskId) : this.activeTask;
|
|
133
123
|
task?.complete(summary);
|
|
@@ -58,9 +58,6 @@ class Chat extends BaseEntity {
|
|
|
58
58
|
lastHistoryMessages(count = 6) {
|
|
59
59
|
return this.messages?.filter((message) => !message.excludeFromContext).slice(-count, -1);
|
|
60
60
|
}
|
|
61
|
-
lastHistoryTurns(count = 6) {
|
|
62
|
-
return (this.lastHistoryMessages(count) ?? []).filter((message) => (message.role === "user" || message.role === "assistant") && message.content).map((message) => ({ role: message.role, content: message.content }));
|
|
63
|
-
}
|
|
64
61
|
addTrace(entry) {
|
|
65
62
|
this.pendingTraces.push({
|
|
66
63
|
...entry,
|
|
@@ -99,13 +96,6 @@ class Chat extends BaseEntity {
|
|
|
99
96
|
this.state?.setActiveTaskId(newTask.id);
|
|
100
97
|
return newTask;
|
|
101
98
|
}
|
|
102
|
-
reopenTask(taskId) {
|
|
103
|
-
const task = this.getTask(taskId);
|
|
104
|
-
if (!task) return void 0;
|
|
105
|
-
task.reopen();
|
|
106
|
-
this.state?.setActiveTaskId(task.id);
|
|
107
|
-
return task;
|
|
108
|
-
}
|
|
109
99
|
completeTask(taskId, summary) {
|
|
110
100
|
const task = taskId ? this.getTask(taskId) : this.activeTask;
|
|
111
101
|
task?.complete(summary);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { Params as
|
|
2
|
+
import { Params as MParams, Output as MOutput } from './use-cases/get-llm-usage-by-message.use-case';
|
|
3
|
+
import { Params as HParams, Output as HOutput } from './use-cases/get-llm-usage-by-chat.use-case';
|
|
3
4
|
import { Params as SParams, Output as SOutput } from './use-cases/get-llm-usage-stats.use-case';
|
|
4
5
|
import { Params as CParams, Output as COutput } from './use-cases/create-llmcall.use-case';
|
|
5
|
-
export declare function
|
|
6
|
+
export declare function getLLMUsageByMessage(props: MParams): Promise<MOutput>;
|
|
7
|
+
export declare function getLLMUsageByChat(props: HParams): Promise<HOutput>;
|
|
6
8
|
export declare function getLLMUsageStats(props: SParams): Promise<SOutput>;
|
|
7
9
|
export declare function createLLMCall(props: CParams): Promise<COutput>;
|
|
@@ -19,18 +19,24 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var module_exports = {};
|
|
20
20
|
__export(module_exports, {
|
|
21
21
|
createLLMCall: () => createLLMCall,
|
|
22
|
-
|
|
22
|
+
getLLMUsageByChat: () => getLLMUsageByChat,
|
|
23
|
+
getLLMUsageByMessage: () => getLLMUsageByMessage,
|
|
23
24
|
getLLMUsageStats: () => getLLMUsageStats
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(module_exports);
|
|
26
27
|
var import_reflect_metadata = require("reflect-metadata");
|
|
27
28
|
var import_tsyringe = require("tsyringe");
|
|
28
|
-
var
|
|
29
|
+
var import_get_llm_usage_by_message = require("./use-cases/get-llm-usage-by-message.use-case");
|
|
30
|
+
var import_get_llm_usage_by_chat = require("./use-cases/get-llm-usage-by-chat.use-case");
|
|
29
31
|
var import_get_llm_usage_stats = require("./use-cases/get-llm-usage-stats.use-case");
|
|
30
32
|
var import_create_llmcall = require("./use-cases/create-llmcall.use-case");
|
|
31
|
-
async function
|
|
32
|
-
const
|
|
33
|
-
return
|
|
33
|
+
async function getLLMUsageByMessage(props) {
|
|
34
|
+
const getLLMUsageByMessageUseCase = import_tsyringe.container.resolve(import_get_llm_usage_by_message.GetLLMUsageByMessageUseCase);
|
|
35
|
+
return getLLMUsageByMessageUseCase.execute(props);
|
|
36
|
+
}
|
|
37
|
+
async function getLLMUsageByChat(props) {
|
|
38
|
+
const getLLMUsageByChatUseCase = import_tsyringe.container.resolve(import_get_llm_usage_by_chat.GetLLMUsageByChatUseCase);
|
|
39
|
+
return getLLMUsageByChatUseCase.execute(props);
|
|
34
40
|
}
|
|
35
41
|
async function getLLMUsageStats(props) {
|
|
36
42
|
const getLLMUsageStatsUseCase = import_tsyringe.container.resolve(import_get_llm_usage_stats.GetLLMUsageStatsUseCase);
|
|
@@ -43,6 +49,7 @@ async function createLLMCall(props) {
|
|
|
43
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
50
|
0 && (module.exports = {
|
|
45
51
|
createLLMCall,
|
|
46
|
-
|
|
52
|
+
getLLMUsageByChat,
|
|
53
|
+
getLLMUsageByMessage,
|
|
47
54
|
getLLMUsageStats
|
|
48
55
|
});
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import "../../chunk-CF3WOMB3.mjs";
|
|
2
2
|
import "reflect-metadata";
|
|
3
3
|
import { container } from "tsyringe";
|
|
4
|
-
import {
|
|
4
|
+
import { GetLLMUsageByMessageUseCase } from "./use-cases/get-llm-usage-by-message.use-case";
|
|
5
|
+
import { GetLLMUsageByChatUseCase } from "./use-cases/get-llm-usage-by-chat.use-case";
|
|
5
6
|
import { GetLLMUsageStatsUseCase } from "./use-cases/get-llm-usage-stats.use-case";
|
|
6
7
|
import { CreateLLMCallUseCase } from "./use-cases/create-llmcall.use-case";
|
|
7
|
-
async function
|
|
8
|
-
const
|
|
9
|
-
return
|
|
8
|
+
async function getLLMUsageByMessage(props) {
|
|
9
|
+
const getLLMUsageByMessageUseCase = container.resolve(GetLLMUsageByMessageUseCase);
|
|
10
|
+
return getLLMUsageByMessageUseCase.execute(props);
|
|
11
|
+
}
|
|
12
|
+
async function getLLMUsageByChat(props) {
|
|
13
|
+
const getLLMUsageByChatUseCase = container.resolve(GetLLMUsageByChatUseCase);
|
|
14
|
+
return getLLMUsageByChatUseCase.execute(props);
|
|
10
15
|
}
|
|
11
16
|
async function getLLMUsageStats(props) {
|
|
12
17
|
const getLLMUsageStatsUseCase = container.resolve(GetLLMUsageStatsUseCase);
|
|
@@ -18,6 +23,7 @@ async function createLLMCall(props) {
|
|
|
18
23
|
}
|
|
19
24
|
export {
|
|
20
25
|
createLLMCall,
|
|
21
|
-
|
|
26
|
+
getLLMUsageByChat,
|
|
27
|
+
getLLMUsageByMessage,
|
|
22
28
|
getLLMUsageStats
|
|
23
29
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
|
|
2
|
+
import { LLMCallRepository } from '../repositories';
|
|
3
|
+
import { UsageReport } from '../utils/usage-totals';
|
|
4
|
+
export interface Params extends BaseUseCaseParams {
|
|
5
|
+
chatId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Output extends BaseUseCaseOutput {
|
|
8
|
+
data: UsageReport;
|
|
9
|
+
}
|
|
10
|
+
export declare class GetLLMUsageByChatUseCase extends BaseUseCase<Params, Output> {
|
|
11
|
+
private readonly llmCallRepository?;
|
|
12
|
+
constructor(llmCallRepository?: LLMCallRepository | undefined);
|
|
13
|
+
execute(params: Params): Promise<Output>;
|
|
14
|
+
}
|