@agent-smith/cli 0.0.84 → 0.0.86

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,5 +1,4 @@
1
1
  import { Agent } from "@agent-smith/agent";
2
- import { useTemplateForModel } from "@agent-smith/tfm";
3
2
  import { input } from "@inquirer/prompts";
4
3
  import { compile, serializeGrammar } from "@intrinsicai/gbnfgen";
5
4
  import { default as color, default as colors } from "ansi-colors";
@@ -15,7 +14,6 @@ import { parseCommandArgs } from "../options_parsers.js";
15
14
  import { runtimeDataError, runtimeWarning } from "../user_msgs.js";
16
15
  import { formatStats, processOutput, readPromptFile } from "../utils.js";
17
16
  import { readTask } from "./read.js";
18
- const tfm = useTemplateForModel();
19
17
  async function executeTask(name, payload, options, quiet) {
20
18
  const agent = new Agent(backend.value);
21
19
  if (options?.debug) {
@@ -35,14 +33,7 @@ async function executeTask(name, payload, options, quiet) {
35
33
  let hasThink = false;
36
34
  let tpl = null;
37
35
  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);
36
+ tpl = new PromptTemplate(model.template ?? "none");
46
37
  hasThink = tpl.tags?.think ? true : false;
47
38
  }
48
39
  const printToken = (t) => {
@@ -143,6 +134,9 @@ async function executeTask(name, payload, options, quiet) {
143
134
  conf.inferParams = {};
144
135
  }
145
136
  conf.inferParams.stream = true;
137
+ if (conf?.model) {
138
+ delete conf.model;
139
+ }
146
140
  const tconf = {
147
141
  model: model,
148
142
  onToolCall: onToolCall,
@@ -1,5 +1,12 @@
1
1
  import { useTemplateForModel } from "@agent-smith/tfm";
2
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
+ }
3
10
  function configureTaskModel(itConf, taskSpec) {
4
11
  let ip = itConf.inferParams;
5
12
  let isModelFromTaskFile = false;
@@ -10,10 +17,22 @@ function configureTaskModel(itConf, taskSpec) {
10
17
  model.template = itConf.templateName;
11
18
  foundTemplate = true;
12
19
  }
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
+ }
26
+ }
13
27
  else if (taskSpec?.model?.template) {
14
28
  model.template = taskSpec.model.template;
15
29
  foundTemplate = true;
16
30
  }
31
+ else {
32
+ const gt = guessTemplate(taskSpec.model.name);
33
+ model.template = gt;
34
+ foundTemplate = true;
35
+ }
17
36
  if (itConf?.model?.name) {
18
37
  if (taskSpec?.models && Object.keys(taskSpec.models).includes(itConf.model.name)) {
19
38
  for (const [k, v] of Object.entries(taskSpec.models)) {
@@ -37,6 +56,10 @@ function configureTaskModel(itConf, taskSpec) {
37
56
  }
38
57
  }
39
58
  }
59
+ else {
60
+ model.name = itConf.model.name;
61
+ foundModel = true;
62
+ }
40
63
  }
41
64
  else {
42
65
  model = taskSpec.model;
package/dist/main.d.ts CHANGED
@@ -3,7 +3,7 @@ import { executeTask } from "./cmd/lib/tasks/cmd.js";
3
3
  import { executeAction } from "./cmd/lib/actions/cmd.js";
4
4
  import { executeWorkflow } from "./cmd/lib/workflows/cmd.js";
5
5
  import { writeToClipboard } from "./cmd/sys/clipboard.js";
6
- import { initState, pluginDataDir } from "./state/state.js";
6
+ import { initState, pluginDataDir, init } from "./state/state.js";
7
7
  import { usePerfTimer } from "./utils/perf.js";
8
8
  import { parseCommandArgs } from "./cmd/lib/options_parsers.js";
9
9
  import { extractToolDoc } from "./cmd/lib/tools.js";
@@ -13,4 +13,4 @@ import { displayOptions, ioOptions, inferenceOptions, allOptions } from "./cmd/o
13
13
  import { McpClient } from "./cmd/lib/mcp.js";
14
14
  import { readTask } from "./cmd/lib/tasks/read.js";
15
15
  import { FeatureType } from "./interfaces.js";
16
- export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initState, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, McpClient, readTask, FeatureType, };
16
+ export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initState, init, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, McpClient, readTask, FeatureType, };
package/dist/main.js CHANGED
@@ -3,7 +3,7 @@ import { executeTask } from "./cmd/lib/tasks/cmd.js";
3
3
  import { executeAction } from "./cmd/lib/actions/cmd.js";
4
4
  import { executeWorkflow } from "./cmd/lib/workflows/cmd.js";
5
5
  import { writeToClipboard } from "./cmd/sys/clipboard.js";
6
- import { initState, pluginDataDir } from "./state/state.js";
6
+ import { initState, pluginDataDir, init } from "./state/state.js";
7
7
  import { usePerfTimer } from "./utils/perf.js";
8
8
  import { parseCommandArgs } from "./cmd/lib/options_parsers.js";
9
9
  import { extractToolDoc } from "./cmd/lib/tools.js";
@@ -12,4 +12,4 @@ import { extractBetweenTags, splitThinking } from "./utils/text.js";
12
12
  import { displayOptions, ioOptions, inferenceOptions, allOptions } from "./cmd/options.js";
13
13
  import { McpClient } from "./cmd/lib/mcp.js";
14
14
  import { readTask } from "./cmd/lib/tasks/read.js";
15
- export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initState, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, McpClient, readTask, };
15
+ export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initState, init, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, McpClient, readTask, };
@@ -14,6 +14,7 @@ declare const lastCmd: {
14
14
  args: Array<string>;
15
15
  };
16
16
  declare function initFilepaths(): void;
17
+ declare function init(): Promise<void>;
17
18
  declare function initState(): Promise<void>;
18
19
  declare function pluginDataDir(pluginName: string): string;
19
- export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, pyShell, };
20
+ export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, init, pyShell, };
@@ -3,6 +3,7 @@ import { initDb } from "../db/db.js";
3
3
  import { readFilePaths } from "../db/read.js";
4
4
  import path from "path";
5
5
  import { createDirectoryIfNotExists } from "../cmd/sys/dirs.js";
6
+ import { initBackends } from "./backends.js";
6
7
  let pyShell;
7
8
  const inputMode = ref("manual");
8
9
  const outputMode = ref("txt");
@@ -28,6 +29,10 @@ function initFilepaths() {
28
29
  }
29
30
  }
30
31
  }
32
+ async function init() {
33
+ await initState();
34
+ await initBackends();
35
+ }
31
36
  async function initState() {
32
37
  if (isStateReady.value) {
33
38
  return;
@@ -48,4 +53,4 @@ function pluginDataDir(pluginName) {
48
53
  createDirectoryIfNotExists(pluginDatapath);
49
54
  return pluginDatapath;
50
55
  }
51
- export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, pyShell, };
56
+ export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, init, pyShell, };
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.84",
5
+ "version": "0.0.86",
6
6
  "scripts": {
7
7
  "buildrl": "rm -rf dist/* && rollup -c",
8
8
  "build": "rm -rf dist/* && tsc",