@agent-smith/agent 0.2.0 → 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/dist/agent.d.ts CHANGED
@@ -2,10 +2,11 @@ import { Lm } from "@locallm/api";
2
2
  import { InferenceParams, ToolSpec, HistoryTurn, InferenceOptions, InferenceResult } from "@locallm/types";
3
3
  import { PromptTemplate } from 'modprompt';
4
4
  declare class Agent {
5
+ name: string;
5
6
  lm: Lm;
6
7
  tools: Record<string, ToolSpec>;
7
8
  history: Array<HistoryTurn>;
8
- constructor(lm: Lm);
9
+ constructor(lm: Lm, name?: string);
9
10
  run(prompt: string, params: InferenceParams, options?: InferenceOptions, template?: PromptTemplate | string): Promise<InferenceResult>;
10
11
  runAgentNoTemplate(it: number, prompt: string, params: InferenceParams, options?: InferenceOptions): Promise<InferenceResult>;
11
12
  runAgentWithTemplate(it: number, prompt: string, params: InferenceParams, options: InferenceOptions | undefined, tpl: PromptTemplate): Promise<InferenceResult>;
package/dist/agent.js CHANGED
@@ -1,17 +1,21 @@
1
1
  import { PromptTemplate } from 'modprompt';
2
2
  import { splitThinking } from "./utils.js";
3
3
  class Agent {
4
+ name = "unamed";
4
5
  lm;
5
6
  tools = {};
6
7
  history = [];
7
- constructor(lm) {
8
+ constructor(lm, name) {
8
9
  this.lm = lm;
10
+ if (name) {
11
+ this.name = name;
12
+ }
9
13
  }
10
14
  async run(prompt, params, options = {}, template) {
11
15
  let tpl;
12
16
  if (options?.debug) {
13
- console.log("Agent inference params:", params);
14
- console.log("Agent options:", options);
17
+ console.log("Agent", this.name, "inference params:", params);
18
+ console.log("Agent", this.name, "options:", options);
15
19
  }
16
20
  if (options?.history) {
17
21
  this.history = options.history;
@@ -94,9 +98,6 @@ class Agent {
94
98
  }
95
99
  }
96
100
  this.history.push({ tools: toolsResults });
97
- if (options?.tools) {
98
- options.tools = Object.values(this.tools);
99
- }
100
101
  if (options?.isToolsRouter) {
101
102
  const fres = {
102
103
  text: JSON.stringify(toolsResults.map(tr => tr.response)),
@@ -107,6 +108,9 @@ class Agent {
107
108
  return fres;
108
109
  }
109
110
  const nit = it + 1;
111
+ if (options?.tools) {
112
+ options.tools = Object.values(this.tools);
113
+ }
110
114
  _res = await this.runAgentNoTemplate(nit, "", params, options);
111
115
  }
112
116
  else {
@@ -191,7 +195,7 @@ class Agent {
191
195
  tools: toolResults,
192
196
  });
193
197
  }
194
- if (options?.isToolsRouter) {
198
+ if (options?.isToolsRouter && isToolCall) {
195
199
  const fres = {
196
200
  text: JSON.stringify(toolResults.map(tr => tr.response)),
197
201
  stats: res.stats,
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/synw/agent-smith.git"
7
7
  },
8
- "version": "0.2.0",
8
+ "version": "0.2.1",
9
9
  "scripts": {
10
10
  "buildrl": "rm -rf dist/* && rollup -c",
11
11
  "build": "rm -rf dist/* && tsc"
@@ -19,9 +19,9 @@
19
19
  "@locallm/types": "^0.6.7",
20
20
  "@rollup/plugin-node-resolve": "^16.0.3",
21
21
  "@rollup/plugin-typescript": "^12.3.0",
22
- "@types/node": "^25.0.3",
23
- "openai": "^6.15.0",
24
- "rollup": "^4.54.0",
22
+ "@types/node": "^25.0.8",
23
+ "openai": "^6.16.0",
24
+ "rollup": "^4.55.1",
25
25
  "ts-node": "^10.9.2",
26
26
  "tslib": "2.8.1",
27
27
  "typescript": "^5.9.3"