@polka-codes/core 0.1.1 → 0.1.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "license": "AGPL-3.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- import { expect, test } from 'bun:test';
2
- import { allTools } from '../../tools';
3
- import { fullSystemPrompt } from './prompts';
4
- test('fullSystemPrompt', () => {
5
- const prompt = fullSystemPrompt({
6
- os: 'Linux',
7
- }, Object.values(allTools), 'tool_', ['custom instructions', 'more'], {
8
- test: 'test',
9
- check: {
10
- command: 'check',
11
- description: 'Check the code',
12
- },
13
- format: {
14
- command: 'format',
15
- description: 'Format the code',
16
- },
17
- });
18
- expect(prompt).toMatchSnapshot();
19
- });
20
- //# sourceMappingURL=prompts.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompts.test.js","sourceRoot":"","sources":["../../../src/Agent/CoderAgent/prompts.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAC5B,MAAM,MAAM,GAAG,gBAAgB,CAC7B;QACE,EAAE,EAAE,OAAO;KACZ,EACD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EACvB,OAAO,EACP,CAAC,qBAAqB,EAAE,MAAM,CAAC,EAC/B;QACE,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE;YACL,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,gBAAgB;SAC9B;QACD,MAAM,EAAE;YACN,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,iBAAiB;SAC/B;KACF,CACF,CAAA;IAED,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAA;AAClC,CAAC,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,172 +0,0 @@
1
- import { describe, expect, test } from 'bun:test';
2
- import { parseAssistantMessage } from './parseAssistantMessage';
3
- describe('parseAssistantMessage', () => {
4
- const mockTools = [
5
- {
6
- name: 'test_tool',
7
- description: 'A test tool',
8
- parameters: [
9
- { name: 'param1', description: 'First parameter', required: true, usageValue: 'value1' },
10
- { name: 'param2', description: 'Second parameter', required: false, usageValue: 'value2' },
11
- ],
12
- },
13
- ];
14
- const toolPrefix = 'tool_';
15
- test('should parse plain text message', () => {
16
- const message = 'This is a plain text message';
17
- const result = parseAssistantMessage(message, mockTools, toolPrefix);
18
- expect(result).toEqual([
19
- {
20
- type: 'text',
21
- content: message,
22
- },
23
- ]);
24
- });
25
- test('should parse message with tool use and XML-like parameters', () => {
26
- const message = `<tool_test_tool>
27
- <tool_parameter_param1>value1</tool_parameter_param1>
28
- <tool_parameter_param2>value2</tool_parameter_param2>
29
- </tool_test_tool>`;
30
- const result = parseAssistantMessage(message, mockTools, toolPrefix);
31
- expect(result).toEqual([
32
- {
33
- type: 'tool_use',
34
- name: 'test_tool',
35
- params: {
36
- param1: 'value1',
37
- param2: 'value2',
38
- },
39
- },
40
- ]);
41
- });
42
- test('should parse message with text before and after tool use', () => {
43
- const message = `Before text <tool_test_tool>
44
- <tool_parameter_param1>value1</tool_parameter_param1>
45
- </tool_test_tool> After text`;
46
- const result = parseAssistantMessage(message, mockTools, toolPrefix);
47
- expect(result).toEqual([
48
- {
49
- type: 'text',
50
- content: 'Before text',
51
- },
52
- {
53
- type: 'tool_use',
54
- name: 'test_tool',
55
- params: {
56
- param1: 'value1',
57
- },
58
- },
59
- {
60
- type: 'text',
61
- content: 'After text',
62
- },
63
- ]);
64
- });
65
- test('should handle tool with missing optional parameter', () => {
66
- const message = `<tool_test_tool>
67
- <tool_parameter_param1>value1</tool_parameter_param1>
68
- </tool_test_tool>`;
69
- const result = parseAssistantMessage(message, mockTools, toolPrefix);
70
- expect(result).toEqual([
71
- {
72
- type: 'tool_use',
73
- name: 'test_tool',
74
- params: {
75
- param1: 'value1',
76
- },
77
- },
78
- ]);
79
- });
80
- test('should handle message with unknown tool', () => {
81
- const message = `<tool_unknown>
82
- <tool_parameter_param1>value1</tool_parameter_param1>
83
- </tool_unknown>`;
84
- const result = parseAssistantMessage(message, mockTools, toolPrefix);
85
- // Should treat the entire message as text since tool is unknown
86
- expect(result).toEqual([
87
- {
88
- type: 'text',
89
- content: message,
90
- },
91
- ]);
92
- });
93
- test('should handle message with malformed parameter tags', () => {
94
- const message = '<tool_test_tool>malformed params</tool_test_tool>';
95
- const result = parseAssistantMessage(message, mockTools, toolPrefix);
96
- expect(result).toEqual([
97
- {
98
- type: 'tool_use',
99
- name: 'test_tool',
100
- params: {}, // No params should be parsed
101
- },
102
- ]);
103
- });
104
- test('should handle multiline parameter values', () => {
105
- const message = `<tool_test_tool>
106
- <tool_parameter_param1>
107
- multiline
108
- value
109
- </tool_parameter_param1>
110
- </tool_test_tool>`;
111
- const result = parseAssistantMessage(message, mockTools, toolPrefix);
112
- expect(result).toEqual([
113
- {
114
- type: 'tool_use',
115
- name: 'test_tool',
116
- params: {
117
- param1: 'multiline\n value',
118
- },
119
- },
120
- ]);
121
- });
122
- test('should handle parameter values containing XML-like tags', () => {
123
- const message = `<tool_test_tool>
124
- <tool_parameter_param1>value with <some>xml</some> tags</tool_parameter_param1>
125
- <tool_parameter_param2>another <tag>nested</tag> value</tool_parameter_param2>
126
- </tool_test_tool>`;
127
- const result = parseAssistantMessage(message, mockTools, toolPrefix);
128
- expect(result).toEqual([
129
- {
130
- type: 'tool_use',
131
- name: 'test_tool',
132
- params: {
133
- param1: 'value with <some>xml</some> tags',
134
- param2: 'another <tag>nested</tag> value',
135
- },
136
- },
137
- ]);
138
- });
139
- test('should handle parameter values containing incomplete/malformed XML tags', () => {
140
- const message = `<tool_test_tool>
141
- <tool_parameter_param1>value with <unclosed tag</tool_parameter_param1>
142
- <tool_parameter_param2>value with </>empty tag</> here</tool_parameter_param2>
143
- </tool_test_tool>`;
144
- const result = parseAssistantMessage(message, mockTools, toolPrefix);
145
- expect(result).toEqual([
146
- {
147
- type: 'tool_use',
148
- name: 'test_tool',
149
- params: {
150
- param1: 'value with <unclosed tag',
151
- param2: 'value with </>empty tag</> here',
152
- },
153
- },
154
- ]);
155
- });
156
- test('should handle parameter values containing tool-like tags', () => {
157
- const message = `<tool_test_tool>
158
- <tool_parameter_param1>value with <tool_test_tool>nested tool</tool_test_tool> tags</tool_parameter_param1>
159
- </tool_test_tool>`;
160
- const result = parseAssistantMessage(message, mockTools, toolPrefix);
161
- expect(result).toEqual([
162
- {
163
- type: 'tool_use',
164
- name: 'test_tool',
165
- params: {
166
- param1: 'value with <tool_test_tool>nested tool</tool_test_tool> tags',
167
- },
168
- },
169
- ]);
170
- });
171
- });
172
- //# sourceMappingURL=parseAssistantMessage.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseAssistantMessage.test.js","sourceRoot":"","sources":["../../src/Agent/parseAssistantMessage.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,MAAM,SAAS,GAAe;QAC5B;YACE,IAAI,EAAE,WAAW;YACjB,WAAW,EAAE,aAAa;YAC1B,UAAU,EAAE;gBACV,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE;gBACxF,EAAE,IAAI,EAAE,QAAQ,EAA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EAAE,UAAU,CAAC,CAAA;QAEpE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB;gBACE,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,WAAW;gBACjB,MAAM,EAAE;oBACN,MAAM,EAAE,8DAA8D;iBACvE;aACF;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,275 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import { convertToAnthropicMessage, convertToOpenAiMessages } from './utils';
3
- describe('convertToOpenAiMessages', () => {
4
- it('should convert simple text messages', () => {
5
- const anthropicMessages = [
6
- { role: 'user', content: 'Hello' },
7
- { role: 'assistant', content: 'Hi there!' },
8
- ];
9
- const result = convertToOpenAiMessages(anthropicMessages);
10
- expect(result).toEqual([
11
- { role: 'user', content: 'Hello' },
12
- { role: 'assistant', content: 'Hi there!' },
13
- ]);
14
- });
15
- it('should handle user messages with images', () => {
16
- const anthropicMessages = [
17
- {
18
- role: 'user',
19
- content: [
20
- { type: 'text', text: 'Check this image:' },
21
- {
22
- type: 'image',
23
- source: {
24
- type: 'base64',
25
- media_type: 'image/jpeg',
26
- data: 'base64data',
27
- },
28
- },
29
- ],
30
- },
31
- ];
32
- const result = convertToOpenAiMessages(anthropicMessages);
33
- expect(result).toEqual([
34
- {
35
- role: 'user',
36
- content: [
37
- { type: 'text', text: 'Check this image:' },
38
- {
39
- type: 'image_url',
40
- image_url: {
41
- url: 'data:image/jpeg;base64,base64data',
42
- },
43
- },
44
- ],
45
- },
46
- ]);
47
- });
48
- it('should handle assistant messages with tool calls', () => {
49
- const anthropicMessages = [
50
- {
51
- role: 'assistant',
52
- content: [
53
- { type: 'text', text: 'Let me help you with that.' },
54
- {
55
- type: 'tool_use',
56
- id: 'tool123',
57
- name: 'search',
58
- input: { query: 'test' },
59
- },
60
- ],
61
- },
62
- ];
63
- const result = convertToOpenAiMessages(anthropicMessages);
64
- expect(result).toEqual([
65
- {
66
- role: 'assistant',
67
- content: 'Let me help you with that.',
68
- tool_calls: [
69
- {
70
- id: 'tool123',
71
- type: 'function',
72
- function: {
73
- name: 'search',
74
- arguments: '{"query":"test"}',
75
- },
76
- },
77
- ],
78
- },
79
- ]);
80
- });
81
- it('should handle tool results', () => {
82
- const anthropicMessages = [
83
- {
84
- role: 'user',
85
- content: [
86
- {
87
- type: 'tool_result',
88
- tool_use_id: 'tool123',
89
- content: 'Search results found',
90
- },
91
- ],
92
- },
93
- ];
94
- const result = convertToOpenAiMessages(anthropicMessages);
95
- expect(result).toEqual([
96
- {
97
- role: 'tool',
98
- tool_call_id: 'tool123',
99
- content: 'Search results found',
100
- },
101
- ]);
102
- });
103
- });
104
- describe('convertToAnthropicMessage', () => {
105
- it('should convert simple text completion', () => {
106
- const openAiCompletion = {
107
- id: 'cmpl-123',
108
- choices: [
109
- {
110
- message: {
111
- role: 'assistant',
112
- content: 'Hello there!',
113
- refusal: null,
114
- },
115
- finish_reason: 'stop',
116
- index: 0,
117
- logprobs: null,
118
- },
119
- ],
120
- created: 1234567890,
121
- model: 'gpt-4',
122
- object: 'chat.completion',
123
- usage: {
124
- prompt_tokens: 10,
125
- completion_tokens: 20,
126
- total_tokens: 30,
127
- },
128
- };
129
- const result = convertToAnthropicMessage(openAiCompletion);
130
- expect(result).toEqual({
131
- id: 'cmpl-123',
132
- type: 'message',
133
- role: 'assistant',
134
- content: [
135
- {
136
- type: 'text',
137
- text: 'Hello there!',
138
- },
139
- ],
140
- model: 'gpt-4',
141
- stop_reason: 'end_turn',
142
- stop_sequence: null,
143
- usage: {
144
- input_tokens: 10,
145
- output_tokens: 20,
146
- cache_creation_input_tokens: null,
147
- cache_read_input_tokens: null,
148
- },
149
- });
150
- });
151
- it('should handle tool calls in completion', () => {
152
- const openAiCompletion = {
153
- id: 'cmpl-123',
154
- choices: [
155
- {
156
- message: {
157
- role: 'assistant',
158
- content: 'Let me search that for you.',
159
- refusal: null,
160
- tool_calls: [
161
- {
162
- id: 'call_123',
163
- type: 'function',
164
- function: {
165
- name: 'search',
166
- arguments: '{"query":"test"}',
167
- },
168
- },
169
- ],
170
- },
171
- finish_reason: 'tool_calls',
172
- index: 0,
173
- logprobs: null,
174
- },
175
- ],
176
- created: 1234567890,
177
- model: 'gpt-4',
178
- object: 'chat.completion',
179
- usage: {
180
- prompt_tokens: 10,
181
- completion_tokens: 20,
182
- total_tokens: 30,
183
- },
184
- };
185
- const result = convertToAnthropicMessage(openAiCompletion);
186
- expect(result).toEqual({
187
- id: 'cmpl-123',
188
- type: 'message',
189
- role: 'assistant',
190
- content: [
191
- {
192
- type: 'text',
193
- text: 'Let me search that for you.',
194
- },
195
- {
196
- type: 'tool_use',
197
- id: 'call_123',
198
- name: 'search',
199
- input: { query: 'test' },
200
- },
201
- ],
202
- model: 'gpt-4',
203
- stop_reason: 'tool_use',
204
- stop_sequence: null,
205
- usage: {
206
- input_tokens: 10,
207
- output_tokens: 20,
208
- cache_creation_input_tokens: null,
209
- cache_read_input_tokens: null,
210
- },
211
- });
212
- });
213
- it('should handle invalid tool call arguments', () => {
214
- const openAiCompletion = {
215
- id: 'cmpl-123',
216
- choices: [
217
- {
218
- message: {
219
- role: 'assistant',
220
- content: 'Testing invalid arguments',
221
- refusal: null,
222
- tool_calls: [
223
- {
224
- id: 'call_123',
225
- type: 'function',
226
- function: {
227
- name: 'test',
228
- arguments: 'invalid json',
229
- },
230
- },
231
- ],
232
- },
233
- finish_reason: 'tool_calls',
234
- index: 0,
235
- logprobs: null,
236
- },
237
- ],
238
- created: 1234567890,
239
- model: 'gpt-4',
240
- object: 'chat.completion',
241
- };
242
- const result = convertToAnthropicMessage(openAiCompletion);
243
- expect(result.content).toHaveLength(2);
244
- expect(result.content[1]).toEqual({
245
- type: 'tool_use',
246
- id: 'call_123',
247
- name: 'test',
248
- input: {},
249
- });
250
- });
251
- it('should handle different finish reasons', () => {
252
- const createCompletion = (finish_reason) => ({
253
- id: 'cmpl-123',
254
- choices: [
255
- {
256
- message: {
257
- role: 'assistant',
258
- content: 'Test',
259
- refusal: null,
260
- },
261
- finish_reason: finish_reason,
262
- index: 0,
263
- logprobs: null,
264
- },
265
- ],
266
- created: 1234567890,
267
- model: 'gpt-4',
268
- object: 'chat.completion',
269
- });
270
- expect(convertToAnthropicMessage(createCompletion('stop')).stop_reason).toBe('end_turn');
271
- expect(convertToAnthropicMessage(createCompletion('length')).stop_reason).toBe('max_tokens');
272
- expect(convertToAnthropicMessage(createCompletion('tool_calls')).stop_reason).toBe('tool_use');
273
- });
274
- });
275
- //# sourceMappingURL=utils.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../src/AiService/utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;AAI/C,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAE5E,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,iBAAiB,GAAsC;YAC3D,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE;YAClC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE;SAC5C,CAAA;QAED,MAAM,MAAM,GAAG,uBAAuB,CAAC,iBAAiB,CAAC,CAAA;QAEzD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE;YAClC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE;SAC5C,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,iBAAiB,GAAsC;YAC3D;gBACE,I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