tarsk 0.2.5 → 0.3.0

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 (119) hide show
  1. package/README.md +1 -7
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.js +92 -32
  4. package/dist/lib/response-builder.d.ts +50 -0
  5. package/dist/lib/response-builder.js +56 -0
  6. package/dist/lib/stream-helper.d.ts +39 -0
  7. package/dist/lib/stream-helper.js +43 -0
  8. package/dist/managers/ConversationManager.d.ts +83 -0
  9. package/dist/managers/ConversationManager.js +129 -0
  10. package/dist/managers/GitManager.d.ts +133 -0
  11. package/dist/managers/GitManager.js +330 -0
  12. package/dist/managers/MetadataManager.d.ts +139 -0
  13. package/dist/managers/MetadataManager.js +309 -0
  14. package/dist/managers/ModelManager.d.ts +57 -0
  15. package/dist/managers/ModelManager.js +129 -0
  16. package/dist/managers/NeovateExecutor.d.ts +40 -0
  17. package/dist/managers/NeovateExecutor.js +138 -0
  18. package/dist/managers/ProjectManager.d.ts +162 -0
  19. package/dist/managers/ProjectManager.js +353 -0
  20. package/dist/managers/ThreadManager.d.ts +181 -0
  21. package/dist/managers/ThreadManager.js +325 -0
  22. package/dist/managers/conversation-manager.d.ts +83 -0
  23. package/dist/managers/conversation-manager.js +129 -0
  24. package/dist/managers/git-manager.d.ts +133 -0
  25. package/dist/managers/git-manager.js +330 -0
  26. package/dist/managers/metadata-manager.d.ts +139 -0
  27. package/dist/managers/metadata-manager.js +305 -0
  28. package/dist/managers/model-manager.d.ts +59 -0
  29. package/dist/managers/model-manager.js +144 -0
  30. package/dist/managers/neovate-executor.d.ts +43 -0
  31. package/dist/managers/neovate-executor.js +205 -0
  32. package/dist/managers/processing-state-manager.d.ts +40 -0
  33. package/dist/managers/processing-state-manager.js +27 -0
  34. package/dist/managers/project-manager.d.ts +199 -0
  35. package/dist/managers/project-manager.js +465 -0
  36. package/dist/managers/thread-manager.d.ts +193 -0
  37. package/dist/managers/thread-manager.js +368 -0
  38. package/dist/model-info-aihubmix.d.ts +25 -0
  39. package/dist/model-info-aihubmix.js +117 -0
  40. package/dist/model-info-openai.d.ts +17 -0
  41. package/dist/model-info-openai.js +59 -0
  42. package/dist/model-info-openrouter.d.ts +25 -0
  43. package/dist/model-info-openrouter.js +101 -0
  44. package/dist/model-info.d.ts +37 -0
  45. package/dist/model-info.js +39 -0
  46. package/dist/provider-data.d.ts +101 -0
  47. package/dist/provider-data.js +471 -0
  48. package/dist/provider.d.ts +10 -0
  49. package/dist/provider.js +192 -0
  50. package/dist/public/android-chrome-192x192.png +0 -0
  51. package/dist/public/android-chrome-512x512.png +0 -0
  52. package/dist/public/apple-touch-icon.png +0 -0
  53. package/dist/public/assets/index-B443aj9k.js +8506 -0
  54. package/dist/public/assets/index-CjXGVbI7.css +1 -0
  55. package/dist/public/assets/index-DJC-p914.js +8506 -0
  56. package/dist/public/favicon-16x16.png +0 -0
  57. package/dist/public/favicon-32x32.png +0 -0
  58. package/dist/public/favicon.ico +0 -0
  59. package/dist/public/index.html +28 -0
  60. package/dist/public/manifest.json +82 -0
  61. package/dist/public/placeholder-logo.svg +1 -0
  62. package/dist/public/placeholder.svg +1 -0
  63. package/dist/public/snpro.woff2 +0 -0
  64. package/dist/public/tarsk-color.svg +12 -0
  65. package/dist/public/tarsk.png +0 -0
  66. package/dist/public/tarsk.svg +12 -0
  67. package/dist/public/zalando-sans.woff2 +0 -0
  68. package/dist/routes/chat-old.d.ts +21 -0
  69. package/dist/routes/chat-old.js +251 -0
  70. package/dist/routes/chat.d.ts +21 -0
  71. package/dist/routes/chat.js +217 -0
  72. package/dist/routes/git.d.ts +4 -0
  73. package/dist/routes/git.js +668 -0
  74. package/dist/routes/models.d.ts +18 -0
  75. package/dist/routes/models.js +128 -0
  76. package/dist/routes/projects-old.d.ts +20 -0
  77. package/dist/routes/projects-old.js +297 -0
  78. package/dist/routes/projects.d.ts +20 -0
  79. package/dist/routes/projects.js +365 -0
  80. package/dist/routes/providers.d.ts +15 -0
  81. package/dist/routes/providers.js +130 -0
  82. package/dist/routes/threads-old.d.ts +14 -0
  83. package/dist/routes/threads-old.js +393 -0
  84. package/dist/routes/threads.d.ts +14 -0
  85. package/dist/routes/threads.js +352 -0
  86. package/dist/types/models.d.ts +315 -0
  87. package/dist/types/models.js +11 -0
  88. package/dist/utils/env-manager.d.ts +3 -0
  89. package/dist/utils/env-manager.js +60 -0
  90. package/dist/utils/open-router-models.d.ts +45 -0
  91. package/dist/utils/open-router-models.js +103 -0
  92. package/dist/utils/openai-models.d.ts +63 -0
  93. package/dist/utils/openai-models.js +152 -0
  94. package/dist/utils/openai-pricing-scraper.d.ts +17 -0
  95. package/dist/utils/openai-pricing-scraper.js +185 -0
  96. package/dist/utils/validation.d.ts +10 -0
  97. package/dist/utils/validation.js +20 -0
  98. package/dist/utils.d.ts +10 -0
  99. package/dist/utils.js +12 -0
  100. package/package.json +36 -22
  101. package/LICENSE.md +0 -7
  102. package/dist/agent/agent.js +0 -131
  103. package/dist/agent/interfaces.js +0 -1
  104. package/dist/api/encryption.js +0 -41
  105. package/dist/api/models.js +0 -169
  106. package/dist/api/prompt.js +0 -12
  107. package/dist/api/settings.js +0 -43
  108. package/dist/api/test.js +0 -29
  109. package/dist/api/tools.js +0 -287
  110. package/dist/api/utils.js +0 -18
  111. package/dist/interfaces/meta.js +0 -1
  112. package/dist/interfaces/model.js +0 -1
  113. package/dist/interfaces/settings.js +0 -1
  114. package/dist/log/log.js +0 -33
  115. package/dist/prompt.js +0 -49
  116. package/dist/tools.js +0 -84
  117. package/dist/utils/files.js +0 -14
  118. package/dist/utils/json-file.js +0 -28
  119. package/dist/utils/strip-markdown.js +0 -5
