@agent-smith/cli 0.0.44 → 0.0.46

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.
Files changed (38) hide show
  1. package/dist/cmd/clicmds/cmds.js +10 -5
  2. package/dist/cmd/lib/actions/cmd.js +3 -1
  3. package/dist/cmd/lib/models.d.ts +2 -0
  4. package/dist/cmd/lib/models.js +35 -0
  5. package/dist/cmd/lib/tasks/cmd.d.ts +2 -2
  6. package/dist/cmd/lib/tasks/cmd.js +41 -68
  7. package/dist/cmd/lib/tasks/conf.d.ts +7 -0
  8. package/dist/cmd/lib/tasks/conf.js +150 -0
  9. package/dist/cmd/lib/utils.d.ts +1 -12
  10. package/dist/cmd/lib/utils.js +5 -167
  11. package/dist/cmd/sys/dirs.d.ts +2 -0
  12. package/dist/cmd/sys/dirs.js +9 -0
  13. package/dist/cmd/sys/read_cmds.js +3 -0
  14. package/dist/cmd/sys/read_features.js +2 -2
  15. package/dist/cmd/sys/read_modelfile.d.ts +8 -0
  16. package/dist/cmd/sys/{read_models.js → read_modelfile.js} +3 -3
  17. package/dist/conf.d.ts +1 -0
  18. package/dist/conf.js +6 -2
  19. package/dist/db/read.d.ts +12 -3
  20. package/dist/db/read.js +39 -9
  21. package/dist/db/schemas.js +8 -1
  22. package/dist/db/write.d.ts +4 -2
  23. package/dist/db/write.js +31 -2
  24. package/dist/interfaces.d.ts +41 -6
  25. package/dist/main.d.ts +6 -2
  26. package/dist/main.js +5 -2
  27. package/dist/primitives/args.d.ts +5 -0
  28. package/dist/primitives/args.js +40 -0
  29. package/dist/primitives/perf.d.ts +7 -0
  30. package/dist/primitives/perf.js +38 -0
  31. package/dist/state/chat.d.ts +2 -0
  32. package/dist/state/features.js +2 -2
  33. package/dist/state/state.d.ts +3 -1
  34. package/dist/state/state.js +29 -3
  35. package/package.json +10 -10
  36. package/dist/cmd/sys/read_models.d.ts +0 -7
  37. /package/dist/cmd/sys/{reset.d.ts → delete_file.d.ts} +0 -0
  38. /package/dist/cmd/sys/{reset.js → delete_file.js} +0 -0
@@ -1,10 +1,10 @@
1
1
  import { default as fs } from "fs";
2
2
  import YAML from 'yaml';
