@agent-smith/cli 0.0.83 → 0.0.85

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.
@@ -9,7 +9,7 @@ function parseCommandArgs(args) {
9
9
  return res;
10
10
  }
11
11
  function parseTaskConfigOptions(options) {
12
- const conf = { inferParams: {}, modelname: "", templateName: "" };
12
+ const conf = { inferParams: {}, templateName: "" };
13
13
  const optionsInferParams = {};
14
14
  if (options?.temperature) {
15
15
  optionsInferParams.temperature = options.temperature;
@@ -33,7 +33,10 @@ function parseTaskConfigOptions(options) {
33
33
  optionsInferParams.images = options.images;
34
34
  }
35
35
  if (options?.model !== undefined) {
36
- conf.modelname = options.model;
36
+ if (!conf?.model) {
37
+ conf.model = { name: "" };
38
+ }
39
+ conf.model.name = options.model;
37
40
  }
38
41
  if (options?.template !== undefined) {
39
42
  conf.templateName = options.template;
@@ -35,14 +35,7 @@ async function executeTask(name, payload, options, quiet) {
35
35
  let hasThink = false;
36
36
  let tpl = null;
37
37
  if (useTemplates) {
38
- if ((!task.def.model?.template)) {
39
- const gt = tfm.guess(task.def.model.name);
40
- if (gt == "none") {
41
- throw new Error(`Unable to guess the template for ${task.def.model}: please provide a template in the taskDef definition`);
42
- }
43
- task.def.model.template = gt;
44
- }
45
- tpl = new PromptTemplate(task.def.model.template);
38
+ tpl = new PromptTemplate(model.template ?? "none");
46
39
  hasThink = tpl.tags?.think ? true : false;
47
40
  }
48
41
  const printToken = (t) => {
@@ -143,6 +136,9 @@ async function executeTask(name, payload, options, quiet) {
143
136
  conf.inferParams = {};
144
137
  }
145
138
  conf.inferParams.stream = true;
139
+ if (conf?.model) {
140
+ delete conf.model;
141
+ }
146
142
  const tconf = {
147
143
  model: model,
148
144
  onToolCall: onToolCall,
@@ -1,39 +1,42 @@
1
1
  import { useTemplateForModel } from "@agent-smith/tfm";
2
- import { readModel } from "../../../db/read.js";
3
2
  const tfm = useTemplateForModel();
3
+ function guessTemplate(modelname) {
4
+ const gt = tfm.guess(modelname);
5
+ if (gt == "none") {
6
+ throw new Error(`Unable to guess the template for ${modelname}: please provide a template name: --tpl templatename`);
7
+ }
8
+ return gt;
9
+ }
4
10
  function configureTaskModel(itConf, taskSpec) {
5
- let modelName = "";
6
- let templateName = "";
7
11
  let ip = itConf.inferParams;
8
12
  let isModelFromTaskFile = false;
9
- let model = {};
10
- let found = false;
13
+ let model = { template: "", name: "" };
14
+ let foundModel = false;
15
+ let foundTemplate = false;
11
16
  if (itConf?.templateName) {
12
- templateName = itConf.templateName;
17
+ model.template = itConf.templateName;
18
+ foundTemplate = true;
13
19
  }
14
- if (!itConf?.modelname) {
15
- if (taskSpec?.model?.name) {
16
- model = taskSpec.model;
17
- isModelFromTaskFile = true;
18
- found = true;
19
- }
20
- else {
21
- if (!taskSpec?.modelpack?.default) {
22
- throw new Error(`provide a default model or a use a modelpack in the ${taskSpec.name} task yaml file`);
23
- }
24
- modelName = taskSpec.modelpack.default;
20
+ if (itConf?.model?.name) {
21
+ if (itConf?.model?.name != taskSpec.model.name) {
22
+ const gt = guessTemplate(itConf.model.name);
23
+ model.template = gt;
24
+ foundTemplate = true;
25
25
  }
26
26
  }
27
+ else if (taskSpec?.model?.template) {
28
+ model.template = taskSpec.model.template;
29
+ foundTemplate = true;
30
+ }
27
31
  else {
28
- modelName = itConf.modelname;
32
+ const gt = guessTemplate(taskSpec.model.name);
33
+ model.template = gt;
34
+ foundTemplate = true;
29
35
  }
30
- if (!found) {
31
- if (modelName.length == 0) {
32
- throw new Error("no model name defined");
33
- }
34
- if (taskSpec?.models) {
36
+ if (itConf?.model?.name) {
37
+ if (taskSpec?.models && Object.keys(taskSpec.models).includes(itConf.model.name)) {
35
38
  for (const [k, v] of Object.entries(taskSpec.models)) {
36
- if (modelName == k) {
39
+ if (k == itConf.model.name) {
37
40
  model = v;
38
41
  if (v?.inferParams) {
39
42
  const tip = v.inferParams;
@@ -48,42 +51,37 @@ function configureTaskModel(itConf, taskSpec) {
48
51
  model.assistant = v.assistant;
49
52
  }
50
53
  isModelFromTaskFile = true;
51
- found = true;
54
+ foundModel = true;
52
55
  break;
53
56
  }
54
57
  }
55
58
  }
56
- }
57
- if (!found) {
58
- const m = readModel(modelName);
59
- if (m.found) {
60
- model = m.modelData;
61
- model.template = templateName ?? m.modelData.template;
62
- found = true;
59
+ else {
60
+ model.name = itConf.model.name;
61
+ foundModel = true;
63
62
  }
64
63
  }
65
- if (!found) {
66
- if (templateName && modelName) {
67
- model = { name: modelName, template: templateName };
68
- }
69
- else {
70
- const gt = tfm.guess(modelName);
71
- if (gt == "none") {
72
- throw new Error(`Unable to guess the template for ${modelName}: please provide a template name: --tpl templatename`);
73
- }
74
- const m = {
75
- name: modelName,
76
- template: gt
77
- };
78
- model = m;
64
+ else {
65
+ model = taskSpec.model;
66
+ foundModel = true;
67
+ }
68
+ if (!foundModel) {
69
+ throw new Error(`No model found in task`);
70
+ }
71
+ if (!foundTemplate) {
72
+ const gt = tfm.guess(model.name);
73
+ if (gt == "none") {
74
+ throw new Error(`Unable to guess the template for ${model.name}: please provide a template name: --tpl templatename`);
79
75
  }
76
+ model.template = gt;
77
+ foundTemplate = true;
78
+ }
79
+ if (!model?.template) {
80
+ throw new Error(`No template found`);
80
81
  }
81
82
  if (!model?.ctx || !isModelFromTaskFile) {
82
83
  model.ctx = taskSpec.ctx;
83
84
  }
84
- if (templateName.length > 0) {
85
- model.template = templateName;
86
- }
87
85
  return model;
88
86
  }
89
87
  function mergeConfOptions(conf, options) {
@@ -18,6 +18,7 @@ async function readTask(name, payload, options, agent) {
18
18
  const conf = parseTaskConfigOptions(opts);
19
19
  if (options?.debug) {
20
20
  console.log("conf:", conf);
21
+ conf.debug = true;
21
22
  }
22
23
  conf.inferParams = mergeInferParams(conf.inferParams, taskFileSpec.inferParams ?? {});
23
24
  const model = configureTaskModel(conf, taskFileSpec);
@@ -36,10 +36,10 @@ async function executeWorkflow(name, params, options) {
36
36
  try {
37
37
  const ares = await executeAction(name, taskRes, options, true);
38
38
  if (typeof ares == "string") {
39
- taskRes = { args: ares };
39
+ taskRes = { args: ares, ...params };
40
40
  }
41
41
  else {
42
- taskRes = ares;
42
+ taskRes = { ...ares, ...params };
43
43
  }
44
44
  if (i == finalTaskIndex) {
45
45
  console.log(taskRes);
@@ -53,10 +53,10 @@ async function executeWorkflow(name, params, options) {
53
53
  try {
54
54
  const ares = await executeAdaptater(name, taskRes, options);
55
55
  if (typeof ares == "string") {
56
- taskRes = { args: ares };
56
+ taskRes = { args: ares, ...params };
57
57
  }
58
58
  else {
59
- taskRes = ares;
59
+ taskRes = { ...ares, ...params };
60
60
  }
61
61
  if (i == finalTaskIndex) {
62
62
  console.log(taskRes);
@@ -92,9 +92,10 @@ interface LmTaskFileSpec extends TaskDef {
92
92
  interface BaseLmTaskConfig {
93
93
  templateName: string;
94
94
  inferParams: InferenceParams;
95
+ debug?: boolean;
95
96
  }
96
97
  interface LmTaskConfig extends BaseLmTaskConfig {
97
- modelname?: string;
98
+ model?: ModelSpec;
98
99
  quiet?: boolean;
99
100
  }
100
101
  interface FinalLmTaskConfig {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@agent-smith/cli",
3
3
  "description": "Agent Smith: terminal client for language model agents",
4
4
  "repository": "https://github.com/synw/agent-smith",
5
- "version": "0.0.83",
5
+ "version": "0.0.85",
6
6
  "scripts": {
7
7
  "buildrl": "rm -rf dist/* && rollup -c",
8
8
  "build": "rm -rf dist/* && tsc",
@@ -10,20 +10,20 @@
10
10
  "watch": "tsc --noCheck -p . -w"
11
11
  },
12
12
  "dependencies": {
13
- "@agent-smith/agent": "^0.1.1",
14
- "@agent-smith/task": "^0.1.1",
15
- "@agent-smith/tfm": "^0.1.2",
16
- "@inquirer/prompts": "^7.10.0",
13
+ "@agent-smith/agent": "^0.1.3",
14
+ "@agent-smith/task": "^0.1.4",
15
+ "@agent-smith/tfm": "^0.2.0",
16
+ "@inquirer/prompts": "^7.10.1",
17
17
  "@intrinsicai/gbnfgen": "0.12.0",
18
18
  "@locallm/api": "^0.6.2",
19
- "@modelcontextprotocol/sdk": "^1.21.1",
19
+ "@modelcontextprotocol/sdk": "^1.22.0",
20
20
  "@vue/reactivity": "^3.5.24",
21
21
  "ansi-colors": "^4.1.3",
22
22
  "better-sqlite3": "^12.4.1",
23
23
  "clipboardy": "^5.0.0",
24
24
  "commander": "^14.0.2",
25
25
  "marked-terminal": "^7.3.0",
26
- "modprompt": "^0.12.3",
26
+ "modprompt": "^0.12.5",
27
27
  "ora": "^9.0.0",
28
28
  "python-shell": "^5.0.0",
29
29
  "yaml": "^2.8.1"
@@ -32,12 +32,12 @@
32
32
  "@agent-smith/tmem-jobs": "^0.0.4",
33
33
  "@cfworker/json-schema": "^4.1.1",
34
34
  "@commander-js/extra-typings": "^14.0.0",
35
- "@locallm/types": "^0.4.2",
35
+ "@locallm/types": "^0.5.0",
36
36
  "@rollup/plugin-node-resolve": "^16.0.3",
37
37
  "@rollup/plugin-typescript": "^12.3.0",
38
38
  "@types/better-sqlite3": "^7.6.13",
39
39
  "@types/marked-terminal": "^6.1.1",
40
- "@types/node": "^24.10.0",
40
+ "@types/node": "^24.10.1",
41
41
  "restmix": "^0.5.0",
42
42
  "rollup": "^4.53.2",
43
43
  "ts-node": "^10.9.2",