@agent-smith/cli 0.0.115 → 0.0.118

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 (114) hide show
  1. package/README.md +274 -34
  2. package/dist/cli.js +4 -8
  3. package/dist/cmd/{clicmds/aliases.d.ts → aliases.d.ts} +1 -1
  4. package/dist/cmd/{clicmds/aliases.js → aliases.js} +1 -26
  5. package/dist/cmd/{clicmds/base.js → base.js} +21 -17
  6. package/dist/cmd/build.d.ts +9 -0
  7. package/dist/cmd/build.js +59 -0
  8. package/dist/cmd/callbacks.d.ts +11 -0
  9. package/dist/cmd/callbacks.js +90 -0
  10. package/dist/cmd/cmds.d.ts +8 -9
  11. package/dist/cmd/cmds.js +134 -103
  12. package/dist/cmd/features.d.ts +6 -0
  13. package/dist/cmd/features.js +57 -0
  14. package/dist/cmd/{sys/read_cmds.d.ts → read_cmds.d.ts} +1 -1
  15. package/dist/cmd/{sys/read_cmds.js → read_cmds.js} +1 -1
  16. package/dist/cmd/user_cmds.d.ts +3 -0
  17. package/dist/cmd/user_cmds.js +23 -0
  18. package/dist/index.js +11 -11
  19. package/dist/main.d.ts +3 -38
  20. package/dist/main.js +3 -37
  21. package/dist/state.d.ts +6 -0
  22. package/dist/state.js +8 -0
  23. package/dist/utils.d.ts +8 -0
  24. package/dist/utils.js +50 -0
  25. package/package.json +10 -20
  26. package/dist/cmd/clicmds/cmds.d.ts +0 -7
  27. package/dist/cmd/clicmds/cmds.js +0 -135
  28. package/dist/cmd/clicmds/updateconf.d.ts +0 -3
  29. package/dist/cmd/clicmds/updateconf.js +0 -74
  30. package/dist/cmd/lib/actions/cmd.d.ts +0 -6
  31. package/dist/cmd/lib/actions/cmd.js +0 -154
  32. package/dist/cmd/lib/actions/read.d.ts +0 -3
  33. package/dist/cmd/lib/actions/read.js +0 -17
  34. package/dist/cmd/lib/adaptaters/cmd.d.ts +0 -2
  35. package/dist/cmd/lib/adaptaters/cmd.js +0 -39
  36. package/dist/cmd/lib/agents/cmd.d.ts +0 -3
  37. package/dist/cmd/lib/agents/cmd.js +0 -11
  38. package/dist/cmd/lib/mcp.d.ts +0 -16
  39. package/dist/cmd/lib/mcp.js +0 -105
  40. package/dist/cmd/lib/options_parsers.d.ts +0 -7
  41. package/dist/cmd/lib/options_parsers.js +0 -52
  42. package/dist/cmd/lib/tasks/cmd.d.ts +0 -4
  43. package/dist/cmd/lib/tasks/cmd.js +0 -419
  44. package/dist/cmd/lib/tasks/conf.d.ts +0 -6
  45. package/dist/cmd/lib/tasks/conf.js +0 -131
  46. package/dist/cmd/lib/tasks/read.d.ts +0 -14
  47. package/dist/cmd/lib/tasks/read.js +0 -186
  48. package/dist/cmd/lib/tasks/utils.d.ts +0 -8
  49. package/dist/cmd/lib/tasks/utils.js +0 -48
  50. package/dist/cmd/lib/tools.d.ts +0 -15
  51. package/dist/cmd/lib/tools.js +0 -147
  52. package/dist/cmd/lib/utils.d.ts +0 -3
  53. package/dist/cmd/lib/utils.js +0 -54
  54. package/dist/cmd/lib/workflows/cmd.d.ts +0 -3
  55. package/dist/cmd/lib/workflows/cmd.js +0 -230
  56. package/dist/cmd/lib/workflows/read.d.ts +0 -6
  57. package/dist/cmd/lib/workflows/read.js +0 -61
  58. package/dist/cmd/sys/clipboard.d.ts +0 -3
  59. package/dist/cmd/sys/clipboard.js +0 -33
  60. package/dist/cmd/sys/delete_file.d.ts +0 -2
  61. package/dist/cmd/sys/delete_file.js +0 -10
  62. package/dist/cmd/sys/dirs.d.ts +0 -2
  63. package/dist/cmd/sys/dirs.js +0 -9
  64. package/dist/cmd/sys/execute.d.ts +0 -13
  65. package/dist/cmd/sys/execute.js +0 -48
  66. package/dist/cmd/sys/read.d.ts +0 -3
  67. package/dist/cmd/sys/read.js +0 -21
  68. package/dist/cmd/sys/read_conf.d.ts +0 -6
  69. package/dist/cmd/sys/read_conf.js +0 -12
  70. package/dist/cmd/sys/read_features.d.ts +0 -3
  71. package/dist/cmd/sys/read_features.js +0 -112
  72. package/dist/cmd/sys/read_task.d.ts +0 -6
  73. package/dist/cmd/sys/read_task.js +0 -23
  74. package/dist/cmd/sys/read_yml_file.d.ts +0 -5
  75. package/dist/cmd/sys/read_yml_file.js +0 -11
  76. package/dist/cmd/sys/run_python.d.ts +0 -6
  77. package/dist/cmd/sys/run_python.js +0 -39
  78. package/dist/conf.d.ts +0 -14
  79. package/dist/conf.js +0 -166
  80. package/dist/const.d.ts +0 -3
  81. package/dist/const.js +0 -24
  82. package/dist/db/db.d.ts +0 -4
  83. package/dist/db/db.js +0 -23
  84. package/dist/db/read.d.ts +0 -34
  85. package/dist/db/read.js +0 -128
  86. package/dist/db/schemas.d.ts +0 -2
  87. package/dist/db/schemas.js +0 -105
  88. package/dist/db/write.d.ts +0 -15
  89. package/dist/db/write.js +0 -376
  90. package/dist/interfaces.d.ts +0 -165
  91. package/dist/interfaces.js +0 -1
  92. package/dist/state/backends.d.ts +0 -7
  93. package/dist/state/backends.js +0 -159
  94. package/dist/state/chat.d.ts +0 -7
  95. package/dist/state/chat.js +0 -10
  96. package/dist/state/features.d.ts +0 -8
  97. package/dist/state/features.js +0 -35
  98. package/dist/state/plugins.d.ts +0 -6
  99. package/dist/state/plugins.js +0 -27
  100. package/dist/state/state.d.ts +0 -20
  101. package/dist/state/state.js +0 -80
  102. package/dist/state/tasks.d.ts +0 -6
  103. package/dist/state/tasks.js +0 -28
  104. package/dist/utils/perf.d.ts +0 -9
  105. package/dist/utils/perf.js +0 -63
  106. package/dist/utils/text.d.ts +0 -6
  107. package/dist/utils/text.js +0 -41
  108. package/dist/utils/user_msgs.d.ts +0 -5
  109. package/dist/utils/user_msgs.js +0 -19
  110. /package/dist/cmd/{clicmds/base.d.ts → base.d.ts} +0 -0
  111. /package/dist/{cmd/options.d.ts → options.d.ts} +0 -0
  112. /package/dist/{cmd/options.js → options.js} +0 -0
  113. /package/dist/{cmd/lib/user_msgs.d.ts → user_msgs.d.ts} +0 -0
  114. /package/dist/{cmd/lib/user_msgs.js → user_msgs.js} +0 -0