3
- function readModelsFile(dir) {
4
- if (!fs.existsSync(dir)) {
3
+ function readModelsFile(fp) {
4
+ if (!fs.existsSync(fp)) {
5
5
  return { models: {}, ctx: 0, max_tokens: 0, found: false };
6
6
  }
7
- const data = fs.readFileSync(dir, 'utf8');
7
+ const data = fs.readFileSync(fp, 'utf8');
8
8
  const m = YAML.parse(data);
9
9
  if (!m?.ctx) {
10
10
  throw new Error(`provide a ctx param in models file`);
package/dist/conf.d.ts CHANGED
@@ -4,5 +4,6 @@ declare function createConfDirIfNotExists(): boolean;
4
4
  declare function processConfPath(confPath: string): Promise<{
5
5
  paths: Array<string>;
6
6
  pf: string;
7
+ dd: string;
7
8
  }>;
8
9
  export { confDir, dbPath, createConfDirIfNotExists, processConfPath, };
package/dist/conf.js CHANGED
@@ -36,9 +36,13 @@ async function processConfPath(confPath) {
36
36
  });
37
37
  }
38
38
  let pf = "";
39
- if (data.promptfile) {
39
+ if (data?.promptfile) {
40
40
  pf = data.promptfile;
41
41
  }
42
- return { paths: allPaths, pf: pf };
42
+ let dd = "";
43
+ if (data?.datadir) {
44
+ dd = data.datadir;
45
+ }
46
+ return { paths: allPaths, pf: pf, dd: dd };
43
47
  }
44
48
  export { confDir, dbPath, createConfDirIfNotExists, processConfPath, };
package/dist/db/read.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ToolSpec } from "modprompt";
2
- import { AliasType, FeatureSpec, FeatureType, ToolType } from "../interfaces.js";
2
+ import { AliasType, FeatureSpec, FeatureType, DbModelDef, ToolType } from "../interfaces.js";
3
3
  declare function readFeaturePaths(): Array<string>;
4
4
  declare function readPlugins(): Array<Record<string, string>>;
5
5
  declare function readFeatures(): Record<FeatureType, Record<string, string>>;
@@ -16,5 +16,14 @@ declare function readTool(name: string): {
16
16
  tool: ToolSpec;
17
17
  type: ToolType;
18
18
  };
19
- declare function readPromptFilePath(): string;
20
- export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readPromptFilePath, readTool, };
19
+ declare function readFilePaths(): Array<{
20
+ name: string;
21
+ path: string;
22
+ }>;
23
+ declare function readModelfiles(): Array<Record<string, string>>;
24
+ declare function readModels(): Array<DbModelDef>;
25
+ declare function readModel(shortname: string): {
26
+ found: boolean;
27
+ modelData: Record<string, any>;
28
+ };
29
+ export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readFilePaths, readTool, readModels, readModelfiles, readModel, };
package/dist/db/read.js CHANGED
@@ -27,13 +27,15 @@ function _readFeaturesType(type) {
27
27
  return f;
28
28
  }
29
29
  function readFeatures() {
30
- const feats = { task: {}, action: {}, cmd: {}, workflow: {}, adaptater: {}, modelset: {} };
30
+ const feats = {
31
+ task: {}, action: {}, cmd: {}, workflow: {}, adaptater: {}, modelfile: {}
32
+ };
31
33
  feats.task = _readFeaturesType("task");
32
34
  feats.action = _readFeaturesType("action");
33
35
  feats.cmd = _readFeaturesType("cmd");
34
36
  feats.workflow = _readFeaturesType("workflow");
35
37
  feats.adaptater = _readFeaturesType("adaptater");
36
- feats.modelset = _readFeaturesType("modelset");
38
+ feats.modelfile = _readFeaturesType("modelfile");
37
39
  return feats;
38
40
  }
39
41
  function readAliases() {
@@ -76,13 +78,41 @@ function readTool(name) {
76
78
  }
77
79
  return { found: false, tool: {}, type: "action" };
78
80
  }
79
- function readPromptFilePath() {
80
- const stmt1 = db.prepare("SELECT * FROM filepath WHERE name = ?");
81
- const result = stmt1.get("promptfile");
82
- let res = "";
81
+ function readFilePaths() {
82
+ const stmt1 = db.prepare("SELECT name, path FROM filepath");
83
+ const data = stmt1.all();
84
+ let f = new Array();
85
+ data.forEach((row) => {
86
+ f.push({ name: row.name, path: row.path });
87
+ });
88
+ return f;
89
+ }
90
+ function readModelfiles() {
91
+ const stmt = db.prepare("SELECT name, path, ext FROM modelfile");
92
+ const data = stmt.all();
93
+ let f = new Array();
94
+ data.forEach((row) => {
95
+ f.push(row);
96
+ });
97
+ return f;
98
+ }
99
+ function readModels() {
100
+ const stmt = db.prepare("SELECT name, shortname, data FROM model");
101
+ const data = stmt.all();
102
+ let f = new Array();
103
+ data.forEach((row) => {
104
+ f.push(row);
105
+ });
106
+ return f;
107
+ }
108
+ function readModel(shortname) {
109
+ const q = `SELECT id, data FROM model WHERE shortname='${shortname}'`;
110
+ const stmt = db.prepare(q);
111
+ const result = stmt.get();
83
112
  if (result?.id) {
84
- res = result.path;
113
+ const data = JSON.parse(result.data);
114
+ return { found: true, modelData: data };
85
115
  }
86
- return res;
116
+ return { found: false, modelData: {} };
87
117
  }
88
- export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readPromptFilePath, readTool, };
118
+ export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readFilePaths, readTool, readModels, readModelfiles, readModel, };
@@ -53,12 +53,18 @@ const alias = `CREATE TABLE IF NOT EXISTS aliases (
53
53
  name TEXT UNIQUE NOT NULL,
54
54
  type TEXT NOT NULL CHECK ( type IN ('task', 'action', 'workflow') )
55
55
  );`;
