@agent-smith/task 0.2.4 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import type { InferenceParams, InferenceResult, InferenceOptions, ToolSpec, HistoryTurn, ToolCallSpec } from "@locallm/types";
1
+ import type { InferenceParams, InferenceResult, InferenceOptions, ToolSpec, HistoryTurn, ToolCallSpec, ToolTurn } from "@locallm/types";
2
2
  import type { PromptTemplate } from "modprompt";
3
3
  interface ModelSpec {
4
4
  name: string;
@@ -35,8 +35,13 @@ interface TaskConf {
35
35
  debug?: boolean;
36
36
  verbose?: boolean;
37
37
  baseDir?: string;
38
+ history?: Array<HistoryTurn>;
38
39
  onToolCall?: (tc: ToolCallSpec) => void;
39
40
  onToolCallEnd?: (tr: any) => void;
41
+ onToolsTurnStart?: (tc: Array<ToolCallSpec>) => void;
42
+ onToolsTurnEnd?: (tr: Array<ToolTurn>) => void;
43
+ onTurnEnd?: (ht: HistoryTurn) => void;
44
+ onAssistant?: (txt: string) => void;
40
45
  }
41
46
  /**
42
47
  * Represents a template specification for a language model task.
package/dist/task.js CHANGED
@@ -48,6 +48,18 @@ class Task {
48
48
  if (conf?.onToolCallEnd) {
49
49
  options.onToolCallEnd = conf.onToolCallEnd;
50
50
  }
51
+ if (conf?.onToolsTurnStart) {
52
+ options.onToolsTurnStart = conf.onToolsTurnStart;
53
+ }
54
+ if (conf?.onToolsTurnEnd) {
55
+ options.onToolsTurnEnd = conf.onToolsTurnEnd;
56
+ }
57
+ if (conf?.onTurnEnd) {
58
+ options.onTurnEnd = conf.onTurnEnd;
59
+ }
60
+ if (conf?.onAssistant) {
61
+ options.onAssistant = conf.onAssistant;
62
+ }
51
63
  let hasTools = false;
52
64
  // add task tools to the agent
53
65
  if (this.def?.tools) {
@@ -87,6 +99,13 @@ class Task {
87
99
  options.tools = this.def.tools;
88
100
  }
89
101
  if (conf?.debug) {
102
+ if (this.agent?.history) {
103
+ this.agent.history.forEach(t => {
104
+ if (t?.assistant || t?.tools) {
105
+ tpl.pushToHistory(t);
106
+ }
107
+ });
108
+ }
90
109
  console.log("-----------", model.name, "- Template:", tpl.name, "- Ctx:", ctx, "-----------");
91
110
  console.log(useTemplates ? tpl.prompt(finalPrompt) : finalPrompt);
92
111
  console.log("----------------------------------------------");
@@ -106,7 +125,10 @@ class Task {
106
125
  // cut debug here. TODO: debug log levels
107
126
  options.debug = false;
108
127
  }
109
- const isRoutingAgent = this.def.description.includes("routing agent");
128
+ let isRoutingAgent = false;
129
+ if (this.def?.description) {
130
+ isRoutingAgent = this.def.description.includes("routing agent");
131
+ }
110
132
  if (isRoutingAgent) {
111
133
  options.isToolsRouter = true;
112
134
  }
@@ -115,7 +137,7 @@ class Task {
115
137
  options.system = this.def.template.system;
116
138
  }
117
139
  if (this.def?.shots) {
118
- options.history = this.def.shots;
140
+ options.history = options?.history ? [...options.history, ...this.def.shots] : this.def.shots;
119
141
  }
120
142
  //console.log("RUN AGENT (TASK) params:", this.def.inferParams);
121
143
  //console.log("RUN AGENT (TASK) options:", options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-smith/task",
3
- "version": "0.2.4",
3
+ "version": "0.3.1",
4
4
  "description": "A toolkit to create human friendly agents: the language model tasks module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,26 +14,22 @@
14
14
  "docs": "typedoc --entryPointStrategy expand"
15
15
  },
16
16
  "dependencies": {
17
- "@agent-smith/agent": "^0.2.3",
17
+ "@agent-smith/agent": "^0.3.1",
18
18
  "@agent-smith/tfm": "^0.2.0",
19
- "modprompt": "0.13.1",
19
+ "modprompt": "^0.14.0",
20
20
  "yaml": "^2.8.2"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@locallm/api": "^0.7.3",
24
- "openai": "6.16.0",
25
- "@locallm/types": "^0.6.7",
24
+ "openai": "6.24.0",
25
+ "@locallm/types": "^0.7.0",
26
26
  "@rollup/plugin-node-resolve": "^16.0.3",
27
27
  "@rollup/plugin-terser": "^0.4.4",
28
28
  "@rollup/plugin-typescript": "^12.3.0",
29
- "@types/node": "^25.0.10",
30
- "markdown-it-replace-link": "^1.2.2",
29
+ "@types/node": "^25.3.0",
31
30
  "restmix": "^0.6.1",
32
- "rollup": "^4.56.0",
31
+ "rollup": "^4.59.0",
33
32
  "tslib": "^2.8.1",
34
- "typedoc": "^0.28.16",
35
- "typedoc-plugin-markdown": "^4.9.0",
36
- "typedoc-plugin-rename-defaults": "^0.7.3",
37
33
  "typescript": "^5.9.3"
38
34
  },
39
35
  "files": [