@polka-codes/core 0.9.86 → 0.9.88
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/dist/_tsup-dts-rollup.d.ts +128 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +85 -10
- package/package.json +1 -1
|
@@ -122,6 +122,7 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
|
122
122
|
project: z.ZodOptional<z.ZodString>;
|
|
123
123
|
keyFile: z.ZodOptional<z.ZodString>;
|
|
124
124
|
baseUrl: z.ZodOptional<z.ZodString>;
|
|
125
|
+
name: z.ZodOptional<z.ZodString>;
|
|
125
126
|
}, z.core.$strip>>>;
|
|
126
127
|
defaultProvider: z.ZodOptional<z.ZodString>;
|
|
127
128
|
defaultModel: z.ZodOptional<z.ZodString>;
|
|
@@ -211,6 +212,59 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
|
211
212
|
branch: z.ZodOptional<z.ZodString>;
|
|
212
213
|
}, z.core.$strict>]>>>, z.ZodString]>>;
|
|
213
214
|
excludeFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
215
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
216
|
+
preset: z.ZodOptional<z.ZodString>;
|
|
217
|
+
strategy: z.ZodOptional<z.ZodEnum<{
|
|
218
|
+
"goal-directed": "goal-directed";
|
|
219
|
+
"continuous-improvement": "continuous-improvement";
|
|
220
|
+
}>>;
|
|
221
|
+
continueOnCompletion: z.ZodOptional<z.ZodBoolean>;
|
|
222
|
+
maxIterations: z.ZodOptional<z.ZodNumber>;
|
|
223
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
224
|
+
requireApprovalFor: z.ZodOptional<z.ZodEnum<{
|
|
225
|
+
none: "none";
|
|
226
|
+
destructive: "destructive";
|
|
227
|
+
commits: "commits";
|
|
228
|
+
all: "all";
|
|
229
|
+
}>>;
|
|
230
|
+
autoApproveSafeTasks: z.ZodOptional<z.ZodBoolean>;
|
|
231
|
+
maxAutoApprovalCost: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
pauseOnError: z.ZodOptional<z.ZodBoolean>;
|
|
233
|
+
workingBranch: z.ZodOptional<z.ZodString>;
|
|
234
|
+
destructiveOperations: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
235
|
+
maxConcurrency: z.ZodOptional<z.ZodNumber>;
|
|
236
|
+
autoSaveInterval: z.ZodOptional<z.ZodNumber>;
|
|
237
|
+
workingDir: z.ZodOptional<z.ZodString>;
|
|
238
|
+
continuousImprovement: z.ZodOptional<z.ZodObject<{
|
|
239
|
+
sleepTimeOnNoTasks: z.ZodOptional<z.ZodNumber>;
|
|
240
|
+
sleepTimeBetweenTasks: z.ZodOptional<z.ZodNumber>;
|
|
241
|
+
maxCycles: z.ZodOptional<z.ZodNumber>;
|
|
242
|
+
}, z.core.$strict>>;
|
|
243
|
+
discovery: z.ZodOptional<z.ZodObject<{
|
|
244
|
+
enabledStrategies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
245
|
+
cacheTime: z.ZodOptional<z.ZodNumber>;
|
|
246
|
+
checkChanges: z.ZodOptional<z.ZodBoolean>;
|
|
247
|
+
}, z.core.$strict>>;
|
|
248
|
+
safety: z.ZodOptional<z.ZodObject<{
|
|
249
|
+
enabledChecks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
250
|
+
blockDestructive: z.ZodOptional<z.ZodBoolean>;
|
|
251
|
+
maxFileSize: z.ZodOptional<z.ZodNumber>;
|
|
252
|
+
}, z.core.$strict>>;
|
|
253
|
+
healthCheck: z.ZodOptional<z.ZodObject<{
|
|
254
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
255
|
+
interval: z.ZodOptional<z.ZodNumber>;
|
|
256
|
+
}, z.core.$strict>>;
|
|
257
|
+
approval: z.ZodOptional<z.ZodObject<{
|
|
258
|
+
level: z.ZodOptional<z.ZodEnum<{
|
|
259
|
+
none: "none";
|
|
260
|
+
destructive: "destructive";
|
|
261
|
+
commits: "commits";
|
|
262
|
+
all: "all";
|
|
263
|
+
}>>;
|
|
264
|
+
autoApproveSafeTasks: z.ZodOptional<z.ZodBoolean>;
|
|
265
|
+
maxAutoApprovalCost: z.ZodOptional<z.ZodNumber>;
|
|
266
|
+
}, z.core.$strict>>;
|
|
267
|
+
}, z.core.$strict>>;
|
|
214
268
|
}, z.core.$strict>>>;
|
|
215
269
|
export { configSchema }
|
|
216
270
|
export { configSchema as configSchema_alias_1 }
|
|
@@ -254,15 +308,86 @@ export { createDynamicWorkflow }
|
|
|
254
308
|
export { createDynamicWorkflow as createDynamicWorkflow_alias_1 }
|
|
255
309
|
export { createDynamicWorkflow as createDynamicWorkflow_alias_2 }
|
|
256
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Create an error tool response
|
|
313
|
+
*
|
|
314
|
+
* @param message - The error message
|
|
315
|
+
* @returns An error tool response object
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```ts
|
|
319
|
+
* return createErrorResponse('Failed to read file')
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
declare function createErrorResponse(message: string): ToolResponse;
|
|
323
|
+
export { createErrorResponse }
|
|
324
|
+
export { createErrorResponse as createErrorResponse_alias_1 }
|
|
325
|
+
export { createErrorResponse as createErrorResponse_alias_2 }
|
|
326
|
+
|
|
257
327
|
/**
|
|
258
328
|
* Create a file content XML element
|
|
259
329
|
*/
|
|
260
330
|
export declare function createFileElement(tagName: string, path: string, content?: string, attrs?: Record<string, string>): string;
|
|
261
331
|
|
|
262
332
|
/**
|
|
263
|
-
* Create a
|
|
333
|
+
* Create a provider capability error response
|
|
334
|
+
* Use this when a required provider capability is not available
|
|
335
|
+
*
|
|
336
|
+
* @param capability - The capability that's missing (e.g., "read file", "write file")
|
|
337
|
+
* @returns An error response indicating the missing capability
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* if (!provider.readFile) {
|
|
342
|
+
* return createProviderErrorResponse('read file')
|
|
343
|
+
* }
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
declare function createProviderErrorResponse(capability: string): ToolResponse;
|
|
347
|
+
export { createProviderErrorResponse as createProviderError }
|
|
348
|
+
export { createProviderErrorResponse }
|
|
349
|
+
export { createProviderErrorResponse as createProviderErrorResponse_alias_1 }
|
|
350
|
+
export { createProviderErrorResponse as createProviderErrorResponse_alias_2 }
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Create a successful tool response
|
|
354
|
+
*
|
|
355
|
+
* @param value - The response value (string or JSON string)
|
|
356
|
+
* @param type - Response type ('text' or 'json')
|
|
357
|
+
* @returns A successful tool response object
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```ts
|
|
361
|
+
* return createSuccessResponse('File content loaded')
|
|
362
|
+
* return createSuccessResponse(JSON.stringify(data), 'json')
|
|
363
|
+
* ```
|
|
264
364
|
*/
|
|
265
|
-
|
|
365
|
+
declare function createSuccessResponse(value: string, type?: 'text' | 'json'): ToolResponse;
|
|
366
|
+
export { createSuccessResponse }
|
|
367
|
+
export { createSuccessResponse as createSuccessResponse_alias_1 }
|
|
368
|
+
export { createSuccessResponse as createSuccessResponse_alias_2 }
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Create a validation error response
|
|
372
|
+
* Use this when input validation fails
|
|
373
|
+
*
|
|
374
|
+
* @param errors - The validation error details
|
|
375
|
+
* @returns An error response with validation details
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```ts
|
|
379
|
+
* const result = schema.safeParse(input)
|
|
380
|
+
* if (!result.success) {
|
|
381
|
+
* return createValidationErrorResponse(result.error)
|
|
382
|
+
* }
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
declare function createValidationErrorResponse(errors: {
|
|
386
|
+
message: string;
|
|
387
|
+
}): ToolResponse;
|
|
388
|
+
export { createValidationErrorResponse }
|
|
389
|
+
export { createValidationErrorResponse as createValidationErrorResponse_alias_1 }
|
|
390
|
+
export { createValidationErrorResponse as createValidationErrorResponse_alias_2 }
|
|
266
391
|
|
|
267
392
|
declare const _default: {
|
|
268
393
|
handler: ToolHandler<{
|
|
@@ -1264,6 +1389,7 @@ declare const providerConfigSchema: z.ZodObject<{
|
|
|
1264
1389
|
project: z.ZodOptional<z.ZodString>;
|
|
1265
1390
|
keyFile: z.ZodOptional<z.ZodString>;
|
|
1266
1391
|
baseUrl: z.ZodOptional<z.ZodString>;
|
|
1392
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1267
1393
|
}, z.core.$strip>;
|
|
1268
1394
|
export { providerConfigSchema }
|
|
1269
1395
|
export { providerConfigSchema as providerConfigSchema_alias_1 }
|
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,10 @@ export { readFile } from './_tsup-dts-rollup.js';
|
|
|
72
72
|
export { removeFile } from './_tsup-dts-rollup.js';
|
|
73
73
|
export { renameFile } from './_tsup-dts-rollup.js';
|
|
74
74
|
export { replaceInFile } from './_tsup-dts-rollup.js';
|
|
75
|
+
export { createErrorResponse } from './_tsup-dts-rollup.js';
|
|
76
|
+
export { createProviderErrorResponse } from './_tsup-dts-rollup.js';
|
|
77
|
+
export { createSuccessResponse } from './_tsup-dts-rollup.js';
|
|
78
|
+
export { createValidationErrorResponse } from './_tsup-dts-rollup.js';
|
|
75
79
|
export { search } from './_tsup-dts-rollup.js';
|
|
76
80
|
export { searchFiles } from './_tsup-dts-rollup.js';
|
|
77
81
|
export { writeToFile } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -146,7 +146,9 @@ var providerConfigSchema = z.object({
|
|
|
146
146
|
location: z.string().optional(),
|
|
147
147
|
project: z.string().optional(),
|
|
148
148
|
keyFile: z.string().optional(),
|
|
149
|
-
baseUrl: z.string().optional()
|
|
149
|
+
baseUrl: z.string().optional(),
|
|
150
|
+
name: z.string().optional()
|
|
151
|
+
// For OpenAI-compatible providers
|
|
150
152
|
});
|
|
151
153
|
var providerModelSchema = z.object({
|
|
152
154
|
provider: z.string().optional(),
|
|
@@ -202,6 +204,51 @@ var mcpServerConfigSchema = z.object({
|
|
|
202
204
|
)
|
|
203
205
|
).optional()
|
|
204
206
|
}).strict();
|
|
207
|
+
var agentContinuousImprovementSchema = z.object({
|
|
208
|
+
sleepTimeOnNoTasks: z.number().int().optional(),
|
|
209
|
+
sleepTimeBetweenTasks: z.number().int().optional(),
|
|
210
|
+
maxCycles: z.number().int().optional()
|
|
211
|
+
}).strict().optional();
|
|
212
|
+
var agentDiscoverySchema = z.object({
|
|
213
|
+
enabledStrategies: z.array(z.string()).optional(),
|
|
214
|
+
cacheTime: z.number().int().optional(),
|
|
215
|
+
checkChanges: z.boolean().optional()
|
|
216
|
+
}).strict().optional();
|
|
217
|
+
var agentSafetySchema = z.object({
|
|
218
|
+
enabledChecks: z.array(z.string()).optional(),
|
|
219
|
+
blockDestructive: z.boolean().optional(),
|
|
220
|
+
maxFileSize: z.number().int().optional()
|
|
221
|
+
}).strict().optional();
|
|
222
|
+
var agentHealthCheckSchema = z.object({
|
|
223
|
+
enabled: z.boolean().optional(),
|
|
224
|
+
interval: z.number().int().optional()
|
|
225
|
+
}).strict().optional();
|
|
226
|
+
var agentApprovalSchema = z.object({
|
|
227
|
+
level: z.enum(["none", "destructive", "commits", "all"]).optional(),
|
|
228
|
+
autoApproveSafeTasks: z.boolean().optional(),
|
|
229
|
+
maxAutoApprovalCost: z.number().optional()
|
|
230
|
+
}).strict().optional();
|
|
231
|
+
var agentSchema = z.object({
|
|
232
|
+
preset: z.string().optional(),
|
|
233
|
+
strategy: z.enum(["goal-directed", "continuous-improvement"]).optional(),
|
|
234
|
+
continueOnCompletion: z.boolean().optional(),
|
|
235
|
+
maxIterations: z.number().int().optional(),
|
|
236
|
+
timeout: z.number().int().optional(),
|
|
237
|
+
requireApprovalFor: z.enum(["none", "destructive", "commits", "all"]).optional(),
|
|
238
|
+
autoApproveSafeTasks: z.boolean().optional(),
|
|
239
|
+
maxAutoApprovalCost: z.number().optional(),
|
|
240
|
+
pauseOnError: z.boolean().optional(),
|
|
241
|
+
workingBranch: z.string().optional(),
|
|
242
|
+
destructiveOperations: z.array(z.string()).optional(),
|
|
243
|
+
maxConcurrency: z.number().int().optional(),
|
|
244
|
+
autoSaveInterval: z.number().int().optional(),
|
|
245
|
+
workingDir: z.string().optional(),
|
|
246
|
+
continuousImprovement: agentContinuousImprovementSchema,
|
|
247
|
+
discovery: agentDiscoverySchema,
|
|
248
|
+
safety: agentSafetySchema,
|
|
249
|
+
healthCheck: agentHealthCheckSchema,
|
|
250
|
+
approval: agentApprovalSchema
|
|
251
|
+
}).strict().optional();
|
|
205
252
|
var configSchema = z.object({
|
|
206
253
|
prices: z.record(
|
|
207
254
|
z.string(),
|
|
@@ -233,7 +280,8 @@ var configSchema = z.object({
|
|
|
233
280
|
}).optional(),
|
|
234
281
|
mcpServers: z.record(z.string(), mcpServerConfigSchema).optional(),
|
|
235
282
|
rules: z.array(ruleSchema).optional().or(z.string()).optional(),
|
|
236
|
-
excludeFiles: z.array(z.string()).optional()
|
|
283
|
+
excludeFiles: z.array(z.string()).optional(),
|
|
284
|
+
agent: agentSchema
|
|
237
285
|
}).strict().nullish();
|
|
238
286
|
|
|
239
287
|
// src/fs/node-provider.ts
|
|
@@ -999,16 +1047,39 @@ var askFollowupQuestion_default = {
|
|
|
999
1047
|
// src/tools/executeCommand.ts
|
|
1000
1048
|
import { z as z7 } from "zod";
|
|
1001
1049
|
|
|
1002
|
-
// src/tools/
|
|
1003
|
-
function
|
|
1050
|
+
// src/tools/response-builders.ts
|
|
1051
|
+
function createSuccessResponse(value, type = "text") {
|
|
1052
|
+
return {
|
|
1053
|
+
success: true,
|
|
1054
|
+
message: { type, value }
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
function createErrorResponse(message) {
|
|
1058
|
+
return {
|
|
1059
|
+
success: false,
|
|
1060
|
+
message: { type: "error-text", value: message }
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
function createProviderErrorResponse(capability) {
|
|
1004
1064
|
return {
|
|
1005
1065
|
success: false,
|
|
1006
1066
|
message: {
|
|
1007
1067
|
type: "error-text",
|
|
1008
|
-
value: `Not possible to ${
|
|
1068
|
+
value: `Not possible to ${capability}.`
|
|
1009
1069
|
}
|
|
1010
1070
|
};
|
|
1011
1071
|
}
|
|
1072
|
+
function createValidationErrorResponse(errors) {
|
|
1073
|
+
return {
|
|
1074
|
+
success: false,
|
|
1075
|
+
message: {
|
|
1076
|
+
type: "error-text",
|
|
1077
|
+
value: `Validation failed: ${errors.message}`
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// src/tools/utils.ts
|
|
1012
1083
|
function preprocessBoolean(val) {
|
|
1013
1084
|
return typeof val === "string" ? val.toLowerCase() === "true" : val;
|
|
1014
1085
|
}
|
|
@@ -1048,7 +1119,7 @@ var toolInfo2 = {
|
|
|
1048
1119
|
};
|
|
1049
1120
|
var handler2 = async (provider, args) => {
|
|
1050
1121
|
if (!provider.executeCommand) {
|
|
1051
|
-
return
|
|
1122
|
+
return createProviderErrorResponse("execute command. Abort");
|
|
1052
1123
|
}
|
|
1053
1124
|
const { command, requiresApproval } = toolInfo2.parameters.parse(args);
|
|
1054
1125
|
try {
|
|
@@ -1203,7 +1274,7 @@ var toolInfo4 = {
|
|
|
1203
1274
|
};
|
|
1204
1275
|
var handler4 = async (provider, args) => {
|
|
1205
1276
|
if (!provider.listFiles) {
|
|
1206
|
-
return
|
|
1277
|
+
return createProviderErrorResponse("list files");
|
|
1207
1278
|
}
|
|
1208
1279
|
const { path, maxCount, recursive, includeIgnored } = toolInfo4.parameters.parse(args);
|
|
1209
1280
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
@@ -1368,7 +1439,7 @@ var toolInfo6 = {
|
|
|
1368
1439
|
};
|
|
1369
1440
|
var handler6 = async (provider, args) => {
|
|
1370
1441
|
if (!provider.readFile) {
|
|
1371
|
-
return
|
|
1442
|
+
return createProviderErrorResponse("read file");
|
|
1372
1443
|
}
|
|
1373
1444
|
const { path: paths, includeIgnored } = toolInfo6.parameters.parse(args);
|
|
1374
1445
|
const resp = [];
|
|
@@ -1413,7 +1484,7 @@ var toolInfo7 = {
|
|
|
1413
1484
|
};
|
|
1414
1485
|
var handler7 = async (provider, args) => {
|
|
1415
1486
|
if (!provider.removeFile) {
|
|
1416
|
-
return
|
|
1487
|
+
return createProviderErrorResponse("remove file");
|
|
1417
1488
|
}
|
|
1418
1489
|
const parsed = toolInfo7.parameters.safeParse(args);
|
|
1419
1490
|
if (!parsed.success) {
|
|
@@ -1980,7 +2051,7 @@ export default App;
|
|
|
1980
2051
|
};
|
|
1981
2052
|
var handler12 = async (provider, args) => {
|
|
1982
2053
|
if (!provider.writeFile) {
|
|
1983
|
-
return
|
|
2054
|
+
return createProviderErrorResponse("write file");
|
|
1984
2055
|
}
|
|
1985
2056
|
const parsed = toolInfo12.parameters.safeParse(args);
|
|
1986
2057
|
if (!parsed.success) {
|
|
@@ -3484,6 +3555,10 @@ export {
|
|
|
3484
3555
|
convertJsonSchemaToZod,
|
|
3485
3556
|
createContext,
|
|
3486
3557
|
createDynamicWorkflow,
|
|
3558
|
+
createErrorResponse,
|
|
3559
|
+
createProviderErrorResponse,
|
|
3560
|
+
createSuccessResponse,
|
|
3561
|
+
createValidationErrorResponse,
|
|
3487
3562
|
executeCommand_default as executeCommand,
|
|
3488
3563
|
fetchUrl_default as fetchUrl,
|
|
3489
3564
|
fromJsonModelMessage,
|