package/package.json CHANGED
@@ -1,32 +1,46 @@
1
1
  {
2
2
  "name": "tarsk",
3
- "version": "0.2.5",
4
- "author": "WebNative LLC",
5
- "description": "Tarsk is a AI tool available at https://tarsk.io",
6
- "license": "MIT",
3
+ "version": "0.3.0",
4
+ "description": "CLI for Tarsk - Project Threads Manager",
7
5
  "type": "module",
8
- "scripts": {
9
- "build": "tsc",
10
- "build:prod": "tsc && rm -rf dist/test && rm -rf dist/tools",
11
- "start": "npm run build && npm link && tarsk",
12
- "restart": "npm unlink tarsk && rm -rf dist && npm run build && npm link && tarsk",
13
- "test": "vitest",
14
- "test2": "bun test/test-get-definition.ts",
15
- "dev": "tsx watch src/index.ts"
16
- },
6
+ "main": "dist/index.js",
17
7
  "bin": {
18
8
  "tarsk": "dist/index.js"
19
9
  },
10
+ "files": [
11
+ "dist",
12
+ "!dist/**/*.map"
13
+ ],
14
+ "scripts": {
15
+ "dev": "tsx watch src/index.ts",
16
+ "build": "tsc",
17
+ "start": "node dist/index.js",
18
+ "lint": "eslint .",
19
+ "test": "vitest run"
20
+ },
21
+ "keywords": [
22
+ "hono",
23
+ "cli",
24
+ "git",
25
+ "project-management"
26
+ ],
27
+ "author": "",
28
+ "license": "MIT",
20
29
  "dependencies": {
21
- "@hono/node-server": "1.14.1",
22
- "hono": "4.7.7",
23
- "open": "10.1.1",
24
- "ts-blank-space": "0.6.1"
30
+ "@hono/node-server": "^1.19.9",
31
+ "@neovate/code": "file:./packages/neovate-code-local",
32
+ "hono": "4.11.9"
25
33
  },
26
34
  "devDependencies": {
27
- "@types/node": "^20.11.17",
28
- "terser": "^5.39.0",
29
- "tsx": "^4.7.1",
30
- "vitest": "^3.1.2"
35
+ "@eslint/js": "^10.0.1",
36
+ "@types/node": "^20.11.0",
37
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
38
+ "@typescript-eslint/parser": "^8.54.0",
39
+ "eslint": "^10.0.0",
40
+ "fast-check": "4.5.3",
41
+ "tsx": "^4.7.0",
42
+ "typescript": "^5.3.3",
43
+ "typescript-eslint": "^8.54.0",
44
+ "vitest": "4.0.18"
31
45
  }
32
- }
46
+ }
package/LICENSE.md DELETED
@@ -1,7 +0,0 @@
1
- Copyright (c) 2011-2025 Web Native LLC.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,131 +0,0 @@
1
- import { logWrite, logEnd, logError, logStart } from "../log/log.js";
2
- export async function completion(request, options) {
3
- const tools = request.tools.map(tool => JSON.parse(JSON.stringify(tool.definition)) ?? []);
4
- const req = {
5
- model: request.model,
6
- tools,
7
- messages: request.messages,
8
- };
9
- logStart({ type: 'completion', args: '' });
10
- let repeating;
11
- let count = 0;
12
- let response = {};
13
- do {
14
- repeating = false;
15
- count++;
16
- logStart({ type: `completion_request_${count}`, args: request });
17
- try {
18
- response = await call(options, req);
19
- }
20
- catch (error) {
21
- logWrite({ type: 'completion_error', args: { error } });
22
- throw new Error(`Error calling completion: ${error}`);
23
- }
24
- finally {
25
- logEnd(`completion_request_${count}`);
26
- }
27
- if (response.error) {
28
- const message = JSON.stringify(response.error.metadata);
29
- logError({ type: 'completion_error', message, args: { ...response.error } });
30
- throw new Error(response.error.message);
31
- }
32
- for (const choice of response.choices) {
33
- logWrite({ type: 'inject_choice', args: choice });
34
- request.messages.push(cleanedMessage(choice.message));
35
- if (choice.finish_reason == 'tool_calls') {
36
- logStart({ type: 'tool_calls', args: choice.message.tool_calls });
37
- const newMessages = await callTools(choice.message.tool_calls ?? [], request);
38
- request.messages.push(...newMessages);
39
- logEnd('tool_calls');
40
- repeating = newMessages.length > 0;
41
- }
42
- }
43
- } while (repeating);
44
- logEnd('completion');
45
- return response;
46
- }
47
- function cleanedMessage(message) {
48
- const cleaned = JSON.parse(JSON.stringify(message));
49
- delete (cleaned.reasoning);
50
- delete (cleaned.refusal);
51
- for (const call of cleaned.tool_calls ?? []) {
52
- delete (call.index);
53
- }
54
- return cleaned;
55
- }
56
- export async function callTools(toolCalls, request) {
57
- const newMessages = [];
58
- for (const toolCall of toolCalls) {
59
- const toolName = toolCall.function.name;
60
- const toolArgs = JSON.parse(toolCall.function.arguments);
61
- let found;
62
- let functionMap;
63
- for (const tool of request.tools) {
64
- for (const definition of tool.definition ?? []) {
65
- if (definition.function.name == toolName) {
66
- found = definition;
67
- functionMap = tool.functionMap;
68
- break;
69
- }
70
- }
71
- }
72
- if (!found) {
73
- throw new Error(`Tool ${toolName} not found`);
74
- }
75
- if (!functionMap) {
76
- throw new Error(`Tool map for ${toolName} not found`);
77
- }
78
- if (!functionMap[toolName]) {
79
- throw new Error(`Tool ${toolName} not found in tool map. Check the function name in the definition matches exactly to the name of the function`);
80
- }
81
- logStart({ type: `tool_call_${toolName}`, args: { toolName, toolArgs } });
82
- logWrite({ type: 'tool_call', args: { functionMap, toolArgs } });
83
- try {
84
- const toolResponse = await functionMap[toolName](...Object.values(toolArgs));
85
- newMessages.push({
86
- role: 'tool',
87
- tool_call_id: toolCall.id,
88
- name: toolName,
89
- content: JSON.stringify(toolResponse),
90
- });
91
- logWrite({ type: 'tool_call_response', args: { toolName, toolResponse }, message: JSON.stringify(toolResponse) });
92
- }
93
- catch (error) {
94
- var err = new Error();
95
- logWrite({ type: 'tool_call_error', args: { toolName, error }, message: err.stack?.toString() });
96
- throw new Error(`Error calling tool ${toolName}: ${error}`);
97
- }
98
- finally {
99
- logEnd(`tool_call_${toolName}`);
100
- }
101
- }
102
- return newMessages;
103
- }
104
- export async function callFunction(_function, args) {
105
- try {
106
- const toolResponse = await _function(args);
107
- return toolResponse;
108
- }
109
- catch (error) {
110
- var err = new Error();
111
- logWrite({
112
- type: 'test_call_error', args: { functionName: _function.name, error: `${error}` },
113
- });
114
- return { error: `Error calling ${_function.name}: ${error}` };
115
- }
116
- }
117
- async function call(options, request) {
118
- const response = await fetch(`${options.baseUrl}/chat/completions`, {
119
- method: 'POST',
120
- headers: {
121
- 'Authorization': 'Bearer ' + options.apiKey,
122
- 'HTTP-Referer': 'https://tarsk.io',
123
- 'X-Title': 'Tarsk',
124
- 'Content-Type': 'application/json',
125
- },
126
- body: JSON.stringify(request)
127
- });
128
- const text = await response.text();
129
- const json = JSON.parse(text);
130
- return json;
131
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,41 +0,0 @@
1
- import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from "crypto";
2
- import { hostname, machine } from "os";
3
- export function encryptString(text) {
4
- let id = `${machineIdSync()}11de20da-f6cf-4b85-b630-555fc6e8b881`;
5
- return encrypt(text, id);
6
- }
7
- export function decryptString(text) {
8
- try {
9
- let id = `${machineIdSync()}11de20da-f6cf-4b85-b630-555fc6e8b881`;
10
- return decrypt(text, id);
11
- }
12
- catch (e) {
13
- return "";
14
- }
15
- }
16
- function machineIdSync() {
17
- return machine() + hostname();
18
- }
19
- const algorithm = "aes-256-cbc";
20
- const ivLength = 16;
21
- function encrypt(text, passPhrase) {
22
- const iv = randomBytes(ivLength);
23
- const key = scryptSync(passPhrase, "salt", 32);
24
- const cipher = createCipheriv(algorithm, key, iv);
25
- let encrypted = cipher.update(text, "utf8", "base64");
26
- encrypted += cipher.final("base64");
27
- const encryptedData = `${iv.toString("base64")}:${encrypted}`;
28
- return encryptedData;
29
- }
30
- function decrypt(encryptedData, passPhrase) {
31
- const [ivBase64, encryptedBase64] = encryptedData.split(":");
32
- if (!ivBase64 || !encryptedBase64) {
33
- throw new Error("Invalid encrypted data format");
34
- }
35
- const iv = Buffer.from(ivBase64, "base64");
36
- const key = scryptSync(passPhrase, "salt", 32);
37
- const decipher = createDecipheriv(algorithm, key, iv);
38
- let decrypted = decipher.update(encryptedBase64, "base64", "utf8");
39
- decrypted += decipher.final("utf8");
40
- return decrypted;
41
- }
@@ -1,169 +0,0 @@
1
- import { getSettings } from "./settings.js";
2
- export async function api_get_models(c) {
3
- const setttings = await getSettings();
4
- const res = await fetch("https://api.tarsk.io/api/v1/models", {
5
- method: "GET",
6
- headers: {
7
- Authorization: `Bearer ${setttings.tarskApiKey}`
8
- }
9
- });
10
- const data = await res.json();
11
- const models = [];
12
- for (const model of data.data) {
13
- if (hasTools(model.id)) {
14
- models.push({
15
- id: model.id,
16
- description: model.description,
17
- name: model.name,
18
- type: model.architecture.tokenizer,
19
- priceM: totalPrice(model.pricing),
20
- price: model.pricing.prompt == "0" && model.pricing.completion == "0"
21
- ? ""
22
- : `($${totalPrice(model.pricing).toFixed(2)}m)`,
23
- });
24
- }
25
- }
26
- return c.json(models);
27
- }
28
- function totalPrice(price) {
29
- const total = v(price.prompt) + v(price.completion);
30
- return total * 1000000;
31
- }
32
- function promptPrice(price) {
33
- const total = v(price.prompt);
34
- return total * 1000000;
35
- }
36
- function completionPrice(price) {
37
- const total = v(price.completion);
38
- return total * 1000000;
39
- }
40
- function v(s) {
41
- if (!s)
42
- return 0;
43
- return Number(s);
44
- }
45
- function hasTools(model) {
46
- return [
47
- "google/gemini-2.5-pro-preview-03-25",
48
- "google/gemini-2.5-flash-preview",
49
- "google/gemini-2.5-flash-preview:thinking",
50
- "openai/o4-mini-high",
51
- "openai/o3",
52
- "openai/o4-mini",
53
- "openai/gpt-4.1",
54
- "openai/gpt-4.1-mini",
55
- "openai/gpt-4.1-nano",
56
- "x-ai/grok-3-beta",
57
- "meta-llama/llama-4-maverick",
58
- "meta-llama/llama-4-scout",
59
- "all-hands/openhands-lm-32b-v0.1",
60
- "mistral/ministral-8b",
61
- "google/gemini-2.5-pro-exp-03-25:free",
62
- "deepseek/deepseek-chat-v3-0324",
63
- "mistralai/mistral-small-3.1-24b-instruct:free",
64
- "mistralai/mistral-small-3.1-24b-instruct",
65
- "ai21/jamba-1.6-large",
66
- "ai21/jamba-1.6-mini",
67
- "qwen/qwq-32b",
68
- "openai/gpt-4.5-preview",
69
- "google/gemini-2.0-flash-lite-001",
70
- "anthropic/claude-3.7-sonnet",
71
- "anthropic/claude-3.7-sonnet:thinking",
72
- "anthropic/claude-3.7-sonnet:beta",
73
- "mistralai/mistral-saba",
74
- "openai/o3-mini-high",
75
- "google/gemini-2.0-flash-001",
76
- "qwen/qwen-turbo",
77
- "qwen/qwen-plus",
78
- "qwen/qwen-max",
79
- "openai/o3-mini",
80
- "mistralai/mistral-small-24b-instruct-2501",
81
- "deepseek/deepseek-r1-distill-llama-70b",
82
- "deepseek/deepseek-r1",
83
- "mistralai/codestral-2501",
84
- "deepseek/deepseek-chat",
85
- "openai/o1",
86
- "x-ai/grok-2-1212",
87
- "google/gemini-2.0-flash-exp:free",
88
- "meta-llama/llama-3.3-70b-instruct",
89
- "amazon/nova-lite-v1",
90
- "amazon/nova-micro-v1",
91
- "amazon/nova-pro-v1",
92
- "openai/gpt-4o-2024-11-20",
93
- "mistralai/mistral-large-2411",
94
- "mistralai/mistral-large-2407",
95
- "mistralai/pixtral-large-2411",
96
- "anthropic/claude-3.5-haiku:beta",
97
- "anthropic/claude-3.5-haiku",
98
- "anthropic/claude-3.5-haiku-20241022:beta",
99
- "anthropic/claude-3.5-haiku-20241022",
100
- "anthropic/claude-3.5-sonnet:beta",
101
- "anthropic/claude-3.5-sonnet",
102
- "x-ai/grok-beta",
103
- "mistralai/ministral-8b",
104
- "mistralai/ministral-3b",
105
- "nvidia/llama-3.1-nemotron-70b-instruct",
106
- "google/gemini-flash-1.5-8b",
107
- "meta-llama/llama-3.2-3b-instruct",
108
- "qwen/qwen-2.5-72b-instruct",
109
- "mistralai/pixtral-12b",
110
- "cohere/command-r-plus-08-2024",
111
- "cohere/command-r-08-2024",
112
- "google/gemini-flash-1.5-8b-exp",
113
- "ai21/jamba-1-5-mini",
114
- "ai21/jamba-1-5-large",
115
- "microsoft/phi-3.5-mini-128k-instruct",
116
- "nousresearch/hermes-3-llama-3.1-70b",
117
- "openai/gpt-4o-2024-08-06",
118
- "meta-llama/llama-3.1-8b-instruct",
119
- "meta-llama/llama-3.1-405b-instruct",
120
- "meta-llama/llama-3.1-70b-instruct",
121
- "mistralai/codestral-mamba",
122
- "mistralai/mistral-nemo",
123
- "openai/gpt-4o-mini",
124
- "openai/gpt-4o-mini-2024-07-18",
125
- "anthropic/claude-3.5-sonnet-20240620:beta",
126
- "anthropic/claude-3.5-sonnet-20240620",
127
- "mistralai/mistral-7b-instruct:free",
128
- "mistralai/mistral-7b-instruct",
129
- "mistralai/mistral-7b-instruct-v0.3",
130
- "microsoft/phi-3-mini-128k-instruct",
131
- "microsoft/phi-3-medium-128k-instruct",
132
- "google/gemini-flash-1.5",
133
- "openai/gpt-4o",
134
- "openai/gpt-4o:extended",
135
- "openai/gpt-4o-2024-05-13",
136
- "meta-llama/llama-3-8b-instruct",
137
- "meta-llama/llama-3-70b-instruct",
138
- "mistralai/mixtral-8x22b-instruct",
139
- "google/gemini-pro-1.5",
140
- "openai/gpt-4-turbo",
141
- "cohere/command-r-plus",
142
- "cohere/command-r-plus-04-2024",
143
- "cohere/command-r",
144
- "anthropic/claude-3-haiku:beta",
145
- "anthropic/claude-3-haiku",
146
- "anthropic/claude-3-opus:beta",
147
- "anthropic/claude-3-opus",
148
- "anthropic/claude-3-sonnet:beta",
149
- "anthropic/claude-3-sonnet",
150
- "cohere/command-r-03-2024",
151
- "mistralai/mistral-large",
152
- "openai/gpt-3.5-turbo-0613",
153
- "openai/gpt-4-turbo-preview",
154
- "mistralai/mistral-medium",
155
- "mistralai/mistral-small",
156
- "mistralai/mistral-tiny",
157
- "mistralai/mixtral-8x7b-instruct",
158
- "openai/gpt-3.5-turbo-1106",
159
- "openai/gpt-4-1106-preview",
160
- "mistralai/mistral-7b-instruct-v0.1",
161
- "openai/gpt-3.5-turbo-16k",
162
- "openai/gpt-4-32k",
163
- "openai/gpt-4-32k-0314",
164
- "openai/gpt-3.5-turbo",
165
- "openai/gpt-3.5-turbo-0125",
166
- "openai/gpt-4",
167
- "openai/gpt-4-0314",
168
- ].includes(model);
169
- }
@@ -1,12 +0,0 @@
1
- import { prompt } from "../prompt.js";
2
- import { logWrite } from "../log/log.js";
3
- export async function api_prompt(c) {
4
- const body = await c.req.json();
5
- logWrite({ type: 'prompt', args: body });
6
- const question = body.prompt;
7
- if (!question) {
8
- return c.json({ error: 'Prompt is required' }, 400);
9
- }
10
- const answer = await prompt(question);
11
- return c.json({ answer });
12
- }
@@ -1,43 +0,0 @@
1
- import {} from "../interfaces/settings.js";
2
- import { getJSON, setJSON } from "../utils/json-file.js";
3
- import { httpValidationErrror as httpValidationError, isEmpty } from "./utils.js";
4
- const defaultTarskURL = "https://api.tarsk.io/api/v1";
5
- export const defaultModel = "meta-llama/llama-3.3-70b-instruct";
6
- export async function api_get_settings(c) {
7
- return c.json(getSettings());
8
- }
9
- export async function api_save_settings(c) {
10
- const settings = await c.req.json();
11
- if (isEmpty(settings.tarskApiKey)) {
12
- httpValidationError("tarskApiKey is required");
13
- }
14
- if (isEmpty(settings.apiURL)) {
15
- settings.apiURL = defaultTarskURL;
16
- }
17
- if (isEmpty(settings.defaultModel) || settings.defaultModel == 'Select a Model') {
18
- settings.defaultModel = defaultModel;
19
- }
20
- if (settings.apiURL == undefined) {
21
- httpValidationError("apiURL is required");
22
- }
23
- if (!settings.apiURL.startsWith("https://")) {
24
- httpValidationError("apiURL must start with https://");
25
- }
26
- if (settings.apiURL.endsWith("/")) {
27
- settings.apiURL = settings.apiURL.slice(0, -1);
28
- }
29
- setJSON('settings', settings);
30
- return c.json(getSettings());
31
- }
32
- export function getSettings() {
33
- const defaultSettings = {
34
- tarskApiKey: "",
35
- apiURL: defaultTarskURL,
36
- defaultModel: defaultModel
37
- };
38
- const settings = getJSON("settings", defaultSettings);
39
- if (isEmpty(settings.tarskApiKey)) {
40
- settings.tarskApiKey = 'aedf201d-bf05-4fa0-912c-15a924f32c65';
41
- }
42
- return settings;
43
- }
package/dist/api/test.js DELETED
@@ -1,29 +0,0 @@
1
- import { prompt } from "../prompt.js";
2
- import { stripMarkdown } from "../utils/strip-markdown.js";
3
- export async function createTest(definition, codeFilename, code) {
4
- const functions = definition.map((tool) => tool.function.name);
5
- let test = `import { ${functions.join(',')} } from "./${codeFilename}";\n\n`;
6
- const comments = functions.map((functionName) => {
7
- return ` // Call ${functionName} to test it`;
8
- });
9
- test += `export async function test() {
10
- ${comments.join('\n')}
11
- return 'place your test results here';
12
- }`;
13
- try {
14
- const updated = await prompt(`Complete the test function with a test case for the following functions ${functions.join(', ')}. The test should be a valid JavaScript code and should return the test results.
15
- Here is the initial test code:\n
16
- ${test}
17
- `, {
18
- ignoreTools: true, firstMessage: {
19
- role: "system",
20
- content: "You must return the code without any explaination."
21
- }
22
- });
23
- test = stripMarkdown(updated);
24
- }
25
- catch (e) {
26
- console.error("Error generating test code:", e);
27
- }
28
- return test;
29
- }