56
- const model = `CREATE TABLE IF NOT EXISTS modelset (
56
+ const modelfile = `CREATE TABLE IF NOT EXISTS modelfile (
57
57
  id INTEGER PRIMARY KEY AUTOINCREMENT,
58
58
  name TEXT UNIQUE NOT NULL,
59
59
  path TEXT NOT NULL,
60
60
  ext TEXT NOT NULL CHECK ( ext IN ('yml') )
61
61
  );`;
62
+ const model = `CREATE TABLE IF NOT EXISTS model (
63
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
64
+ name TEXT UNIQUE NOT NULL,
65
+ shortname TEXT UNIQUE NOT NULL,
66
+ data TEXT NOT NULL
67
+ );`;
62
68
  const schemas = [
63
69
  filepath,
64
70
  featurespath,
@@ -70,6 +76,7 @@ const schemas = [
70
76
  plugin,
71
77
  alias,
72
78
  model,
79
+ modelfile,
73
80
  adaptater,
74
81
  ];
75
82
  export { schemas };
@@ -1,8 +1,10 @@
1
- import { Features } from "../interfaces.js";
1
+ import { Features, DbModelDef } from "../interfaces.js";
2
2
  declare function updatePromptfilePath(pf: string): void;
3
+ declare function updateDataDirPath(dd: string): void;
3
4
  declare function insertFeaturesPathIfNotExists(path: string): boolean;
4
5
  declare function insertPluginIfNotExists(n: string, p: string): boolean;
5
6
  declare function cleanupFeaturePaths(paths: Array<string>): Array<string>;
6
7
  declare function updateAliases(feats: Features): void;
8
+ declare function upsertModels(models: Array<DbModelDef>): void;
7
9
  declare function updateFeatures(feats: Features): void;
8
- export { updatePromptfilePath, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, };
10
+ export { updatePromptfilePath, updateDataDirPath, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, upsertModels, };
package/dist/db/write.js CHANGED
@@ -6,6 +6,12 @@ function updatePromptfilePath(pf) {
6
6
  const stmt = db.prepare("INSERT INTO filepath (name, path) VALUES (?, ?)");
7
7
  stmt.run("promptfile", pf);
8
8
  }
9
+ function updateDataDirPath(dd) {
10
+ const deleteStmt = db.prepare("DELETE FROM filepath WHERE name = ?");
11
+ deleteStmt.run("datadir");
12
+ const stmt = db.prepare("INSERT INTO filepath (name, path) VALUES (?, ?)");
13
+ stmt.run("datadir", dd);
14
+ }
9
15
  function insertFeaturesPathIfNotExists(path) {
10
16
  const stmt1 = db.prepare("SELECT * FROM featurespath WHERE path = ?");
11
17
  const result = stmt1.get(path);
@@ -104,6 +110,29 @@ function upsertTool(name, type, toolDoc) {
104
110
  stmt.run(name, toolDoc, type);
105
111
  console.log("+", "[tool] from", type, ":", name);
106
112
  }
113
+ function upsertModels(models) {
114
+ const stmt1 = db.prepare("SELECT shortname FROM model");
115
+ const rows = stmt1.all();
116
+ const existingModelShortNames = rows.map(row => row.shortname);
117
+ const stmt = db.prepare(`INSERT INTO model (name, shortname, data) VALUES (?,?,?)`);
118
+ existingModelShortNames.forEach((name) => {
119
+ if (!existingModelShortNames.includes(name)) {
120
+ const deleteStmt = db.prepare("DELETE FROM model WHERE name = ?");
121
+ deleteStmt.run(name);
122
+ console.log("-", "[model]", name);
123
+ }
124
+ });
125
+ db.transaction(() => {
126
+ for (const model of models) {
127
+ const stmt1 = db.prepare("SELECT * FROM model WHERE shortname = ?");
128
+ const result = stmt1.get(model.shortname);
129
+ if (result?.id) {
130
+ continue;
131
+ }
132
+ stmt.run(model.name, model.shortname, JSON.stringify(model.data));
133
+ }
134
+ })();
135
+ }
107
136
  function updateFeatures(feats) {
108
137
  upsertAndCleanFeatures(feats.task, "task");
109
138
  const newActions = upsertAndCleanFeatures(feats.action, "action");
@@ -118,6 +147,6 @@ function updateFeatures(feats) {
118
147
  upsertAndCleanFeatures(feats.cmd, "cmd");
119
148
  upsertAndCleanFeatures(feats.workflow, "workflow");
120
149
  upsertAndCleanFeatures(feats.adaptater, "adaptater");
121
- upsertAndCleanFeatures(feats.modelset, "modelset");
150
+ upsertAndCleanFeatures(feats.modelfile, "modelfile");
122
151
  }
123
- export { updatePromptfilePath, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, };
152
+ export { updatePromptfilePath, updateDataDirPath, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, upsertModels, };
@@ -1,9 +1,12 @@
1
+ import { BaseLmTask, ModelSpec } from "@agent-smith/lmtask";
2
+ import { InferenceParams } from "@locallm/types";
1
3
  interface Cmd {
2
4
  cmd: CmdExecutor;
3
5
  description: string;
4
6
  args?: string;
5
7
  }
6
8
  interface FeatureSpec {
9
+ id?: number;
7
10
  name: string;
8
11
  path: string;
9
12
  ext: FeatureExtension;
@@ -34,14 +37,15 @@ interface Features {
34
37
  path: string;
35
38
  ext: AdaptaterExtension;
36
39
  }>;
37
- modelset: Array<{
40
+ modelfile: Array<{
38
41
  name: string;
39
42
  path: string;
40
- ext: ModelsetExtension;
43
+ ext: ModelFileExtension;
41
44
  }>;
42
45
  }
43
46
  interface ConfigFile {
44
47
  promptfile?: string;
48
+ datadir?: string;
45
49
  features?: Array<string>;
46
50
  plugins?: Array<string>;
47
51
  }
@@ -56,19 +60,50 @@ interface Settings {
56
60
  isverbose: boolean;
57
61
  promptfile: string;
58
62
  }
63
+ interface DbModelDef {
64
+ id?: number;
65
+ name: string;
66
+ shortname: string;
67
+ data: Record<string, any>;
68
+ }
69
+ interface ModelfileSpec {
70
+ ctx: number;
71
+ max_tokens: number;
72
+ models: Array<ModelSpec>;
73
+ }
74
+ interface ModelPack {
75
+ default: string;
76
+ recommended?: Array<string>;
77
+ }
78
+ interface LmTaskFileSpec extends BaseLmTask {
79
+ ctx: number;
80
+ model?: ModelSpec;
81
+ modelpack?: ModelPack;
82
+ }
83
+ interface BaseLmTaskConfig {
84
+ templateName: string;
85
+ inferParams: InferenceParams;
86
+ }
87
+ interface LmTaskConfig extends BaseLmTaskConfig {
88
+ modelname?: string;
89
+ }
90
+ interface FinalLmTaskConfig {
91
+ model?: ModelSpec;
92
+ modelname?: string;
93
+ }
59
94
  type CmdExecutor = (args: Array<string>, options: any) => Promise<any>;
60
95
  type InputMode = "manual" | "promptfile" | "clipboard";
61
96
  type OutputMode = "txt" | "clipboard";
62
97
  type RunMode = "cli" | "cmd";
63
98
  type FormatMode = "text" | "markdown";
64
- type FeatureType = "task" | "action" | "cmd" | "workflow" | "adaptater" | "modelset";
99
+ type FeatureType = "task" | "action" | "cmd" | "workflow" | "adaptater" | "modelfile";
65
100
  type ToolType = "task" | "action" | "cmd" | "workflow";
66
101
  type ActionExtension = "js" | "mjs" | "py" | "yml";
67
102
  type TaskExtension = "yml";
68
103
  type AdaptaterExtension = "js";
69
104
  type WorkflowExtension = "yml";
70
105
  type CmdExtension = "js";
71
- type ModelsetExtension = "yml";
72
- type FeatureExtension = TaskExtension | CmdExtension | ActionExtension | WorkflowExtension;
106
+ type ModelFileExtension = "yml";
107
+ type FeatureExtension = TaskExtension | CmdExtension | ActionExtension | WorkflowExtension | ModelFileExtension;
73
108
  type AliasType = "task" | "action" | "workflow";
74
- export { Cmd, CmdExecutor, InputMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, WorkflowExtension, AdaptaterExtension, CmdExtension, ModelsetExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, AliasType, ToolType, Settings, };
109
+ export { Cmd, CmdExecutor, InputMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, WorkflowExtension, AdaptaterExtension, CmdExtension, ModelFileExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, AliasType, ToolType, Settings, DbModelDef, ModelSpec, ModelfileSpec, ModelPack, LmTaskFileSpec, LmTaskConfig, FinalLmTaskConfig, };
package/dist/main.d.ts CHANGED
@@ -5,5 +5,9 @@ import { executeWorkflowCmd } from "./cmd/lib/workflows/cmd.js";
5
5
  import { writeToClipboard } from "./cmd/sys/clipboard.js";
6
6
  import { pingCmd } from "./cmd/clicmds/cmds.js";
7
7
  import { initAgent } from "./agent.js";
8
- import { initState } from "./state/state.js";
9
- export { execute, run, pingCmd, executeWorkflowCmd, executeActionCmd, executeTaskCmd, writeToClipboard, initAgent, initState, };
8
+ import { initState, pluginDataDir } from "./state/state.js";
9
+ import { usePerfTimer } from "./primitives/perf.js";
10
+ import { parseInferenceArgs } from "./primitives/args.js";
11
+ import { parseTaskVars } from "./cmd/lib/tasks/conf.js";
12
+ import { LmTaskConf } from "@agent-smith/lmtask/dist/interfaces.js";
13
+ export { execute, run, pingCmd, executeWorkflowCmd, executeActionCmd, executeTaskCmd, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseInferenceArgs, parseTaskVars, LmTaskConf, };
package/dist/main.js CHANGED
@@ -5,5 +5,8 @@ import { executeWorkflowCmd } from "./cmd/lib/workflows/cmd.js";
5
5
  import { writeToClipboard } from "./cmd/sys/clipboard.js";
6
6
  import { pingCmd } from "./cmd/clicmds/cmds.js";
7
7
  import { initAgent } from "./agent.js";
8
- import { initState } from "./state/state.js";
9
- export { execute, run, pingCmd, executeWorkflowCmd, executeActionCmd, executeTaskCmd, writeToClipboard, initAgent, initState, };
8
+ import { initState, pluginDataDir } from "./state/state.js";
9
+ import { usePerfTimer } from "./primitives/perf.js";
10
+ import { parseInferenceArgs } from "./primitives/args.js";
11
+ import { parseTaskVars } from "./cmd/lib/tasks/conf.js";
12
+ export { execute, run, pingCmd, executeWorkflowCmd, executeActionCmd, executeTaskCmd, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseInferenceArgs, parseTaskVars, };
@@ -0,0 +1,5 @@
1
+ declare function parseInferenceArgs(args: Array<string>): {
2
+ inferenceVars: Record<string, any>;
3
+ currentArgs: Array<string>;
4
+ };
5
+ export { parseInferenceArgs, };
@@ -0,0 +1,40 @@
1
+ function parseInferenceArgs(args) {
2
+ const vars = {};
3
+ const nargs = new Array();
4
+ args.forEach((a) => {
5
+ if (a.includes("=")) {
6
+ const t = a.split("=");
7
+ const k = t[0];
8
+ const v = t[1];
9
+ switch (k) {
10
+ case "m":
11
+ if (v.includes("/")) {
12
+ const _s = v.split("/");
13
+ vars.model = _s[0];
14
+ vars.template = _s[1];
15
+ }
16
+ else {
17
+ vars.model = v;
18
+ }
19
+ break;
20
+ case "ip":
21
+ v.split(",").forEach((p) => {
22
+ const s = p.split(":");
23
+ vars["inferParams"][s[0]] = parseFloat(s[1]);
24
+ });
25
+ break;
26
+ case "s":
27
+ vars.size = v;
28
+ break;
29
+ default:
30
+ vars[k] = v;
31
+ break;
32
+ }
33
+ }
34
+ else {
35
+ nargs.push(a);
36
+ }
37
+ });
38
+ return { inferenceVars: vars, currentArgs: nargs };
39
+ }
40
+ export { parseInferenceArgs, };
@@ -0,0 +1,7 @@
1
+ declare const usePerfTimer: (startTimer?: boolean) => {
2
+ start: () => number;
3
+ time: () => string | number;
4
+ timeRaw: () => string | number;
5
+ printTime: () => void;
6
+ };
7
+ export { usePerfTimer };
@@ -0,0 +1,38 @@
1
+ const usePerfTimer = (startTimer = true) => {
2
+ let _startTime;
3
+ if (startTimer) {
4
+ _startTime = performance.now();
5
+ }
6
+ const start = () => _startTime = performance.now();
7
+ const _end = (raw) => {
8
+ if (!_startTime) {
9
+ throw new Error("the timer has not started, can not end it");
10
+ }
11
+ const endTime = performance.now();
12
+ const duration = endTime - _startTime;
13
+ if (raw) {
14
+ return duration;
15
+ }
16
+ const humanizedTime = _formatDuration(duration);
17
+ return humanizedTime;
18
+ };
19
+ const time = () => _end(false);
20
+ const printTime = () => console.log(_end(false));
21
+ const timeRaw = () => _end(true);
22
+ const _formatDuration = (ms) => {
23
+ const seconds = Math.floor(ms / 1000);
24
+ const minutes = Math.floor(seconds / 60);
25
+ if (ms < 1000)
26
+ return `${ms.toFixed(2)}ms`;
27
+ if (seconds < 60)
28
+ return `${seconds.toFixed(2)}s`;
29
+ return `${minutes}m ${seconds % 60}s`;
30
+ };
31
+ return {
32
+ start,
33
+ time,
34
+ timeRaw,
35
+ printTime,
36
+ };
37
+ };
38
+ export { usePerfTimer };
@@ -19,6 +19,8 @@ declare const chatInferenceParams: {
19
19
  tfs?: number | undefined;
20
20
  stop?: Array<string> | undefined;
21
21
  grammar?: string | undefined;
22
+ tsGrammar?: string | undefined;
23
+ schema?: Record<string, any> | undefined;
22
24
  images?: Array<string> | undefined;
23
25
  extra?: Record<string, any> | undefined;
24
26
  };
@@ -8,7 +8,7 @@ function readFeaturesDirs(featuresPaths) {
8
8
  cmd: [],
9
9
  workflow: [],
10
10
  adaptater: [],
11
- modelset: [],
11
+ modelfile: [],
12
12
  };
13
13
  featuresPaths.forEach((dir) => {
14
14
  const _f = readFeaturesDir(dir);
@@ -17,7 +17,7 @@ function readFeaturesDirs(featuresPaths) {
17
17
  _f.cmd.forEach((item) => feats.cmd.push(item));
18
18
  _f.workflow.forEach((item) => feats.workflow.push(item));
19
19
  _f.adaptater.forEach((item) => feats.adaptater.push(item));
20
- _f.modelset.forEach((item) => feats.modelset.push(item));
20
+ _f.modelfile.forEach((item) => feats.modelfile.push(item));
21
21
  });
22
22
  return feats;
23
23
  }
@@ -10,10 +10,12 @@ declare const isDebug: import("@vue/reactivity").Ref<boolean, boolean>;
10
10
  declare const isVerbose: import("@vue/reactivity").Ref<boolean, boolean>;
11
11
  declare const isShowTokens: import("@vue/reactivity").Ref<boolean, boolean>;
12
12
  declare const promptfilePath: import("@vue/reactivity").Ref<string, string>;
13
+ declare const dataDirPath: import("@vue/reactivity").Ref<string, string>;
13
14
  declare const lastCmd: {
14
15
  name: string;
15
16
  args: Array<string>;
16
17
  };
17
18
  declare function initFeatures(): Promise<void>;
18
19
  declare function initState(): Promise<void>;
19
- export { inputMode, outputMode, isChatMode, isShowTokens, runMode, formatMode, lastCmd, isDebug, isVerbose, promptfilePath, initState, initFeatures, pyShell, };
20
+ declare function pluginDataDir(pluginName: string): string;
21
+ export { inputMode, outputMode, isChatMode, isShowTokens, runMode, formatMode, lastCmd, isDebug, isVerbose, promptfilePath, dataDirPath, pluginDataDir, initState, initFeatures, pyShell, };
@@ -1,10 +1,13 @@
1
1
  import { reactive, ref } from "@vue/reactivity";
2
2
  import { createConfDirIfNotExists, confDir } from "../conf.js";
3
3
  import { initDb } from "../db/db.js";
4
- import { readFeaturePaths, readPromptFilePath } from "../db/read.js";
4
+ import { readFeaturePaths, readFilePaths } from "../db/read.js";
5
5
  import { updateAliases, updateFeatures } from "../db/write.js";
6
6
  import { readFeaturesDirs } from "./features.js";
7
7
  import { readPluginsPaths } from "./plugins.js";
8
+ import path from "path";
9
+ import { createDirectoryIfNotExists } from "../cmd/sys/dirs.js";
10
+ import { updateModels } from "../cmd/lib/models.js";
8
11
  let pyShell;
9
12
  const inputMode = ref("manual");
10
13
  const outputMode = ref("txt");
@@ -15,6 +18,7 @@ const isDebug = ref(false);
15
18
  const isVerbose = ref(false);
16
19
  const isShowTokens = ref(false);
17
20
  const promptfilePath = ref("");
21
+ const dataDirPath = ref("");
18
22
  const isStateReady = ref(false);
19
23
  const lastCmd = reactive({
20
24
  name: "",
@@ -34,7 +38,17 @@ async function initFeatures() {
34
38
  const feats = readFeaturesDirs(p);
35
39
  updateFeatures(feats);
36
40
  updateAliases(feats);
37
- promptfilePath.value = readPromptFilePath();
41
+ updateModels();
42
+ const filePaths = readFilePaths();
43
+ for (const fp of filePaths) {
44
+ switch (fp.name) {
45
+ case "promptfile":
46
+ promptfilePath.value = fp.path;
47
+ break;
48
+ case "datadir":
49
+ dataDirPath.value = fp.path;
50
+ }
51
+ }
38
52
  }
39
53
  async function initState() {
40
54
  if (isStateReady.value) {
@@ -44,4 +58,16 @@ async function initState() {
44
58
  await initFeatures();
45
59
  isStateReady.value = true;
46
60
  }
47
- export { inputMode, outputMode, isChatMode, isShowTokens, runMode, formatMode, lastCmd, isDebug, isVerbose, promptfilePath, initState, initFeatures, pyShell, };
61
+ function _getDataDirPath() {
62
+ if (dataDirPath.value.length == 0) {
63
+ throw new Error("datadir path is not configured: update your config file with 'datadir' and run conf");
64
+ }
65
+ return dataDirPath.value;
66
+ }
67
+ function pluginDataDir(pluginName) {
68
+ const dd = _getDataDirPath();
69
+ const pluginDatapath = path.join(dd, pluginName);
70
+ createDirectoryIfNotExists(pluginDatapath);
71
+ return pluginDatapath;
72
+ }
73
+ export { inputMode, outputMode, isChatMode, isShowTokens, runMode, formatMode, lastCmd, isDebug, isVerbose, promptfilePath, dataDirPath, pluginDataDir, initState, initFeatures, 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.44",
5
+ "version": "0.0.46",
6
6
  "scripts": {
7
7
  "buildrl": "rm -rf dist/* && rollup -c",
8
8
  "build": "rm -rf dist/* && tsc",
@@ -10,12 +10,12 @@
10
10
  "watch": "tsc --noCheck -p . -w"
11
11
  },
12
12
  "dependencies": {
13
- "@agent-smith/brain": "^0.0.41",
13
+ "@agent-smith/brain": "^0.0.42",
14
14
  "@agent-smith/jobs": "^0.0.14",
15
- "@agent-smith/lmtask": "^0.0.35",
15
+ "@agent-smith/lmtask": "^0.0.37",
16
16
  "@agent-smith/tfm": "^0.1.2",
17
- "@inquirer/prompts": "^7.4.0",
18
- "@inquirer/select": "^4.1.0",
17
+ "@inquirer/prompts": "^7.4.1",
18
+ "@inquirer/select": "^4.1.1",
19
19
  "@vue/reactivity": "^3.5.13",
20
20
  "@wllama/wllama": "^2.3.0",
21
21
  "better-sqlite3": "^11.9.1",
@@ -29,17 +29,17 @@
29
29
  "devDependencies": {
30
30
  "@agent-smith/tmem-jobs": "^0.0.4",
31
31
  "@commander-js/extra-typings": "^13.1.0",
32
- "@locallm/types": "^0.1.6",
32
+ "@locallm/types": "^0.1.9",
33
33
  "@rollup/plugin-node-resolve": "^16.0.1",
34
34
  "@rollup/plugin-typescript": "^12.1.2",
35
- "@types/better-sqlite3": "^7.6.12",
35
+ "@types/better-sqlite3": "^7.6.13",
36
36
  "@types/marked-terminal": "^6.1.1",
37
- "@types/node": "^22.13.14",
37
+ "@types/node": "^22.14.0",
38
38
  "restmix": "^0.5.0",
39
- "rollup": "^4.38.0",
39
+ "rollup": "^4.39.0",
40
40
  "ts-node": "^10.9.2",
41
41
  "tslib": "2.8.1",
42
- "typescript": "^5.8.2"
42
+ "typescript": "^5.8.3"
43
43
  },
44
44
  "type": "module",
45
45
  "preferGlobal": true,
@@ -1,7 +0,0 @@
1
- declare function readModelsFile(dir: string): {
2
- found: boolean;
3
- ctx: number;
4
- max_tokens: number;
5
- models: Record<string, any>;
6
- };
7
- export { readModelsFile, };
File without changes
File without changes