@@ -1,159 +0,0 @@
1
- import { Lm } from "@locallm/api";
2
- import { ref } from "@vue/reactivity";
3
- import colors from "ansi-colors";
4
- import { readBackends } from "../db/read.js";
5
- import { setDefaultBackend } from "../db/write.js";
6
- import { runtimeDataError } from "../utils/user_msgs.js";
7
- const backend = ref();
8
- const backends = {};
9
- const isBackendUp = ref(false);
10
- async function initBackends() {
11
- const rmb = readBackends();
12
- //console.log("Backends:", rmb)
13
- let defaultBackendName = null;
14
- for (const bk of Object.values(rmb)) {
15
- //console.log("BK", bk.name);
16
- let name = bk.name;
17
- let apiKey = "";
18
- if (bk?.apiKey) {
19
- if (bk.apiKey == "$OPENROUTER_API_KEY") {
20
- const apk = process.env.OPENROUTER_API_KEY;
21
- if (apk === undefined) {
22
- runtimeDataError("No $OPENROUTER_API_KEY environment variable found, required for ", name);
23
- return;
24
- }
25
- apiKey = apk;
26
- }
27
- else {
28
- apiKey = bk.apiKey;
29
- }
30
- }
31
- ;
32
- const lm = new Lm({
33
- providerType: bk.type,
34
- serverUrl: bk.url,
35
- apiKey: apiKey.length > 0 ? apiKey : undefined,
36
- });
37
- lm.name = bk.name;
38
- //console.log("ADD BK", lm);
39
- backends[name] = lm;
40
- if (bk.isDefault) {
41
- defaultBackendName = bk.name;
42
- }
43
- }
44
- if (defaultBackendName !== null) {
45
- backend.value = backends[defaultBackendName];
46
- //console.log("Setting default backend", defaultBackendName, "/", backend.value.name)
47
- /*isBackendUp.value = await probeBackend(backend.value, isVerbose);
48
-
49
- if (isBackendUp.value && backend.value.providerType == "ollama") {
50
- await backend.value.modelsInfo();
51
- }*/
52
- }
53
- }
54
- async function setBackend(name, isVerbose = false) {
55
- if (!(Object.keys(backends).includes(name))) {
56
- runtimeDataError(`Backend ${name} not found. Available backends: ${Object.keys(backends)}`);
57
- return false;
58
- }
59
- backend.value = backends[name];
60
- setDefaultBackend(name);
61
- console.log("Default backend set to", name);
62
- isBackendUp.value = await probeBackend(backend.value, isVerbose);
63
- return isBackendUp.value;
64
- }
65
- async function listBackends(printResult = true) {
66
- //console.log("DEFB", backend.value?.name);
67
- const allBk = new Array();
68
- for (const [name, lm] of Object.entries(backends)) {
69
- const bcn = (name == backend.value?.name) ? colors.bold(name) : name;
70
- //const isUp = await probeBackend(lm, false);
71
- const buf = new Array("-", bcn, colors.dim("(" + lm.providerType + ") " + lm.serverUrl));
72
- const str = buf.join(" ");
73
- if (printResult) {
74
- console.log(str);
75
- }
76
- allBk.push(str);
77
- }
78
- return allBk.join(" ");
79
- }
80
- const probeBackend = async (lm, isVerbose) => {
81
- let isUp = false;
82
- switch (lm.providerType) {
83
- case "llamacpp":
84
- try {
85
- if (isVerbose) {
86
- const info = await lm.modelInfo();
87
- console.log(`Provider ${lm.name} up`, info);
88
- }
89
- isUp = true;
90
- }
91
- catch (e) {
92
- if (isVerbose) {
93
- console.log(`Provider ${lm.name} down`, e);
94
- }
95
- }
96
- break;
97
- case "koboldcpp":
98
- try {
99
- if (lm.model.name.length > 0) {
100
- if (isVerbose) {
101
- const info = await lm.modelInfo();
102
- console.log(`Provider ${lm.name} up`, info);
103
- }
104
- isUp = true;
105
- }
106
- else {
107
- if (isVerbose) {
108
- console.log(`Provider ${lm.name} down`);
109
- }
110
- }
111
- }
112
- catch (e) {
113
- if (isVerbose) {
114
- console.log(`Provider ${lm.name} down`, e);
115
- }
116
- }
117
- break;
118
- case "ollama":
119
- //console.warn("The Ollama provider is not yet supported");
120
- //break;
121
- try {
122
- await lm.modelsInfo();
123
- if (isVerbose) {
124
- console.log(`Provider ${lm.name} up`);
125
- }
126
- isUp = true;
127
- }
128
- catch (e) {
129
- if (isVerbose) {
130
- console.log(`Provider ${lm.name} down`, e);
131
- }
132
- }
133
- break;
134
- case "openai":
135
- //console.warn("The Ollama provider is not yet supported");
136
- //break;
137
- try {
138
- await lm.modelsInfo();
139
- if (isVerbose) {
140
- console.log(`Provider ${lm.name} up`);
141
- }
142
- isUp = true;
143
- }
144
- catch (e) {
145
- if (isVerbose) {
146
- console.log(`Provider ${lm.name} down`, e);
147
- }
148
- }
149
- break;
150
- case "browser":
151
- await lm.modelsInfo();
152
- isUp = true;
153
- break;
154
- default:
155
- throw new Error("Unknown provider type");
156
- }
157
- return isUp;
158
- };
159
- export { backend, backends, initBackends, listBackends, setBackend };
@@ -1,7 +0,0 @@
1
- import { InferenceParams } from "@locallm/types";
2
- import { PromptTemplate } from "modprompt";
3
- declare let chatInferenceParams: InferenceParams;
4
- declare let chatTemplate: PromptTemplate;
5
- declare function setChatTemplate(tpl: PromptTemplate): void;
6
- declare function setChatInferenceParams(ip: InferenceParams): void;
7
- export { chatInferenceParams, chatTemplate, setChatInferenceParams, setChatTemplate, };
@@ -1,10 +0,0 @@
1
- import { PromptTemplate } from "modprompt";
2
- let chatInferenceParams = { temperature: 0.2, min_p: 0.05, max_tokens: 2048 };
3
- let chatTemplate = new PromptTemplate("none");
4
- function setChatTemplate(tpl) {
5
- chatTemplate = tpl;
6
- }
7
- function setChatInferenceParams(ip) {
8
- chatInferenceParams = ip;
9
- }
10
- export { chatInferenceParams, chatTemplate, setChatInferenceParams, setChatTemplate, };
@@ -1,8 +0,0 @@
1
- import { FeatureExtension, FeatureType, Features } from "../interfaces.js";
2
- declare function readFeaturesDirs(featuresPaths: Array<string>, isverbose?: boolean): Features;
3
- declare function getFeatureSpec(name: string, type: FeatureType): {
4
- found: boolean;
5
- path: string;
6
- ext: FeatureExtension;
7
- };
8
- export { readFeaturesDirs, getFeatureSpec, };
@@ -1,35 +0,0 @@
1
- import { default as path } from "path";
2
- import { readFeaturesDir } from "../cmd/sys/read_features.js";
3
- import { readFeature } from "../db/read.js";
4
- function readFeaturesDirs(featuresPaths, isverbose = false) {
5
- const feats = {
6
- task: [],
7
- action: [],
8
- cmd: [],
9
- workflow: [],
10
- adaptater: [],
11
- agent: [],
12
- };
13
- featuresPaths.forEach((dir) => {
14
- if (isverbose) {
15
- console.log("Reading feats in", dir);
16
- }
17
- const _f = readFeaturesDir(dir);
18
- _f.agent.forEach((item) => feats.agent.push(item));
19
- _f.task.forEach((item) => feats.task.push(item));
20
- _f.action.forEach((item) => feats.action.push(item));
21
- _f.cmd.forEach((item) => feats.cmd.push(item));
22
- _f.workflow.forEach((item) => feats.workflow.push(item));
23
- _f.adaptater.forEach((item) => feats.adaptater.push(item));
24
- });
25
- return feats;
26
- }
27
- function getFeatureSpec(name, type) {
28
- const { found, feature } = readFeature(name, type);
29
- if (!found) {
30
- return { found: false, path: "", ext: "yml" };
31
- }
32
- const f = path.join(feature.path, name + "." + feature.ext);
33
- return { found: true, path: f, ext: feature.ext };
34
- }
35
- export { readFeaturesDirs, getFeatureSpec, };
@@ -1,6 +0,0 @@
1
- declare function buildPluginsPaths(names: Array<string>): Promise<Array<{
2
- name: string;
3
- path: string;
4
- }>>;
5
- declare function readPluginsPaths(): Promise<Array<string>>;
6
- export { buildPluginsPaths, readPluginsPaths };
@@ -1,27 +0,0 @@
1
- import { execute } from "../main.js";
2
- import { readPlugins } from "../db/read.js";
3
- import path from "path";
4
- async function buildPluginsPaths(names) {
5
- const plugins = new Array();
6
- const root = await execute("npm", ["root", "-g"]);
7
- const rootPath = root.trim();
8
- //console.log("PLUGINS", packs);
9
- names.forEach((p) => {
10
- plugins.push({
11
- name: p,
12
- path: path.join(rootPath, p, "dist")
13
- });
14
- });
15
- //console.log("PLUGINS PATHS", paths);
16
- return plugins;
17
- }
18
- async function readPluginsPaths() {
19
- const paths = new Array();
20
- const plugins = readPlugins();
21
- plugins.forEach((p) => {
22
- paths.push(p.path);
23
- });
24
- //console.log("PLUGINS PATHS", paths);
25
- return paths;
26
- }
27
- export { buildPluginsPaths, readPluginsPaths };
@@ -1,20 +0,0 @@
1
- import { PythonShell } from 'python-shell';
2
- import { InputMode, RunMode, FormatMode, OutputMode } from "../interfaces.js";
3
- declare let pyShell: PythonShell;
4
- declare const inputMode: import("@vue/reactivity").Ref<InputMode, InputMode>;
5
- declare const outputMode: import("@vue/reactivity").Ref<OutputMode, OutputMode>;
6
- declare const runMode: import("@vue/reactivity").Ref<RunMode, RunMode>;
7
- declare const formatMode: import("@vue/reactivity").Ref<FormatMode, FormatMode>;
8
- declare const isChatMode: import("@vue/reactivity").Ref<boolean, boolean>;
9
- declare const promptfilePath: import("@vue/reactivity").Ref<string, string>;
10
- declare const dataDirPath: import("@vue/reactivity").Ref<string, string>;
11
- declare const isStateReady: import("@vue/reactivity").Ref<boolean, boolean>;
12
- declare const lastCmd: {
13
- name: string;
14
- args: Array<string>;
15
- };
16
- declare function initFilepaths(): void;
17
- declare function init(): Promise<void>;
18
- declare function initState(): Promise<void>;
19
- declare function pluginDataDir(pluginName: string): string;
20
- export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, init, pyShell, };
@@ -1,80 +0,0 @@
1
- import { reactive, ref } from "@vue/reactivity";
2
- import { initDb } from "../db/db.js";
3
- import { readFilePaths } from "../db/read.js";
4
- import path from "path";
5
- import { createDirectoryIfNotExists } from "../cmd/sys/dirs.js";
6
- import { backend, initBackends } from "./backends.js";
7
- import { runtimeDataError } from "../utils/user_msgs.js";
8
- //import { usePerfTimer } from "../main.js";
9
- let pyShell;
10
- const inputMode = ref("manual");
11
- const outputMode = ref("txt");
12
- const runMode = ref("cmd");
13
- const formatMode = ref("text");
14
- const isChatMode = ref(false);
15
- //const verbosity = ref<VerbosityMode>("quiet");
16
- const promptfilePath = ref("");
17
- const dataDirPath = ref("");
18
- const isStateReady = ref(false);
19
- const isReady = ref(false);
20
- const lastCmd = reactive({
21
- name: "",
22
- args: [],
23
- });
24
- function initFilepaths() {
25
- const filePaths = readFilePaths();
26
- //console.log("FP", filePaths);
27
- for (const fp of filePaths) {
28
- switch (fp.name) {
29
- case "promptfile":
30
- promptfilePath.value = fp.path;
31
- break;
32
- case "datadir":
33
- dataDirPath.value = fp.path;
34
- }
35
- }
36
- }
37
- async function init() {
38
- //const perf = usePerfTimer();
39
- await initState();
40
- //perf.measure("initState");
41
- if (!isReady.value) {
42
- await initBackends();
43
- }
44
- //perf.measure("initBackends");
45
- if (!backend.value) {
46
- runtimeDataError("No backend found, can not initialize agent");
47
- return;
48
- }
49
- isReady.value = true;
50
- //perf.final("init")
51
- //console.log("Agent", agent);
52
- }
53
- async function initState() {
54
- if (isStateReady.value) {
55
- return;
56
- }
57
- //sconsole.log("INIT STATE");
58
- initDb(false, false);
59
- initFilepaths();
60
- isStateReady.value = true;
61
- //console.log("State ready, available features:", readFeatures())
62
- }
63
- function _getDataDirPath() {
64
- if (dataDirPath.value.length == 0) {
65
- throw new Error("datadir path is not configured: update your config file with 'datadir' and run conf");
66
- }
67
- return dataDirPath.value;
68
- }
69
- function pluginDataDir(pluginName) {
70
- const dd = _getDataDirPath();
71
- const pluginDatapath = path.join(dd, pluginName);
72
- createDirectoryIfNotExists(pluginDatapath);
73
- return pluginDatapath;
74
- }
75
- /*function setVerbosity(mode: VerbosityMode) {
76
- verbosity.value = mode
77
- }*/
78
- export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, init,
79
- //setVerbosity,
80
- pyShell, };
@@ -1,6 +0,0 @@
1
- import { TaskSettings } from "../interfaces.js";
2
- declare const tasksSettings: Record<string, TaskSettings>;
3
- declare const isTaskSettingsInitialized: import("@vue/reactivity").Ref<boolean, boolean>;
4
- declare function initTaskSettings(): void;
5
- declare function getTaskSettings(force?: boolean): Record<string, TaskSettings>;
6
- export { tasksSettings, isTaskSettingsInitialized, initTaskSettings, getTaskSettings };
@@ -1,28 +0,0 @@
1
- import { ref } from "@vue/reactivity";
2
- import { readTaskSettings } from "../db/read.js";
3
- const tasksSettings = {};
4
- const isTaskSettingsInitialized = ref(false);
5
- function initTaskSettings() {
6
- const data = readTaskSettings();
7
- data.forEach(row => {
8
- const name = row.name;
9
- delete row.name;
10
- delete row.id;
11
- const vals = {};
12
- for (const [k, v] of Object.entries(row)) {
13
- if (v !== null) {
14
- vals[k] = v;
15
- }
16
- }
17
- tasksSettings[name] = vals;
18
- });
19
- //console.log("TS", tasksSettings);
20
- isTaskSettingsInitialized.value = true;
21
- }
22
- function getTaskSettings(force = false) {
23
- if (!isTaskSettingsInitialized.value === true || force) {
24
- initTaskSettings();
25
- }
26
- return tasksSettings;
27
- }
28
- export { tasksSettings, isTaskSettingsInitialized, initTaskSettings, getTaskSettings };
@@ -1,9 +0,0 @@
1
- declare const usePerfTimer: (startTimer?: boolean) => {
2
- start: () => void;
3
- time: () => string;
4
- timeRaw: () => string | number;
5
- printTime: () => void;
6
- measure: (name: string) => void;
7
- final: (name?: string) => void;
8
- };
9
- export { usePerfTimer };
@@ -1,63 +0,0 @@
1
- const usePerfTimer = (startTimer = true) => {
2
- let startTime;
3
- const measurements = [];
4
- let lastTime;
5
- if (startTimer) {
6
- startTime = performance.now();
7
- lastTime = startTime;
8
- }
9
- const measure = (name) => {
10
- const currentTime = performance.now();
11
- const elapsedNs = Number(currentTime - lastTime);
12
- const elapsedSec = elapsedNs / 1000;
13
- measurements.push({ name, time: elapsedSec, percentage: 0 });
14
- lastTime = currentTime;
15
- console.log(name, elapsedSec);
16
- };
17
- const final = (name = "") => {
18
- const totalTime = Number(performance.now() - startTime) / 1000;
19
- console.log("\n*** Performance", name.length > 0 ? `for ${name}` : "", " ***");
20
- measurements.forEach(m => {
21
- m.percentage = (m.time / totalTime) * 100;
22
- console.log(` - ${m.name}: ${m.time.toFixed(6)}s (${m.percentage.toFixed(2)}%)`);
23
- });
24
- console.log(`Total time: ${totalTime.toFixed(6)}s\n`);
25
- };
26
- const start = () => {
27
- startTime = performance.now();
28
- lastTime = startTime;
29
- };
30
- const _end = (raw) => {
31
- if (!startTime) {
32
- throw new Error("the timer has not started, can not end it");
33
- }
34
- const endTime = performance.now();
35
- const duration = endTime - startTime;
36
- if (raw) {
37
- return duration;
38
- }
39
- const humanizedTime = _formatDuration(duration);
40
- return humanizedTime;
41
- };
42
- const time = () => _end(false).toString();
43
- const printTime = () => console.log(_end(false));
44
- const timeRaw = () => _end(true);
45
- const _formatDuration = (ms) => {
46
- const seconds = ms / 1000;
47
- const minutes = seconds / 60;
48
- if (ms < 1000)
49
- return `${ms.toFixed(2)} milliseconds`;
50
- if (seconds < 60)
51
- return `${seconds.toFixed(1)} seconds`;
52
- return `${minutes.toFixed()} minutes ${(seconds % 60).toFixed()} seconds`;
53
- };
54
- return {
55
- start,
56
- time,
57
- timeRaw,
58
- printTime,
59
- measure,
60
- final,
61
- };
62
- };
63
- export { usePerfTimer };
@@ -1,6 +0,0 @@
1
- declare function extractBetweenTags(text: string, startTag: string, endTag: string): string;
2
- declare function splitThinking(text: string, startTag: string, endTag: string): {
3
- think: string;
4
- finalAnswer: string;
5
- };
6
- export { extractBetweenTags, splitThinking, };
@@ -1,41 +0,0 @@
1
- function extractBetweenTags(text, startTag, endTag) {
2
- try {
3
- // Find start position
4
- const startIndex = text.indexOf(startTag);
5
- if (startIndex === -1)
6
- return text;
7
- // Calculate content boundaries
8
- let contentStart = startIndex + startTag.length;
9
- let contentEnd;
10
- if (endTag) {
11
- contentEnd = text.indexOf(endTag, contentStart);
12
- if (contentEnd === -1)
13
- return text;
14
- }
15
- else {
16
- // Find next newline for self-closing tags
17
- contentEnd = text.indexOf('\n', contentStart);
18
- if (contentEnd === -1)
19
- contentEnd = text.length;
20
- }
21
- // Extract content
22
- return text.substring(contentStart, contentEnd).trim();
23
- }
24
- catch (error) {
25
- throw new Error(`Error parsing content between tags ${startTag} ${endTag}: ${error}`);
26
- }
27
- }
28
- function splitThinking(text, startTag, endTag) {
29
- let think = "";
30
- let answer = "";
31
- const st = text.split(endTag);
32
- if (st.length > 1) {
33
- think = extractBetweenTags(text, startTag, endTag);
34
- answer = st[1].trim();
35
- }
36
- else {
37
- answer = text;
38
- }
39
- return { think: think, finalAnswer: answer };
40
- }
41
- export { extractBetweenTags, splitThinking, };
@@ -1,5 +0,0 @@
1
- declare function runtimeError(...msg: string[]): void;
2
- declare function runtimeWarning(...msg: string[]): void;
3
- declare function runtimeDataError(...msg: string[]): void;
4
- declare function runtimeInfo(...msg: string[]): void;
5
- export { runtimeError, runtimeWarning, runtimeDataError, runtimeInfo, };
@@ -1,19 +0,0 @@
1
- import { exit } from "process";
2
- import colors from "ansi-colors";
3
- function runtimeError(...msg) {
4
- console.warn("💥", colors.dim("Runtime error:"), ...msg);
5
- exit(1);
6
- }
7
- function runtimeWarning(...msg) {
8
- console.warn("⚠️", colors.dim("Runtime warning:"), ...msg);
9
- //exit(1)
10
- }
11
- function runtimeDataError(...msg) {
12
- console.warn("❌", colors.dim("Runtime data error:"), ...msg);
13
- exit(1);
14
- }
15
- function runtimeInfo(...msg) {
16
- //console.log("ℹ️ ", colors.dim("Info:"), ...msg);
17
- console.log("📫", colors.dim("Info:"), ...msg);
18
- }
19
- export { runtimeError, runtimeWarning, runtimeDataError, runtimeInfo, };
File without changes
File without changes
File without changes
File without changes
File without changes