@polka-codes/runner 0.9.2 → 0.9.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/dist/index.js +665 -407
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19540,9 +19540,9 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
19540
19540
|
}
|
|
19541
19541
|
Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
|
|
19542
19542
|
var EventTarget = {
|
|
19543
|
-
addEventListener(type,
|
|
19543
|
+
addEventListener(type, handler15, options = {}) {
|
|
19544
19544
|
for (const listener of this.listeners(type)) {
|
|
19545
|
-
if (!options[kForOnEventAttribute] && listener[kListener] ===
|
|
19545
|
+
if (!options[kForOnEventAttribute] && listener[kListener] === handler15 && !listener[kForOnEventAttribute]) {
|
|
19546
19546
|
return;
|
|
19547
19547
|
}
|
|
19548
19548
|
}
|
|
@@ -19553,7 +19553,7 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
19553
19553
|
data: isBinary ? data : data.toString()
|
|
19554
19554
|
});
|
|
19555
19555
|
event[kTarget] = this;
|
|
19556
|
-
callListener(
|
|
19556
|
+
callListener(handler15, this, event);
|
|
19557
19557
|
};
|
|
19558
19558
|
} else if (type === "close") {
|
|
19559
19559
|
wrapper = function onClose(code, message) {
|
|
@@ -19563,7 +19563,7 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
19563
19563
|
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
19564
19564
|
});
|
|
19565
19565
|
event[kTarget] = this;
|
|
19566
|
-
callListener(
|
|
19566
|
+
callListener(handler15, this, event);
|
|
19567
19567
|
};
|
|
19568
19568
|
} else if (type === "error") {
|
|
19569
19569
|
wrapper = function onError(error81) {
|
|
@@ -19572,28 +19572,28 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
19572
19572
|
message: error81.message
|
|
19573
19573
|
});
|
|
19574
19574
|
event[kTarget] = this;
|
|
19575
|
-
callListener(
|
|
19575
|
+
callListener(handler15, this, event);
|
|
19576
19576
|
};
|
|
19577
19577
|
} else if (type === "open") {
|
|
19578
19578
|
wrapper = function onOpen() {
|
|
19579
19579
|
const event = new Event("open");
|
|
19580
19580
|
event[kTarget] = this;
|
|
19581
|
-
callListener(
|
|
19581
|
+
callListener(handler15, this, event);
|
|
19582
19582
|
};
|
|
19583
19583
|
} else {
|
|
19584
19584
|
return;
|
|
19585
19585
|
}
|
|
19586
19586
|
wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
|
|
19587
|
-
wrapper[kListener] =
|
|
19587
|
+
wrapper[kListener] = handler15;
|
|
19588
19588
|
if (options.once) {
|
|
19589
19589
|
this.once(type, wrapper);
|
|
19590
19590
|
} else {
|
|
19591
19591
|
this.on(type, wrapper);
|
|
19592
19592
|
}
|
|
19593
19593
|
},
|
|
19594
|
-
removeEventListener(type,
|
|
19594
|
+
removeEventListener(type, handler15) {
|
|
19595
19595
|
for (const listener of this.listeners(type)) {
|
|
19596
|
-
if (listener[kListener] ===
|
|
19596
|
+
if (listener[kListener] === handler15 && !listener[kForOnEventAttribute]) {
|
|
19597
19597
|
this.removeListener(type, listener);
|
|
19598
19598
|
break;
|
|
19599
19599
|
}
|
|
@@ -20119,16 +20119,16 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
20119
20119
|
}
|
|
20120
20120
|
return null;
|
|
20121
20121
|
},
|
|
20122
|
-
set(
|
|
20122
|
+
set(handler15) {
|
|
20123
20123
|
for (const listener of this.listeners(method)) {
|
|
20124
20124
|
if (listener[kForOnEventAttribute]) {
|
|
20125
20125
|
this.removeListener(method, listener);
|
|
20126
20126
|
break;
|
|
20127
20127
|
}
|
|
20128
20128
|
}
|
|
20129
|
-
if (typeof
|
|
20129
|
+
if (typeof handler15 !== "function")
|
|
20130
20130
|
return;
|
|
20131
|
-
this.addEventListener(method,
|
|
20131
|
+
this.addEventListener(method, handler15, {
|
|
20132
20132
|
[kForOnEventAttribute]: true
|
|
20133
20133
|
});
|
|
20134
20134
|
}
|
|
@@ -21008,7 +21008,7 @@ var {
|
|
|
21008
21008
|
Help
|
|
21009
21009
|
} = import__.default;
|
|
21010
21010
|
// package.json
|
|
21011
|
-
var version = "0.9.
|
|
21011
|
+
var version = "0.9.3";
|
|
21012
21012
|
|
|
21013
21013
|
// src/runner.ts
|
|
21014
21014
|
import { execSync } from "node:child_process";
|
|
@@ -32092,35 +32092,27 @@ var toolInfo = {
|
|
|
32092
32092
|
description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.",
|
|
32093
32093
|
parameters: exports_external.object({
|
|
32094
32094
|
questions: exports_external.array(questionObject).describe("One or more follow-up questions you need answered before you can continue.").meta({ usageValue: "questions here" })
|
|
32095
|
-
})
|
|
32096
|
-
|
|
32097
|
-
|
|
32098
|
-
|
|
32099
|
-
|
|
32100
|
-
|
|
32101
|
-
name: "questions",
|
|
32102
|
-
value: { prompt: "What is the target deployment environment?" }
|
|
32095
|
+
}).meta({
|
|
32096
|
+
examples: [
|
|
32097
|
+
{
|
|
32098
|
+
description: "Single clarifying question (no options)",
|
|
32099
|
+
input: {
|
|
32100
|
+
questions: { prompt: "What is the target deployment environment?" }
|
|
32103
32101
|
}
|
|
32104
|
-
|
|
32105
|
-
|
|
32106
|
-
|
|
32107
|
-
|
|
32108
|
-
|
|
32109
|
-
{
|
|
32110
|
-
name: "questions",
|
|
32111
|
-
value: {
|
|
32102
|
+
},
|
|
32103
|
+
{
|
|
32104
|
+
description: "Single question with multiple-choice options",
|
|
32105
|
+
input: {
|
|
32106
|
+
questions: {
|
|
32112
32107
|
prompt: "Which frontend framework are you using?",
|
|
32113
32108
|
options: ["React", "Angular", "Vue", "Svelte"]
|
|
32114
32109
|
}
|
|
32115
32110
|
}
|
|
32116
|
-
|
|
32117
|
-
|
|
32118
|
-
|
|
32119
|
-
|
|
32120
|
-
|
|
32121
|
-
{
|
|
32122
|
-
name: "questions",
|
|
32123
|
-
value: [
|
|
32111
|
+
},
|
|
32112
|
+
{
|
|
32113
|
+
description: "Two related questions in one call",
|
|
32114
|
+
input: {
|
|
32115
|
+
questions: [
|
|
32124
32116
|
{ prompt: "What type of application are you building?" },
|
|
32125
32117
|
{
|
|
32126
32118
|
prompt: "Preferred programming language?",
|
|
@@ -32128,21 +32120,18 @@ var toolInfo = {
|
|
|
32128
32120
|
}
|
|
32129
32121
|
]
|
|
32130
32122
|
}
|
|
32131
|
-
|
|
32132
|
-
|
|
32133
|
-
|
|
32134
|
-
|
|
32135
|
-
|
|
32136
|
-
{
|
|
32137
|
-
name: "questions",
|
|
32138
|
-
value: {
|
|
32123
|
+
},
|
|
32124
|
+
{
|
|
32125
|
+
description: "Binary (yes/no) confirmation",
|
|
32126
|
+
input: {
|
|
32127
|
+
questions: {
|
|
32139
32128
|
prompt: "Is it acceptable to refactor existing tests to improve performance?",
|
|
32140
32129
|
options: ["Yes", "No"]
|
|
32141
32130
|
}
|
|
32142
32131
|
}
|
|
32143
|
-
|
|
32144
|
-
|
|
32145
|
-
|
|
32132
|
+
}
|
|
32133
|
+
]
|
|
32134
|
+
}),
|
|
32146
32135
|
permissionLevel: 0 /* None */
|
|
32147
32136
|
};
|
|
32148
32137
|
var handler = async (provider, args) => {
|
|
@@ -32187,18 +32176,16 @@ var toolInfo2 = {
|
|
|
32187
32176
|
description: "Use this tool when you believe the user’s requested task is complete. Indicate that your work is finished, but acknowledge the user may still provide additional instructions or questions if they want to continue. This tool MUST NOT to be used with any other tool.",
|
|
32188
32177
|
parameters: exports_external.object({
|
|
32189
32178
|
result: exports_external.string().describe("The result of the task. Formulate this result in a way that is final and does not require further input from the user. Don't end your result with questions or offers for further assistance.").meta({ usageValue: "Your final result description here" })
|
|
32190
|
-
})
|
|
32191
|
-
|
|
32192
|
-
|
|
32193
|
-
|
|
32194
|
-
|
|
32195
|
-
|
|
32196
|
-
name: "result",
|
|
32197
|
-
value: "Your final result description here"
|
|
32179
|
+
}).meta({
|
|
32180
|
+
examples: [
|
|
32181
|
+
{
|
|
32182
|
+
description: "Request to present the result of the task",
|
|
32183
|
+
input: {
|
|
32184
|
+
result: "Your final result description here"
|
|
32198
32185
|
}
|
|
32199
|
-
|
|
32200
|
-
|
|
32201
|
-
|
|
32186
|
+
}
|
|
32187
|
+
]
|
|
32188
|
+
}),
|
|
32202
32189
|
permissionLevel: 0 /* None */
|
|
32203
32190
|
};
|
|
32204
32191
|
var handler2 = async (provider, args) => {
|
|
@@ -32244,30 +32231,19 @@ var toolInfo3 = {
|
|
|
32244
32231
|
const values = Array.isArray(val) ? val : [val];
|
|
32245
32232
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
32246
32233
|
}, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
|
|
32247
|
-
})
|
|
32248
|
-
|
|
32249
|
-
|
|
32250
|
-
|
|
32251
|
-
|
|
32252
|
-
|
|
32253
|
-
|
|
32254
|
-
|
|
32255
|
-
|
|
32256
|
-
{
|
|
32257
|
-
name: "task",
|
|
32258
|
-
value: "Analyze the authentication implementation"
|
|
32259
|
-
},
|
|
32260
|
-
{
|
|
32261
|
-
name: "context",
|
|
32262
|
-
value: "Need to understand the security implications of the current auth system"
|
|
32263
|
-
},
|
|
32264
|
-
{
|
|
32265
|
-
name: "files",
|
|
32266
|
-
value: "src/auth/login.ts,src/auth/types.ts"
|
|
32234
|
+
}).meta({
|
|
32235
|
+
examples: [
|
|
32236
|
+
{
|
|
32237
|
+
description: "Delegate a code analysis task to the analyzer agent",
|
|
32238
|
+
input: {
|
|
32239
|
+
agentName: "analyzer",
|
|
32240
|
+
task: "Analyze the authentication implementation",
|
|
32241
|
+
context: "Need to understand the security implications of the current auth system",
|
|
32242
|
+
files: "src/auth/login.ts,src/auth/types.ts"
|
|
32267
32243
|
}
|
|
32268
|
-
|
|
32269
|
-
|
|
32270
|
-
|
|
32244
|
+
}
|
|
32245
|
+
]
|
|
32246
|
+
}),
|
|
32271
32247
|
permissionLevel: 0 /* None */
|
|
32272
32248
|
};
|
|
32273
32249
|
var handler3 = async (_provider, args) => {
|
|
@@ -32311,16 +32287,17 @@ var toolInfo4 = {
|
|
|
32311
32287
|
}
|
|
32312
32288
|
return val;
|
|
32313
32289
|
}, exports_external.boolean().optional().default(false)).describe("Set to `true` for commands that install/uninstall software, modify or delete files, change system settings, perform network operations, or have other side effects. Use `false` for safe, read-only, or purely local development actions (e.g., listing files, make a build, running tests).").meta({ usageValue: "true | false" })
|
|
32290
|
+
}).meta({
|
|
32291
|
+
examples: [
|
|
32292
|
+
{
|
|
32293
|
+
description: "Make a build",
|
|
32294
|
+
input: {
|
|
32295
|
+
command: "npm run build",
|
|
32296
|
+
requiresApproval: "false"
|
|
32297
|
+
}
|
|
32298
|
+
}
|
|
32299
|
+
]
|
|
32314
32300
|
}),
|
|
32315
|
-
examples: [
|
|
32316
|
-
{
|
|
32317
|
-
description: "Make a build",
|
|
32318
|
-
parameters: [
|
|
32319
|
-
{ name: "command", value: "npm run build" },
|
|
32320
|
-
{ name: "requiresApproval", value: "false" }
|
|
32321
|
-
]
|
|
32322
|
-
}
|
|
32323
|
-
],
|
|
32324
32301
|
permissionLevel: 3 /* Arbitrary */
|
|
32325
32302
|
};
|
|
32326
32303
|
var handler4 = async (provider, args) => {
|
|
@@ -32378,36 +32355,28 @@ var toolInfo5 = {
|
|
|
32378
32355
|
const values = Array.isArray(val) ? val : [val];
|
|
32379
32356
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
32380
32357
|
}, exports_external.array(exports_external.string())).describe("One or more URLs to fetch, separated by commas if multiple.").meta({ usageValue: "url" })
|
|
32381
|
-
})
|
|
32382
|
-
|
|
32383
|
-
|
|
32384
|
-
|
|
32385
|
-
|
|
32386
|
-
|
|
32387
|
-
name: "url",
|
|
32388
|
-
value: "https://example.com"
|
|
32358
|
+
}).meta({
|
|
32359
|
+
examples: [
|
|
32360
|
+
{
|
|
32361
|
+
description: "Fetch a single webpage",
|
|
32362
|
+
input: {
|
|
32363
|
+
url: "https://example.com"
|
|
32389
32364
|
}
|
|
32390
|
-
|
|
32391
|
-
|
|
32392
|
-
|
|
32393
|
-
|
|
32394
|
-
|
|
32395
|
-
{
|
|
32396
|
-
name: "url",
|
|
32397
|
-
value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
|
|
32365
|
+
},
|
|
32366
|
+
{
|
|
32367
|
+
description: "Fetch multiple webpages",
|
|
32368
|
+
input: {
|
|
32369
|
+
url: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
|
|
32398
32370
|
}
|
|
32399
|
-
|
|
32400
|
-
|
|
32401
|
-
|
|
32402
|
-
|
|
32403
|
-
|
|
32404
|
-
{
|
|
32405
|
-
name: "url",
|
|
32406
|
-
value: "https://raw.githubusercontent.com/user/repo/main/README.md"
|
|
32371
|
+
},
|
|
32372
|
+
{
|
|
32373
|
+
description: "Fetch a raw file from GitHub",
|
|
32374
|
+
input: {
|
|
32375
|
+
url: "https://raw.githubusercontent.com/user/repo/main/README.md"
|
|
32407
32376
|
}
|
|
32408
|
-
|
|
32409
|
-
|
|
32410
|
-
|
|
32377
|
+
}
|
|
32378
|
+
]
|
|
32379
|
+
}),
|
|
32411
32380
|
permissionLevel: 1 /* Read */
|
|
32412
32381
|
};
|
|
32413
32382
|
var handler5 = async (provider, args) => {
|
|
@@ -32463,30 +32432,19 @@ var toolInfo6 = {
|
|
|
32463
32432
|
const values = Array.isArray(val) ? val : [val];
|
|
32464
32433
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
32465
32434
|
}, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
|
|
32466
|
-
})
|
|
32467
|
-
|
|
32468
|
-
|
|
32469
|
-
|
|
32470
|
-
|
|
32471
|
-
|
|
32472
|
-
|
|
32473
|
-
|
|
32474
|
-
|
|
32475
|
-
{
|
|
32476
|
-
name: "task",
|
|
32477
|
-
value: "Implement the login feature"
|
|
32478
|
-
},
|
|
32479
|
-
{
|
|
32480
|
-
name: "context",
|
|
32481
|
-
value: "We need a secure login system with email and password"
|
|
32482
|
-
},
|
|
32483
|
-
{
|
|
32484
|
-
name: "files",
|
|
32485
|
-
value: "src/auth/login.ts,src/auth/types.ts"
|
|
32435
|
+
}).meta({
|
|
32436
|
+
examples: [
|
|
32437
|
+
{
|
|
32438
|
+
description: "Hand over a coding task to the coder agent",
|
|
32439
|
+
input: {
|
|
32440
|
+
agentName: "coder",
|
|
32441
|
+
task: "Implement the login feature",
|
|
32442
|
+
context: "We need a secure login system with email and password",
|
|
32443
|
+
files: "src/auth/login.ts,src/auth/types.ts"
|
|
32486
32444
|
}
|
|
32487
|
-
|
|
32488
|
-
|
|
32489
|
-
|
|
32445
|
+
}
|
|
32446
|
+
]
|
|
32447
|
+
}),
|
|
32490
32448
|
permissionLevel: 0 /* None */
|
|
32491
32449
|
};
|
|
32492
32450
|
var handler6 = async (_provider, args) => {
|
|
@@ -32531,22 +32489,17 @@ var toolInfo7 = {
|
|
|
32531
32489
|
}
|
|
32532
32490
|
return val;
|
|
32533
32491
|
}, exports_external.boolean().optional().default(true)).describe("Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.").meta({ usageValue: "true or false (optional)" })
|
|
32534
|
-
})
|
|
32535
|
-
|
|
32536
|
-
|
|
32537
|
-
|
|
32538
|
-
|
|
32539
|
-
|
|
32540
|
-
|
|
32541
|
-
value: "src"
|
|
32542
|
-
},
|
|
32543
|
-
{
|
|
32544
|
-
name: "maxCount",
|
|
32545
|
-
value: "100"
|
|
32492
|
+
}).meta({
|
|
32493
|
+
examples: [
|
|
32494
|
+
{
|
|
32495
|
+
description: "Request to list files",
|
|
32496
|
+
input: {
|
|
32497
|
+
path: "src",
|
|
32498
|
+
maxCount: "100"
|
|
32546
32499
|
}
|
|
32547
|
-
|
|
32548
|
-
|
|
32549
|
-
|
|
32500
|
+
}
|
|
32501
|
+
]
|
|
32502
|
+
}),
|
|
32550
32503
|
permissionLevel: 1 /* Read */
|
|
32551
32504
|
};
|
|
32552
32505
|
var handler7 = async (provider, args) => {
|
|
@@ -32587,27 +32540,22 @@ var toolInfo8 = {
|
|
|
32587
32540
|
const values = Array.isArray(val) ? val : [val];
|
|
32588
32541
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
32589
32542
|
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" })
|
|
32590
|
-
})
|
|
32591
|
-
|
|
32592
|
-
|
|
32593
|
-
|
|
32594
|
-
|
|
32595
|
-
|
|
32596
|
-
name: "path",
|
|
32597
|
-
value: "src/main.js"
|
|
32543
|
+
}).meta({
|
|
32544
|
+
examples: [
|
|
32545
|
+
{
|
|
32546
|
+
description: "Request to read the contents of a file",
|
|
32547
|
+
input: {
|
|
32548
|
+
path: "src/main.js"
|
|
32598
32549
|
}
|
|
32599
|
-
|
|
32600
|
-
|
|
32601
|
-
|
|
32602
|
-
|
|
32603
|
-
|
|
32604
|
-
{
|
|
32605
|
-
name: "path",
|
|
32606
|
-
value: "src/main.js,src/index.js"
|
|
32550
|
+
},
|
|
32551
|
+
{
|
|
32552
|
+
description: "Request to read multiple files",
|
|
32553
|
+
input: {
|
|
32554
|
+
path: "src/main.js,src/index.js"
|
|
32607
32555
|
}
|
|
32608
|
-
|
|
32609
|
-
|
|
32610
|
-
|
|
32556
|
+
}
|
|
32557
|
+
]
|
|
32558
|
+
}),
|
|
32611
32559
|
permissionLevel: 1 /* Read */
|
|
32612
32560
|
};
|
|
32613
32561
|
var handler8 = async (provider, args) => {
|
|
@@ -32652,18 +32600,16 @@ var toolInfo9 = {
|
|
|
32652
32600
|
description: "Request to remove a file at the specified path.",
|
|
32653
32601
|
parameters: exports_external.object({
|
|
32654
32602
|
path: exports_external.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
|
|
32655
|
-
})
|
|
32656
|
-
|
|
32657
|
-
|
|
32658
|
-
|
|
32659
|
-
|
|
32660
|
-
|
|
32661
|
-
name: "path",
|
|
32662
|
-
value: "src/main.js"
|
|
32603
|
+
}).meta({
|
|
32604
|
+
examples: [
|
|
32605
|
+
{
|
|
32606
|
+
description: "Request to remove a file",
|
|
32607
|
+
input: {
|
|
32608
|
+
path: "src/main.js"
|
|
32663
32609
|
}
|
|
32664
|
-
|
|
32665
|
-
|
|
32666
|
-
|
|
32610
|
+
}
|
|
32611
|
+
]
|
|
32612
|
+
}),
|
|
32667
32613
|
permissionLevel: 2 /* Write */
|
|
32668
32614
|
};
|
|
32669
32615
|
var handler9 = async (provider, args) => {
|
|
@@ -32702,22 +32648,17 @@ var toolInfo10 = {
|
|
|
32702
32648
|
parameters: exports_external.object({
|
|
32703
32649
|
source_path: exports_external.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
|
|
32704
32650
|
target_path: exports_external.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
|
|
32705
|
-
})
|
|
32706
|
-
|
|
32707
|
-
|
|
32708
|
-
|
|
32709
|
-
|
|
32710
|
-
|
|
32711
|
-
|
|
32712
|
-
value: "src/old-name.js"
|
|
32713
|
-
},
|
|
32714
|
-
{
|
|
32715
|
-
name: "target_path",
|
|
32716
|
-
value: "src/new-name.js"
|
|
32651
|
+
}).meta({
|
|
32652
|
+
examples: [
|
|
32653
|
+
{
|
|
32654
|
+
description: "Request to rename a file",
|
|
32655
|
+
input: {
|
|
32656
|
+
source_path: "src/old-name.js",
|
|
32657
|
+
target_path: "src/new-name.js"
|
|
32717
32658
|
}
|
|
32718
|
-
|
|
32719
|
-
|
|
32720
|
-
|
|
32659
|
+
}
|
|
32660
|
+
]
|
|
32661
|
+
}),
|
|
32721
32662
|
permissionLevel: 2 /* Write */
|
|
32722
32663
|
};
|
|
32723
32664
|
var handler10 = async (provider, args) => {
|
|
@@ -32846,18 +32787,13 @@ Critical rules:
|
|
|
32846
32787
|
4. Special operations:
|
|
32847
32788
|
* To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
|
|
32848
32789
|
* To delete code: Use empty REPLACE section`).meta({ usageValue: "Search and replace blocks here" })
|
|
32849
|
-
})
|
|
32850
|
-
|
|
32851
|
-
|
|
32852
|
-
|
|
32853
|
-
|
|
32854
|
-
|
|
32855
|
-
|
|
32856
|
-
value: "src/main.js"
|
|
32857
|
-
},
|
|
32858
|
-
{
|
|
32859
|
-
name: "diff",
|
|
32860
|
-
value: `<<<<<<< SEARCH
|
|
32790
|
+
}).meta({
|
|
32791
|
+
examples: [
|
|
32792
|
+
{
|
|
32793
|
+
description: "Request to replace sections of content in a file",
|
|
32794
|
+
input: {
|
|
32795
|
+
path: "src/main.js",
|
|
32796
|
+
diff: `<<<<<<< SEARCH
|
|
32861
32797
|
import React from 'react';
|
|
32862
32798
|
=======
|
|
32863
32799
|
import React, { useState } from 'react';
|
|
@@ -32885,35 +32821,23 @@ return (
|
|
|
32885
32821
|
<div>
|
|
32886
32822
|
>>>>>>> REPLACE`
|
|
32887
32823
|
}
|
|
32888
|
-
|
|
32889
|
-
|
|
32890
|
-
|
|
32891
|
-
|
|
32892
|
-
|
|
32893
|
-
|
|
32894
|
-
name: "path",
|
|
32895
|
-
value: "src/config.js"
|
|
32896
|
-
},
|
|
32897
|
-
{
|
|
32898
|
-
name: "diff",
|
|
32899
|
-
value: `<<<<<<< SEARCH
|
|
32824
|
+
},
|
|
32825
|
+
{
|
|
32826
|
+
description: "Request to perform a simple, single-line replacement",
|
|
32827
|
+
input: {
|
|
32828
|
+
path: "src/config.js",
|
|
32829
|
+
diff: `<<<<<<< SEARCH
|
|
32900
32830
|
const API_URL = 'https://api.example.com';
|
|
32901
32831
|
=======
|
|
32902
32832
|
const API_URL = 'https://api.staging.example.com';
|
|
32903
32833
|
>>>>>>> REPLACE`
|
|
32904
32834
|
}
|
|
32905
|
-
|
|
32906
|
-
|
|
32907
|
-
|
|
32908
|
-
|
|
32909
|
-
|
|
32910
|
-
|
|
32911
|
-
name: "path",
|
|
32912
|
-
value: "src/utils.js"
|
|
32913
|
-
},
|
|
32914
|
-
{
|
|
32915
|
-
name: "diff",
|
|
32916
|
-
value: `<<<<<<< SEARCH
|
|
32835
|
+
},
|
|
32836
|
+
{
|
|
32837
|
+
description: "Request to add a new function to a file",
|
|
32838
|
+
input: {
|
|
32839
|
+
path: "src/utils.js",
|
|
32840
|
+
diff: `<<<<<<< SEARCH
|
|
32917
32841
|
function helperA() {
|
|
32918
32842
|
// ...
|
|
32919
32843
|
}
|
|
@@ -32927,18 +32851,12 @@ function newHelper() {
|
|
|
32927
32851
|
}
|
|
32928
32852
|
>>>>>>> REPLACE`
|
|
32929
32853
|
}
|
|
32930
|
-
|
|
32931
|
-
|
|
32932
|
-
|
|
32933
|
-
|
|
32934
|
-
|
|
32935
|
-
|
|
32936
|
-
name: "path",
|
|
32937
|
-
value: "src/app.js"
|
|
32938
|
-
},
|
|
32939
|
-
{
|
|
32940
|
-
name: "diff",
|
|
32941
|
-
value: `<<<<<<< SEARCH
|
|
32854
|
+
},
|
|
32855
|
+
{
|
|
32856
|
+
description: "Request to delete a block of code from a file",
|
|
32857
|
+
input: {
|
|
32858
|
+
path: "src/app.js",
|
|
32859
|
+
diff: `<<<<<<< SEARCH
|
|
32942
32860
|
function oldFeature() {
|
|
32943
32861
|
// This is no longer needed
|
|
32944
32862
|
}
|
|
@@ -32946,9 +32864,9 @@ function oldFeature() {
|
|
|
32946
32864
|
=======
|
|
32947
32865
|
>>>>>>> REPLACE`
|
|
32948
32866
|
}
|
|
32949
|
-
|
|
32950
|
-
|
|
32951
|
-
|
|
32867
|
+
}
|
|
32868
|
+
]
|
|
32869
|
+
}),
|
|
32952
32870
|
permissionLevel: 2 /* Write */
|
|
32953
32871
|
};
|
|
32954
32872
|
var handler11 = async (provider, args) => {
|
|
@@ -33016,26 +32934,18 @@ var toolInfo12 = {
|
|
|
33016
32934
|
filePattern: exports_external.string().optional().describe('Comma-separated glob pattern to filter files (e.g., "*.ts" for TypeScript files or "*.ts,*.js" for both TypeScript and JavaScript files). If not provided, it will search all files (*).').meta({
|
|
33017
32935
|
usageValue: "file pattern here (optional)"
|
|
33018
32936
|
})
|
|
33019
|
-
})
|
|
33020
|
-
|
|
33021
|
-
|
|
33022
|
-
|
|
33023
|
-
|
|
33024
|
-
|
|
33025
|
-
|
|
33026
|
-
|
|
33027
|
-
},
|
|
33028
|
-
{
|
|
33029
|
-
name: "regex",
|
|
33030
|
-
value: "^components/"
|
|
33031
|
-
},
|
|
33032
|
-
{
|
|
33033
|
-
name: "filePattern",
|
|
33034
|
-
value: "*.ts,*.tsx"
|
|
32937
|
+
}).meta({
|
|
32938
|
+
examples: [
|
|
32939
|
+
{
|
|
32940
|
+
description: "Request to perform a regex search across files",
|
|
32941
|
+
input: {
|
|
32942
|
+
path: "src",
|
|
32943
|
+
regex: "^components/",
|
|
32944
|
+
filePattern: "*.ts,*.tsx"
|
|
33035
32945
|
}
|
|
33036
|
-
|
|
33037
|
-
|
|
33038
|
-
|
|
32946
|
+
}
|
|
32947
|
+
]
|
|
32948
|
+
}),
|
|
33039
32949
|
permissionLevel: 1 /* Read */
|
|
33040
32950
|
};
|
|
33041
32951
|
var handler12 = async (provider, args) => {
|
|
@@ -33081,18 +32991,13 @@ var toolInfo13 = {
|
|
|
33081
32991
|
parameters: exports_external.object({
|
|
33082
32992
|
path: exports_external.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
33083
32993
|
content: exports_external.string().describe("The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.").meta({ usageValue: "Your file content here" })
|
|
33084
|
-
})
|
|
33085
|
-
|
|
33086
|
-
|
|
33087
|
-
|
|
33088
|
-
|
|
33089
|
-
|
|
33090
|
-
|
|
33091
|
-
value: "src/main.js"
|
|
33092
|
-
},
|
|
33093
|
-
{
|
|
33094
|
-
name: "content",
|
|
33095
|
-
value: `import React from 'react';
|
|
32994
|
+
}).meta({
|
|
32995
|
+
examples: [
|
|
32996
|
+
{
|
|
32997
|
+
description: "Request to write content to a file",
|
|
32998
|
+
input: {
|
|
32999
|
+
path: "src/main.js",
|
|
33000
|
+
content: `import React from 'react';
|
|
33096
33001
|
|
|
33097
33002
|
function App() {
|
|
33098
33003
|
return (
|
|
@@ -33105,9 +33010,9 @@ function App() {
|
|
|
33105
33010
|
export default App;
|
|
33106
33011
|
`
|
|
33107
33012
|
}
|
|
33108
|
-
|
|
33109
|
-
|
|
33110
|
-
|
|
33013
|
+
}
|
|
33014
|
+
]
|
|
33015
|
+
}),
|
|
33111
33016
|
permissionLevel: 2 /* Write */
|
|
33112
33017
|
};
|
|
33113
33018
|
var handler13 = async (provider, args) => {
|
|
@@ -33167,45 +33072,6 @@ var getAvailableTools = ({
|
|
|
33167
33072
|
return tools;
|
|
33168
33073
|
};
|
|
33169
33074
|
|
|
33170
|
-
// ../core/src/tool-v1-compat.ts
|
|
33171
|
-
function zodSchemaToParameters(schema) {
|
|
33172
|
-
const parameters = [];
|
|
33173
|
-
const { shape } = schema;
|
|
33174
|
-
for (const name in shape) {
|
|
33175
|
-
const def = shape[name];
|
|
33176
|
-
const isOptional = def.safeParse(undefined).success;
|
|
33177
|
-
const description = def.description || "";
|
|
33178
|
-
const param = {
|
|
33179
|
-
name,
|
|
33180
|
-
description,
|
|
33181
|
-
required: !isOptional
|
|
33182
|
-
};
|
|
33183
|
-
const usageValue = def.meta()?.usageValue;
|
|
33184
|
-
if (usageValue) {
|
|
33185
|
-
param.usageValue = usageValue;
|
|
33186
|
-
}
|
|
33187
|
-
if (def instanceof exports_external.ZodObject) {
|
|
33188
|
-
param.children = zodSchemaToParameters(def);
|
|
33189
|
-
} else if (def instanceof exports_external.ZodArray) {
|
|
33190
|
-
param.allowMultiple = true;
|
|
33191
|
-
const element = def.element;
|
|
33192
|
-
if (element instanceof exports_external.ZodObject) {
|
|
33193
|
-
param.children = zodSchemaToParameters(element);
|
|
33194
|
-
}
|
|
33195
|
-
}
|
|
33196
|
-
parameters.push(param);
|
|
33197
|
-
}
|
|
33198
|
-
return parameters;
|
|
33199
|
-
}
|
|
33200
|
-
function toToolInfoV1(tool) {
|
|
33201
|
-
const { parameters: zodSchema, ...rest } = tool;
|
|
33202
|
-
const v1Parameters = zodSchemaToParameters(zodSchema);
|
|
33203
|
-
return {
|
|
33204
|
-
...rest,
|
|
33205
|
-
parameters: v1Parameters
|
|
33206
|
-
};
|
|
33207
|
-
}
|
|
33208
|
-
|
|
33209
33075
|
// ../core/src/UsageMeter.ts
|
|
33210
33076
|
class UsageMeter {
|
|
33211
33077
|
#totals = { input: 0, output: 0, cachedRead: 0, cost: 0 };
|
|
@@ -55873,6 +55739,53 @@ var JSONRPCMessageSchema = exports_external2.union([
|
|
|
55873
55739
|
JSONRPCErrorSchema
|
|
55874
55740
|
]);
|
|
55875
55741
|
|
|
55742
|
+
// ../core/src/Agent/AgentBase.ts
|
|
55743
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
55744
|
+
|
|
55745
|
+
// ../core/src/tool-v1-compat.ts
|
|
55746
|
+
function zodSchemaToParameters(schema) {
|
|
55747
|
+
const parameters = [];
|
|
55748
|
+
const { shape } = schema;
|
|
55749
|
+
for (const name17 in shape) {
|
|
55750
|
+
const def = shape[name17];
|
|
55751
|
+
const isOptional = def.safeParse(undefined).success;
|
|
55752
|
+
const description = def.description || "";
|
|
55753
|
+
const param = {
|
|
55754
|
+
name: name17,
|
|
55755
|
+
description,
|
|
55756
|
+
required: !isOptional
|
|
55757
|
+
};
|
|
55758
|
+
const usageValue = def.meta()?.usageValue;
|
|
55759
|
+
if (usageValue) {
|
|
55760
|
+
param.usageValue = usageValue;
|
|
55761
|
+
}
|
|
55762
|
+
if (def instanceof exports_external.ZodObject) {
|
|
55763
|
+
param.children = zodSchemaToParameters(def);
|
|
55764
|
+
} else if (def instanceof exports_external.ZodArray) {
|
|
55765
|
+
param.allowMultiple = true;
|
|
55766
|
+
const element = def.element;
|
|
55767
|
+
if (element instanceof exports_external.ZodObject) {
|
|
55768
|
+
param.children = zodSchemaToParameters(element);
|
|
55769
|
+
}
|
|
55770
|
+
}
|
|
55771
|
+
parameters.push(param);
|
|
55772
|
+
}
|
|
55773
|
+
return parameters;
|
|
55774
|
+
}
|
|
55775
|
+
function toToolInfoV1(tool) {
|
|
55776
|
+
const { parameters: zodSchema2, ...rest } = tool;
|
|
55777
|
+
const v1Parameters = zodSchemaToParameters(zodSchema2);
|
|
55778
|
+
const examples = zodSchema2.meta()?.examples;
|
|
55779
|
+
const v1Tool = {
|
|
55780
|
+
...rest,
|
|
55781
|
+
parameters: v1Parameters
|
|
55782
|
+
};
|
|
55783
|
+
if (examples) {
|
|
55784
|
+
v1Tool.examples = examples;
|
|
55785
|
+
}
|
|
55786
|
+
return v1Tool;
|
|
55787
|
+
}
|
|
55788
|
+
|
|
55876
55789
|
// ../core/src/Agent/parseAssistantMessage.ts
|
|
55877
55790
|
function parseNestedParameters(content, parameterPrefix, childrenParams) {
|
|
55878
55791
|
const result = {};
|
|
@@ -56046,7 +55959,7 @@ var toolInfoExamplesPrompt = (tool, example, toolNamePrefix, parameterPrefix) =>
|
|
|
56046
55959
|
## Example: ${example.description}
|
|
56047
55960
|
|
|
56048
55961
|
<${toolNamePrefix}${tool.name}>
|
|
56049
|
-
${example.
|
|
55962
|
+
${Object.entries(example.input).map(([name17, value]) => renderParameterValue(name17, value, parameterPrefix)).join(`
|
|
56050
55963
|
`)}
|
|
56051
55964
|
</${toolNamePrefix}${tool.name}>
|
|
56052
55965
|
`;
|
|
@@ -56055,6 +55968,7 @@ var toolUsePrompt = (tools, toolNamePrefix) => {
|
|
|
56055
55968
|
return "";
|
|
56056
55969
|
}
|
|
56057
55970
|
const parameterPrefix = `${toolNamePrefix}parameter_`;
|
|
55971
|
+
const v1Tools = tools.map(toToolInfoV1);
|
|
56058
55972
|
return `
|
|
56059
55973
|
====
|
|
56060
55974
|
|
|
@@ -56113,11 +56027,11 @@ Always adhere to this format, ensuring every opening tag has a matching closing
|
|
|
56113
56027
|
NEVER surround tool use with triple backticks (\`\`\`).
|
|
56114
56028
|
|
|
56115
56029
|
# Tools
|
|
56116
|
-
${
|
|
56030
|
+
${v1Tools.map((tool) => toolInfoPrompt(tool, toolNamePrefix, parameterPrefix)).join(`
|
|
56117
56031
|
`)}
|
|
56118
56032
|
|
|
56119
56033
|
# Tool Use Examples
|
|
56120
|
-
${
|
|
56034
|
+
${v1Tools.map((tool) => {
|
|
56121
56035
|
let promp = "";
|
|
56122
56036
|
for (const example of tool.examples ?? []) {
|
|
56123
56037
|
promp += toolInfoExamplesPrompt(tool, example, toolNamePrefix, parameterPrefix);
|
|
@@ -56210,6 +56124,8 @@ e.g. <tool_tool_name>tool_name</tool_tool_name>
|
|
|
56210
56124
|
Ensure the opening and closing tags are correctly nested and closed, and that you are using the correct tool name.
|
|
56211
56125
|
Avoid unnecessary text or symbols before or after the tool use.
|
|
56212
56126
|
Avoid unnecessary escape characters or special characters.
|
|
56127
|
+
`,
|
|
56128
|
+
requireUseToolNative: `Error: No tool use detected. You MUST use a tool before proceeding.
|
|
56213
56129
|
`,
|
|
56214
56130
|
toolResults: (tool, result) => {
|
|
56215
56131
|
if (typeof result === "string") {
|
|
@@ -56248,6 +56164,7 @@ class AgentBase {
|
|
|
56248
56164
|
config;
|
|
56249
56165
|
handlers;
|
|
56250
56166
|
#policies;
|
|
56167
|
+
#toolSet;
|
|
56251
56168
|
#messages = [];
|
|
56252
56169
|
#aborted = false;
|
|
56253
56170
|
#abortController;
|
|
@@ -56285,6 +56202,20 @@ ${instance.prompt}`;
|
|
|
56285
56202
|
role: "system",
|
|
56286
56203
|
content: this.config.systemPrompt
|
|
56287
56204
|
});
|
|
56205
|
+
if (this.config.toolFormat === "native") {
|
|
56206
|
+
const tools = {};
|
|
56207
|
+
for (const tool of Object.values(this.handlers)) {
|
|
56208
|
+
const toolName = import_lodash.camelCase(tool.name);
|
|
56209
|
+
tools[toolName] = {
|
|
56210
|
+
description: tool.description,
|
|
56211
|
+
inputSchema: jsonSchema(toJSONSchema(tool.parameters))
|
|
56212
|
+
};
|
|
56213
|
+
this.handlers[toolName] = tool;
|
|
56214
|
+
}
|
|
56215
|
+
this.#toolSet = tools;
|
|
56216
|
+
} else {
|
|
56217
|
+
this.#toolSet = {};
|
|
56218
|
+
}
|
|
56288
56219
|
}
|
|
56289
56220
|
abort() {
|
|
56290
56221
|
this.#aborted = true;
|
|
@@ -56312,13 +56243,19 @@ ${instance.prompt}`;
|
|
|
56312
56243
|
if (this.#messages.length === 0) {
|
|
56313
56244
|
this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
|
|
56314
56245
|
}
|
|
56315
|
-
return await this.#request(
|
|
56246
|
+
return await this.#request({
|
|
56247
|
+
role: "user",
|
|
56248
|
+
content: prompt
|
|
56249
|
+
});
|
|
56316
56250
|
}
|
|
56317
56251
|
async handleStepResponse(response) {
|
|
56318
56252
|
return this.#handleResponse(response);
|
|
56319
56253
|
}
|
|
56320
56254
|
async#processLoop(userMessage) {
|
|
56321
|
-
let nextRequest =
|
|
56255
|
+
let nextRequest = {
|
|
56256
|
+
role: "user",
|
|
56257
|
+
content: userMessage
|
|
56258
|
+
};
|
|
56322
56259
|
while (true) {
|
|
56323
56260
|
if (this.#aborted) {
|
|
56324
56261
|
return { type: "Aborted" };
|
|
@@ -56347,10 +56284,7 @@ ${instance.prompt}`;
|
|
|
56347
56284
|
throw new Error("userMessage is missing");
|
|
56348
56285
|
}
|
|
56349
56286
|
await this.#callback({ kind: "StartRequest" /* StartRequest */, agent: this, userMessage });
|
|
56350
|
-
this.#messages.push(
|
|
56351
|
-
role: "user",
|
|
56352
|
-
content: userMessage
|
|
56353
|
-
});
|
|
56287
|
+
this.#messages.push(userMessage);
|
|
56354
56288
|
for (const instance of this.#policies) {
|
|
56355
56289
|
if (instance.onBeforeRequest) {
|
|
56356
56290
|
await instance.onBeforeRequest(this);
|
|
@@ -56362,11 +56296,11 @@ ${instance.prompt}`;
|
|
|
56362
56296
|
messages = await instance.prepareMessages(this, messages);
|
|
56363
56297
|
}
|
|
56364
56298
|
}
|
|
56365
|
-
let currentAssistantMessage = "";
|
|
56366
56299
|
const retryCount = this.config.retryCount ?? 5;
|
|
56367
|
-
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ??
|
|
56300
|
+
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 90;
|
|
56301
|
+
let respMessages = [];
|
|
56368
56302
|
for (let i = 0;i < retryCount; i++) {
|
|
56369
|
-
|
|
56303
|
+
respMessages = [];
|
|
56370
56304
|
let timeout;
|
|
56371
56305
|
const resetTimeout = () => {
|
|
56372
56306
|
if (timeout) {
|
|
@@ -56380,40 +56314,22 @@ ${instance.prompt}`;
|
|
|
56380
56314
|
}
|
|
56381
56315
|
};
|
|
56382
56316
|
this.#abortController = new AbortController;
|
|
56383
|
-
const providerOptions = {};
|
|
56384
|
-
const thinkingBudgetTokens = this.config.parameters?.thinkingBudgetTokens;
|
|
56385
|
-
const enableThinking = thinkingBudgetTokens > 0;
|
|
56386
|
-
if (enableThinking) {
|
|
56387
|
-
providerOptions.anthropic = {
|
|
56388
|
-
thinking: { type: "enabled", budgetTokens: thinkingBudgetTokens }
|
|
56389
|
-
};
|
|
56390
|
-
providerOptions.openrouter = {
|
|
56391
|
-
reasoning: {
|
|
56392
|
-
max_tokens: thinkingBudgetTokens
|
|
56393
|
-
}
|
|
56394
|
-
};
|
|
56395
|
-
providerOptions.google = {
|
|
56396
|
-
thinkingConfig: {
|
|
56397
|
-
includeThoughts: true,
|
|
56398
|
-
thinkingBudget: thinkingBudgetTokens
|
|
56399
|
-
}
|
|
56400
|
-
};
|
|
56401
|
-
}
|
|
56402
56317
|
try {
|
|
56403
|
-
const
|
|
56318
|
+
const streamTextOptions = {
|
|
56404
56319
|
model: this.ai,
|
|
56405
56320
|
messages,
|
|
56406
|
-
providerOptions,
|
|
56321
|
+
providerOptions: this.config.parameters?.providerOptions,
|
|
56407
56322
|
onChunk: async ({ chunk }) => {
|
|
56408
56323
|
resetTimeout();
|
|
56409
56324
|
switch (chunk.type) {
|
|
56410
56325
|
case "text":
|
|
56411
|
-
currentAssistantMessage += chunk.text;
|
|
56412
56326
|
await this.#callback({ kind: "Text" /* Text */, agent: this, newText: chunk.text });
|
|
56413
56327
|
break;
|
|
56414
56328
|
case "reasoning":
|
|
56415
56329
|
await this.#callback({ kind: "Reasoning" /* Reasoning */, agent: this, newText: chunk.text });
|
|
56416
56330
|
break;
|
|
56331
|
+
case "tool-call":
|
|
56332
|
+
break;
|
|
56417
56333
|
}
|
|
56418
56334
|
},
|
|
56419
56335
|
onFinish: this.config.usageMeter.onFinishHandler(this.ai),
|
|
@@ -56421,8 +56337,18 @@ ${instance.prompt}`;
|
|
|
56421
56337
|
console.error("Error in stream:", error81);
|
|
56422
56338
|
},
|
|
56423
56339
|
abortSignal: this.#abortController.signal
|
|
56340
|
+
};
|
|
56341
|
+
if (this.config.toolFormat === "native") {
|
|
56342
|
+
streamTextOptions.tools = this.#toolSet;
|
|
56343
|
+
}
|
|
56344
|
+
const stream = streamText(streamTextOptions);
|
|
56345
|
+
await stream.consumeStream({
|
|
56346
|
+
onError: (error81) => {
|
|
56347
|
+
console.error("Error in stream:", error81);
|
|
56348
|
+
}
|
|
56424
56349
|
});
|
|
56425
|
-
await stream.
|
|
56350
|
+
const resp = await stream.response;
|
|
56351
|
+
respMessages = resp.messages;
|
|
56426
56352
|
} catch (error81) {
|
|
56427
56353
|
if (error81 instanceof Error && error81.name === "AbortError") {
|
|
56428
56354
|
break;
|
|
@@ -56433,7 +56359,7 @@ ${instance.prompt}`;
|
|
|
56433
56359
|
clearTimeout(timeout);
|
|
56434
56360
|
}
|
|
56435
56361
|
}
|
|
56436
|
-
if (
|
|
56362
|
+
if (respMessages.length > 0) {
|
|
56437
56363
|
break;
|
|
56438
56364
|
}
|
|
56439
56365
|
if (this.#aborted) {
|
|
@@ -56441,17 +56367,45 @@ ${instance.prompt}`;
|
|
|
56441
56367
|
}
|
|
56442
56368
|
console.debug(`Retrying request ${i + 1} of ${retryCount}`);
|
|
56443
56369
|
}
|
|
56444
|
-
if (
|
|
56370
|
+
if (respMessages.length === 0) {
|
|
56445
56371
|
if (this.#aborted) {
|
|
56446
56372
|
return [];
|
|
56447
56373
|
}
|
|
56448
56374
|
throw new Error("No assistant message received");
|
|
56449
56375
|
}
|
|
56450
|
-
|
|
56451
|
-
this
|
|
56452
|
-
|
|
56453
|
-
|
|
56454
|
-
|
|
56376
|
+
this.#messages.push(...respMessages);
|
|
56377
|
+
if (this.config.toolFormat === "native") {
|
|
56378
|
+
return respMessages.flatMap((msg) => {
|
|
56379
|
+
if (msg.role === "assistant") {
|
|
56380
|
+
const content = msg.content;
|
|
56381
|
+
if (typeof content === "string") {
|
|
56382
|
+
return [{ type: "text", content }];
|
|
56383
|
+
}
|
|
56384
|
+
return content.flatMap((part) => {
|
|
56385
|
+
if (part.type === "text") {
|
|
56386
|
+
return [{ type: "text", content: part.text }];
|
|
56387
|
+
}
|
|
56388
|
+
if (part.type === "tool-call") {
|
|
56389
|
+
return [{ type: "tool_use", id: part.toolCallId, name: part.toolName, params: part.input }];
|
|
56390
|
+
}
|
|
56391
|
+
return [];
|
|
56392
|
+
});
|
|
56393
|
+
}
|
|
56394
|
+
return [];
|
|
56395
|
+
});
|
|
56396
|
+
}
|
|
56397
|
+
const currentAssistantMessage = respMessages.map((msg) => {
|
|
56398
|
+
if (typeof msg.content === "string") {
|
|
56399
|
+
return msg.content;
|
|
56400
|
+
}
|
|
56401
|
+
return msg.content.map((part) => {
|
|
56402
|
+
if (part.type === "text") {
|
|
56403
|
+
return part.text;
|
|
56404
|
+
}
|
|
56405
|
+
return "";
|
|
56406
|
+
});
|
|
56407
|
+
}).join(`
|
|
56408
|
+
`);
|
|
56455
56409
|
const ret = parseAssistantMessage(currentAssistantMessage, this.config.tools.map(toToolInfoV1), this.config.toolNamePrefix);
|
|
56456
56410
|
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: currentAssistantMessage });
|
|
56457
56411
|
return ret;
|
|
@@ -56465,12 +56419,12 @@ ${instance.prompt}`;
|
|
|
56465
56419
|
case "text":
|
|
56466
56420
|
break;
|
|
56467
56421
|
case "tool_use": {
|
|
56468
|
-
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
|
|
56422
|
+
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, content: content.params });
|
|
56469
56423
|
const toolResp = await this.#invokeTool(content.name, content.params);
|
|
56470
56424
|
switch (toolResp.type) {
|
|
56471
56425
|
case "Reply" /* Reply */: {
|
|
56472
|
-
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
|
|
56473
|
-
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
56426
|
+
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name, content: toolResp.message });
|
|
56427
|
+
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
|
|
56474
56428
|
break;
|
|
56475
56429
|
}
|
|
56476
56430
|
case "Exit" /* Exit */:
|
|
@@ -56479,17 +56433,17 @@ ${instance.prompt}`;
|
|
|
56479
56433
|
}
|
|
56480
56434
|
return { type: "exit", reason: toolResp };
|
|
56481
56435
|
case "Invalid" /* Invalid */: {
|
|
56482
|
-
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
|
|
56483
|
-
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
56436
|
+
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
|
|
56437
|
+
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
|
|
56484
56438
|
break outer;
|
|
56485
56439
|
}
|
|
56486
56440
|
case "Error" /* Error */: {
|
|
56487
|
-
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
|
|
56488
|
-
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
56441
|
+
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
|
|
56442
|
+
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
|
|
56489
56443
|
break outer;
|
|
56490
56444
|
}
|
|
56491
56445
|
case "Interrupted" /* Interrupted */:
|
|
56492
|
-
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
|
|
56446
|
+
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
|
|
56493
56447
|
return { type: "exit", reason: toolResp };
|
|
56494
56448
|
case "HandOver" /* HandOver */: {
|
|
56495
56449
|
if (toolResponses.length > 0) {
|
|
@@ -56523,7 +56477,7 @@ ${instance.prompt}`;
|
|
|
56523
56477
|
}
|
|
56524
56478
|
case "Pause" /* Pause */: {
|
|
56525
56479
|
await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
|
|
56526
|
-
toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object });
|
|
56480
|
+
toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object, id: content.id });
|
|
56527
56481
|
hasPause = true;
|
|
56528
56482
|
}
|
|
56529
56483
|
}
|
|
@@ -56535,10 +56489,49 @@ ${instance.prompt}`;
|
|
|
56535
56489
|
return { type: "exit", reason: { type: "Pause", responses: toolResponses } };
|
|
56536
56490
|
}
|
|
56537
56491
|
if (toolResponses.length === 0) {
|
|
56538
|
-
return {
|
|
56492
|
+
return {
|
|
56493
|
+
type: "reply",
|
|
56494
|
+
message: {
|
|
56495
|
+
role: "user",
|
|
56496
|
+
content: responsePrompts.requireUseToolNative
|
|
56497
|
+
}
|
|
56498
|
+
};
|
|
56499
|
+
}
|
|
56500
|
+
if (this.config.toolFormat === "native") {
|
|
56501
|
+
const toolResults = toolResponses.filter((resp) => resp.type === "response").map((resp) => ({
|
|
56502
|
+
type: "tool-result",
|
|
56503
|
+
toolCallId: resp.id,
|
|
56504
|
+
toolName: resp.tool,
|
|
56505
|
+
output: {
|
|
56506
|
+
type: "text",
|
|
56507
|
+
value: resp.response
|
|
56508
|
+
}
|
|
56509
|
+
}));
|
|
56510
|
+
return {
|
|
56511
|
+
type: "reply",
|
|
56512
|
+
message: {
|
|
56513
|
+
role: "tool",
|
|
56514
|
+
content: toolResults
|
|
56515
|
+
}
|
|
56516
|
+
};
|
|
56517
|
+
}
|
|
56518
|
+
if (toolResponses.length === 0) {
|
|
56519
|
+
return {
|
|
56520
|
+
type: "reply",
|
|
56521
|
+
message: {
|
|
56522
|
+
role: "user",
|
|
56523
|
+
content: responsePrompts.requireUseTool
|
|
56524
|
+
}
|
|
56525
|
+
};
|
|
56539
56526
|
}
|
|
56540
56527
|
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
|
|
56541
|
-
return {
|
|
56528
|
+
return {
|
|
56529
|
+
type: "reply",
|
|
56530
|
+
message: {
|
|
56531
|
+
role: "user",
|
|
56532
|
+
content: finalResp
|
|
56533
|
+
}
|
|
56534
|
+
};
|
|
56542
56535
|
}
|
|
56543
56536
|
async#invokeTool(name17, args) {
|
|
56544
56537
|
try {
|
|
@@ -56579,6 +56572,80 @@ ${instance.prompt}`;
|
|
|
56579
56572
|
}
|
|
56580
56573
|
}
|
|
56581
56574
|
|
|
56575
|
+
// ../core/src/Agent/AnalyzerAgent/prompts.ts
|
|
56576
|
+
var fullSystemPrompt = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
|
|
56577
|
+
# Analyzer Agent
|
|
56578
|
+
|
|
56579
|
+
## Role
|
|
56580
|
+
You are the **Analyzer** agent, responsible for:
|
|
56581
|
+
1. **Project Structure Analysis** – Understand codebase organization and architecture.
|
|
56582
|
+
2. **Code Pattern Analysis** – Identify common patterns, conventions, and best practices.
|
|
56583
|
+
3. **Dependency Analysis** – Examine project dependencies and their usage.
|
|
56584
|
+
4. **Workflow Analysis** – Understand development tools, scripts, and processes.
|
|
56585
|
+
5. **Documentation Review** – Analyze documentation and code comments.
|
|
56586
|
+
|
|
56587
|
+
> **Note**: The **Analyzer** agent focuses on understanding and analyzing the codebase without making modifications. Your role is to provide insights and understanding that can inform development decisions.
|
|
56588
|
+
|
|
56589
|
+
## Rules
|
|
56590
|
+
1. **Thoroughness**: Conduct comprehensive analysis of relevant project aspects.
|
|
56591
|
+
2. **Pattern Recognition**: Identify recurring patterns, conventions, and architectural decisions.
|
|
56592
|
+
3. **Dependency Mapping**: Track and understand relationships between components.
|
|
56593
|
+
4. **Workflow Understanding**: Analyze build processes, testing approaches, and development tools.
|
|
56594
|
+
5. **Documentation Assessment**: Review documentation quality and completeness.
|
|
56595
|
+
6. **Non-Modification**: Never modify code or files - focus solely on analysis.
|
|
56596
|
+
|
|
56597
|
+
${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
|
|
56598
|
+
${capabilities(toolNamePrefix)}
|
|
56599
|
+
${systemInformation(info)}
|
|
56600
|
+
${customInstructions(instructions)}
|
|
56601
|
+
${customScripts(scripts)}
|
|
56602
|
+
`;
|
|
56603
|
+
|
|
56604
|
+
// ../core/src/Agent/AnalyzerAgent/index.ts
|
|
56605
|
+
class AnalyzerAgent extends AgentBase {
|
|
56606
|
+
constructor(options) {
|
|
56607
|
+
const combinedTools = [...options.additionalTools ?? [], ...Object.values(exports_allTools)];
|
|
56608
|
+
const tools = getAvailableTools({
|
|
56609
|
+
provider: options.provider,
|
|
56610
|
+
allTools: combinedTools,
|
|
56611
|
+
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
56612
|
+
permissionLevel: 1 /* Read */,
|
|
56613
|
+
interactive: true
|
|
56614
|
+
});
|
|
56615
|
+
const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
|
|
56616
|
+
const systemPrompt = fullSystemPrompt({
|
|
56617
|
+
os: options.os
|
|
56618
|
+
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.toolFormat === "native");
|
|
56619
|
+
super(analyzerAgentInfo.name, options.ai, {
|
|
56620
|
+
systemPrompt,
|
|
56621
|
+
tools,
|
|
56622
|
+
toolNamePrefix,
|
|
56623
|
+
provider: options.provider,
|
|
56624
|
+
interactive: options.interactive,
|
|
56625
|
+
agents: options.agents,
|
|
56626
|
+
scripts: options.scripts,
|
|
56627
|
+
callback: options.callback,
|
|
56628
|
+
policies: options.policies,
|
|
56629
|
+
toolFormat: options.toolFormat,
|
|
56630
|
+
parameters: options.parameters ?? {},
|
|
56631
|
+
usageMeter: options.usageMeter ?? new UsageMeter
|
|
56632
|
+
});
|
|
56633
|
+
}
|
|
56634
|
+
onBeforeInvokeTool() {
|
|
56635
|
+
return Promise.resolve(undefined);
|
|
56636
|
+
}
|
|
56637
|
+
}
|
|
56638
|
+
var analyzerAgentInfo = {
|
|
56639
|
+
name: "analyzer",
|
|
56640
|
+
responsibilities: [
|
|
56641
|
+
"Analyzing project structure and organization",
|
|
56642
|
+
"Identifying key source code files and their relationships",
|
|
56643
|
+
"Understanding common coding patterns and conventions",
|
|
56644
|
+
"Examining development workflow and tooling",
|
|
56645
|
+
"Analyzing dependencies and their usage patterns"
|
|
56646
|
+
]
|
|
56647
|
+
};
|
|
56648
|
+
|
|
56582
56649
|
// ../core/src/Agent/CodeFixerAgent/prompts.ts
|
|
56583
56650
|
var basePrompt = `You are a highly skilled software engineer specializing in debugging and fixing code issues. You have extensive experience with:
|
|
56584
56651
|
- Type systems and type checking
|
|
@@ -56668,10 +56735,10 @@ class CodeFixerAgent extends AgentBase {
|
|
|
56668
56735
|
permissionLevel: 3 /* Arbitrary */,
|
|
56669
56736
|
interactive: true
|
|
56670
56737
|
});
|
|
56671
|
-
const toolNamePrefix = "tool_";
|
|
56738
|
+
const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
|
|
56672
56739
|
const systemPrompt = fullSystemPrompt3({
|
|
56673
56740
|
os: options.os
|
|
56674
|
-
}, tools
|
|
56741
|
+
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.interactive, options.toolFormat === "native");
|
|
56675
56742
|
super(codeFixerAgentInfo.name, options.ai, {
|
|
56676
56743
|
systemPrompt,
|
|
56677
56744
|
tools,
|
|
@@ -56917,23 +56984,23 @@ var prompt = `You are an AiTool designed to assist users in creating new project
|
|
|
56917
56984
|
- Create a .gitattributes file with appropriate configurations:
|
|
56918
56985
|
- Mark lock files as generated and exclude them from diffs
|
|
56919
56986
|
- Example for different package managers:
|
|
56920
|
-
|
|
56987
|
+
|
|
56921
56988
|
# For Bun
|
|
56922
56989
|
bun.lock linguist-generated=true
|
|
56923
56990
|
bun.lock -diff
|
|
56924
|
-
|
|
56991
|
+
|
|
56925
56992
|
# For npm
|
|
56926
56993
|
package-lock.json linguist-generated=true
|
|
56927
56994
|
package-lock.json -diff
|
|
56928
|
-
|
|
56995
|
+
|
|
56929
56996
|
# For Yarn
|
|
56930
56997
|
yarn.lock linguist-generated=true
|
|
56931
56998
|
yarn.lock -diff
|
|
56932
|
-
|
|
56999
|
+
|
|
56933
57000
|
# For pnpm
|
|
56934
57001
|
pnpm-lock.yaml linguist-generated=true
|
|
56935
57002
|
pnpm-lock.yaml -diff
|
|
56936
|
-
|
|
57003
|
+
|
|
56937
57004
|
- Include other common configurations as needed based on project type
|
|
56938
57005
|
|
|
56939
57006
|
6. **Handover to Coder Agent:**
|
|
@@ -57189,6 +57256,184 @@ var generateProjectConfig_default = {
|
|
|
57189
57256
|
agent: "analyzer"
|
|
57190
57257
|
};
|
|
57191
57258
|
|
|
57259
|
+
// ../core/src/AiTool/tools/gitDiff.ts
|
|
57260
|
+
var toolInfo14 = {
|
|
57261
|
+
name: "git_diff",
|
|
57262
|
+
description: "Get the git diff for the current repository. Can be used to get staged changes, unstaged changes, or changes between commits. By default, it returns unstaged changes.",
|
|
57263
|
+
parameters: exports_external.object({
|
|
57264
|
+
staged: exports_external.preprocess((val) => {
|
|
57265
|
+
if (typeof val === "string") {
|
|
57266
|
+
const lower = val.toLowerCase();
|
|
57267
|
+
if (lower === "false")
|
|
57268
|
+
return false;
|
|
57269
|
+
if (lower === "true")
|
|
57270
|
+
return true;
|
|
57271
|
+
}
|
|
57272
|
+
return val;
|
|
57273
|
+
}, exports_external.boolean().optional().default(false)).describe("Get staged changes instead of unstaged changes."),
|
|
57274
|
+
commitRange: exports_external.string().optional().describe('The commit range to get the diff for (e.g., "main...HEAD").'),
|
|
57275
|
+
file: exports_external.string().optional().describe("Get the diff for a specific file.")
|
|
57276
|
+
}),
|
|
57277
|
+
permissionLevel: 1 /* Read */
|
|
57278
|
+
};
|
|
57279
|
+
var handler14 = async (provider2, args) => {
|
|
57280
|
+
if (!provider2.executeCommand) {
|
|
57281
|
+
return {
|
|
57282
|
+
type: "Error" /* Error */,
|
|
57283
|
+
message: "Not possible to execute command. Abort."
|
|
57284
|
+
};
|
|
57285
|
+
}
|
|
57286
|
+
const { staged, file: file3, commitRange } = toolInfo14.parameters.parse(args);
|
|
57287
|
+
const commandParts = ["git", "diff", "--no-color"];
|
|
57288
|
+
if (staged) {
|
|
57289
|
+
commandParts.push("--staged");
|
|
57290
|
+
}
|
|
57291
|
+
if (commitRange) {
|
|
57292
|
+
commandParts.push(commitRange);
|
|
57293
|
+
}
|
|
57294
|
+
if (file3) {
|
|
57295
|
+
commandParts.push("--", file3);
|
|
57296
|
+
}
|
|
57297
|
+
const command = commandParts.join(" ");
|
|
57298
|
+
try {
|
|
57299
|
+
const result = await provider2.executeCommand(command, false);
|
|
57300
|
+
if (result.exitCode === 0) {
|
|
57301
|
+
if (!result.stdout.trim()) {
|
|
57302
|
+
return {
|
|
57303
|
+
type: "Reply" /* Reply */,
|
|
57304
|
+
message: "No diff found."
|
|
57305
|
+
};
|
|
57306
|
+
}
|
|
57307
|
+
return {
|
|
57308
|
+
type: "Reply" /* Reply */,
|
|
57309
|
+
message: `<diff file="${file3 ?? "all"}">
|
|
57310
|
+
${result.stdout}
|
|
57311
|
+
</diff>`
|
|
57312
|
+
};
|
|
57313
|
+
}
|
|
57314
|
+
return {
|
|
57315
|
+
type: "Error" /* Error */,
|
|
57316
|
+
message: `\`${command}\` exited with code ${result.exitCode}:
|
|
57317
|
+
${result.stderr}`
|
|
57318
|
+
};
|
|
57319
|
+
} catch (error81) {
|
|
57320
|
+
return {
|
|
57321
|
+
type: "Error" /* Error */,
|
|
57322
|
+
message: error81 instanceof Error ? error81.message : String(error81)
|
|
57323
|
+
};
|
|
57324
|
+
}
|
|
57325
|
+
};
|
|
57326
|
+
var isAvailable14 = (provider2) => {
|
|
57327
|
+
return !!provider2.executeCommand;
|
|
57328
|
+
};
|
|
57329
|
+
var gitDiff_default = {
|
|
57330
|
+
...toolInfo14,
|
|
57331
|
+
handler: handler14,
|
|
57332
|
+
isAvailable: isAvailable14
|
|
57333
|
+
};
|
|
57334
|
+
|
|
57335
|
+
// ../core/src/AiTool/reviewDiff.ts
|
|
57336
|
+
var prompt5 = `
|
|
57337
|
+
# Code Review Prompt
|
|
57338
|
+
|
|
57339
|
+
You are a senior software engineer reviewing code changes.
|
|
57340
|
+
|
|
57341
|
+
## Viewing Changes
|
|
57342
|
+
- Use **git_diff** to inspect code.
|
|
57343
|
+
- **Pull request**: use the provided commit range.
|
|
57344
|
+
- **Local changes**: diff staged or unstaged files.
|
|
57345
|
+
- If a pull request is present you may receive:
|
|
57346
|
+
- <pr_title>
|
|
57347
|
+
- <pr_description>
|
|
57348
|
+
- <commit_messages>
|
|
57349
|
+
- A <review_instructions> tag tells you the focus of the review.
|
|
57350
|
+
|
|
57351
|
+
## Focus Areas
|
|
57352
|
+
- Readability and maintainability
|
|
57353
|
+
- Correctness, edge cases, potential bugs
|
|
57354
|
+
- Performance implications
|
|
57355
|
+
- Clarity of intent
|
|
57356
|
+
- Best-practice adherence
|
|
57357
|
+
|
|
57358
|
+
## Output Format
|
|
57359
|
+
Do **not** include praise or positive feedback. Ignore generated files such as lock files.
|
|
57360
|
+
|
|
57361
|
+
Return your review as a JSON object inside a \`\`\`json block, wrapped like:
|
|
57362
|
+
<tool_attempt_completion>
|
|
57363
|
+
<tool_parameter_result>
|
|
57364
|
+
\`\`\`json
|
|
57365
|
+
{
|
|
57366
|
+
"overview": "Summary of overall concerns.",
|
|
57367
|
+
"specificReviews": [
|
|
57368
|
+
{
|
|
57369
|
+
"file": "path/filename.ext",
|
|
57370
|
+
"lines": "N or N-M",
|
|
57371
|
+
"review": "Describe the issue and actionable fix or improvement."
|
|
57372
|
+
}
|
|
57373
|
+
]
|
|
57374
|
+
}
|
|
57375
|
+
\`\`\`
|
|
57376
|
+
</tool_parameter_result>
|
|
57377
|
+
</tool_attempt_completion>
|
|
57378
|
+
`;
|
|
57379
|
+
var reviewDiff_default = {
|
|
57380
|
+
name: "reviewDiff",
|
|
57381
|
+
description: "Reviews a git diff",
|
|
57382
|
+
prompt: prompt5,
|
|
57383
|
+
formatInput: (params) => {
|
|
57384
|
+
const parts = [];
|
|
57385
|
+
if (params.pullRequestTitle) {
|
|
57386
|
+
parts.push(`<pr_title>
|
|
57387
|
+
${params.pullRequestTitle}
|
|
57388
|
+
</pr_title>`);
|
|
57389
|
+
}
|
|
57390
|
+
if (params.pullRequestDescription) {
|
|
57391
|
+
parts.push(`<pr_description>
|
|
57392
|
+
${params.pullRequestDescription}
|
|
57393
|
+
</pr_description>`);
|
|
57394
|
+
}
|
|
57395
|
+
if (params.commitMessages) {
|
|
57396
|
+
parts.push(`<commit_messages>
|
|
57397
|
+
${params.commitMessages}
|
|
57398
|
+
</commit_messages>`);
|
|
57399
|
+
}
|
|
57400
|
+
let instructions = "";
|
|
57401
|
+
if (params.commitRange) {
|
|
57402
|
+
instructions = `Review the pull request. Get the diff using the git_diff tool with the commit range '${params.commitRange}'.`;
|
|
57403
|
+
} else if (params.staged) {
|
|
57404
|
+
instructions = "Review the staged changes. Get the diff using the git_diff tool with staged: true.";
|
|
57405
|
+
} else {
|
|
57406
|
+
instructions = "Review the unstaged changes. Get the diff using the git_diff tool.";
|
|
57407
|
+
}
|
|
57408
|
+
parts.push(`<review_instructions>
|
|
57409
|
+
${instructions}
|
|
57410
|
+
</review_instructions>`);
|
|
57411
|
+
return parts.join(`
|
|
57412
|
+
`);
|
|
57413
|
+
},
|
|
57414
|
+
parseOutput: (output) => {
|
|
57415
|
+
const jsonBlockRegex = /```json\n([\s\S]*?)\n```/;
|
|
57416
|
+
const match = output.match(jsonBlockRegex);
|
|
57417
|
+
const content = match ? match[1] : output;
|
|
57418
|
+
try {
|
|
57419
|
+
return JSON.parse(content);
|
|
57420
|
+
} catch (error81) {
|
|
57421
|
+
console.error("Error parsing JSON output:", error81);
|
|
57422
|
+
return {
|
|
57423
|
+
overview: `Could not parse review output. Raw output:
|
|
57424
|
+
${output}`,
|
|
57425
|
+
specificReviews: []
|
|
57426
|
+
};
|
|
57427
|
+
}
|
|
57428
|
+
},
|
|
57429
|
+
agent: (options) => {
|
|
57430
|
+
return new AnalyzerAgent({
|
|
57431
|
+
...options,
|
|
57432
|
+
additionalTools: [gitDiff_default]
|
|
57433
|
+
});
|
|
57434
|
+
}
|
|
57435
|
+
};
|
|
57436
|
+
|
|
57192
57437
|
// ../core/src/AiTool/index.ts
|
|
57193
57438
|
var executeTool = async (definition, ai, params, usageMeter) => {
|
|
57194
57439
|
const resp = await generateText({
|
|
@@ -57204,10 +57449,7 @@ var executeTool = async (definition, ai, params, usageMeter) => {
|
|
|
57204
57449
|
usageMeter.addUsage(ai, resp);
|
|
57205
57450
|
return definition.parseOutput(resp.text);
|
|
57206
57451
|
};
|
|
57207
|
-
var
|
|
57208
|
-
if (!definition.agent) {
|
|
57209
|
-
throw new Error("Agent not specified");
|
|
57210
|
-
}
|
|
57452
|
+
var executeMultiAgentTool = async (definition, agent, params) => {
|
|
57211
57453
|
const exitReason = await agent.startTask({
|
|
57212
57454
|
agentName: definition.agent,
|
|
57213
57455
|
task: definition.prompt,
|
|
@@ -57218,22 +57460,38 @@ var executeAgentTool = async (definition, agent, params) => {
|
|
|
57218
57460
|
}
|
|
57219
57461
|
throw new Error(`Tool execution failed: ${exitReason.type}`);
|
|
57220
57462
|
};
|
|
57463
|
+
var executeAgentTool = async (definition, options, params) => {
|
|
57464
|
+
const agent = definition.agent(options);
|
|
57465
|
+
const exitReason = await agent.start(`${definition.prompt}
|
|
57466
|
+
|
|
57467
|
+
${definition.formatInput(params)}`);
|
|
57468
|
+
if (exitReason.type === "Exit" /* Exit */) {
|
|
57469
|
+
return definition.parseOutput(exitReason.message);
|
|
57470
|
+
}
|
|
57471
|
+
throw new Error(`Tool execution failed: ${exitReason.type}`);
|
|
57472
|
+
};
|
|
57221
57473
|
var makeTool = (definition) => {
|
|
57222
57474
|
return async (ai, params, usageMeter) => {
|
|
57223
57475
|
return executeTool(definition, ai, params, usageMeter);
|
|
57224
57476
|
};
|
|
57225
57477
|
};
|
|
57226
|
-
var
|
|
57478
|
+
var makeMultiAgentTool = (definition) => {
|
|
57227
57479
|
return async (agent, params) => {
|
|
57228
|
-
return
|
|
57480
|
+
return executeMultiAgentTool(definition, agent, params);
|
|
57481
|
+
};
|
|
57482
|
+
};
|
|
57483
|
+
var makeAgentTool = (definition) => {
|
|
57484
|
+
return async (options, params) => {
|
|
57485
|
+
return executeAgentTool(definition, options, params);
|
|
57229
57486
|
};
|
|
57230
57487
|
};
|
|
57231
57488
|
var generateGitCommitMessage = makeTool(generateGitCommitMessage_default);
|
|
57232
57489
|
var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails_default);
|
|
57233
|
-
var
|
|
57234
|
-
var
|
|
57490
|
+
var reviewDiff = makeAgentTool(reviewDiff_default);
|
|
57491
|
+
var generateProjectConfig = makeMultiAgentTool(generateProjectConfig_default);
|
|
57492
|
+
var createNewProject = makeMultiAgentTool(createNewProject_default);
|
|
57235
57493
|
// ../cli-shared/src/config.ts
|
|
57236
|
-
var
|
|
57494
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
57237
57495
|
|
|
57238
57496
|
// ../cli-shared/node_modules/yaml/dist/index.js
|
|
57239
57497
|
var composer = require_composer();
|
|
@@ -61137,7 +61395,7 @@ function mergeConfigs(configs) {
|
|
|
61137
61395
|
return {};
|
|
61138
61396
|
}
|
|
61139
61397
|
const mergedConfig = configs.reduce((acc, config4) => {
|
|
61140
|
-
const merged =
|
|
61398
|
+
const merged = import_lodash2.merge({}, acc, config4);
|
|
61141
61399
|
let accRules = acc.rules ?? [];
|
|
61142
61400
|
if (typeof accRules === "string") {
|
|
61143
61401
|
accRules = [accRules];
|
|
@@ -61761,15 +62019,15 @@ function useKeypress(userHandler) {
|
|
|
61761
62019
|
signal.current = userHandler;
|
|
61762
62020
|
useEffect((rl) => {
|
|
61763
62021
|
let ignore = false;
|
|
61764
|
-
const
|
|
62022
|
+
const handler15 = withUpdates((_input, event) => {
|
|
61765
62023
|
if (ignore)
|
|
61766
62024
|
return;
|
|
61767
62025
|
signal.current(event, rl);
|
|
61768
62026
|
});
|
|
61769
|
-
rl.input.on("keypress",
|
|
62027
|
+
rl.input.on("keypress", handler15);
|
|
61770
62028
|
return () => {
|
|
61771
62029
|
ignore = true;
|
|
61772
|
-
rl.input.removeListener("keypress",
|
|
62030
|
+
rl.input.removeListener("keypress", handler15);
|
|
61773
62031
|
};
|
|
61774
62032
|
}, []);
|
|
61775
62033
|
}
|
|
@@ -61928,16 +62186,16 @@ class Emitter {
|
|
|
61928
62186
|
|
|
61929
62187
|
class SignalExitBase {
|
|
61930
62188
|
}
|
|
61931
|
-
var signalExitWrap = (
|
|
62189
|
+
var signalExitWrap = (handler15) => {
|
|
61932
62190
|
return {
|
|
61933
62191
|
onExit(cb, opts) {
|
|
61934
|
-
return
|
|
62192
|
+
return handler15.onExit(cb, opts);
|
|
61935
62193
|
},
|
|
61936
62194
|
load() {
|
|
61937
|
-
return
|
|
62195
|
+
return handler15.load();
|
|
61938
62196
|
},
|
|
61939
62197
|
unload() {
|
|
61940
|
-
return
|
|
62198
|
+
return handler15.unload();
|
|
61941
62199
|
}
|
|
61942
62200
|
};
|
|
61943
62201
|
};
|
|
@@ -62093,11 +62351,11 @@ class ScreenManager {
|
|
|
62093
62351
|
render(content, bottomContent = "") {
|
|
62094
62352
|
const promptLine = lastLine(content);
|
|
62095
62353
|
const rawPromptLine = stripVTControlCharacters(promptLine);
|
|
62096
|
-
let
|
|
62354
|
+
let prompt6 = rawPromptLine;
|
|
62097
62355
|
if (this.rl.line.length > 0) {
|
|
62098
|
-
|
|
62356
|
+
prompt6 = prompt6.slice(0, -this.rl.line.length);
|
|
62099
62357
|
}
|
|
62100
|
-
this.rl.setPrompt(
|
|
62358
|
+
this.rl.setPrompt(prompt6);
|
|
62101
62359
|
this.cursorPos = this.rl.getCursorPos();
|
|
62102
62360
|
const width = readlineWidth();
|
|
62103
62361
|
content = breakLines(content, width);
|
|
@@ -62167,7 +62425,7 @@ function getCallSites() {
|
|
|
62167
62425
|
}
|
|
62168
62426
|
function createPrompt(view) {
|
|
62169
62427
|
const callSites = getCallSites();
|
|
62170
|
-
const
|
|
62428
|
+
const prompt6 = (config4, context = {}) => {
|
|
62171
62429
|
const { input = process.stdin, signal } = context;
|
|
62172
62430
|
const cleanups = new Set;
|
|
62173
62431
|
const output = new import_mute_stream.default;
|
|
@@ -62232,7 +62490,7 @@ function createPrompt(view) {
|
|
|
62232
62490
|
}).then(() => promise4), { cancel });
|
|
62233
62491
|
});
|
|
62234
62492
|
};
|
|
62235
|
-
return
|
|
62493
|
+
return prompt6;
|
|
62236
62494
|
}
|
|
62237
62495
|
// ../../node_modules/@inquirer/core/dist/esm/lib/Separator.js
|
|
62238
62496
|
var import_yoctocolors_cjs2 = __toESM(require_yoctocolors_cjs(), 1);
|