@polka-codes/cli 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/index.js +2334 -640
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -2565,6 +2565,58 @@ var require_commander = __commonJS((exports) => {
|
|
|
2565
2565
|
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2566
2566
|
});
|
|
2567
2567
|
|
|
2568
|
+
// ../core/src/Agent/parseJsonFromMarkdown.ts
|
|
2569
|
+
var parseJsonFromMarkdown = (markdown) => {
|
|
2570
|
+
const jsonRegex = /```(?:json)?\n([\s\S]*?)\n```/;
|
|
2571
|
+
const match = markdown.match(jsonRegex);
|
|
2572
|
+
const tryParse = (str) => {
|
|
2573
|
+
try {
|
|
2574
|
+
let parsed = JSON.parse(str);
|
|
2575
|
+
if (typeof parsed === "string") {
|
|
2576
|
+
try {
|
|
2577
|
+
parsed = JSON.parse(parsed);
|
|
2578
|
+
} catch {}
|
|
2579
|
+
}
|
|
2580
|
+
return { success: true, data: parsed };
|
|
2581
|
+
} catch (e) {
|
|
2582
|
+
const error = e instanceof Error ? e.message : String(e);
|
|
2583
|
+
return { success: false, error: `Failed to parse JSON: ${error}` };
|
|
2584
|
+
}
|
|
2585
|
+
};
|
|
2586
|
+
if (match?.[1]) {
|
|
2587
|
+
const content = match[1].trim();
|
|
2588
|
+
return tryParse(content);
|
|
2589
|
+
}
|
|
2590
|
+
const parseResult = tryParse(markdown);
|
|
2591
|
+
if (parseResult.success) {
|
|
2592
|
+
return parseResult;
|
|
2593
|
+
}
|
|
2594
|
+
return { success: false, error: "No JSON object found in the string." };
|
|
2595
|
+
};
|
|
2596
|
+
|
|
2597
|
+
// ../core/src/Agent/prompts.ts
|
|
2598
|
+
var init_prompts = () => {};
|
|
2599
|
+
|
|
2600
|
+
// ../core/src/Agent/index.ts
|
|
2601
|
+
var init_Agent = __esm(() => {
|
|
2602
|
+
init_prompts();
|
|
2603
|
+
});
|
|
2604
|
+
|
|
2605
|
+
// ../core/src/Agent/backoff.ts
|
|
2606
|
+
function computeRateLimitBackoffSeconds(count, baseSeconds = 2, capSeconds = 60) {
|
|
2607
|
+
if (!Number.isFinite(count) || count <= 0) {
|
|
2608
|
+
count = 1;
|
|
2609
|
+
}
|
|
2610
|
+
if (!Number.isFinite(baseSeconds) || baseSeconds <= 0) {
|
|
2611
|
+
baseSeconds = 2;
|
|
2612
|
+
}
|
|
2613
|
+
if (!Number.isFinite(capSeconds) || capSeconds <= 0) {
|
|
2614
|
+
capSeconds = 60;
|
|
2615
|
+
}
|
|
2616
|
+
const delay = baseSeconds * 2 ** (count - 1);
|
|
2617
|
+
return Math.min(delay, capSeconds);
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2568
2620
|
// ../../node_modules/zod/v4/core/core.js
|
|
2569
2621
|
function $constructor(name, initializer, params) {
|
|
2570
2622
|
function init(inst, def) {
|
|
@@ -16431,60 +16483,8 @@ var init_zod = __esm(() => {
|
|
|
16431
16483
|
init_external();
|
|
16432
16484
|
});
|
|
16433
16485
|
|
|
16434
|
-
// ../core/src/Agent/parseJsonFromMarkdown.ts
|
|
16435
|
-
var parseJsonFromMarkdown = (markdown) => {
|
|
16436
|
-
const jsonRegex = /```(?:json)?\n([\s\S]*?)\n```/;
|
|
16437
|
-
const match = markdown.match(jsonRegex);
|
|
16438
|
-
const tryParse = (str) => {
|
|
16439
|
-
try {
|
|
16440
|
-
let parsed = JSON.parse(str);
|
|
16441
|
-
if (typeof parsed === "string") {
|
|
16442
|
-
try {
|
|
16443
|
-
parsed = JSON.parse(parsed);
|
|
16444
|
-
} catch {}
|
|
16445
|
-
}
|
|
16446
|
-
return { success: true, data: parsed };
|
|
16447
|
-
} catch (e) {
|
|
16448
|
-
const error48 = e instanceof Error ? e.message : String(e);
|
|
16449
|
-
return { success: false, error: `Failed to parse JSON: ${error48}` };
|
|
16450
|
-
}
|
|
16451
|
-
};
|
|
16452
|
-
if (match?.[1]) {
|
|
16453
|
-
const content = match[1].trim();
|
|
16454
|
-
return tryParse(content);
|
|
16455
|
-
}
|
|
16456
|
-
const parseResult = tryParse(markdown);
|
|
16457
|
-
if (parseResult.success) {
|
|
16458
|
-
return parseResult;
|
|
16459
|
-
}
|
|
16460
|
-
return { success: false, error: "No JSON object found in the string." };
|
|
16461
|
-
};
|
|
16462
|
-
|
|
16463
|
-
// ../core/src/Agent/prompts.ts
|
|
16464
|
-
var init_prompts = () => {};
|
|
16465
|
-
|
|
16466
|
-
// ../core/src/Agent/index.ts
|
|
16467
|
-
var init_Agent = __esm(() => {
|
|
16468
|
-
init_prompts();
|
|
16469
|
-
});
|
|
16470
|
-
|
|
16471
|
-
// ../core/src/Agent/backoff.ts
|
|
16472
|
-
function computeRateLimitBackoffSeconds(count, baseSeconds = 2, capSeconds = 60) {
|
|
16473
|
-
if (!Number.isFinite(count) || count <= 0) {
|
|
16474
|
-
count = 1;
|
|
16475
|
-
}
|
|
16476
|
-
if (!Number.isFinite(baseSeconds) || baseSeconds <= 0) {
|
|
16477
|
-
baseSeconds = 2;
|
|
16478
|
-
}
|
|
16479
|
-
if (!Number.isFinite(capSeconds) || capSeconds <= 0) {
|
|
16480
|
-
capSeconds = 60;
|
|
16481
|
-
}
|
|
16482
|
-
const delay = baseSeconds * 2 ** (count - 1);
|
|
16483
|
-
return Math.min(delay, capSeconds);
|
|
16484
|
-
}
|
|
16485
|
-
|
|
16486
16486
|
// ../core/src/config.ts
|
|
16487
|
-
var ruleSchema, providerConfigSchema, providerModelSchema, scriptSchema, mcpServerConfigSchema, configSchema;
|
|
16487
|
+
var ruleSchema, providerConfigSchema, providerModelSchema, scriptSchema, mcpServerConfigSchema, agentContinuousImprovementSchema, agentDiscoverySchema, agentSafetySchema, agentHealthCheckSchema, agentApprovalSchema, agentSchema, configSchema;
|
|
16488
16488
|
var init_config = __esm(() => {
|
|
16489
16489
|
init_zod();
|
|
16490
16490
|
ruleSchema = exports_external.union([
|
|
@@ -16506,7 +16506,8 @@ var init_config = __esm(() => {
|
|
|
16506
16506
|
location: exports_external.string().optional(),
|
|
16507
16507
|
project: exports_external.string().optional(),
|
|
16508
16508
|
keyFile: exports_external.string().optional(),
|
|
16509
|
-
baseUrl: exports_external.string().optional()
|
|
16509
|
+
baseUrl: exports_external.string().optional(),
|
|
16510
|
+
name: exports_external.string().optional()
|
|
16510
16511
|
});
|
|
16511
16512
|
providerModelSchema = exports_external.object({
|
|
16512
16513
|
provider: exports_external.string().optional(),
|
|
@@ -16548,6 +16549,51 @@ var init_config = __esm(() => {
|
|
|
16548
16549
|
parameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
16549
16550
|
}).strict())).optional()
|
|
16550
16551
|
}).strict();
|
|
16552
|
+
agentContinuousImprovementSchema = exports_external.object({
|
|
16553
|
+
sleepTimeOnNoTasks: exports_external.number().int().optional(),
|
|
16554
|
+
sleepTimeBetweenTasks: exports_external.number().int().optional(),
|
|
16555
|
+
maxCycles: exports_external.number().int().optional()
|
|
16556
|
+
}).strict().optional();
|
|
16557
|
+
agentDiscoverySchema = exports_external.object({
|
|
16558
|
+
enabledStrategies: exports_external.array(exports_external.string()).optional(),
|
|
16559
|
+
cacheTime: exports_external.number().int().optional(),
|
|
16560
|
+
checkChanges: exports_external.boolean().optional()
|
|
16561
|
+
}).strict().optional();
|
|
16562
|
+
agentSafetySchema = exports_external.object({
|
|
16563
|
+
enabledChecks: exports_external.array(exports_external.string()).optional(),
|
|
16564
|
+
blockDestructive: exports_external.boolean().optional(),
|
|
16565
|
+
maxFileSize: exports_external.number().int().optional()
|
|
16566
|
+
}).strict().optional();
|
|
16567
|
+
agentHealthCheckSchema = exports_external.object({
|
|
16568
|
+
enabled: exports_external.boolean().optional(),
|
|
16569
|
+
interval: exports_external.number().int().optional()
|
|
16570
|
+
}).strict().optional();
|
|
16571
|
+
agentApprovalSchema = exports_external.object({
|
|
16572
|
+
level: exports_external.enum(["none", "destructive", "commits", "all"]).optional(),
|
|
16573
|
+
autoApproveSafeTasks: exports_external.boolean().optional(),
|
|
16574
|
+
maxAutoApprovalCost: exports_external.number().optional()
|
|
16575
|
+
}).strict().optional();
|
|
16576
|
+
agentSchema = exports_external.object({
|
|
16577
|
+
preset: exports_external.string().optional(),
|
|
16578
|
+
strategy: exports_external.enum(["goal-directed", "continuous-improvement"]).optional(),
|
|
16579
|
+
continueOnCompletion: exports_external.boolean().optional(),
|
|
16580
|
+
maxIterations: exports_external.number().int().optional(),
|
|
16581
|
+
timeout: exports_external.number().int().optional(),
|
|
16582
|
+
requireApprovalFor: exports_external.enum(["none", "destructive", "commits", "all"]).optional(),
|
|
16583
|
+
autoApproveSafeTasks: exports_external.boolean().optional(),
|
|
16584
|
+
maxAutoApprovalCost: exports_external.number().optional(),
|
|
16585
|
+
pauseOnError: exports_external.boolean().optional(),
|
|
16586
|
+
workingBranch: exports_external.string().optional(),
|
|
16587
|
+
destructiveOperations: exports_external.array(exports_external.string()).optional(),
|
|
16588
|
+
maxConcurrency: exports_external.number().int().optional(),
|
|
16589
|
+
autoSaveInterval: exports_external.number().int().optional(),
|
|
16590
|
+
workingDir: exports_external.string().optional(),
|
|
16591
|
+
continuousImprovement: agentContinuousImprovementSchema,
|
|
16592
|
+
discovery: agentDiscoverySchema,
|
|
16593
|
+
safety: agentSafetySchema,
|
|
16594
|
+
healthCheck: agentHealthCheckSchema,
|
|
16595
|
+
approval: agentApprovalSchema
|
|
16596
|
+
}).strict().optional();
|
|
16551
16597
|
configSchema = exports_external.object({
|
|
16552
16598
|
prices: exports_external.record(exports_external.string(), exports_external.record(exports_external.string(), exports_external.object({
|
|
16553
16599
|
inputPrice: exports_external.number().optional(),
|
|
@@ -16571,7 +16617,8 @@ var init_config = __esm(() => {
|
|
|
16571
16617
|
}).optional(),
|
|
16572
16618
|
mcpServers: exports_external.record(exports_external.string(), mcpServerConfigSchema).optional(),
|
|
16573
16619
|
rules: exports_external.array(ruleSchema).optional().or(exports_external.string()).optional(),
|
|
16574
|
-
excludeFiles: exports_external.array(exports_external.string()).optional()
|
|
16620
|
+
excludeFiles: exports_external.array(exports_external.string()).optional(),
|
|
16621
|
+
agent: agentSchema
|
|
16575
16622
|
}).strict().nullish();
|
|
16576
16623
|
});
|
|
16577
16624
|
|
|
@@ -23573,52 +23620,52 @@ var require_public_api = __commonJS((exports) => {
|
|
|
23573
23620
|
});
|
|
23574
23621
|
|
|
23575
23622
|
// ../../node_modules/yaml/dist/index.js
|
|
23576
|
-
var
|
|
23577
|
-
|
|
23578
|
-
|
|
23579
|
-
|
|
23580
|
-
|
|
23581
|
-
|
|
23582
|
-
|
|
23583
|
-
|
|
23584
|
-
|
|
23585
|
-
|
|
23586
|
-
|
|
23587
|
-
|
|
23588
|
-
|
|
23589
|
-
|
|
23590
|
-
|
|
23591
|
-
|
|
23592
|
-
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
|
|
23597
|
-
|
|
23598
|
-
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
|
|
23602
|
-
|
|
23603
|
-
|
|
23604
|
-
|
|
23605
|
-
|
|
23606
|
-
|
|
23607
|
-
|
|
23608
|
-
|
|
23609
|
-
|
|
23610
|
-
|
|
23611
|
-
|
|
23612
|
-
|
|
23613
|
-
|
|
23614
|
-
|
|
23615
|
-
|
|
23616
|
-
|
|
23617
|
-
|
|
23618
|
-
|
|
23619
|
-
|
|
23620
|
-
|
|
23621
|
-
|
|
23623
|
+
var composer, Document, Schema, errors3, Alias, identity, Pair, Scalar, YAMLMap, YAMLSeq, cst, lexer, lineCounter, parser, publicApi, visit, $Composer, $Document, $Schema, $YAMLError, $YAMLParseError, $YAMLWarning, $Alias, $isAlias, $isCollection, $isDocument, $isMap, $isNode, $isPair, $isScalar, $isSeq, $Pair, $Scalar, $YAMLMap, $YAMLSeq, $Lexer, $LineCounter, $Parser, $parse, $parseAllDocuments, $parseDocument, $stringify, $visit, $visitAsync;
|
|
23624
|
+
var init_dist = __esm(() => {
|
|
23625
|
+
composer = require_composer();
|
|
23626
|
+
Document = require_Document();
|
|
23627
|
+
Schema = require_Schema();
|
|
23628
|
+
errors3 = require_errors();
|
|
23629
|
+
Alias = require_Alias();
|
|
23630
|
+
identity = require_identity();
|
|
23631
|
+
Pair = require_Pair();
|
|
23632
|
+
Scalar = require_Scalar();
|
|
23633
|
+
YAMLMap = require_YAMLMap();
|
|
23634
|
+
YAMLSeq = require_YAMLSeq();
|
|
23635
|
+
cst = require_cst();
|
|
23636
|
+
lexer = require_lexer();
|
|
23637
|
+
lineCounter = require_line_counter();
|
|
23638
|
+
parser = require_parser();
|
|
23639
|
+
publicApi = require_public_api();
|
|
23640
|
+
visit = require_visit();
|
|
23641
|
+
$Composer = composer.Composer;
|
|
23642
|
+
$Document = Document.Document;
|
|
23643
|
+
$Schema = Schema.Schema;
|
|
23644
|
+
$YAMLError = errors3.YAMLError;
|
|
23645
|
+
$YAMLParseError = errors3.YAMLParseError;
|
|
23646
|
+
$YAMLWarning = errors3.YAMLWarning;
|
|
23647
|
+
$Alias = Alias.Alias;
|
|
23648
|
+
$isAlias = identity.isAlias;
|
|
23649
|
+
$isCollection = identity.isCollection;
|
|
23650
|
+
$isDocument = identity.isDocument;
|
|
23651
|
+
$isMap = identity.isMap;
|
|
23652
|
+
$isNode = identity.isNode;
|
|
23653
|
+
$isPair = identity.isPair;
|
|
23654
|
+
$isScalar = identity.isScalar;
|
|
23655
|
+
$isSeq = identity.isSeq;
|
|
23656
|
+
$Pair = Pair.Pair;
|
|
23657
|
+
$Scalar = Scalar.Scalar;
|
|
23658
|
+
$YAMLMap = YAMLMap.YAMLMap;
|
|
23659
|
+
$YAMLSeq = YAMLSeq.YAMLSeq;
|
|
23660
|
+
$Lexer = lexer.Lexer;
|
|
23661
|
+
$LineCounter = lineCounter.LineCounter;
|
|
23662
|
+
$Parser = parser.Parser;
|
|
23663
|
+
$parse = publicApi.parse;
|
|
23664
|
+
$parseAllDocuments = publicApi.parseAllDocuments;
|
|
23665
|
+
$parseDocument = publicApi.parseDocument;
|
|
23666
|
+
$stringify = publicApi.stringify;
|
|
23667
|
+
$visit = visit.visit;
|
|
23668
|
+
$visitAsync = visit.visitAsync;
|
|
23622
23669
|
});
|
|
23623
23670
|
|
|
23624
23671
|
// ../core/src/skills/types.ts
|
|
@@ -23833,7 +23880,7 @@ class SkillDiscoveryService {
|
|
|
23833
23880
|
return { metadata, content: instructions };
|
|
23834
23881
|
}
|
|
23835
23882
|
parseMetadata(frontmatter) {
|
|
23836
|
-
const parsed =
|
|
23883
|
+
const parsed = $parse(frontmatter);
|
|
23837
23884
|
return skillMetadataSchema.parse(parsed);
|
|
23838
23885
|
}
|
|
23839
23886
|
async loadDirectoryFiles(dirPath, prefix, files, depth = 0, currentTotal = 0) {
|
|
@@ -23898,13 +23945,13 @@ class SkillDiscoveryService {
|
|
|
23898
23945
|
};
|
|
23899
23946
|
}
|
|
23900
23947
|
}
|
|
23901
|
-
var
|
|
23948
|
+
var BINARY_EXTENSIONS;
|
|
23902
23949
|
var init_discovery = __esm(() => {
|
|
23950
|
+
init_dist();
|
|
23903
23951
|
init_zod();
|
|
23904
23952
|
init_fs();
|
|
23905
23953
|
init_constants();
|
|
23906
23954
|
init_types();
|
|
23907
|
-
import_yaml = __toESM(require_dist(), 1);
|
|
23908
23955
|
BINARY_EXTENSIONS = [
|
|
23909
23956
|
".png",
|
|
23910
23957
|
".jpg",
|
|
@@ -23996,11 +24043,11 @@ function validateSkillReferences(skill) {
|
|
|
23996
24043
|
return warnings;
|
|
23997
24044
|
}
|
|
23998
24045
|
function validateSkillMetadata(skill) {
|
|
23999
|
-
const
|
|
24046
|
+
const errors4 = [];
|
|
24000
24047
|
if (skill.metadata.description.length < 20) {
|
|
24001
|
-
|
|
24048
|
+
errors4.push(`Description too short: ${skill.metadata.description.length} < 20`);
|
|
24002
24049
|
}
|
|
24003
|
-
return
|
|
24050
|
+
return errors4;
|
|
24004
24051
|
}
|
|
24005
24052
|
var init_validation = __esm(() => {
|
|
24006
24053
|
init_constants();
|
|
@@ -24256,16 +24303,30 @@ var init_askFollowupQuestion = __esm(() => {
|
|
|
24256
24303
|
};
|
|
24257
24304
|
});
|
|
24258
24305
|
|
|
24259
|
-
// ../core/src/tools/
|
|
24260
|
-
function
|
|
24306
|
+
// ../core/src/tools/response-builders.ts
|
|
24307
|
+
function createSuccessResponse(value, type = "text") {
|
|
24308
|
+
return {
|
|
24309
|
+
success: true,
|
|
24310
|
+
message: { type, value }
|
|
24311
|
+
};
|
|
24312
|
+
}
|
|
24313
|
+
function createErrorResponse(message) {
|
|
24314
|
+
return {
|
|
24315
|
+
success: false,
|
|
24316
|
+
message: { type: "error-text", value: message }
|
|
24317
|
+
};
|
|
24318
|
+
}
|
|
24319
|
+
function createProviderErrorResponse(capability) {
|
|
24261
24320
|
return {
|
|
24262
24321
|
success: false,
|
|
24263
24322
|
message: {
|
|
24264
24323
|
type: "error-text",
|
|
24265
|
-
value: `Not possible to ${
|
|
24324
|
+
value: `Not possible to ${capability}.`
|
|
24266
24325
|
}
|
|
24267
24326
|
};
|
|
24268
24327
|
}
|
|
24328
|
+
|
|
24329
|
+
// ../core/src/tools/utils.ts
|
|
24269
24330
|
function preprocessBoolean(val) {
|
|
24270
24331
|
return typeof val === "string" ? val.toLowerCase() === "true" : val;
|
|
24271
24332
|
}
|
|
@@ -24281,11 +24342,12 @@ function createFileElement(tagName, path, content, attrs) {
|
|
|
24281
24342
|
}
|
|
24282
24343
|
return `<${tagName}${attrStr}>${content}</${tagName}>`;
|
|
24283
24344
|
}
|
|
24345
|
+
var init_utils = () => {};
|
|
24284
24346
|
|
|
24285
24347
|
// ../core/src/tools/executeCommand.ts
|
|
24286
24348
|
var toolInfo2, handler2 = async (provider, args) => {
|
|
24287
24349
|
if (!provider.executeCommand) {
|
|
24288
|
-
return
|
|
24350
|
+
return createProviderErrorResponse("execute command. Abort");
|
|
24289
24351
|
}
|
|
24290
24352
|
const { command, requiresApproval } = toolInfo2.parameters.parse(args);
|
|
24291
24353
|
try {
|
|
@@ -24335,6 +24397,7 @@ ${result.stderr}
|
|
|
24335
24397
|
}, executeCommand_default;
|
|
24336
24398
|
var init_executeCommand = __esm(() => {
|
|
24337
24399
|
init_zod();
|
|
24400
|
+
init_utils();
|
|
24338
24401
|
toolInfo2 = {
|
|
24339
24402
|
name: "executeCommand",
|
|
24340
24403
|
description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. **IMPORTANT**: After an `execute_command` call, you MUST stop and NOT allowed to make further tool calls in the same message.",
|
|
@@ -24444,7 +24507,7 @@ var init_fetchUrl = __esm(() => {
|
|
|
24444
24507
|
// ../core/src/tools/listFiles.ts
|
|
24445
24508
|
var toolInfo4, handler4 = async (provider, args) => {
|
|
24446
24509
|
if (!provider.listFiles) {
|
|
24447
|
-
return
|
|
24510
|
+
return createProviderErrorResponse("list files");
|
|
24448
24511
|
}
|
|
24449
24512
|
const { path, maxCount, recursive, includeIgnored } = toolInfo4.parameters.parse(args);
|
|
24450
24513
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
@@ -24463,6 +24526,7 @@ ${files.join(`
|
|
|
24463
24526
|
}, listFiles_default;
|
|
24464
24527
|
var init_listFiles = __esm(() => {
|
|
24465
24528
|
init_zod();
|
|
24529
|
+
init_utils();
|
|
24466
24530
|
toolInfo4 = {
|
|
24467
24531
|
name: "listFiles",
|
|
24468
24532
|
description: "Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.",
|
|
@@ -24545,7 +24609,7 @@ var init_readBinaryFile = __esm(() => {
|
|
|
24545
24609
|
// ../core/src/tools/readFile.ts
|
|
24546
24610
|
var toolInfo6, handler6 = async (provider, args) => {
|
|
24547
24611
|
if (!provider.readFile) {
|
|
24548
|
-
return
|
|
24612
|
+
return createProviderErrorResponse("read file");
|
|
24549
24613
|
}
|
|
24550
24614
|
const { path: paths, includeIgnored } = toolInfo6.parameters.parse(args);
|
|
24551
24615
|
const resp = [];
|
|
@@ -24568,6 +24632,7 @@ var toolInfo6, handler6 = async (provider, args) => {
|
|
|
24568
24632
|
}, readFile_default;
|
|
24569
24633
|
var init_readFile = __esm(() => {
|
|
24570
24634
|
init_zod();
|
|
24635
|
+
init_utils();
|
|
24571
24636
|
toolInfo6 = {
|
|
24572
24637
|
name: "readFile",
|
|
24573
24638
|
description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.",
|
|
@@ -24605,7 +24670,7 @@ var init_readFile = __esm(() => {
|
|
|
24605
24670
|
// ../core/src/tools/removeFile.ts
|
|
24606
24671
|
var toolInfo7, handler7 = async (provider, args) => {
|
|
24607
24672
|
if (!provider.removeFile) {
|
|
24608
|
-
return
|
|
24673
|
+
return createProviderErrorResponse("remove file");
|
|
24609
24674
|
}
|
|
24610
24675
|
const parsed = toolInfo7.parameters.safeParse(args);
|
|
24611
24676
|
if (!parsed.success) {
|
|
@@ -24629,6 +24694,7 @@ var toolInfo7, handler7 = async (provider, args) => {
|
|
|
24629
24694
|
}, removeFile_default;
|
|
24630
24695
|
var init_removeFile = __esm(() => {
|
|
24631
24696
|
init_zod();
|
|
24697
|
+
init_utils();
|
|
24632
24698
|
toolInfo7 = {
|
|
24633
24699
|
name: "removeFile",
|
|
24634
24700
|
description: "Request to remove a file at the specified path.",
|
|
@@ -25163,7 +25229,7 @@ var init_todo = __esm(() => {
|
|
|
25163
25229
|
// ../core/src/tools/writeToFile.ts
|
|
25164
25230
|
var toolInfo12, handler12 = async (provider, args) => {
|
|
25165
25231
|
if (!provider.writeFile) {
|
|
25166
|
-
return
|
|
25232
|
+
return createProviderErrorResponse("write file");
|
|
25167
25233
|
}
|
|
25168
25234
|
const parsed = toolInfo12.parameters.safeParse(args);
|
|
25169
25235
|
if (!parsed.success) {
|
|
@@ -25190,6 +25256,7 @@ var toolInfo12, handler12 = async (provider, args) => {
|
|
|
25190
25256
|
}, writeToFile_default;
|
|
25191
25257
|
var init_writeToFile = __esm(() => {
|
|
25192
25258
|
init_zod();
|
|
25259
|
+
init_utils();
|
|
25193
25260
|
toolInfo12 = {
|
|
25194
25261
|
name: "writeToFile",
|
|
25195
25262
|
description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<`, `>`, or `&`. Also ensure there is no unwanted CDATA tags in the content.",
|
|
@@ -25398,7 +25465,7 @@ function getErrorMessage(error48) {
|
|
|
25398
25465
|
return JSON.stringify(error48);
|
|
25399
25466
|
}
|
|
25400
25467
|
var marker = "vercel.ai.error", symbol2, _a2, _b, AISDKError, name = "AI_APICallError", marker2, symbol22, _a22, _b2, APICallError, name2 = "AI_EmptyResponseBodyError", marker3, symbol3, _a3, _b3, EmptyResponseBodyError, name3 = "AI_InvalidArgumentError", marker4, symbol4, _a4, _b4, InvalidArgumentError2, name4 = "AI_InvalidPromptError", marker5, symbol5, _a5, _b5, InvalidPromptError, name5 = "AI_InvalidResponseDataError", marker6, symbol6, _a6, _b6, InvalidResponseDataError, name6 = "AI_JSONParseError", marker7, symbol7, _a7, _b7, JSONParseError, name7 = "AI_LoadAPIKeyError", marker8, symbol8, _a8, _b8, LoadAPIKeyError, name8 = "AI_LoadSettingError", marker9, symbol9, _a9, _b9, LoadSettingError, name9 = "AI_NoContentGeneratedError", marker10, symbol10, _a10, _b10, NoContentGeneratedError, name10 = "AI_NoSuchModelError", marker11, symbol11, _a11, _b11, NoSuchModelError, name11 = "AI_TooManyEmbeddingValuesForCallError", marker12, symbol12, _a12, _b12, TooManyEmbeddingValuesForCallError, name12 = "AI_TypeValidationError", marker13, symbol13, _a13, _b13, TypeValidationError, name13 = "AI_UnsupportedFunctionalityError", marker14, symbol14, _a14, _b14, UnsupportedFunctionalityError;
|
|
25401
|
-
var
|
|
25468
|
+
var init_dist2 = __esm(() => {
|
|
25402
25469
|
symbol2 = Symbol.for(marker);
|
|
25403
25470
|
AISDKError = class _AISDKError extends (_b = Error, _a2 = symbol2, _b) {
|
|
25404
25471
|
constructor({
|
|
@@ -25719,7 +25786,7 @@ function splitLines(chunk) {
|
|
|
25719
25786
|
return [lines, incompleteLine];
|
|
25720
25787
|
}
|
|
25721
25788
|
var ParseError;
|
|
25722
|
-
var
|
|
25789
|
+
var init_dist3 = __esm(() => {
|
|
25723
25790
|
ParseError = class ParseError extends Error {
|
|
25724
25791
|
constructor(message, options) {
|
|
25725
25792
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
@@ -25730,13 +25797,13 @@ var init_dist2 = __esm(() => {
|
|
|
25730
25797
|
// ../../node_modules/eventsource-parser/dist/stream.js
|
|
25731
25798
|
var EventSourceParserStream;
|
|
25732
25799
|
var init_stream = __esm(() => {
|
|
25733
|
-
|
|
25800
|
+
init_dist3();
|
|
25734
25801
|
EventSourceParserStream = class EventSourceParserStream extends TransformStream {
|
|
25735
25802
|
constructor({ onError, onRetry, onComment } = {}) {
|
|
25736
|
-
let
|
|
25803
|
+
let parser2;
|
|
25737
25804
|
super({
|
|
25738
25805
|
start(controller) {
|
|
25739
|
-
|
|
25806
|
+
parser2 = createParser({
|
|
25740
25807
|
onEvent: (event) => {
|
|
25741
25808
|
controller.enqueue(event);
|
|
25742
25809
|
},
|
|
@@ -25748,7 +25815,7 @@ var init_stream = __esm(() => {
|
|
|
25748
25815
|
});
|
|
25749
25816
|
},
|
|
25750
25817
|
transform(chunk) {
|
|
25751
|
-
|
|
25818
|
+
parser2.feed(chunk);
|
|
25752
25819
|
}
|
|
25753
25820
|
});
|
|
25754
25821
|
}
|
|
@@ -29575,7 +29642,7 @@ var init_v3 = __esm(() => {
|
|
|
29575
29642
|
});
|
|
29576
29643
|
|
|
29577
29644
|
// ../../node_modules/@standard-schema/spec/dist/index.js
|
|
29578
|
-
var
|
|
29645
|
+
var init_dist4 = () => {};
|
|
29579
29646
|
|
|
29580
29647
|
// ../../node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
29581
29648
|
function combineHeaders(...headers) {
|
|
@@ -31479,24 +31546,24 @@ var DelayedPromise = class {
|
|
|
31479
31546
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
31480
31547
|
return combined;
|
|
31481
31548
|
}, zod_to_json_schema_default, schemaSymbol, btoa2, atob2;
|
|
31482
|
-
var
|
|
31483
|
-
|
|
31484
|
-
|
|
31485
|
-
|
|
31486
|
-
|
|
31487
|
-
|
|
31488
|
-
|
|
31489
|
-
|
|
31490
|
-
|
|
31549
|
+
var init_dist5 = __esm(() => {
|
|
31550
|
+
init_dist2();
|
|
31551
|
+
init_dist2();
|
|
31552
|
+
init_dist2();
|
|
31553
|
+
init_dist2();
|
|
31554
|
+
init_dist2();
|
|
31555
|
+
init_dist2();
|
|
31556
|
+
init_dist2();
|
|
31557
|
+
init_dist2();
|
|
31491
31558
|
init_stream();
|
|
31492
|
-
|
|
31493
|
-
|
|
31494
|
-
|
|
31559
|
+
init_dist2();
|
|
31560
|
+
init_dist2();
|
|
31561
|
+
init_dist2();
|
|
31495
31562
|
init_v4();
|
|
31496
31563
|
init_v3();
|
|
31497
31564
|
init_v3();
|
|
31498
31565
|
init_v3();
|
|
31499
|
-
|
|
31566
|
+
init_dist4();
|
|
31500
31567
|
generateId = createIdGenerator();
|
|
31501
31568
|
FETCH_FAILED_ERROR_MESSAGES = ["fetch failed", "failed to fetch"];
|
|
31502
31569
|
suspectProtoRx = /"__proto__"\s*:/;
|
|
@@ -31963,7 +32030,7 @@ ${error48.message}`;
|
|
|
31963
32030
|
});
|
|
31964
32031
|
|
|
31965
32032
|
// ../../node_modules/@vercel/oidc/dist/index.js
|
|
31966
|
-
var
|
|
32033
|
+
var require_dist = __commonJS((exports, module) => {
|
|
31967
32034
|
var __defProp2 = Object.defineProperty;
|
|
31968
32035
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
31969
32036
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
@@ -32513,26 +32580,26 @@ var import_oidc, import_oidc2, marker15 = "vercel.ai.gateway.error", symbol15, _
|
|
|
32513
32580
|
};
|
|
32514
32581
|
}
|
|
32515
32582
|
}, providerMetadataEntrySchema, gatewayImageResponseSchema, VERSION2 = "2.0.24", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
|
|
32516
|
-
var
|
|
32517
|
-
|
|
32518
|
-
|
|
32583
|
+
var init_dist6 = __esm(() => {
|
|
32584
|
+
init_dist5();
|
|
32585
|
+
init_dist2();
|
|
32519
32586
|
init_v4();
|
|
32520
32587
|
init_v4();
|
|
32521
|
-
|
|
32522
|
-
|
|
32588
|
+
init_dist5();
|
|
32589
|
+
init_dist5();
|
|
32523
32590
|
init_v4();
|
|
32524
|
-
|
|
32525
|
-
|
|
32591
|
+
init_dist5();
|
|
32592
|
+
init_dist5();
|
|
32526
32593
|
init_v4();
|
|
32527
|
-
|
|
32594
|
+
init_dist5();
|
|
32528
32595
|
init_v4();
|
|
32529
|
-
|
|
32596
|
+
init_dist5();
|
|
32530
32597
|
init_v4();
|
|
32531
|
-
|
|
32598
|
+
init_dist5();
|
|
32532
32599
|
init_v4();
|
|
32533
|
-
|
|
32534
|
-
import_oidc = __toESM(
|
|
32535
|
-
import_oidc2 = __toESM(
|
|
32600
|
+
init_dist5();
|
|
32601
|
+
import_oidc = __toESM(require_dist(), 1);
|
|
32602
|
+
import_oidc2 = __toESM(require_dist(), 1);
|
|
32536
32603
|
symbol15 = Symbol.for(marker15);
|
|
32537
32604
|
GatewayError = class _GatewayError extends (_b15 = Error, _a15 = symbol15, _b15) {
|
|
32538
32605
|
constructor({
|
|
@@ -34853,7 +34920,7 @@ async function _retryWithExponentialBackoff(f, {
|
|
|
34853
34920
|
delayInMs,
|
|
34854
34921
|
backoffFactor,
|
|
34855
34922
|
abortSignal
|
|
34856
|
-
},
|
|
34923
|
+
}, errors5 = []) {
|
|
34857
34924
|
try {
|
|
34858
34925
|
return await f();
|
|
34859
34926
|
} catch (error48) {
|
|
@@ -34864,7 +34931,7 @@ async function _retryWithExponentialBackoff(f, {
|
|
|
34864
34931
|
throw error48;
|
|
34865
34932
|
}
|
|
34866
34933
|
const errorMessage = getErrorMessage2(error48);
|
|
34867
|
-
const newErrors = [...
|
|
34934
|
+
const newErrors = [...errors5, error48];
|
|
34868
34935
|
const tryNumber = newErrors.length;
|
|
34869
34936
|
if (tryNumber > maxRetries) {
|
|
34870
34937
|
throw new RetryError({
|
|
@@ -38493,53 +38560,53 @@ var import_api, import_api2, __defProp2, __export2 = (target, all) => {
|
|
|
38493
38560
|
}
|
|
38494
38561
|
};
|
|
38495
38562
|
}, name15 = "AI_NoSuchProviderError", marker152, symbol152, _a152, uiMessagesSchema;
|
|
38496
|
-
var
|
|
38497
|
-
|
|
38498
|
-
|
|
38499
|
-
|
|
38563
|
+
var init_dist7 = __esm(() => {
|
|
38564
|
+
init_dist5();
|
|
38565
|
+
init_dist5();
|
|
38566
|
+
init_dist2();
|
|
38567
|
+
init_dist6();
|
|
38568
|
+
init_dist2();
|
|
38569
|
+
init_dist2();
|
|
38570
|
+
init_dist2();
|
|
38571
|
+
init_dist2();
|
|
38572
|
+
init_dist2();
|
|
38573
|
+
init_dist2();
|
|
38574
|
+
init_dist2();
|
|
38575
|
+
init_dist2();
|
|
38576
|
+
init_dist2();
|
|
38577
|
+
init_dist2();
|
|
38578
|
+
init_dist5();
|
|
38579
|
+
init_dist5();
|
|
38580
|
+
init_dist5();
|
|
38581
|
+
init_dist2();
|
|
38500
38582
|
init_dist5();
|
|
38501
|
-
init_dist();
|
|
38502
|
-
init_dist();
|
|
38503
|
-
init_dist();
|
|
38504
|
-
init_dist();
|
|
38505
|
-
init_dist();
|
|
38506
|
-
init_dist();
|
|
38507
|
-
init_dist();
|
|
38508
|
-
init_dist();
|
|
38509
|
-
init_dist();
|
|
38510
|
-
init_dist();
|
|
38511
|
-
init_dist4();
|
|
38512
|
-
init_dist4();
|
|
38513
|
-
init_dist4();
|
|
38514
|
-
init_dist();
|
|
38515
|
-
init_dist4();
|
|
38516
38583
|
init_v4();
|
|
38517
|
-
|
|
38518
|
-
|
|
38519
|
-
|
|
38584
|
+
init_dist5();
|
|
38585
|
+
init_dist2();
|
|
38586
|
+
init_dist5();
|
|
38520
38587
|
init_v4();
|
|
38521
38588
|
init_v4();
|
|
38522
38589
|
init_v4();
|
|
38523
38590
|
init_v4();
|
|
38524
38591
|
init_v4();
|
|
38592
|
+
init_dist6();
|
|
38593
|
+
init_dist2();
|
|
38594
|
+
init_dist2();
|
|
38595
|
+
init_dist5();
|
|
38596
|
+
init_dist5();
|
|
38597
|
+
init_dist5();
|
|
38598
|
+
init_dist2();
|
|
38599
|
+
init_dist2();
|
|
38600
|
+
init_dist5();
|
|
38525
38601
|
init_dist5();
|
|
38526
|
-
init_dist();
|
|
38527
|
-
init_dist();
|
|
38528
|
-
init_dist4();
|
|
38529
|
-
init_dist4();
|
|
38530
|
-
init_dist4();
|
|
38531
|
-
init_dist();
|
|
38532
|
-
init_dist();
|
|
38533
|
-
init_dist4();
|
|
38534
|
-
init_dist4();
|
|
38535
38602
|
init_v4();
|
|
38536
|
-
|
|
38537
|
-
|
|
38538
|
-
|
|
38539
|
-
|
|
38540
|
-
|
|
38541
|
-
|
|
38542
|
-
|
|
38603
|
+
init_dist5();
|
|
38604
|
+
init_dist5();
|
|
38605
|
+
init_dist5();
|
|
38606
|
+
init_dist5();
|
|
38607
|
+
init_dist5();
|
|
38608
|
+
init_dist5();
|
|
38609
|
+
init_dist5();
|
|
38543
38610
|
init_v4();
|
|
38544
38611
|
import_api = __toESM(require_src(), 1);
|
|
38545
38612
|
import_api2 = __toESM(require_src(), 1);
|
|
@@ -38735,13 +38802,13 @@ var init_dist6 = __esm(() => {
|
|
|
38735
38802
|
constructor({
|
|
38736
38803
|
message,
|
|
38737
38804
|
reason,
|
|
38738
|
-
errors:
|
|
38805
|
+
errors: errors5
|
|
38739
38806
|
}) {
|
|
38740
38807
|
super({ name: name142, message });
|
|
38741
38808
|
this[_a142] = true;
|
|
38742
38809
|
this.reason = reason;
|
|
38743
|
-
this.errors =
|
|
38744
|
-
this.lastError =
|
|
38810
|
+
this.errors = errors5;
|
|
38811
|
+
this.lastError = errors5[errors5.length - 1];
|
|
38745
38812
|
}
|
|
38746
38813
|
static isInstance(error48) {
|
|
38747
38814
|
return AISDKError.hasMarker(error48, marker142);
|
|
@@ -39539,7 +39606,7 @@ var agentWorkflow = async (input, { step, tools, logger }) => {
|
|
|
39539
39606
|
return exitReason;
|
|
39540
39607
|
};
|
|
39541
39608
|
var init_agent_workflow = __esm(() => {
|
|
39542
|
-
|
|
39609
|
+
init_dist7();
|
|
39543
39610
|
init_zod();
|
|
39544
39611
|
init_types3();
|
|
39545
39612
|
});
|
|
@@ -39698,17 +39765,17 @@ function convertJsonSchemaToZod(schema) {
|
|
|
39698
39765
|
}
|
|
39699
39766
|
}
|
|
39700
39767
|
function validateWorkflowFile(definition) {
|
|
39701
|
-
const
|
|
39768
|
+
const errors5 = [];
|
|
39702
39769
|
for (const [workflowId, workflow] of Object.entries(definition.workflows)) {
|
|
39703
39770
|
if (!workflow.steps || workflow.steps.length === 0) {
|
|
39704
|
-
|
|
39771
|
+
errors5.push(`Workflow '${workflowId}' has no steps`);
|
|
39705
39772
|
continue;
|
|
39706
39773
|
}
|
|
39707
39774
|
const checkBreakOutsideLoop = (steps, inLoop, path) => {
|
|
39708
39775
|
for (const step of steps) {
|
|
39709
39776
|
if (isBreakStep(step) || isContinueStep(step)) {
|
|
39710
39777
|
if (!inLoop) {
|
|
39711
|
-
|
|
39778
|
+
errors5.push(`${path} has break/continue outside of a loop`);
|
|
39712
39779
|
}
|
|
39713
39780
|
}
|
|
39714
39781
|
if (isWhileLoopStep(step)) {
|
|
@@ -39750,14 +39817,14 @@ function validateWorkflowFile(definition) {
|
|
|
39750
39817
|
};
|
|
39751
39818
|
findRunWorkflowCalls(workflow.steps, workflowId);
|
|
39752
39819
|
}
|
|
39753
|
-
if (
|
|
39754
|
-
return { success: false, errors:
|
|
39820
|
+
if (errors5.length > 0) {
|
|
39821
|
+
return { success: false, errors: errors5 };
|
|
39755
39822
|
}
|
|
39756
39823
|
return { success: true };
|
|
39757
39824
|
}
|
|
39758
39825
|
function parseDynamicWorkflowDefinition(source) {
|
|
39759
39826
|
try {
|
|
39760
|
-
const raw =
|
|
39827
|
+
const raw = $parse(source);
|
|
39761
39828
|
const validated = WorkflowFileSchema.safeParse(raw);
|
|
39762
39829
|
if (!validated.success) {
|
|
39763
39830
|
return { success: false, error: exports_external.prettifyError(validated.error) };
|
|
@@ -39778,7 +39845,7 @@ function validateAndApplyDefaults(workflowId, workflow, input) {
|
|
|
39778
39845
|
return input;
|
|
39779
39846
|
}
|
|
39780
39847
|
const validatedInput = { ...input };
|
|
39781
|
-
const
|
|
39848
|
+
const errors5 = [];
|
|
39782
39849
|
for (const inputDef of workflow.inputs) {
|
|
39783
39850
|
const providedValue = input[inputDef.id];
|
|
39784
39851
|
if (providedValue !== undefined && providedValue !== null) {
|
|
@@ -39786,12 +39853,12 @@ function validateAndApplyDefaults(workflowId, workflow, input) {
|
|
|
39786
39853
|
} else if (inputDef.default !== undefined && inputDef.default !== null) {
|
|
39787
39854
|
validatedInput[inputDef.id] = inputDef.default;
|
|
39788
39855
|
} else {
|
|
39789
|
-
|
|
39856
|
+
errors5.push(`Missing required input '${inputDef.id}'${inputDef.description ? `: ${inputDef.description}` : ""}`);
|
|
39790
39857
|
}
|
|
39791
39858
|
}
|
|
39792
|
-
if (
|
|
39859
|
+
if (errors5.length > 0) {
|
|
39793
39860
|
throw new Error(`Workflow '${workflowId}' input validation failed:
|
|
39794
|
-
${
|
|
39861
|
+
${errors5.map((e) => ` - ${e}`).join(`
|
|
39795
39862
|
`)}`);
|
|
39796
39863
|
}
|
|
39797
39864
|
return validatedInput;
|
|
@@ -40398,12 +40465,12 @@ function createDynamicWorkflow(definition, options = {}) {
|
|
|
40398
40465
|
return await runInternal(workflowId, input, context, {});
|
|
40399
40466
|
};
|
|
40400
40467
|
}
|
|
40401
|
-
var
|
|
40468
|
+
var MAX_WHILE_LOOP_ITERATIONS = 1000, TOOL_GROUPS;
|
|
40402
40469
|
var init_dynamic = __esm(() => {
|
|
40470
|
+
init_dist();
|
|
40403
40471
|
init_zod();
|
|
40404
40472
|
init_agent_workflow();
|
|
40405
40473
|
init_dynamic_types();
|
|
40406
|
-
import_yaml2 = __toESM(require_dist(), 1);
|
|
40407
40474
|
TOOL_GROUPS = {
|
|
40408
40475
|
readonly: ["readFile", "readBinaryFile", "listFiles", "searchFiles"],
|
|
40409
40476
|
readwrite: ["readFile", "readBinaryFile", "listFiles", "searchFiles", "writeToFile", "replaceInFile", "removeFile", "renameFile"],
|
|
@@ -40754,12 +40821,12 @@ var init_isObject = __esm(() => {
|
|
|
40754
40821
|
});
|
|
40755
40822
|
|
|
40756
40823
|
// ../../node_modules/lodash-es/identity.js
|
|
40757
|
-
function
|
|
40824
|
+
function identity2(value) {
|
|
40758
40825
|
return value;
|
|
40759
40826
|
}
|
|
40760
40827
|
var identity_default;
|
|
40761
40828
|
var init_identity = __esm(() => {
|
|
40762
|
-
identity_default =
|
|
40829
|
+
identity_default = identity2;
|
|
40763
40830
|
});
|
|
40764
40831
|
|
|
40765
40832
|
// ../../node_modules/lodash-es/isFunction.js
|
|
@@ -42395,7 +42462,7 @@ ${error48}`);
|
|
|
42395
42462
|
rules: resolvedRules
|
|
42396
42463
|
};
|
|
42397
42464
|
}
|
|
42398
|
-
var
|
|
42465
|
+
var localConfigFileName = ".polkacodes.yml", mergeArray = (a, b) => {
|
|
42399
42466
|
if (!a && !b) {
|
|
42400
42467
|
return;
|
|
42401
42468
|
}
|
|
@@ -42408,7 +42475,7 @@ var import_yaml3, localConfigFileName = ".polkacodes.yml", mergeArray = (a, b) =
|
|
|
42408
42475
|
return [...a, ...b];
|
|
42409
42476
|
}, readConfig = (path) => {
|
|
42410
42477
|
const file2 = readFileSync(path, "utf8");
|
|
42411
|
-
const config3 =
|
|
42478
|
+
const config3 = $parse(file2);
|
|
42412
42479
|
const result = configSchema.parse(config3);
|
|
42413
42480
|
if (result == null) {
|
|
42414
42481
|
return {};
|
|
@@ -42418,8 +42485,8 @@ var import_yaml3, localConfigFileName = ".polkacodes.yml", mergeArray = (a, b) =
|
|
|
42418
42485
|
var init_config2 = __esm(() => {
|
|
42419
42486
|
init_src();
|
|
42420
42487
|
init_lodash();
|
|
42488
|
+
init_dist();
|
|
42421
42489
|
init_zod();
|
|
42422
|
-
import_yaml3 = __toESM(require_dist(), 1);
|
|
42423
42490
|
});
|
|
42424
42491
|
|
|
42425
42492
|
// ../../node_modules/extend/index.js
|
|
@@ -42914,13 +42981,13 @@ var require_ms = __commonJS((exports, module) => {
|
|
|
42914
42981
|
options = options || {};
|
|
42915
42982
|
var type = typeof val;
|
|
42916
42983
|
if (type === "string" && val.length > 0) {
|
|
42917
|
-
return
|
|
42984
|
+
return parse5(val);
|
|
42918
42985
|
} else if (type === "number" && isFinite(val)) {
|
|
42919
42986
|
return options.long ? fmtLong(val) : fmtShort(val);
|
|
42920
42987
|
}
|
|
42921
42988
|
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
|
42922
42989
|
};
|
|
42923
|
-
function
|
|
42990
|
+
function parse5(str) {
|
|
42924
42991
|
str = String(str);
|
|
42925
42992
|
if (str.length > 100) {
|
|
42926
42993
|
return;
|
|
@@ -43721,7 +43788,7 @@ var require_helpers = __commonJS((exports) => {
|
|
|
43721
43788
|
});
|
|
43722
43789
|
|
|
43723
43790
|
// ../../node_modules/agent-base/dist/index.js
|
|
43724
|
-
var
|
|
43791
|
+
var require_dist2 = __commonJS((exports) => {
|
|
43725
43792
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
43726
43793
|
if (k2 === undefined)
|
|
43727
43794
|
k2 = k;
|
|
@@ -43968,7 +44035,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
|
|
|
43968
44035
|
});
|
|
43969
44036
|
|
|
43970
44037
|
// ../../node_modules/https-proxy-agent/dist/index.js
|
|
43971
|
-
var
|
|
44038
|
+
var require_dist3 = __commonJS((exports) => {
|
|
43972
44039
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
43973
44040
|
if (k2 === undefined)
|
|
43974
44041
|
k2 = k;
|
|
@@ -44010,7 +44077,7 @@ var require_dist4 = __commonJS((exports) => {
|
|
|
44010
44077
|
var tls = __importStar(__require("tls"));
|
|
44011
44078
|
var assert_1 = __importDefault(__require("assert"));
|
|
44012
44079
|
var debug_1 = __importDefault(require_src2());
|
|
44013
|
-
var agent_base_1 =
|
|
44080
|
+
var agent_base_1 = require_dist2();
|
|
44014
44081
|
var url_1 = __require("url");
|
|
44015
44082
|
var parse_proxy_response_1 = require_parse_proxy_response();
|
|
44016
44083
|
var debug = (0, debug_1.default)("https-proxy-agent");
|
|
@@ -44153,7 +44220,7 @@ function dataUriToBuffer(uri) {
|
|
|
44153
44220
|
return buffer;
|
|
44154
44221
|
}
|
|
44155
44222
|
var dist_default;
|
|
44156
|
-
var
|
|
44223
|
+
var init_dist8 = __esm(() => {
|
|
44157
44224
|
dist_default = dataUriToBuffer;
|
|
44158
44225
|
});
|
|
44159
44226
|
|
|
@@ -48930,7 +48997,7 @@ async function toFormData(Body, ct) {
|
|
|
48930
48997
|
if (!m2) {
|
|
48931
48998
|
throw new TypeError("no or bad content-type header, no multipart boundary");
|
|
48932
48999
|
}
|
|
48933
|
-
const
|
|
49000
|
+
const parser2 = new MultipartParser(m2[1] || m2[2]);
|
|
48934
49001
|
let headerField;
|
|
48935
49002
|
let headerValue;
|
|
48936
49003
|
let entryValue;
|
|
@@ -48954,9 +49021,9 @@ async function toFormData(Body, ct) {
|
|
|
48954
49021
|
};
|
|
48955
49022
|
const decoder = new TextDecoder("utf-8");
|
|
48956
49023
|
decoder.decode();
|
|
48957
|
-
|
|
48958
|
-
|
|
48959
|
-
|
|
49024
|
+
parser2.onPartBegin = function() {
|
|
49025
|
+
parser2.onPartData = onPartData;
|
|
49026
|
+
parser2.onPartEnd = appendEntryToFormData;
|
|
48960
49027
|
headerField = "";
|
|
48961
49028
|
headerValue = "";
|
|
48962
49029
|
entryValue = "";
|
|
@@ -48965,13 +49032,13 @@ async function toFormData(Body, ct) {
|
|
|
48965
49032
|
filename = null;
|
|
48966
49033
|
entryChunks.length = 0;
|
|
48967
49034
|
};
|
|
48968
|
-
|
|
49035
|
+
parser2.onHeaderField = function(ui8a) {
|
|
48969
49036
|
headerField += decoder.decode(ui8a, { stream: true });
|
|
48970
49037
|
};
|
|
48971
|
-
|
|
49038
|
+
parser2.onHeaderValue = function(ui8a) {
|
|
48972
49039
|
headerValue += decoder.decode(ui8a, { stream: true });
|
|
48973
49040
|
};
|
|
48974
|
-
|
|
49041
|
+
parser2.onHeaderEnd = function() {
|
|
48975
49042
|
headerValue += decoder.decode();
|
|
48976
49043
|
headerField = headerField.toLowerCase();
|
|
48977
49044
|
if (headerField === "content-disposition") {
|
|
@@ -48981,8 +49048,8 @@ async function toFormData(Body, ct) {
|
|
|
48981
49048
|
}
|
|
48982
49049
|
filename = _fileName(headerValue);
|
|
48983
49050
|
if (filename) {
|
|
48984
|
-
|
|
48985
|
-
|
|
49051
|
+
parser2.onPartData = appendToFile;
|
|
49052
|
+
parser2.onPartEnd = appendFileToFormData;
|
|
48986
49053
|
}
|
|
48987
49054
|
} else if (headerField === "content-type") {
|
|
48988
49055
|
contentType = headerValue;
|
|
@@ -48991,9 +49058,9 @@ async function toFormData(Body, ct) {
|
|
|
48991
49058
|
headerField = "";
|
|
48992
49059
|
};
|
|
48993
49060
|
for await (const chunk of Body) {
|
|
48994
|
-
|
|
49061
|
+
parser2.write(chunk);
|
|
48995
49062
|
}
|
|
48996
|
-
|
|
49063
|
+
parser2.end();
|
|
48997
49064
|
return formData;
|
|
48998
49065
|
}
|
|
48999
49066
|
var s = 0, S, f2 = 1, F, LF = 10, CR = 13, SPACE = 32, HYPHEN = 45, COLON = 58, A = 97, Z = 122, lower = (c) => c | 32, noop2 = () => {};
|
|
@@ -50145,7 +50212,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
50145
50212
|
}
|
|
50146
50213
|
var supportedSchemas;
|
|
50147
50214
|
var init_src2 = __esm(() => {
|
|
50148
|
-
|
|
50215
|
+
init_dist8();
|
|
50149
50216
|
init_body();
|
|
50150
50217
|
init_response();
|
|
50151
50218
|
init_headers();
|
|
@@ -50495,7 +50562,7 @@ Content-Type: ${partContentType}\r
|
|
|
50495
50562
|
static #proxyAgent;
|
|
50496
50563
|
static #fetch;
|
|
50497
50564
|
static async#getProxyAgent() {
|
|
50498
|
-
this.#proxyAgent ||= (await Promise.resolve().then(() => __toESM(
|
|
50565
|
+
this.#proxyAgent ||= (await Promise.resolve().then(() => __toESM(require_dist3()))).HttpsProxyAgent;
|
|
50499
50566
|
return this.#proxyAgent;
|
|
50500
50567
|
}
|
|
50501
50568
|
static async#getFetch() {
|
|
@@ -59979,28 +60046,28 @@ var googleErrorDataSchema, googleFailedResponseHandler, googleGenerativeAIProvid
|
|
|
59979
60046
|
}))
|
|
59980
60047
|
}), responseSchema, chunkSchema, codeExecution, enterpriseWebSearch, fileSearchArgsBaseSchema, fileSearchArgsSchema, fileSearch, googleMaps, googleSearch, urlContext, vertexRagStore, googleTools;
|
|
59981
60048
|
var init_internal = __esm(() => {
|
|
59982
|
-
|
|
60049
|
+
init_dist5();
|
|
59983
60050
|
init_v4();
|
|
59984
|
-
|
|
59985
|
-
|
|
59986
|
-
|
|
60051
|
+
init_dist2();
|
|
60052
|
+
init_dist5();
|
|
60053
|
+
init_dist5();
|
|
59987
60054
|
init_v4();
|
|
59988
|
-
|
|
60055
|
+
init_dist5();
|
|
59989
60056
|
init_v4();
|
|
59990
|
-
|
|
59991
|
-
|
|
60057
|
+
init_dist2();
|
|
60058
|
+
init_dist5();
|
|
59992
60059
|
init_v4();
|
|
59993
|
-
|
|
60060
|
+
init_dist5();
|
|
59994
60061
|
init_v4();
|
|
59995
|
-
|
|
60062
|
+
init_dist5();
|
|
59996
60063
|
init_v4();
|
|
59997
|
-
|
|
60064
|
+
init_dist5();
|
|
59998
60065
|
init_v4();
|
|
59999
|
-
|
|
60066
|
+
init_dist5();
|
|
60000
60067
|
init_v4();
|
|
60001
|
-
|
|
60068
|
+
init_dist5();
|
|
60002
60069
|
init_v4();
|
|
60003
|
-
|
|
60070
|
+
init_dist5();
|
|
60004
60071
|
init_v4();
|
|
60005
60072
|
googleErrorDataSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
60006
60073
|
error: exports_external.object({
|
|
@@ -60404,17 +60471,17 @@ var import_google_auth_library, authInstance = null, authOptions = null, VERSION
|
|
|
60404
60471
|
};
|
|
60405
60472
|
}
|
|
60406
60473
|
}, vertexImageResponseSchema, vertexImageProviderOptionsSchema, googleVertexTools, vertex;
|
|
60407
|
-
var
|
|
60408
|
-
|
|
60474
|
+
var init_dist9 = __esm(() => {
|
|
60475
|
+
init_dist5();
|
|
60409
60476
|
init_internal();
|
|
60410
|
-
|
|
60411
|
-
|
|
60412
|
-
|
|
60477
|
+
init_dist5();
|
|
60478
|
+
init_dist2();
|
|
60479
|
+
init_dist5();
|
|
60413
60480
|
init_v4();
|
|
60414
|
-
|
|
60481
|
+
init_dist5();
|
|
60415
60482
|
init_v4();
|
|
60416
60483
|
init_v4();
|
|
60417
|
-
|
|
60484
|
+
init_dist5();
|
|
60418
60485
|
init_v4();
|
|
60419
60486
|
init_internal();
|
|
60420
60487
|
import_google_auth_library = __toESM(require_src7(), 1);
|
|
@@ -60670,7 +60737,7 @@ function isUnicodeSupported() {
|
|
|
60670
60737
|
return Boolean(process3.env["WT_SESSION"]) || Boolean(process3.env["TERMINUS_SUBLIME"]) || process3.env["ConEmuTask"] === "{cmd::Cmder}" || process3.env["TERM_PROGRAM"] === "Terminus-Sublime" || process3.env["TERM_PROGRAM"] === "vscode" || process3.env["TERM"] === "xterm-256color" || process3.env["TERM"] === "alacritty" || process3.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
|
|
60671
60738
|
}
|
|
60672
60739
|
var common, specialMainSymbols, specialFallbackSymbols, mainSymbols, fallbackSymbols, shouldUseMain, figures, dist_default2, replacements;
|
|
60673
|
-
var
|
|
60740
|
+
var init_dist10 = __esm(() => {
|
|
60674
60741
|
common = {
|
|
60675
60742
|
circleQuestionMark: "(?)",
|
|
60676
60743
|
questionMarkPrefix: "(?)",
|
|
@@ -60957,7 +61024,7 @@ var init_dist9 = __esm(() => {
|
|
|
60957
61024
|
import { styleText } from "node:util";
|
|
60958
61025
|
var defaultTheme;
|
|
60959
61026
|
var init_theme = __esm(() => {
|
|
60960
|
-
|
|
61027
|
+
init_dist10();
|
|
60961
61028
|
defaultTheme = {
|
|
60962
61029
|
prefix: {
|
|
60963
61030
|
idle: styleText("blue", "?"),
|
|
@@ -61589,7 +61656,7 @@ function readlineWidth() {
|
|
|
61589
61656
|
return import_cli_width.default({ defaultWidth: 80, output: readline().output });
|
|
61590
61657
|
}
|
|
61591
61658
|
var import_cli_width;
|
|
61592
|
-
var
|
|
61659
|
+
var init_utils2 = __esm(() => {
|
|
61593
61660
|
init_wrap_ansi();
|
|
61594
61661
|
init_hook_engine();
|
|
61595
61662
|
import_cli_width = __toESM(require_cli_width(), 1);
|
|
@@ -61663,7 +61730,7 @@ function usePagination({ items, active, renderItem, pageSize, loop = true }) {
|
|
|
61663
61730
|
}
|
|
61664
61731
|
var init_use_pagination = __esm(() => {
|
|
61665
61732
|
init_use_ref();
|
|
61666
|
-
|
|
61733
|
+
init_utils2();
|
|
61667
61734
|
});
|
|
61668
61735
|
|
|
61669
61736
|
// ../../node_modules/mute-stream/lib/index.js
|
|
@@ -62003,7 +62070,7 @@ var ESC = "\x1B[", cursorLeft, cursorHide, cursorShow, cursorUp = (rows = 1) =>
|
|
|
62003
62070
|
}
|
|
62004
62071
|
return `${ESC}${x2 + 1}G`;
|
|
62005
62072
|
}, eraseLine, eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
|
|
62006
|
-
var
|
|
62073
|
+
var init_dist11 = __esm(() => {
|
|
62007
62074
|
cursorLeft = ESC + "G";
|
|
62008
62075
|
cursorHide = ESC + "?25l";
|
|
62009
62076
|
cursorShow = ESC + "?25h";
|
|
@@ -62075,8 +62142,8 @@ var height = (content) => content.split(`
|
|
|
62075
62142
|
`).length, lastLine = (content) => content.split(`
|
|
62076
62143
|
`).pop() ?? "";
|
|
62077
62144
|
var init_screen_manager = __esm(() => {
|
|
62078
|
-
|
|
62079
|
-
|
|
62145
|
+
init_utils2();
|
|
62146
|
+
init_dist11();
|
|
62080
62147
|
});
|
|
62081
62148
|
|
|
62082
62149
|
// ../../node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
@@ -62209,11 +62276,11 @@ class Separator {
|
|
|
62209
62276
|
}
|
|
62210
62277
|
}
|
|
62211
62278
|
var init_Separator = __esm(() => {
|
|
62212
|
-
|
|
62279
|
+
init_dist10();
|
|
62213
62280
|
});
|
|
62214
62281
|
|
|
62215
62282
|
// ../../node_modules/@inquirer/core/dist/index.js
|
|
62216
|
-
var
|
|
62283
|
+
var init_dist12 = __esm(() => {
|
|
62217
62284
|
init_use_prefix();
|
|
62218
62285
|
init_use_state();
|
|
62219
62286
|
init_use_effect();
|
|
@@ -62273,10 +62340,10 @@ function normalizeChoices(choices) {
|
|
|
62273
62340
|
});
|
|
62274
62341
|
}
|
|
62275
62342
|
var checkboxTheme, dist_default3;
|
|
62276
|
-
var
|
|
62343
|
+
var init_dist13 = __esm(() => {
|
|
62344
|
+
init_dist12();
|
|
62277
62345
|
init_dist11();
|
|
62278
62346
|
init_dist10();
|
|
62279
|
-
init_dist9();
|
|
62280
62347
|
checkboxTheme = {
|
|
62281
62348
|
icon: {
|
|
62282
62349
|
checked: styleText3("green", dist_default2.circleFilled),
|
|
@@ -62420,8 +62487,8 @@ function boolToString(value) {
|
|
|
62420
62487
|
return value ? "Yes" : "No";
|
|
62421
62488
|
}
|
|
62422
62489
|
var dist_default4;
|
|
62423
|
-
var
|
|
62424
|
-
|
|
62490
|
+
var init_dist14 = __esm(() => {
|
|
62491
|
+
init_dist12();
|
|
62425
62492
|
dist_default4 = createPrompt((config3, done) => {
|
|
62426
62493
|
const { transformer = boolToString } = config3;
|
|
62427
62494
|
const [status, setStatus] = useState("idle");
|
|
@@ -62459,8 +62526,8 @@ var init_dist13 = __esm(() => {
|
|
|
62459
62526
|
|
|
62460
62527
|
// ../../node_modules/@inquirer/input/dist/index.js
|
|
62461
62528
|
var inputTheme, dist_default5;
|
|
62462
|
-
var
|
|
62463
|
-
|
|
62529
|
+
var init_dist15 = __esm(() => {
|
|
62530
|
+
init_dist12();
|
|
62464
62531
|
inputTheme = {
|
|
62465
62532
|
validationFailureMode: "keep"
|
|
62466
62533
|
};
|
|
@@ -62548,9 +62615,9 @@ var init_dist14 = __esm(() => {
|
|
|
62548
62615
|
|
|
62549
62616
|
// ../../node_modules/@inquirer/password/dist/index.js
|
|
62550
62617
|
var dist_default6;
|
|
62551
|
-
var
|
|
62618
|
+
var init_dist16 = __esm(() => {
|
|
62619
|
+
init_dist12();
|
|
62552
62620
|
init_dist11();
|
|
62553
|
-
init_dist10();
|
|
62554
62621
|
dist_default6 = createPrompt((config3, done) => {
|
|
62555
62622
|
const { validate: validate2 = () => true } = config3;
|
|
62556
62623
|
const theme = makeTheme(config3.theme);
|
|
@@ -62632,10 +62699,10 @@ function normalizeChoices2(choices) {
|
|
|
62632
62699
|
});
|
|
62633
62700
|
}
|
|
62634
62701
|
var selectTheme, dist_default7;
|
|
62635
|
-
var
|
|
62702
|
+
var init_dist17 = __esm(() => {
|
|
62703
|
+
init_dist12();
|
|
62636
62704
|
init_dist11();
|
|
62637
62705
|
init_dist10();
|
|
62638
|
-
init_dist9();
|
|
62639
62706
|
selectTheme = {
|
|
62640
62707
|
icon: { cursor: dist_default2.pointer },
|
|
62641
62708
|
style: {
|
|
@@ -62764,12 +62831,12 @@ var init_dist16 = __esm(() => {
|
|
|
62764
62831
|
});
|
|
62765
62832
|
|
|
62766
62833
|
// ../../node_modules/@inquirer/prompts/dist/index.js
|
|
62767
|
-
var
|
|
62768
|
-
init_dist12();
|
|
62834
|
+
var init_dist18 = __esm(() => {
|
|
62769
62835
|
init_dist13();
|
|
62770
62836
|
init_dist14();
|
|
62771
62837
|
init_dist15();
|
|
62772
62838
|
init_dist16();
|
|
62839
|
+
init_dist17();
|
|
62773
62840
|
});
|
|
62774
62841
|
|
|
62775
62842
|
// ../../node_modules/ignore/index.js
|
|
@@ -72687,12 +72754,20 @@ var init_listFiles2 = __esm(() => {
|
|
|
72687
72754
|
];
|
|
72688
72755
|
});
|
|
72689
72756
|
|
|
72757
|
+
// ../cli-shared/src/utils/search.constants.ts
|
|
72758
|
+
var SEARCH_CONSTANTS;
|
|
72759
|
+
var init_search_constants = __esm(() => {
|
|
72760
|
+
SEARCH_CONSTANTS = {
|
|
72761
|
+
DEFAULT_CONTEXT_LINES: 5
|
|
72762
|
+
};
|
|
72763
|
+
});
|
|
72764
|
+
|
|
72690
72765
|
// ../cli-shared/src/utils/searchFiles.ts
|
|
72691
72766
|
import { spawn } from "node:child_process";
|
|
72692
72767
|
async function searchFiles(path, regex2, filePattern, cwd, excludeFiles) {
|
|
72693
72768
|
const args = [
|
|
72694
72769
|
"--line-number",
|
|
72695
|
-
|
|
72770
|
+
`--context=${SEARCH_CONSTANTS.DEFAULT_CONTEXT_LINES}`,
|
|
72696
72771
|
"--color=never",
|
|
72697
72772
|
"--with-filename",
|
|
72698
72773
|
"--smart-case"
|
|
@@ -72734,7 +72809,9 @@ async function searchFiles(path, regex2, filePattern, cwd, excludeFiles) {
|
|
|
72734
72809
|
});
|
|
72735
72810
|
});
|
|
72736
72811
|
}
|
|
72737
|
-
var init_searchFiles2 = () => {
|
|
72812
|
+
var init_searchFiles2 = __esm(() => {
|
|
72813
|
+
init_search_constants();
|
|
72814
|
+
});
|
|
72738
72815
|
|
|
72739
72816
|
// ../cli-shared/src/provider.ts
|
|
72740
72817
|
import { spawn as spawn2 } from "node:child_process";
|
|
@@ -73050,9 +73127,9 @@ ${content}`;
|
|
|
73050
73127
|
return provider2;
|
|
73051
73128
|
};
|
|
73052
73129
|
var init_provider = __esm(() => {
|
|
73053
|
-
|
|
73054
|
-
|
|
73055
|
-
|
|
73130
|
+
init_dist9();
|
|
73131
|
+
init_dist18();
|
|
73132
|
+
init_dist7();
|
|
73056
73133
|
init_mime_types();
|
|
73057
73134
|
init_checkRipgrep();
|
|
73058
73135
|
init_listFiles2();
|
|
@@ -73644,7 +73721,7 @@ var taskToolCallStats, globalToolCallStats, mergeToolCallStats = (a, b) => {
|
|
|
73644
73721
|
return merged;
|
|
73645
73722
|
}, printEvent = (verbose, usageMeter, stream = process.stdout) => {
|
|
73646
73723
|
if (verbose < 0) {
|
|
73647
|
-
return () => {};
|
|
73724
|
+
return (_event) => {};
|
|
73648
73725
|
}
|
|
73649
73726
|
const customConsole = new Console(stream, stream);
|
|
73650
73727
|
let hadReasoning = false;
|
|
@@ -73846,7 +73923,7 @@ function readMultiline(prompt = "Enter text (Ctrl+D to finish):") {
|
|
|
73846
73923
|
var init_readMultiline = () => {};
|
|
73847
73924
|
|
|
73848
73925
|
// ../cli-shared/src/utils/index.ts
|
|
73849
|
-
var
|
|
73926
|
+
var init_utils3 = __esm(() => {
|
|
73850
73927
|
init_checkRipgrep();
|
|
73851
73928
|
init_eventHandler();
|
|
73852
73929
|
init_listFiles2();
|
|
@@ -73859,7 +73936,7 @@ var init_utils2 = __esm(() => {
|
|
|
73859
73936
|
var init_src3 = __esm(() => {
|
|
73860
73937
|
init_config2();
|
|
73861
73938
|
init_provider();
|
|
73862
|
-
|
|
73939
|
+
init_utils3();
|
|
73863
73940
|
});
|
|
73864
73941
|
|
|
73865
73942
|
// src/workflows/prompts/shared.ts
|
|
@@ -76480,46 +76557,46 @@ var VERSION5 = "2.0.57", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
76480
76557
|
};
|
|
76481
76558
|
}
|
|
76482
76559
|
}, bash_20241022InputSchema, bash_20241022, bash_20250124InputSchema, bash_20250124, computer_20241022InputSchema, computer_20241022, computer_20250124InputSchema, computer_20250124, memory_20250818InputSchema, memory_20250818, textEditor_20241022InputSchema, textEditor_20241022, textEditor_20250124InputSchema, textEditor_20250124, textEditor_20250429InputSchema, textEditor_20250429, anthropicTools, anthropic;
|
|
76483
|
-
var
|
|
76484
|
-
|
|
76485
|
-
|
|
76486
|
-
|
|
76487
|
-
|
|
76488
|
-
|
|
76560
|
+
var init_dist19 = __esm(() => {
|
|
76561
|
+
init_dist2();
|
|
76562
|
+
init_dist5();
|
|
76563
|
+
init_dist2();
|
|
76564
|
+
init_dist5();
|
|
76565
|
+
init_dist5();
|
|
76489
76566
|
init_v4();
|
|
76490
|
-
|
|
76567
|
+
init_dist5();
|
|
76491
76568
|
init_v4();
|
|
76492
76569
|
init_v4();
|
|
76493
|
-
|
|
76494
|
-
|
|
76570
|
+
init_dist2();
|
|
76571
|
+
init_dist5();
|
|
76495
76572
|
init_v4();
|
|
76496
|
-
|
|
76497
|
-
|
|
76573
|
+
init_dist5();
|
|
76574
|
+
init_dist5();
|
|
76498
76575
|
init_v4();
|
|
76499
|
-
|
|
76576
|
+
init_dist5();
|
|
76500
76577
|
init_v4();
|
|
76501
|
-
|
|
76502
|
-
|
|
76503
|
-
|
|
76504
|
-
|
|
76578
|
+
init_dist5();
|
|
76579
|
+
init_dist2();
|
|
76580
|
+
init_dist5();
|
|
76581
|
+
init_dist5();
|
|
76505
76582
|
init_v4();
|
|
76506
|
-
|
|
76583
|
+
init_dist5();
|
|
76507
76584
|
init_v4();
|
|
76508
|
-
|
|
76585
|
+
init_dist5();
|
|
76509
76586
|
init_v4();
|
|
76510
|
-
|
|
76587
|
+
init_dist5();
|
|
76511
76588
|
init_v4();
|
|
76512
|
-
|
|
76589
|
+
init_dist5();
|
|
76513
76590
|
init_v4();
|
|
76514
|
-
|
|
76591
|
+
init_dist5();
|
|
76515
76592
|
init_v4();
|
|
76516
|
-
|
|
76593
|
+
init_dist5();
|
|
76517
76594
|
init_v4();
|
|
76518
|
-
|
|
76595
|
+
init_dist5();
|
|
76519
76596
|
init_v4();
|
|
76520
|
-
|
|
76597
|
+
init_dist5();
|
|
76521
76598
|
init_v4();
|
|
76522
|
-
|
|
76599
|
+
init_dist5();
|
|
76523
76600
|
init_v4();
|
|
76524
76601
|
anthropicErrorDataSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
76525
76602
|
type: exports_external.literal("error"),
|
|
@@ -77952,15 +78029,15 @@ var tokenUsageSchema, deepSeekErrorSchema, deepseekChatResponseSchema, deepseekC
|
|
|
77952
78029
|
};
|
|
77953
78030
|
}
|
|
77954
78031
|
}, VERSION6 = "1.0.33", deepseek;
|
|
77955
|
-
var
|
|
77956
|
-
|
|
77957
|
-
|
|
77958
|
-
|
|
77959
|
-
|
|
77960
|
-
|
|
78032
|
+
var init_dist20 = __esm(() => {
|
|
78033
|
+
init_dist2();
|
|
78034
|
+
init_dist5();
|
|
78035
|
+
init_dist2();
|
|
78036
|
+
init_dist5();
|
|
78037
|
+
init_dist5();
|
|
77961
78038
|
init_v4();
|
|
77962
78039
|
init_v4();
|
|
77963
|
-
|
|
78040
|
+
init_dist2();
|
|
77964
78041
|
tokenUsageSchema = exports_external.object({
|
|
77965
78042
|
prompt_tokens: exports_external.number().nullish(),
|
|
77966
78043
|
completion_tokens: exports_external.number().nullish(),
|
|
@@ -79363,37 +79440,37 @@ var VERSION7 = "2.0.52", googleErrorDataSchema2, googleFailedResponseHandler2, g
|
|
|
79363
79440
|
};
|
|
79364
79441
|
}
|
|
79365
79442
|
}, googleImageResponseSchema, googleImageProviderOptionsSchema, google;
|
|
79366
|
-
var
|
|
79367
|
-
|
|
79368
|
-
|
|
79369
|
-
|
|
79443
|
+
var init_dist21 = __esm(() => {
|
|
79444
|
+
init_dist5();
|
|
79445
|
+
init_dist2();
|
|
79446
|
+
init_dist5();
|
|
79370
79447
|
init_v4();
|
|
79371
|
-
|
|
79448
|
+
init_dist5();
|
|
79372
79449
|
init_v4();
|
|
79373
|
-
|
|
79450
|
+
init_dist5();
|
|
79374
79451
|
init_v4();
|
|
79375
|
-
|
|
79452
|
+
init_dist5();
|
|
79376
79453
|
init_v4();
|
|
79377
|
-
|
|
79378
|
-
|
|
79379
|
-
|
|
79454
|
+
init_dist2();
|
|
79455
|
+
init_dist5();
|
|
79456
|
+
init_dist5();
|
|
79380
79457
|
init_v4();
|
|
79381
|
-
|
|
79382
|
-
|
|
79458
|
+
init_dist2();
|
|
79459
|
+
init_dist5();
|
|
79383
79460
|
init_v4();
|
|
79384
|
-
|
|
79461
|
+
init_dist5();
|
|
79385
79462
|
init_v4();
|
|
79386
|
-
|
|
79463
|
+
init_dist5();
|
|
79387
79464
|
init_v4();
|
|
79388
|
-
|
|
79465
|
+
init_dist5();
|
|
79389
79466
|
init_v4();
|
|
79390
|
-
|
|
79467
|
+
init_dist5();
|
|
79391
79468
|
init_v4();
|
|
79392
|
-
|
|
79469
|
+
init_dist5();
|
|
79393
79470
|
init_v4();
|
|
79394
|
-
|
|
79471
|
+
init_dist5();
|
|
79395
79472
|
init_v4();
|
|
79396
|
-
|
|
79473
|
+
init_dist5();
|
|
79397
79474
|
init_v4();
|
|
79398
79475
|
googleErrorDataSchema2 = lazySchema(() => zodSchema(exports_external.object({
|
|
79399
79476
|
error: exports_external.object({
|
|
@@ -82565,64 +82642,64 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
82565
82642
|
};
|
|
82566
82643
|
}
|
|
82567
82644
|
}, VERSION8 = "2.0.89", openai;
|
|
82568
|
-
var
|
|
82569
|
-
|
|
82570
|
-
|
|
82571
|
-
|
|
82645
|
+
var init_dist22 = __esm(() => {
|
|
82646
|
+
init_dist5();
|
|
82647
|
+
init_dist2();
|
|
82648
|
+
init_dist5();
|
|
82572
82649
|
init_v4();
|
|
82573
|
-
|
|
82574
|
-
|
|
82575
|
-
|
|
82576
|
-
|
|
82650
|
+
init_dist5();
|
|
82651
|
+
init_dist2();
|
|
82652
|
+
init_dist5();
|
|
82653
|
+
init_dist5();
|
|
82577
82654
|
init_v4();
|
|
82578
|
-
|
|
82655
|
+
init_dist5();
|
|
82579
82656
|
init_v4();
|
|
82580
|
-
|
|
82581
|
-
|
|
82582
|
-
|
|
82657
|
+
init_dist2();
|
|
82658
|
+
init_dist5();
|
|
82659
|
+
init_dist2();
|
|
82583
82660
|
init_v4();
|
|
82584
|
-
|
|
82585
|
-
|
|
82661
|
+
init_dist5();
|
|
82662
|
+
init_dist5();
|
|
82586
82663
|
init_v4();
|
|
82587
|
-
|
|
82588
|
-
|
|
82589
|
-
|
|
82664
|
+
init_dist2();
|
|
82665
|
+
init_dist5();
|
|
82666
|
+
init_dist5();
|
|
82590
82667
|
init_v4();
|
|
82591
|
-
|
|
82668
|
+
init_dist5();
|
|
82592
82669
|
init_v4();
|
|
82593
|
-
|
|
82594
|
-
|
|
82670
|
+
init_dist5();
|
|
82671
|
+
init_dist5();
|
|
82595
82672
|
init_v4();
|
|
82596
|
-
|
|
82673
|
+
init_dist5();
|
|
82597
82674
|
init_v4();
|
|
82598
|
-
|
|
82675
|
+
init_dist5();
|
|
82599
82676
|
init_v4();
|
|
82600
|
-
|
|
82677
|
+
init_dist5();
|
|
82601
82678
|
init_v4();
|
|
82602
|
-
|
|
82679
|
+
init_dist5();
|
|
82603
82680
|
init_v4();
|
|
82604
|
-
|
|
82681
|
+
init_dist5();
|
|
82605
82682
|
init_v4();
|
|
82606
|
-
|
|
82683
|
+
init_dist5();
|
|
82607
82684
|
init_v4();
|
|
82608
|
-
|
|
82609
|
-
|
|
82610
|
-
|
|
82611
|
-
|
|
82685
|
+
init_dist2();
|
|
82686
|
+
init_dist5();
|
|
82687
|
+
init_dist2();
|
|
82688
|
+
init_dist5();
|
|
82612
82689
|
init_v4();
|
|
82613
|
-
|
|
82690
|
+
init_dist5();
|
|
82614
82691
|
init_v4();
|
|
82615
|
-
|
|
82692
|
+
init_dist5();
|
|
82616
82693
|
init_v4();
|
|
82617
|
-
|
|
82618
|
-
|
|
82619
|
-
|
|
82620
|
-
|
|
82694
|
+
init_dist2();
|
|
82695
|
+
init_dist5();
|
|
82696
|
+
init_dist5();
|
|
82697
|
+
init_dist5();
|
|
82621
82698
|
init_v4();
|
|
82622
|
-
|
|
82623
|
-
|
|
82699
|
+
init_dist5();
|
|
82700
|
+
init_dist5();
|
|
82624
82701
|
init_v4();
|
|
82625
|
-
|
|
82702
|
+
init_dist5();
|
|
82626
82703
|
init_v4();
|
|
82627
82704
|
openaiErrorDataSchema = exports_external.object({
|
|
82628
82705
|
error: exports_external.object({
|
|
@@ -83636,6 +83713,1260 @@ var init_dist21 = __esm(() => {
|
|
|
83636
83713
|
openai = createOpenAI();
|
|
83637
83714
|
});
|
|
83638
83715
|
|
|
83716
|
+
// ../../node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
83717
|
+
function getOpenAIMetadata(message) {
|
|
83718
|
+
var _a16, _b16;
|
|
83719
|
+
return (_b16 = (_a16 = message == null ? undefined : message.providerOptions) == null ? undefined : _a16.openaiCompatible) != null ? _b16 : {};
|
|
83720
|
+
}
|
|
83721
|
+
function convertToOpenAICompatibleChatMessages(prompt) {
|
|
83722
|
+
const messages = [];
|
|
83723
|
+
for (const { role, content, ...message } of prompt) {
|
|
83724
|
+
const metadata = getOpenAIMetadata({ ...message });
|
|
83725
|
+
switch (role) {
|
|
83726
|
+
case "system": {
|
|
83727
|
+
messages.push({ role: "system", content, ...metadata });
|
|
83728
|
+
break;
|
|
83729
|
+
}
|
|
83730
|
+
case "user": {
|
|
83731
|
+
if (content.length === 1 && content[0].type === "text") {
|
|
83732
|
+
messages.push({
|
|
83733
|
+
role: "user",
|
|
83734
|
+
content: content[0].text,
|
|
83735
|
+
...getOpenAIMetadata(content[0])
|
|
83736
|
+
});
|
|
83737
|
+
break;
|
|
83738
|
+
}
|
|
83739
|
+
messages.push({
|
|
83740
|
+
role: "user",
|
|
83741
|
+
content: content.map((part) => {
|
|
83742
|
+
const partMetadata = getOpenAIMetadata(part);
|
|
83743
|
+
switch (part.type) {
|
|
83744
|
+
case "text": {
|
|
83745
|
+
return { type: "text", text: part.text, ...partMetadata };
|
|
83746
|
+
}
|
|
83747
|
+
case "file": {
|
|
83748
|
+
if (part.mediaType.startsWith("image/")) {
|
|
83749
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
83750
|
+
return {
|
|
83751
|
+
type: "image_url",
|
|
83752
|
+
image_url: {
|
|
83753
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`
|
|
83754
|
+
},
|
|
83755
|
+
...partMetadata
|
|
83756
|
+
};
|
|
83757
|
+
} else {
|
|
83758
|
+
throw new UnsupportedFunctionalityError({
|
|
83759
|
+
functionality: `file part media type ${part.mediaType}`
|
|
83760
|
+
});
|
|
83761
|
+
}
|
|
83762
|
+
}
|
|
83763
|
+
}
|
|
83764
|
+
}),
|
|
83765
|
+
...metadata
|
|
83766
|
+
});
|
|
83767
|
+
break;
|
|
83768
|
+
}
|
|
83769
|
+
case "assistant": {
|
|
83770
|
+
let text2 = "";
|
|
83771
|
+
const toolCalls = [];
|
|
83772
|
+
for (const part of content) {
|
|
83773
|
+
const partMetadata = getOpenAIMetadata(part);
|
|
83774
|
+
switch (part.type) {
|
|
83775
|
+
case "text": {
|
|
83776
|
+
text2 += part.text;
|
|
83777
|
+
break;
|
|
83778
|
+
}
|
|
83779
|
+
case "tool-call": {
|
|
83780
|
+
toolCalls.push({
|
|
83781
|
+
id: part.toolCallId,
|
|
83782
|
+
type: "function",
|
|
83783
|
+
function: {
|
|
83784
|
+
name: part.toolName,
|
|
83785
|
+
arguments: JSON.stringify(part.input)
|
|
83786
|
+
},
|
|
83787
|
+
...partMetadata
|
|
83788
|
+
});
|
|
83789
|
+
break;
|
|
83790
|
+
}
|
|
83791
|
+
}
|
|
83792
|
+
}
|
|
83793
|
+
messages.push({
|
|
83794
|
+
role: "assistant",
|
|
83795
|
+
content: text2,
|
|
83796
|
+
tool_calls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
83797
|
+
...metadata
|
|
83798
|
+
});
|
|
83799
|
+
break;
|
|
83800
|
+
}
|
|
83801
|
+
case "tool": {
|
|
83802
|
+
for (const toolResponse of content) {
|
|
83803
|
+
const output = toolResponse.output;
|
|
83804
|
+
let contentValue;
|
|
83805
|
+
switch (output.type) {
|
|
83806
|
+
case "text":
|
|
83807
|
+
case "error-text":
|
|
83808
|
+
contentValue = output.value;
|
|
83809
|
+
break;
|
|
83810
|
+
case "content":
|
|
83811
|
+
case "json":
|
|
83812
|
+
case "error-json":
|
|
83813
|
+
contentValue = JSON.stringify(output.value);
|
|
83814
|
+
break;
|
|
83815
|
+
}
|
|
83816
|
+
const toolResponseMetadata = getOpenAIMetadata(toolResponse);
|
|
83817
|
+
messages.push({
|
|
83818
|
+
role: "tool",
|
|
83819
|
+
tool_call_id: toolResponse.toolCallId,
|
|
83820
|
+
content: contentValue,
|
|
83821
|
+
...toolResponseMetadata
|
|
83822
|
+
});
|
|
83823
|
+
}
|
|
83824
|
+
break;
|
|
83825
|
+
}
|
|
83826
|
+
default: {
|
|
83827
|
+
const _exhaustiveCheck = role;
|
|
83828
|
+
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
|
83829
|
+
}
|
|
83830
|
+
}
|
|
83831
|
+
}
|
|
83832
|
+
return messages;
|
|
83833
|
+
}
|
|
83834
|
+
function getResponseMetadata3({
|
|
83835
|
+
id,
|
|
83836
|
+
model,
|
|
83837
|
+
created
|
|
83838
|
+
}) {
|
|
83839
|
+
return {
|
|
83840
|
+
id: id != null ? id : undefined,
|
|
83841
|
+
modelId: model != null ? model : undefined,
|
|
83842
|
+
timestamp: created != null ? new Date(created * 1000) : undefined
|
|
83843
|
+
};
|
|
83844
|
+
}
|
|
83845
|
+
function mapOpenAICompatibleFinishReason(finishReason) {
|
|
83846
|
+
switch (finishReason) {
|
|
83847
|
+
case "stop":
|
|
83848
|
+
return "stop";
|
|
83849
|
+
case "length":
|
|
83850
|
+
return "length";
|
|
83851
|
+
case "content_filter":
|
|
83852
|
+
return "content-filter";
|
|
83853
|
+
case "function_call":
|
|
83854
|
+
case "tool_calls":
|
|
83855
|
+
return "tool-calls";
|
|
83856
|
+
default:
|
|
83857
|
+
return "unknown";
|
|
83858
|
+
}
|
|
83859
|
+
}
|
|
83860
|
+
function prepareTools5({
|
|
83861
|
+
tools: tools3,
|
|
83862
|
+
toolChoice
|
|
83863
|
+
}) {
|
|
83864
|
+
tools3 = (tools3 == null ? undefined : tools3.length) ? tools3 : undefined;
|
|
83865
|
+
const toolWarnings = [];
|
|
83866
|
+
if (tools3 == null) {
|
|
83867
|
+
return { tools: undefined, toolChoice: undefined, toolWarnings };
|
|
83868
|
+
}
|
|
83869
|
+
const openaiCompatTools = [];
|
|
83870
|
+
for (const tool3 of tools3) {
|
|
83871
|
+
if (tool3.type === "provider-defined") {
|
|
83872
|
+
toolWarnings.push({ type: "unsupported-tool", tool: tool3 });
|
|
83873
|
+
} else {
|
|
83874
|
+
openaiCompatTools.push({
|
|
83875
|
+
type: "function",
|
|
83876
|
+
function: {
|
|
83877
|
+
name: tool3.name,
|
|
83878
|
+
description: tool3.description,
|
|
83879
|
+
parameters: tool3.inputSchema
|
|
83880
|
+
}
|
|
83881
|
+
});
|
|
83882
|
+
}
|
|
83883
|
+
}
|
|
83884
|
+
if (toolChoice == null) {
|
|
83885
|
+
return { tools: openaiCompatTools, toolChoice: undefined, toolWarnings };
|
|
83886
|
+
}
|
|
83887
|
+
const type = toolChoice.type;
|
|
83888
|
+
switch (type) {
|
|
83889
|
+
case "auto":
|
|
83890
|
+
case "none":
|
|
83891
|
+
case "required":
|
|
83892
|
+
return { tools: openaiCompatTools, toolChoice: type, toolWarnings };
|
|
83893
|
+
case "tool":
|
|
83894
|
+
return {
|
|
83895
|
+
tools: openaiCompatTools,
|
|
83896
|
+
toolChoice: {
|
|
83897
|
+
type: "function",
|
|
83898
|
+
function: { name: toolChoice.toolName }
|
|
83899
|
+
},
|
|
83900
|
+
toolWarnings
|
|
83901
|
+
};
|
|
83902
|
+
default: {
|
|
83903
|
+
const _exhaustiveCheck = type;
|
|
83904
|
+
throw new UnsupportedFunctionalityError({
|
|
83905
|
+
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
83906
|
+
});
|
|
83907
|
+
}
|
|
83908
|
+
}
|
|
83909
|
+
}
|
|
83910
|
+
function convertToOpenAICompatibleCompletionPrompt({
|
|
83911
|
+
prompt,
|
|
83912
|
+
user = "user",
|
|
83913
|
+
assistant = "assistant"
|
|
83914
|
+
}) {
|
|
83915
|
+
let text2 = "";
|
|
83916
|
+
if (prompt[0].role === "system") {
|
|
83917
|
+
text2 += `${prompt[0].content}
|
|
83918
|
+
|
|
83919
|
+
`;
|
|
83920
|
+
prompt = prompt.slice(1);
|
|
83921
|
+
}
|
|
83922
|
+
for (const { role, content } of prompt) {
|
|
83923
|
+
switch (role) {
|
|
83924
|
+
case "system": {
|
|
83925
|
+
throw new InvalidPromptError({
|
|
83926
|
+
message: "Unexpected system message in prompt: ${content}",
|
|
83927
|
+
prompt
|
|
83928
|
+
});
|
|
83929
|
+
}
|
|
83930
|
+
case "user": {
|
|
83931
|
+
const userMessage = content.map((part) => {
|
|
83932
|
+
switch (part.type) {
|
|
83933
|
+
case "text": {
|
|
83934
|
+
return part.text;
|
|
83935
|
+
}
|
|
83936
|
+
}
|
|
83937
|
+
}).filter(Boolean).join("");
|
|
83938
|
+
text2 += `${user}:
|
|
83939
|
+
${userMessage}
|
|
83940
|
+
|
|
83941
|
+
`;
|
|
83942
|
+
break;
|
|
83943
|
+
}
|
|
83944
|
+
case "assistant": {
|
|
83945
|
+
const assistantMessage = content.map((part) => {
|
|
83946
|
+
switch (part.type) {
|
|
83947
|
+
case "text": {
|
|
83948
|
+
return part.text;
|
|
83949
|
+
}
|
|
83950
|
+
case "tool-call": {
|
|
83951
|
+
throw new UnsupportedFunctionalityError({
|
|
83952
|
+
functionality: "tool-call messages"
|
|
83953
|
+
});
|
|
83954
|
+
}
|
|
83955
|
+
}
|
|
83956
|
+
}).join("");
|
|
83957
|
+
text2 += `${assistant}:
|
|
83958
|
+
${assistantMessage}
|
|
83959
|
+
|
|
83960
|
+
`;
|
|
83961
|
+
break;
|
|
83962
|
+
}
|
|
83963
|
+
case "tool": {
|
|
83964
|
+
throw new UnsupportedFunctionalityError({
|
|
83965
|
+
functionality: "tool messages"
|
|
83966
|
+
});
|
|
83967
|
+
}
|
|
83968
|
+
default: {
|
|
83969
|
+
const _exhaustiveCheck = role;
|
|
83970
|
+
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
|
83971
|
+
}
|
|
83972
|
+
}
|
|
83973
|
+
}
|
|
83974
|
+
text2 += `${assistant}:
|
|
83975
|
+
`;
|
|
83976
|
+
return {
|
|
83977
|
+
prompt: text2,
|
|
83978
|
+
stopSequences: [`
|
|
83979
|
+
${user}:`]
|
|
83980
|
+
};
|
|
83981
|
+
}
|
|
83982
|
+
function getResponseMetadata23({
|
|
83983
|
+
id,
|
|
83984
|
+
model,
|
|
83985
|
+
created
|
|
83986
|
+
}) {
|
|
83987
|
+
return {
|
|
83988
|
+
id: id != null ? id : undefined,
|
|
83989
|
+
modelId: model != null ? model : undefined,
|
|
83990
|
+
timestamp: created != null ? new Date(created * 1000) : undefined
|
|
83991
|
+
};
|
|
83992
|
+
}
|
|
83993
|
+
function mapOpenAICompatibleFinishReason2(finishReason) {
|
|
83994
|
+
switch (finishReason) {
|
|
83995
|
+
case "stop":
|
|
83996
|
+
return "stop";
|
|
83997
|
+
case "length":
|
|
83998
|
+
return "length";
|
|
83999
|
+
case "content_filter":
|
|
84000
|
+
return "content-filter";
|
|
84001
|
+
case "function_call":
|
|
84002
|
+
case "tool_calls":
|
|
84003
|
+
return "tool-calls";
|
|
84004
|
+
default:
|
|
84005
|
+
return "unknown";
|
|
84006
|
+
}
|
|
84007
|
+
}
|
|
84008
|
+
function createOpenAICompatible(options) {
|
|
84009
|
+
const baseURL = withoutTrailingSlash(options.baseURL);
|
|
84010
|
+
const providerName = options.name;
|
|
84011
|
+
const headers = {
|
|
84012
|
+
...options.apiKey && { Authorization: `Bearer ${options.apiKey}` },
|
|
84013
|
+
...options.headers
|
|
84014
|
+
};
|
|
84015
|
+
const getHeaders = () => withUserAgentSuffix(headers, `ai-sdk/openai-compatible/${VERSION9}`);
|
|
84016
|
+
const getCommonModelConfig = (modelType) => ({
|
|
84017
|
+
provider: `${providerName}.${modelType}`,
|
|
84018
|
+
url: ({ path }) => {
|
|
84019
|
+
const url2 = new URL(`${baseURL}${path}`);
|
|
84020
|
+
if (options.queryParams) {
|
|
84021
|
+
url2.search = new URLSearchParams(options.queryParams).toString();
|
|
84022
|
+
}
|
|
84023
|
+
return url2.toString();
|
|
84024
|
+
},
|
|
84025
|
+
headers: getHeaders,
|
|
84026
|
+
fetch: options.fetch
|
|
84027
|
+
});
|
|
84028
|
+
const createLanguageModel = (modelId) => createChatModel(modelId);
|
|
84029
|
+
const createChatModel = (modelId) => new OpenAICompatibleChatLanguageModel(modelId, {
|
|
84030
|
+
...getCommonModelConfig("chat"),
|
|
84031
|
+
includeUsage: options.includeUsage,
|
|
84032
|
+
supportsStructuredOutputs: options.supportsStructuredOutputs
|
|
84033
|
+
});
|
|
84034
|
+
const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(modelId, {
|
|
84035
|
+
...getCommonModelConfig("completion"),
|
|
84036
|
+
includeUsage: options.includeUsage
|
|
84037
|
+
});
|
|
84038
|
+
const createEmbeddingModel = (modelId) => new OpenAICompatibleEmbeddingModel(modelId, {
|
|
84039
|
+
...getCommonModelConfig("embedding")
|
|
84040
|
+
});
|
|
84041
|
+
const createImageModel = (modelId) => new OpenAICompatibleImageModel(modelId, getCommonModelConfig("image"));
|
|
84042
|
+
const provider3 = (modelId) => createLanguageModel(modelId);
|
|
84043
|
+
provider3.languageModel = createLanguageModel;
|
|
84044
|
+
provider3.chatModel = createChatModel;
|
|
84045
|
+
provider3.completionModel = createCompletionModel;
|
|
84046
|
+
provider3.textEmbeddingModel = createEmbeddingModel;
|
|
84047
|
+
provider3.imageModel = createImageModel;
|
|
84048
|
+
return provider3;
|
|
84049
|
+
}
|
|
84050
|
+
var openaiCompatibleProviderOptions, openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, OpenAICompatibleChatLanguageModel = class {
|
|
84051
|
+
constructor(modelId, config4) {
|
|
84052
|
+
this.specificationVersion = "v2";
|
|
84053
|
+
var _a16, _b16;
|
|
84054
|
+
this.modelId = modelId;
|
|
84055
|
+
this.config = config4;
|
|
84056
|
+
const errorStructure = (_a16 = config4.errorStructure) != null ? _a16 : defaultOpenAICompatibleErrorStructure;
|
|
84057
|
+
this.chunkSchema = createOpenAICompatibleChatChunkSchema(errorStructure.errorSchema);
|
|
84058
|
+
this.failedResponseHandler = createJsonErrorResponseHandler(errorStructure);
|
|
84059
|
+
this.supportsStructuredOutputs = (_b16 = config4.supportsStructuredOutputs) != null ? _b16 : false;
|
|
84060
|
+
}
|
|
84061
|
+
get provider() {
|
|
84062
|
+
return this.config.provider;
|
|
84063
|
+
}
|
|
84064
|
+
get providerOptionsName() {
|
|
84065
|
+
return this.config.provider.split(".")[0].trim();
|
|
84066
|
+
}
|
|
84067
|
+
get supportedUrls() {
|
|
84068
|
+
var _a16, _b16, _c;
|
|
84069
|
+
return (_c = (_b16 = (_a16 = this.config).supportedUrls) == null ? undefined : _b16.call(_a16)) != null ? _c : {};
|
|
84070
|
+
}
|
|
84071
|
+
async getArgs({
|
|
84072
|
+
prompt,
|
|
84073
|
+
maxOutputTokens,
|
|
84074
|
+
temperature,
|
|
84075
|
+
topP,
|
|
84076
|
+
topK,
|
|
84077
|
+
frequencyPenalty,
|
|
84078
|
+
presencePenalty,
|
|
84079
|
+
providerOptions,
|
|
84080
|
+
stopSequences,
|
|
84081
|
+
responseFormat,
|
|
84082
|
+
seed,
|
|
84083
|
+
toolChoice,
|
|
84084
|
+
tools: tools3
|
|
84085
|
+
}) {
|
|
84086
|
+
var _a16, _b16, _c, _d;
|
|
84087
|
+
const warnings = [];
|
|
84088
|
+
const compatibleOptions = Object.assign((_a16 = await parseProviderOptions({
|
|
84089
|
+
provider: "openai-compatible",
|
|
84090
|
+
providerOptions,
|
|
84091
|
+
schema: openaiCompatibleProviderOptions
|
|
84092
|
+
})) != null ? _a16 : {}, (_b16 = await parseProviderOptions({
|
|
84093
|
+
provider: this.providerOptionsName,
|
|
84094
|
+
providerOptions,
|
|
84095
|
+
schema: openaiCompatibleProviderOptions
|
|
84096
|
+
})) != null ? _b16 : {});
|
|
84097
|
+
if (topK != null) {
|
|
84098
|
+
warnings.push({ type: "unsupported-setting", setting: "topK" });
|
|
84099
|
+
}
|
|
84100
|
+
if ((responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null && !this.supportsStructuredOutputs) {
|
|
84101
|
+
warnings.push({
|
|
84102
|
+
type: "unsupported-setting",
|
|
84103
|
+
setting: "responseFormat",
|
|
84104
|
+
details: "JSON response format schema is only supported with structuredOutputs"
|
|
84105
|
+
});
|
|
84106
|
+
}
|
|
84107
|
+
const {
|
|
84108
|
+
tools: openaiTools2,
|
|
84109
|
+
toolChoice: openaiToolChoice,
|
|
84110
|
+
toolWarnings
|
|
84111
|
+
} = prepareTools5({
|
|
84112
|
+
tools: tools3,
|
|
84113
|
+
toolChoice
|
|
84114
|
+
});
|
|
84115
|
+
return {
|
|
84116
|
+
args: {
|
|
84117
|
+
model: this.modelId,
|
|
84118
|
+
user: compatibleOptions.user,
|
|
84119
|
+
max_tokens: maxOutputTokens,
|
|
84120
|
+
temperature,
|
|
84121
|
+
top_p: topP,
|
|
84122
|
+
frequency_penalty: frequencyPenalty,
|
|
84123
|
+
presence_penalty: presencePenalty,
|
|
84124
|
+
response_format: (responseFormat == null ? undefined : responseFormat.type) === "json" ? this.supportsStructuredOutputs === true && responseFormat.schema != null ? {
|
|
84125
|
+
type: "json_schema",
|
|
84126
|
+
json_schema: {
|
|
84127
|
+
schema: responseFormat.schema,
|
|
84128
|
+
name: (_c = responseFormat.name) != null ? _c : "response",
|
|
84129
|
+
description: responseFormat.description
|
|
84130
|
+
}
|
|
84131
|
+
} : { type: "json_object" } : undefined,
|
|
84132
|
+
stop: stopSequences,
|
|
84133
|
+
seed,
|
|
84134
|
+
...Object.fromEntries(Object.entries((_d = providerOptions == null ? undefined : providerOptions[this.providerOptionsName]) != null ? _d : {}).filter(([key]) => !Object.keys(openaiCompatibleProviderOptions.shape).includes(key))),
|
|
84135
|
+
reasoning_effort: compatibleOptions.reasoningEffort,
|
|
84136
|
+
verbosity: compatibleOptions.textVerbosity,
|
|
84137
|
+
messages: convertToOpenAICompatibleChatMessages(prompt),
|
|
84138
|
+
tools: openaiTools2,
|
|
84139
|
+
tool_choice: openaiToolChoice
|
|
84140
|
+
},
|
|
84141
|
+
warnings: [...warnings, ...toolWarnings]
|
|
84142
|
+
};
|
|
84143
|
+
}
|
|
84144
|
+
async doGenerate(options) {
|
|
84145
|
+
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
84146
|
+
const { args, warnings } = await this.getArgs({ ...options });
|
|
84147
|
+
const body = JSON.stringify(args);
|
|
84148
|
+
const {
|
|
84149
|
+
responseHeaders,
|
|
84150
|
+
value: responseBody,
|
|
84151
|
+
rawValue: rawResponse
|
|
84152
|
+
} = await postJsonToApi({
|
|
84153
|
+
url: this.config.url({
|
|
84154
|
+
path: "/chat/completions",
|
|
84155
|
+
modelId: this.modelId
|
|
84156
|
+
}),
|
|
84157
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
84158
|
+
body: args,
|
|
84159
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
84160
|
+
successfulResponseHandler: createJsonResponseHandler(OpenAICompatibleChatResponseSchema),
|
|
84161
|
+
abortSignal: options.abortSignal,
|
|
84162
|
+
fetch: this.config.fetch
|
|
84163
|
+
});
|
|
84164
|
+
const choice = responseBody.choices[0];
|
|
84165
|
+
const content = [];
|
|
84166
|
+
const text2 = choice.message.content;
|
|
84167
|
+
if (text2 != null && text2.length > 0) {
|
|
84168
|
+
content.push({ type: "text", text: text2 });
|
|
84169
|
+
}
|
|
84170
|
+
const reasoning = (_a16 = choice.message.reasoning_content) != null ? _a16 : choice.message.reasoning;
|
|
84171
|
+
if (reasoning != null && reasoning.length > 0) {
|
|
84172
|
+
content.push({
|
|
84173
|
+
type: "reasoning",
|
|
84174
|
+
text: reasoning
|
|
84175
|
+
});
|
|
84176
|
+
}
|
|
84177
|
+
if (choice.message.tool_calls != null) {
|
|
84178
|
+
for (const toolCall of choice.message.tool_calls) {
|
|
84179
|
+
content.push({
|
|
84180
|
+
type: "tool-call",
|
|
84181
|
+
toolCallId: (_b16 = toolCall.id) != null ? _b16 : generateId(),
|
|
84182
|
+
toolName: toolCall.function.name,
|
|
84183
|
+
input: toolCall.function.arguments
|
|
84184
|
+
});
|
|
84185
|
+
}
|
|
84186
|
+
}
|
|
84187
|
+
const providerMetadata = {
|
|
84188
|
+
[this.providerOptionsName]: {},
|
|
84189
|
+
...await ((_d = (_c = this.config.metadataExtractor) == null ? undefined : _c.extractMetadata) == null ? undefined : _d.call(_c, {
|
|
84190
|
+
parsedBody: rawResponse
|
|
84191
|
+
}))
|
|
84192
|
+
};
|
|
84193
|
+
const completionTokenDetails = (_e = responseBody.usage) == null ? undefined : _e.completion_tokens_details;
|
|
84194
|
+
if ((completionTokenDetails == null ? undefined : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
84195
|
+
providerMetadata[this.providerOptionsName].acceptedPredictionTokens = completionTokenDetails == null ? undefined : completionTokenDetails.accepted_prediction_tokens;
|
|
84196
|
+
}
|
|
84197
|
+
if ((completionTokenDetails == null ? undefined : completionTokenDetails.rejected_prediction_tokens) != null) {
|
|
84198
|
+
providerMetadata[this.providerOptionsName].rejectedPredictionTokens = completionTokenDetails == null ? undefined : completionTokenDetails.rejected_prediction_tokens;
|
|
84199
|
+
}
|
|
84200
|
+
return {
|
|
84201
|
+
content,
|
|
84202
|
+
finishReason: mapOpenAICompatibleFinishReason(choice.finish_reason),
|
|
84203
|
+
usage: {
|
|
84204
|
+
inputTokens: (_g = (_f = responseBody.usage) == null ? undefined : _f.prompt_tokens) != null ? _g : undefined,
|
|
84205
|
+
outputTokens: (_i = (_h = responseBody.usage) == null ? undefined : _h.completion_tokens) != null ? _i : undefined,
|
|
84206
|
+
totalTokens: (_k = (_j = responseBody.usage) == null ? undefined : _j.total_tokens) != null ? _k : undefined,
|
|
84207
|
+
reasoningTokens: (_n = (_m = (_l = responseBody.usage) == null ? undefined : _l.completion_tokens_details) == null ? undefined : _m.reasoning_tokens) != null ? _n : undefined,
|
|
84208
|
+
cachedInputTokens: (_q = (_p = (_o = responseBody.usage) == null ? undefined : _o.prompt_tokens_details) == null ? undefined : _p.cached_tokens) != null ? _q : undefined
|
|
84209
|
+
},
|
|
84210
|
+
providerMetadata,
|
|
84211
|
+
request: { body },
|
|
84212
|
+
response: {
|
|
84213
|
+
...getResponseMetadata3(responseBody),
|
|
84214
|
+
headers: responseHeaders,
|
|
84215
|
+
body: rawResponse
|
|
84216
|
+
},
|
|
84217
|
+
warnings
|
|
84218
|
+
};
|
|
84219
|
+
}
|
|
84220
|
+
async doStream(options) {
|
|
84221
|
+
var _a16;
|
|
84222
|
+
const { args, warnings } = await this.getArgs({ ...options });
|
|
84223
|
+
const body = {
|
|
84224
|
+
...args,
|
|
84225
|
+
stream: true,
|
|
84226
|
+
stream_options: this.config.includeUsage ? { include_usage: true } : undefined
|
|
84227
|
+
};
|
|
84228
|
+
const metadataExtractor = (_a16 = this.config.metadataExtractor) == null ? undefined : _a16.createStreamExtractor();
|
|
84229
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
84230
|
+
url: this.config.url({
|
|
84231
|
+
path: "/chat/completions",
|
|
84232
|
+
modelId: this.modelId
|
|
84233
|
+
}),
|
|
84234
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
84235
|
+
body,
|
|
84236
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
84237
|
+
successfulResponseHandler: createEventSourceResponseHandler(this.chunkSchema),
|
|
84238
|
+
abortSignal: options.abortSignal,
|
|
84239
|
+
fetch: this.config.fetch
|
|
84240
|
+
});
|
|
84241
|
+
const toolCalls = [];
|
|
84242
|
+
let finishReason = "unknown";
|
|
84243
|
+
const usage = {
|
|
84244
|
+
completionTokens: undefined,
|
|
84245
|
+
completionTokensDetails: {
|
|
84246
|
+
reasoningTokens: undefined,
|
|
84247
|
+
acceptedPredictionTokens: undefined,
|
|
84248
|
+
rejectedPredictionTokens: undefined
|
|
84249
|
+
},
|
|
84250
|
+
promptTokens: undefined,
|
|
84251
|
+
promptTokensDetails: {
|
|
84252
|
+
cachedTokens: undefined
|
|
84253
|
+
},
|
|
84254
|
+
totalTokens: undefined
|
|
84255
|
+
};
|
|
84256
|
+
let isFirstChunk = true;
|
|
84257
|
+
const providerOptionsName = this.providerOptionsName;
|
|
84258
|
+
let isActiveReasoning = false;
|
|
84259
|
+
let isActiveText = false;
|
|
84260
|
+
return {
|
|
84261
|
+
stream: response.pipeThrough(new TransformStream({
|
|
84262
|
+
start(controller) {
|
|
84263
|
+
controller.enqueue({ type: "stream-start", warnings });
|
|
84264
|
+
},
|
|
84265
|
+
transform(chunk, controller) {
|
|
84266
|
+
var _a25, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
84267
|
+
if (options.includeRawChunks) {
|
|
84268
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
84269
|
+
}
|
|
84270
|
+
if (!chunk.success) {
|
|
84271
|
+
finishReason = "error";
|
|
84272
|
+
controller.enqueue({ type: "error", error: chunk.error });
|
|
84273
|
+
return;
|
|
84274
|
+
}
|
|
84275
|
+
const value = chunk.value;
|
|
84276
|
+
metadataExtractor == null || metadataExtractor.processChunk(chunk.rawValue);
|
|
84277
|
+
if ("error" in value) {
|
|
84278
|
+
finishReason = "error";
|
|
84279
|
+
controller.enqueue({ type: "error", error: value.error.message });
|
|
84280
|
+
return;
|
|
84281
|
+
}
|
|
84282
|
+
if (isFirstChunk) {
|
|
84283
|
+
isFirstChunk = false;
|
|
84284
|
+
controller.enqueue({
|
|
84285
|
+
type: "response-metadata",
|
|
84286
|
+
...getResponseMetadata3(value)
|
|
84287
|
+
});
|
|
84288
|
+
}
|
|
84289
|
+
if (value.usage != null) {
|
|
84290
|
+
const {
|
|
84291
|
+
prompt_tokens,
|
|
84292
|
+
completion_tokens,
|
|
84293
|
+
total_tokens,
|
|
84294
|
+
prompt_tokens_details,
|
|
84295
|
+
completion_tokens_details
|
|
84296
|
+
} = value.usage;
|
|
84297
|
+
usage.promptTokens = prompt_tokens != null ? prompt_tokens : undefined;
|
|
84298
|
+
usage.completionTokens = completion_tokens != null ? completion_tokens : undefined;
|
|
84299
|
+
usage.totalTokens = total_tokens != null ? total_tokens : undefined;
|
|
84300
|
+
if ((completion_tokens_details == null ? undefined : completion_tokens_details.reasoning_tokens) != null) {
|
|
84301
|
+
usage.completionTokensDetails.reasoningTokens = completion_tokens_details == null ? undefined : completion_tokens_details.reasoning_tokens;
|
|
84302
|
+
}
|
|
84303
|
+
if ((completion_tokens_details == null ? undefined : completion_tokens_details.accepted_prediction_tokens) != null) {
|
|
84304
|
+
usage.completionTokensDetails.acceptedPredictionTokens = completion_tokens_details == null ? undefined : completion_tokens_details.accepted_prediction_tokens;
|
|
84305
|
+
}
|
|
84306
|
+
if ((completion_tokens_details == null ? undefined : completion_tokens_details.rejected_prediction_tokens) != null) {
|
|
84307
|
+
usage.completionTokensDetails.rejectedPredictionTokens = completion_tokens_details == null ? undefined : completion_tokens_details.rejected_prediction_tokens;
|
|
84308
|
+
}
|
|
84309
|
+
if ((prompt_tokens_details == null ? undefined : prompt_tokens_details.cached_tokens) != null) {
|
|
84310
|
+
usage.promptTokensDetails.cachedTokens = prompt_tokens_details == null ? undefined : prompt_tokens_details.cached_tokens;
|
|
84311
|
+
}
|
|
84312
|
+
}
|
|
84313
|
+
const choice = value.choices[0];
|
|
84314
|
+
if ((choice == null ? undefined : choice.finish_reason) != null) {
|
|
84315
|
+
finishReason = mapOpenAICompatibleFinishReason(choice.finish_reason);
|
|
84316
|
+
}
|
|
84317
|
+
if ((choice == null ? undefined : choice.delta) == null) {
|
|
84318
|
+
return;
|
|
84319
|
+
}
|
|
84320
|
+
const delta = choice.delta;
|
|
84321
|
+
const reasoningContent = (_a25 = delta.reasoning_content) != null ? _a25 : delta.reasoning;
|
|
84322
|
+
if (reasoningContent) {
|
|
84323
|
+
if (!isActiveReasoning) {
|
|
84324
|
+
controller.enqueue({
|
|
84325
|
+
type: "reasoning-start",
|
|
84326
|
+
id: "reasoning-0"
|
|
84327
|
+
});
|
|
84328
|
+
isActiveReasoning = true;
|
|
84329
|
+
}
|
|
84330
|
+
controller.enqueue({
|
|
84331
|
+
type: "reasoning-delta",
|
|
84332
|
+
id: "reasoning-0",
|
|
84333
|
+
delta: reasoningContent
|
|
84334
|
+
});
|
|
84335
|
+
}
|
|
84336
|
+
if (delta.content) {
|
|
84337
|
+
if (!isActiveText) {
|
|
84338
|
+
controller.enqueue({ type: "text-start", id: "txt-0" });
|
|
84339
|
+
isActiveText = true;
|
|
84340
|
+
}
|
|
84341
|
+
controller.enqueue({
|
|
84342
|
+
type: "text-delta",
|
|
84343
|
+
id: "txt-0",
|
|
84344
|
+
delta: delta.content
|
|
84345
|
+
});
|
|
84346
|
+
}
|
|
84347
|
+
if (delta.tool_calls != null) {
|
|
84348
|
+
for (const toolCallDelta of delta.tool_calls) {
|
|
84349
|
+
const index = toolCallDelta.index;
|
|
84350
|
+
if (toolCalls[index] == null) {
|
|
84351
|
+
if (toolCallDelta.id == null) {
|
|
84352
|
+
throw new InvalidResponseDataError({
|
|
84353
|
+
data: toolCallDelta,
|
|
84354
|
+
message: `Expected 'id' to be a string.`
|
|
84355
|
+
});
|
|
84356
|
+
}
|
|
84357
|
+
if (((_b16 = toolCallDelta.function) == null ? undefined : _b16.name) == null) {
|
|
84358
|
+
throw new InvalidResponseDataError({
|
|
84359
|
+
data: toolCallDelta,
|
|
84360
|
+
message: `Expected 'function.name' to be a string.`
|
|
84361
|
+
});
|
|
84362
|
+
}
|
|
84363
|
+
controller.enqueue({
|
|
84364
|
+
type: "tool-input-start",
|
|
84365
|
+
id: toolCallDelta.id,
|
|
84366
|
+
toolName: toolCallDelta.function.name
|
|
84367
|
+
});
|
|
84368
|
+
toolCalls[index] = {
|
|
84369
|
+
id: toolCallDelta.id,
|
|
84370
|
+
type: "function",
|
|
84371
|
+
function: {
|
|
84372
|
+
name: toolCallDelta.function.name,
|
|
84373
|
+
arguments: (_c = toolCallDelta.function.arguments) != null ? _c : ""
|
|
84374
|
+
},
|
|
84375
|
+
hasFinished: false
|
|
84376
|
+
};
|
|
84377
|
+
const toolCall2 = toolCalls[index];
|
|
84378
|
+
if (((_d = toolCall2.function) == null ? undefined : _d.name) != null && ((_e = toolCall2.function) == null ? undefined : _e.arguments) != null) {
|
|
84379
|
+
if (toolCall2.function.arguments.length > 0) {
|
|
84380
|
+
controller.enqueue({
|
|
84381
|
+
type: "tool-input-delta",
|
|
84382
|
+
id: toolCall2.id,
|
|
84383
|
+
delta: toolCall2.function.arguments
|
|
84384
|
+
});
|
|
84385
|
+
}
|
|
84386
|
+
if (isParsableJson(toolCall2.function.arguments)) {
|
|
84387
|
+
controller.enqueue({
|
|
84388
|
+
type: "tool-input-end",
|
|
84389
|
+
id: toolCall2.id
|
|
84390
|
+
});
|
|
84391
|
+
controller.enqueue({
|
|
84392
|
+
type: "tool-call",
|
|
84393
|
+
toolCallId: (_f = toolCall2.id) != null ? _f : generateId(),
|
|
84394
|
+
toolName: toolCall2.function.name,
|
|
84395
|
+
input: toolCall2.function.arguments
|
|
84396
|
+
});
|
|
84397
|
+
toolCall2.hasFinished = true;
|
|
84398
|
+
}
|
|
84399
|
+
}
|
|
84400
|
+
continue;
|
|
84401
|
+
}
|
|
84402
|
+
const toolCall = toolCalls[index];
|
|
84403
|
+
if (toolCall.hasFinished) {
|
|
84404
|
+
continue;
|
|
84405
|
+
}
|
|
84406
|
+
if (((_g = toolCallDelta.function) == null ? undefined : _g.arguments) != null) {
|
|
84407
|
+
toolCall.function.arguments += (_i = (_h = toolCallDelta.function) == null ? undefined : _h.arguments) != null ? _i : "";
|
|
84408
|
+
}
|
|
84409
|
+
controller.enqueue({
|
|
84410
|
+
type: "tool-input-delta",
|
|
84411
|
+
id: toolCall.id,
|
|
84412
|
+
delta: (_j = toolCallDelta.function.arguments) != null ? _j : ""
|
|
84413
|
+
});
|
|
84414
|
+
if (((_k = toolCall.function) == null ? undefined : _k.name) != null && ((_l = toolCall.function) == null ? undefined : _l.arguments) != null && isParsableJson(toolCall.function.arguments)) {
|
|
84415
|
+
controller.enqueue({
|
|
84416
|
+
type: "tool-input-end",
|
|
84417
|
+
id: toolCall.id
|
|
84418
|
+
});
|
|
84419
|
+
controller.enqueue({
|
|
84420
|
+
type: "tool-call",
|
|
84421
|
+
toolCallId: (_m = toolCall.id) != null ? _m : generateId(),
|
|
84422
|
+
toolName: toolCall.function.name,
|
|
84423
|
+
input: toolCall.function.arguments
|
|
84424
|
+
});
|
|
84425
|
+
toolCall.hasFinished = true;
|
|
84426
|
+
}
|
|
84427
|
+
}
|
|
84428
|
+
}
|
|
84429
|
+
},
|
|
84430
|
+
flush(controller) {
|
|
84431
|
+
var _a25, _b16, _c, _d, _e, _f;
|
|
84432
|
+
if (isActiveReasoning) {
|
|
84433
|
+
controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
|
|
84434
|
+
}
|
|
84435
|
+
if (isActiveText) {
|
|
84436
|
+
controller.enqueue({ type: "text-end", id: "txt-0" });
|
|
84437
|
+
}
|
|
84438
|
+
for (const toolCall of toolCalls.filter((toolCall2) => !toolCall2.hasFinished)) {
|
|
84439
|
+
controller.enqueue({
|
|
84440
|
+
type: "tool-input-end",
|
|
84441
|
+
id: toolCall.id
|
|
84442
|
+
});
|
|
84443
|
+
controller.enqueue({
|
|
84444
|
+
type: "tool-call",
|
|
84445
|
+
toolCallId: (_a25 = toolCall.id) != null ? _a25 : generateId(),
|
|
84446
|
+
toolName: toolCall.function.name,
|
|
84447
|
+
input: toolCall.function.arguments
|
|
84448
|
+
});
|
|
84449
|
+
}
|
|
84450
|
+
const providerMetadata = {
|
|
84451
|
+
[providerOptionsName]: {},
|
|
84452
|
+
...metadataExtractor == null ? undefined : metadataExtractor.buildMetadata()
|
|
84453
|
+
};
|
|
84454
|
+
if (usage.completionTokensDetails.acceptedPredictionTokens != null) {
|
|
84455
|
+
providerMetadata[providerOptionsName].acceptedPredictionTokens = usage.completionTokensDetails.acceptedPredictionTokens;
|
|
84456
|
+
}
|
|
84457
|
+
if (usage.completionTokensDetails.rejectedPredictionTokens != null) {
|
|
84458
|
+
providerMetadata[providerOptionsName].rejectedPredictionTokens = usage.completionTokensDetails.rejectedPredictionTokens;
|
|
84459
|
+
}
|
|
84460
|
+
controller.enqueue({
|
|
84461
|
+
type: "finish",
|
|
84462
|
+
finishReason,
|
|
84463
|
+
usage: {
|
|
84464
|
+
inputTokens: (_b16 = usage.promptTokens) != null ? _b16 : undefined,
|
|
84465
|
+
outputTokens: (_c = usage.completionTokens) != null ? _c : undefined,
|
|
84466
|
+
totalTokens: (_d = usage.totalTokens) != null ? _d : undefined,
|
|
84467
|
+
reasoningTokens: (_e = usage.completionTokensDetails.reasoningTokens) != null ? _e : undefined,
|
|
84468
|
+
cachedInputTokens: (_f = usage.promptTokensDetails.cachedTokens) != null ? _f : undefined
|
|
84469
|
+
},
|
|
84470
|
+
providerMetadata
|
|
84471
|
+
});
|
|
84472
|
+
}
|
|
84473
|
+
})),
|
|
84474
|
+
request: { body },
|
|
84475
|
+
response: { headers: responseHeaders }
|
|
84476
|
+
};
|
|
84477
|
+
}
|
|
84478
|
+
}, openaiCompatibleTokenUsageSchema, OpenAICompatibleChatResponseSchema, createOpenAICompatibleChatChunkSchema = (errorSchema) => exports_external.union([
|
|
84479
|
+
exports_external.object({
|
|
84480
|
+
id: exports_external.string().nullish(),
|
|
84481
|
+
created: exports_external.number().nullish(),
|
|
84482
|
+
model: exports_external.string().nullish(),
|
|
84483
|
+
choices: exports_external.array(exports_external.object({
|
|
84484
|
+
delta: exports_external.object({
|
|
84485
|
+
role: exports_external.enum(["assistant"]).nullish(),
|
|
84486
|
+
content: exports_external.string().nullish(),
|
|
84487
|
+
reasoning_content: exports_external.string().nullish(),
|
|
84488
|
+
reasoning: exports_external.string().nullish(),
|
|
84489
|
+
tool_calls: exports_external.array(exports_external.object({
|
|
84490
|
+
index: exports_external.number(),
|
|
84491
|
+
id: exports_external.string().nullish(),
|
|
84492
|
+
function: exports_external.object({
|
|
84493
|
+
name: exports_external.string().nullish(),
|
|
84494
|
+
arguments: exports_external.string().nullish()
|
|
84495
|
+
})
|
|
84496
|
+
})).nullish()
|
|
84497
|
+
}).nullish(),
|
|
84498
|
+
finish_reason: exports_external.string().nullish()
|
|
84499
|
+
})),
|
|
84500
|
+
usage: openaiCompatibleTokenUsageSchema
|
|
84501
|
+
}),
|
|
84502
|
+
errorSchema
|
|
84503
|
+
]), openaiCompatibleCompletionProviderOptions, OpenAICompatibleCompletionLanguageModel = class {
|
|
84504
|
+
constructor(modelId, config4) {
|
|
84505
|
+
this.specificationVersion = "v2";
|
|
84506
|
+
var _a16;
|
|
84507
|
+
this.modelId = modelId;
|
|
84508
|
+
this.config = config4;
|
|
84509
|
+
const errorStructure = (_a16 = config4.errorStructure) != null ? _a16 : defaultOpenAICompatibleErrorStructure;
|
|
84510
|
+
this.chunkSchema = createOpenAICompatibleCompletionChunkSchema(errorStructure.errorSchema);
|
|
84511
|
+
this.failedResponseHandler = createJsonErrorResponseHandler(errorStructure);
|
|
84512
|
+
}
|
|
84513
|
+
get provider() {
|
|
84514
|
+
return this.config.provider;
|
|
84515
|
+
}
|
|
84516
|
+
get providerOptionsName() {
|
|
84517
|
+
return this.config.provider.split(".")[0].trim();
|
|
84518
|
+
}
|
|
84519
|
+
get supportedUrls() {
|
|
84520
|
+
var _a16, _b16, _c;
|
|
84521
|
+
return (_c = (_b16 = (_a16 = this.config).supportedUrls) == null ? undefined : _b16.call(_a16)) != null ? _c : {};
|
|
84522
|
+
}
|
|
84523
|
+
async getArgs({
|
|
84524
|
+
prompt,
|
|
84525
|
+
maxOutputTokens,
|
|
84526
|
+
temperature,
|
|
84527
|
+
topP,
|
|
84528
|
+
topK,
|
|
84529
|
+
frequencyPenalty,
|
|
84530
|
+
presencePenalty,
|
|
84531
|
+
stopSequences: userStopSequences,
|
|
84532
|
+
responseFormat,
|
|
84533
|
+
seed,
|
|
84534
|
+
providerOptions,
|
|
84535
|
+
tools: tools3,
|
|
84536
|
+
toolChoice
|
|
84537
|
+
}) {
|
|
84538
|
+
var _a16;
|
|
84539
|
+
const warnings = [];
|
|
84540
|
+
const completionOptions = (_a16 = await parseProviderOptions({
|
|
84541
|
+
provider: this.providerOptionsName,
|
|
84542
|
+
providerOptions,
|
|
84543
|
+
schema: openaiCompatibleCompletionProviderOptions
|
|
84544
|
+
})) != null ? _a16 : {};
|
|
84545
|
+
if (topK != null) {
|
|
84546
|
+
warnings.push({ type: "unsupported-setting", setting: "topK" });
|
|
84547
|
+
}
|
|
84548
|
+
if (tools3 == null ? undefined : tools3.length) {
|
|
84549
|
+
warnings.push({ type: "unsupported-setting", setting: "tools" });
|
|
84550
|
+
}
|
|
84551
|
+
if (toolChoice != null) {
|
|
84552
|
+
warnings.push({ type: "unsupported-setting", setting: "toolChoice" });
|
|
84553
|
+
}
|
|
84554
|
+
if (responseFormat != null && responseFormat.type !== "text") {
|
|
84555
|
+
warnings.push({
|
|
84556
|
+
type: "unsupported-setting",
|
|
84557
|
+
setting: "responseFormat",
|
|
84558
|
+
details: "JSON response format is not supported."
|
|
84559
|
+
});
|
|
84560
|
+
}
|
|
84561
|
+
const { prompt: completionPrompt, stopSequences } = convertToOpenAICompatibleCompletionPrompt({ prompt });
|
|
84562
|
+
const stop = [...stopSequences != null ? stopSequences : [], ...userStopSequences != null ? userStopSequences : []];
|
|
84563
|
+
return {
|
|
84564
|
+
args: {
|
|
84565
|
+
model: this.modelId,
|
|
84566
|
+
echo: completionOptions.echo,
|
|
84567
|
+
logit_bias: completionOptions.logitBias,
|
|
84568
|
+
suffix: completionOptions.suffix,
|
|
84569
|
+
user: completionOptions.user,
|
|
84570
|
+
max_tokens: maxOutputTokens,
|
|
84571
|
+
temperature,
|
|
84572
|
+
top_p: topP,
|
|
84573
|
+
frequency_penalty: frequencyPenalty,
|
|
84574
|
+
presence_penalty: presencePenalty,
|
|
84575
|
+
seed,
|
|
84576
|
+
...providerOptions == null ? undefined : providerOptions[this.providerOptionsName],
|
|
84577
|
+
prompt: completionPrompt,
|
|
84578
|
+
stop: stop.length > 0 ? stop : undefined
|
|
84579
|
+
},
|
|
84580
|
+
warnings
|
|
84581
|
+
};
|
|
84582
|
+
}
|
|
84583
|
+
async doGenerate(options) {
|
|
84584
|
+
var _a16, _b16, _c, _d, _e, _f;
|
|
84585
|
+
const { args, warnings } = await this.getArgs(options);
|
|
84586
|
+
const {
|
|
84587
|
+
responseHeaders,
|
|
84588
|
+
value: response,
|
|
84589
|
+
rawValue: rawResponse
|
|
84590
|
+
} = await postJsonToApi({
|
|
84591
|
+
url: this.config.url({
|
|
84592
|
+
path: "/completions",
|
|
84593
|
+
modelId: this.modelId
|
|
84594
|
+
}),
|
|
84595
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
84596
|
+
body: args,
|
|
84597
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
84598
|
+
successfulResponseHandler: createJsonResponseHandler(openaiCompatibleCompletionResponseSchema),
|
|
84599
|
+
abortSignal: options.abortSignal,
|
|
84600
|
+
fetch: this.config.fetch
|
|
84601
|
+
});
|
|
84602
|
+
const choice = response.choices[0];
|
|
84603
|
+
const content = [];
|
|
84604
|
+
if (choice.text != null && choice.text.length > 0) {
|
|
84605
|
+
content.push({ type: "text", text: choice.text });
|
|
84606
|
+
}
|
|
84607
|
+
return {
|
|
84608
|
+
content,
|
|
84609
|
+
usage: {
|
|
84610
|
+
inputTokens: (_b16 = (_a16 = response.usage) == null ? undefined : _a16.prompt_tokens) != null ? _b16 : undefined,
|
|
84611
|
+
outputTokens: (_d = (_c = response.usage) == null ? undefined : _c.completion_tokens) != null ? _d : undefined,
|
|
84612
|
+
totalTokens: (_f = (_e = response.usage) == null ? undefined : _e.total_tokens) != null ? _f : undefined
|
|
84613
|
+
},
|
|
84614
|
+
finishReason: mapOpenAICompatibleFinishReason2(choice.finish_reason),
|
|
84615
|
+
request: { body: args },
|
|
84616
|
+
response: {
|
|
84617
|
+
...getResponseMetadata23(response),
|
|
84618
|
+
headers: responseHeaders,
|
|
84619
|
+
body: rawResponse
|
|
84620
|
+
},
|
|
84621
|
+
warnings
|
|
84622
|
+
};
|
|
84623
|
+
}
|
|
84624
|
+
async doStream(options) {
|
|
84625
|
+
const { args, warnings } = await this.getArgs(options);
|
|
84626
|
+
const body = {
|
|
84627
|
+
...args,
|
|
84628
|
+
stream: true,
|
|
84629
|
+
stream_options: this.config.includeUsage ? { include_usage: true } : undefined
|
|
84630
|
+
};
|
|
84631
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
84632
|
+
url: this.config.url({
|
|
84633
|
+
path: "/completions",
|
|
84634
|
+
modelId: this.modelId
|
|
84635
|
+
}),
|
|
84636
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
84637
|
+
body,
|
|
84638
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
84639
|
+
successfulResponseHandler: createEventSourceResponseHandler(this.chunkSchema),
|
|
84640
|
+
abortSignal: options.abortSignal,
|
|
84641
|
+
fetch: this.config.fetch
|
|
84642
|
+
});
|
|
84643
|
+
let finishReason = "unknown";
|
|
84644
|
+
const usage = {
|
|
84645
|
+
inputTokens: undefined,
|
|
84646
|
+
outputTokens: undefined,
|
|
84647
|
+
totalTokens: undefined
|
|
84648
|
+
};
|
|
84649
|
+
let isFirstChunk = true;
|
|
84650
|
+
return {
|
|
84651
|
+
stream: response.pipeThrough(new TransformStream({
|
|
84652
|
+
start(controller) {
|
|
84653
|
+
controller.enqueue({ type: "stream-start", warnings });
|
|
84654
|
+
},
|
|
84655
|
+
transform(chunk, controller) {
|
|
84656
|
+
var _a16, _b16, _c;
|
|
84657
|
+
if (options.includeRawChunks) {
|
|
84658
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
84659
|
+
}
|
|
84660
|
+
if (!chunk.success) {
|
|
84661
|
+
finishReason = "error";
|
|
84662
|
+
controller.enqueue({ type: "error", error: chunk.error });
|
|
84663
|
+
return;
|
|
84664
|
+
}
|
|
84665
|
+
const value = chunk.value;
|
|
84666
|
+
if ("error" in value) {
|
|
84667
|
+
finishReason = "error";
|
|
84668
|
+
controller.enqueue({ type: "error", error: value.error });
|
|
84669
|
+
return;
|
|
84670
|
+
}
|
|
84671
|
+
if (isFirstChunk) {
|
|
84672
|
+
isFirstChunk = false;
|
|
84673
|
+
controller.enqueue({
|
|
84674
|
+
type: "response-metadata",
|
|
84675
|
+
...getResponseMetadata23(value)
|
|
84676
|
+
});
|
|
84677
|
+
controller.enqueue({
|
|
84678
|
+
type: "text-start",
|
|
84679
|
+
id: "0"
|
|
84680
|
+
});
|
|
84681
|
+
}
|
|
84682
|
+
if (value.usage != null) {
|
|
84683
|
+
usage.inputTokens = (_a16 = value.usage.prompt_tokens) != null ? _a16 : undefined;
|
|
84684
|
+
usage.outputTokens = (_b16 = value.usage.completion_tokens) != null ? _b16 : undefined;
|
|
84685
|
+
usage.totalTokens = (_c = value.usage.total_tokens) != null ? _c : undefined;
|
|
84686
|
+
}
|
|
84687
|
+
const choice = value.choices[0];
|
|
84688
|
+
if ((choice == null ? undefined : choice.finish_reason) != null) {
|
|
84689
|
+
finishReason = mapOpenAICompatibleFinishReason2(choice.finish_reason);
|
|
84690
|
+
}
|
|
84691
|
+
if ((choice == null ? undefined : choice.text) != null) {
|
|
84692
|
+
controller.enqueue({
|
|
84693
|
+
type: "text-delta",
|
|
84694
|
+
id: "0",
|
|
84695
|
+
delta: choice.text
|
|
84696
|
+
});
|
|
84697
|
+
}
|
|
84698
|
+
},
|
|
84699
|
+
flush(controller) {
|
|
84700
|
+
if (!isFirstChunk) {
|
|
84701
|
+
controller.enqueue({ type: "text-end", id: "0" });
|
|
84702
|
+
}
|
|
84703
|
+
controller.enqueue({
|
|
84704
|
+
type: "finish",
|
|
84705
|
+
finishReason,
|
|
84706
|
+
usage
|
|
84707
|
+
});
|
|
84708
|
+
}
|
|
84709
|
+
})),
|
|
84710
|
+
request: { body },
|
|
84711
|
+
response: { headers: responseHeaders }
|
|
84712
|
+
};
|
|
84713
|
+
}
|
|
84714
|
+
}, usageSchema3, openaiCompatibleCompletionResponseSchema, createOpenAICompatibleCompletionChunkSchema = (errorSchema) => exports_external.union([
|
|
84715
|
+
exports_external.object({
|
|
84716
|
+
id: exports_external.string().nullish(),
|
|
84717
|
+
created: exports_external.number().nullish(),
|
|
84718
|
+
model: exports_external.string().nullish(),
|
|
84719
|
+
choices: exports_external.array(exports_external.object({
|
|
84720
|
+
text: exports_external.string(),
|
|
84721
|
+
finish_reason: exports_external.string().nullish(),
|
|
84722
|
+
index: exports_external.number()
|
|
84723
|
+
})),
|
|
84724
|
+
usage: usageSchema3.nullish()
|
|
84725
|
+
}),
|
|
84726
|
+
errorSchema
|
|
84727
|
+
]), openaiCompatibleEmbeddingProviderOptions, OpenAICompatibleEmbeddingModel = class {
|
|
84728
|
+
constructor(modelId, config4) {
|
|
84729
|
+
this.specificationVersion = "v2";
|
|
84730
|
+
this.modelId = modelId;
|
|
84731
|
+
this.config = config4;
|
|
84732
|
+
}
|
|
84733
|
+
get provider() {
|
|
84734
|
+
return this.config.provider;
|
|
84735
|
+
}
|
|
84736
|
+
get maxEmbeddingsPerCall() {
|
|
84737
|
+
var _a16;
|
|
84738
|
+
return (_a16 = this.config.maxEmbeddingsPerCall) != null ? _a16 : 2048;
|
|
84739
|
+
}
|
|
84740
|
+
get supportsParallelCalls() {
|
|
84741
|
+
var _a16;
|
|
84742
|
+
return (_a16 = this.config.supportsParallelCalls) != null ? _a16 : true;
|
|
84743
|
+
}
|
|
84744
|
+
get providerOptionsName() {
|
|
84745
|
+
return this.config.provider.split(".")[0].trim();
|
|
84746
|
+
}
|
|
84747
|
+
async doEmbed({
|
|
84748
|
+
values,
|
|
84749
|
+
headers,
|
|
84750
|
+
abortSignal,
|
|
84751
|
+
providerOptions
|
|
84752
|
+
}) {
|
|
84753
|
+
var _a16, _b16, _c;
|
|
84754
|
+
const compatibleOptions = Object.assign((_a16 = await parseProviderOptions({
|
|
84755
|
+
provider: "openai-compatible",
|
|
84756
|
+
providerOptions,
|
|
84757
|
+
schema: openaiCompatibleEmbeddingProviderOptions
|
|
84758
|
+
})) != null ? _a16 : {}, (_b16 = await parseProviderOptions({
|
|
84759
|
+
provider: this.providerOptionsName,
|
|
84760
|
+
providerOptions,
|
|
84761
|
+
schema: openaiCompatibleEmbeddingProviderOptions
|
|
84762
|
+
})) != null ? _b16 : {});
|
|
84763
|
+
if (values.length > this.maxEmbeddingsPerCall) {
|
|
84764
|
+
throw new TooManyEmbeddingValuesForCallError({
|
|
84765
|
+
provider: this.provider,
|
|
84766
|
+
modelId: this.modelId,
|
|
84767
|
+
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
84768
|
+
values
|
|
84769
|
+
});
|
|
84770
|
+
}
|
|
84771
|
+
const {
|
|
84772
|
+
responseHeaders,
|
|
84773
|
+
value: response,
|
|
84774
|
+
rawValue
|
|
84775
|
+
} = await postJsonToApi({
|
|
84776
|
+
url: this.config.url({
|
|
84777
|
+
path: "/embeddings",
|
|
84778
|
+
modelId: this.modelId
|
|
84779
|
+
}),
|
|
84780
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
84781
|
+
body: {
|
|
84782
|
+
model: this.modelId,
|
|
84783
|
+
input: values,
|
|
84784
|
+
encoding_format: "float",
|
|
84785
|
+
dimensions: compatibleOptions.dimensions,
|
|
84786
|
+
user: compatibleOptions.user
|
|
84787
|
+
},
|
|
84788
|
+
failedResponseHandler: createJsonErrorResponseHandler((_c = this.config.errorStructure) != null ? _c : defaultOpenAICompatibleErrorStructure),
|
|
84789
|
+
successfulResponseHandler: createJsonResponseHandler(openaiTextEmbeddingResponseSchema2),
|
|
84790
|
+
abortSignal,
|
|
84791
|
+
fetch: this.config.fetch
|
|
84792
|
+
});
|
|
84793
|
+
return {
|
|
84794
|
+
embeddings: response.data.map((item) => item.embedding),
|
|
84795
|
+
usage: response.usage ? { tokens: response.usage.prompt_tokens } : undefined,
|
|
84796
|
+
providerMetadata: response.providerMetadata,
|
|
84797
|
+
response: { headers: responseHeaders, body: rawValue }
|
|
84798
|
+
};
|
|
84799
|
+
}
|
|
84800
|
+
}, openaiTextEmbeddingResponseSchema2, OpenAICompatibleImageModel = class {
|
|
84801
|
+
constructor(modelId, config4) {
|
|
84802
|
+
this.modelId = modelId;
|
|
84803
|
+
this.config = config4;
|
|
84804
|
+
this.specificationVersion = "v2";
|
|
84805
|
+
this.maxImagesPerCall = 10;
|
|
84806
|
+
}
|
|
84807
|
+
get provider() {
|
|
84808
|
+
return this.config.provider;
|
|
84809
|
+
}
|
|
84810
|
+
async doGenerate({
|
|
84811
|
+
prompt,
|
|
84812
|
+
n,
|
|
84813
|
+
size,
|
|
84814
|
+
aspectRatio,
|
|
84815
|
+
seed,
|
|
84816
|
+
providerOptions,
|
|
84817
|
+
headers,
|
|
84818
|
+
abortSignal
|
|
84819
|
+
}) {
|
|
84820
|
+
var _a16, _b16, _c, _d, _e;
|
|
84821
|
+
const warnings = [];
|
|
84822
|
+
if (aspectRatio != null) {
|
|
84823
|
+
warnings.push({
|
|
84824
|
+
type: "unsupported-setting",
|
|
84825
|
+
setting: "aspectRatio",
|
|
84826
|
+
details: "This model does not support aspect ratio. Use `size` instead."
|
|
84827
|
+
});
|
|
84828
|
+
}
|
|
84829
|
+
if (seed != null) {
|
|
84830
|
+
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
84831
|
+
}
|
|
84832
|
+
const currentDate = (_c = (_b16 = (_a16 = this.config._internal) == null ? undefined : _a16.currentDate) == null ? undefined : _b16.call(_a16)) != null ? _c : /* @__PURE__ */ new Date;
|
|
84833
|
+
const { value: response, responseHeaders } = await postJsonToApi({
|
|
84834
|
+
url: this.config.url({
|
|
84835
|
+
path: "/images/generations",
|
|
84836
|
+
modelId: this.modelId
|
|
84837
|
+
}),
|
|
84838
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
84839
|
+
body: {
|
|
84840
|
+
model: this.modelId,
|
|
84841
|
+
prompt,
|
|
84842
|
+
n,
|
|
84843
|
+
size,
|
|
84844
|
+
...(_d = providerOptions.openai) != null ? _d : {},
|
|
84845
|
+
response_format: "b64_json"
|
|
84846
|
+
},
|
|
84847
|
+
failedResponseHandler: createJsonErrorResponseHandler((_e = this.config.errorStructure) != null ? _e : defaultOpenAICompatibleErrorStructure),
|
|
84848
|
+
successfulResponseHandler: createJsonResponseHandler(openaiCompatibleImageResponseSchema),
|
|
84849
|
+
abortSignal,
|
|
84850
|
+
fetch: this.config.fetch
|
|
84851
|
+
});
|
|
84852
|
+
return {
|
|
84853
|
+
images: response.data.map((item) => item.b64_json),
|
|
84854
|
+
warnings,
|
|
84855
|
+
response: {
|
|
84856
|
+
timestamp: currentDate,
|
|
84857
|
+
modelId: this.modelId,
|
|
84858
|
+
headers: responseHeaders
|
|
84859
|
+
}
|
|
84860
|
+
};
|
|
84861
|
+
}
|
|
84862
|
+
}, openaiCompatibleImageResponseSchema, VERSION9 = "1.0.30";
|
|
84863
|
+
var init_dist23 = __esm(() => {
|
|
84864
|
+
init_dist2();
|
|
84865
|
+
init_dist5();
|
|
84866
|
+
init_v4();
|
|
84867
|
+
init_dist2();
|
|
84868
|
+
init_dist5();
|
|
84869
|
+
init_v4();
|
|
84870
|
+
init_v4();
|
|
84871
|
+
init_dist2();
|
|
84872
|
+
init_dist5();
|
|
84873
|
+
init_v4();
|
|
84874
|
+
init_dist2();
|
|
84875
|
+
init_v4();
|
|
84876
|
+
init_dist2();
|
|
84877
|
+
init_dist5();
|
|
84878
|
+
init_v4();
|
|
84879
|
+
init_v4();
|
|
84880
|
+
init_dist5();
|
|
84881
|
+
init_v4();
|
|
84882
|
+
init_dist5();
|
|
84883
|
+
openaiCompatibleProviderOptions = exports_external.object({
|
|
84884
|
+
user: exports_external.string().optional(),
|
|
84885
|
+
reasoningEffort: exports_external.string().optional(),
|
|
84886
|
+
textVerbosity: exports_external.string().optional()
|
|
84887
|
+
});
|
|
84888
|
+
openaiCompatibleErrorDataSchema = exports_external.object({
|
|
84889
|
+
error: exports_external.object({
|
|
84890
|
+
message: exports_external.string(),
|
|
84891
|
+
type: exports_external.string().nullish(),
|
|
84892
|
+
param: exports_external.any().nullish(),
|
|
84893
|
+
code: exports_external.union([exports_external.string(), exports_external.number()]).nullish()
|
|
84894
|
+
})
|
|
84895
|
+
});
|
|
84896
|
+
defaultOpenAICompatibleErrorStructure = {
|
|
84897
|
+
errorSchema: openaiCompatibleErrorDataSchema,
|
|
84898
|
+
errorToMessage: (data) => data.error.message
|
|
84899
|
+
};
|
|
84900
|
+
openaiCompatibleTokenUsageSchema = exports_external.object({
|
|
84901
|
+
prompt_tokens: exports_external.number().nullish(),
|
|
84902
|
+
completion_tokens: exports_external.number().nullish(),
|
|
84903
|
+
total_tokens: exports_external.number().nullish(),
|
|
84904
|
+
prompt_tokens_details: exports_external.object({
|
|
84905
|
+
cached_tokens: exports_external.number().nullish()
|
|
84906
|
+
}).nullish(),
|
|
84907
|
+
completion_tokens_details: exports_external.object({
|
|
84908
|
+
reasoning_tokens: exports_external.number().nullish(),
|
|
84909
|
+
accepted_prediction_tokens: exports_external.number().nullish(),
|
|
84910
|
+
rejected_prediction_tokens: exports_external.number().nullish()
|
|
84911
|
+
}).nullish()
|
|
84912
|
+
}).nullish();
|
|
84913
|
+
OpenAICompatibleChatResponseSchema = exports_external.object({
|
|
84914
|
+
id: exports_external.string().nullish(),
|
|
84915
|
+
created: exports_external.number().nullish(),
|
|
84916
|
+
model: exports_external.string().nullish(),
|
|
84917
|
+
choices: exports_external.array(exports_external.object({
|
|
84918
|
+
message: exports_external.object({
|
|
84919
|
+
role: exports_external.literal("assistant").nullish(),
|
|
84920
|
+
content: exports_external.string().nullish(),
|
|
84921
|
+
reasoning_content: exports_external.string().nullish(),
|
|
84922
|
+
reasoning: exports_external.string().nullish(),
|
|
84923
|
+
tool_calls: exports_external.array(exports_external.object({
|
|
84924
|
+
id: exports_external.string().nullish(),
|
|
84925
|
+
function: exports_external.object({
|
|
84926
|
+
name: exports_external.string(),
|
|
84927
|
+
arguments: exports_external.string()
|
|
84928
|
+
})
|
|
84929
|
+
})).nullish()
|
|
84930
|
+
}),
|
|
84931
|
+
finish_reason: exports_external.string().nullish()
|
|
84932
|
+
})),
|
|
84933
|
+
usage: openaiCompatibleTokenUsageSchema
|
|
84934
|
+
});
|
|
84935
|
+
openaiCompatibleCompletionProviderOptions = exports_external.object({
|
|
84936
|
+
echo: exports_external.boolean().optional(),
|
|
84937
|
+
logitBias: exports_external.record(exports_external.string(), exports_external.number()).optional(),
|
|
84938
|
+
suffix: exports_external.string().optional(),
|
|
84939
|
+
user: exports_external.string().optional()
|
|
84940
|
+
});
|
|
84941
|
+
usageSchema3 = exports_external.object({
|
|
84942
|
+
prompt_tokens: exports_external.number(),
|
|
84943
|
+
completion_tokens: exports_external.number(),
|
|
84944
|
+
total_tokens: exports_external.number()
|
|
84945
|
+
});
|
|
84946
|
+
openaiCompatibleCompletionResponseSchema = exports_external.object({
|
|
84947
|
+
id: exports_external.string().nullish(),
|
|
84948
|
+
created: exports_external.number().nullish(),
|
|
84949
|
+
model: exports_external.string().nullish(),
|
|
84950
|
+
choices: exports_external.array(exports_external.object({
|
|
84951
|
+
text: exports_external.string(),
|
|
84952
|
+
finish_reason: exports_external.string()
|
|
84953
|
+
})),
|
|
84954
|
+
usage: usageSchema3.nullish()
|
|
84955
|
+
});
|
|
84956
|
+
openaiCompatibleEmbeddingProviderOptions = exports_external.object({
|
|
84957
|
+
dimensions: exports_external.number().optional(),
|
|
84958
|
+
user: exports_external.string().optional()
|
|
84959
|
+
});
|
|
84960
|
+
openaiTextEmbeddingResponseSchema2 = exports_external.object({
|
|
84961
|
+
data: exports_external.array(exports_external.object({ embedding: exports_external.array(exports_external.number()) })),
|
|
84962
|
+
usage: exports_external.object({ prompt_tokens: exports_external.number() }).nullish(),
|
|
84963
|
+
providerMetadata: exports_external.record(exports_external.string(), exports_external.record(exports_external.string(), exports_external.any())).optional()
|
|
84964
|
+
});
|
|
84965
|
+
openaiCompatibleImageResponseSchema = exports_external.object({
|
|
84966
|
+
data: exports_external.array(exports_external.object({ b64_json: exports_external.string() }))
|
|
84967
|
+
});
|
|
84968
|
+
});
|
|
84969
|
+
|
|
83639
84970
|
// ../../node_modules/@openrouter/ai-sdk-provider/dist/index.mjs
|
|
83640
84971
|
function getErrorMessage3(error48) {
|
|
83641
84972
|
if (error48 == null) {
|
|
@@ -84381,7 +85712,7 @@ function createOpenRouter(options = {}) {
|
|
|
84381
85712
|
})}`
|
|
84382
85713
|
}, options.headers), options.api_keys && Object.keys(options.api_keys).length > 0 && {
|
|
84383
85714
|
"X-Provider-API-Keys": JSON.stringify(options.api_keys)
|
|
84384
|
-
}), `ai-sdk/openrouter/${
|
|
85715
|
+
}), `ai-sdk/openrouter/${VERSION10}`);
|
|
84385
85716
|
const createChatModel = (modelId, settings = {}) => new OpenRouterChatLanguageModel(modelId, settings, {
|
|
84386
85717
|
provider: "openrouter.chat",
|
|
84387
85718
|
url: ({ path }) => `${baseURL}${path}`,
|
|
@@ -85589,8 +86920,8 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
85589
86920
|
}
|
|
85590
86921
|
};
|
|
85591
86922
|
}
|
|
85592
|
-
},
|
|
85593
|
-
var
|
|
86923
|
+
}, VERSION10 = "1.5.4", openrouter;
|
|
86924
|
+
var init_dist24 = __esm(() => {
|
|
85594
86925
|
init_v4();
|
|
85595
86926
|
init_v4();
|
|
85596
86927
|
init_v4();
|
|
@@ -85819,10 +87150,10 @@ Error message: ${getErrorMessage3(cause)}`,
|
|
|
85819
87150
|
};
|
|
85820
87151
|
EventSourceParserStream2 = class extends TransformStream {
|
|
85821
87152
|
constructor({ onError, onRetry, onComment } = {}) {
|
|
85822
|
-
let
|
|
87153
|
+
let parser2;
|
|
85823
87154
|
super({
|
|
85824
87155
|
start(controller) {
|
|
85825
|
-
|
|
87156
|
+
parser2 = createParser2({
|
|
85826
87157
|
onEvent: (event) => {
|
|
85827
87158
|
controller.enqueue(event);
|
|
85828
87159
|
},
|
|
@@ -85834,7 +87165,7 @@ Error message: ${getErrorMessage3(cause)}`,
|
|
|
85834
87165
|
});
|
|
85835
87166
|
},
|
|
85836
87167
|
transform(chunk) {
|
|
85837
|
-
|
|
87168
|
+
parser2.feed(chunk);
|
|
85838
87169
|
}
|
|
85839
87170
|
});
|
|
85840
87171
|
}
|
|
@@ -86297,7 +87628,7 @@ function mapOllamaFinishReason(finishReason) {
|
|
|
86297
87628
|
return "unknown";
|
|
86298
87629
|
}
|
|
86299
87630
|
}
|
|
86300
|
-
function
|
|
87631
|
+
function getResponseMetadata4({
|
|
86301
87632
|
model,
|
|
86302
87633
|
created_at
|
|
86303
87634
|
}) {
|
|
@@ -86804,7 +88135,7 @@ var ollamaErrorDataSchema, ollamaFailedResponseHandler, ollamaCompletionProvider
|
|
|
86804
88135
|
finishReason: mapOllamaFinishReason("stop"),
|
|
86805
88136
|
request: { body: JSON.stringify(body) },
|
|
86806
88137
|
response: {
|
|
86807
|
-
...
|
|
88138
|
+
...getResponseMetadata4(response),
|
|
86808
88139
|
headers: responseHeaders,
|
|
86809
88140
|
body: rawResponse
|
|
86810
88141
|
},
|
|
@@ -86856,7 +88187,7 @@ var ollamaErrorDataSchema, ollamaFailedResponseHandler, ollamaCompletionProvider
|
|
|
86856
88187
|
isFirstChunk = false;
|
|
86857
88188
|
controller.enqueue({
|
|
86858
88189
|
type: "response-metadata",
|
|
86859
|
-
...
|
|
88190
|
+
...getResponseMetadata4(value)
|
|
86860
88191
|
});
|
|
86861
88192
|
}
|
|
86862
88193
|
if (value.done) {
|
|
@@ -87181,7 +88512,7 @@ var ollamaErrorDataSchema, ollamaFailedResponseHandler, ollamaCompletionProvider
|
|
|
87181
88512
|
this.state.isFirstChunk = false;
|
|
87182
88513
|
controller.enqueue({
|
|
87183
88514
|
type: "response-metadata",
|
|
87184
|
-
...
|
|
88515
|
+
...getResponseMetadata4(value)
|
|
87185
88516
|
});
|
|
87186
88517
|
}
|
|
87187
88518
|
if (value.done) {
|
|
@@ -87372,26 +88703,26 @@ var ollamaErrorDataSchema, ollamaFailedResponseHandler, ollamaCompletionProvider
|
|
|
87372
88703
|
});
|
|
87373
88704
|
}
|
|
87374
88705
|
}, ollama;
|
|
87375
|
-
var
|
|
87376
|
-
|
|
87377
|
-
|
|
87378
|
-
|
|
88706
|
+
var init_dist25 = __esm(() => {
|
|
88707
|
+
init_dist2();
|
|
88708
|
+
init_dist5();
|
|
88709
|
+
init_dist5();
|
|
87379
88710
|
init_v4();
|
|
87380
88711
|
init_v4();
|
|
87381
|
-
|
|
87382
|
-
|
|
87383
|
-
|
|
87384
|
-
|
|
88712
|
+
init_dist5();
|
|
88713
|
+
init_dist2();
|
|
88714
|
+
init_dist2();
|
|
88715
|
+
init_dist5();
|
|
87385
88716
|
init_v4();
|
|
87386
|
-
|
|
87387
|
-
|
|
87388
|
-
|
|
87389
|
-
|
|
88717
|
+
init_dist5();
|
|
88718
|
+
init_dist5();
|
|
88719
|
+
init_dist2();
|
|
88720
|
+
init_dist2();
|
|
87390
88721
|
init_v4();
|
|
87391
|
-
|
|
88722
|
+
init_dist5();
|
|
87392
88723
|
init_v4();
|
|
87393
|
-
|
|
87394
|
-
|
|
88724
|
+
init_dist2();
|
|
88725
|
+
init_dist5();
|
|
87395
88726
|
ollamaErrorDataSchema = exports_external.object({
|
|
87396
88727
|
error: exports_external.object({
|
|
87397
88728
|
message: exports_external.string(),
|
|
@@ -87677,6 +89008,18 @@ var AiProvider, getModel = (config4, debugLogging = false) => {
|
|
|
87677
89008
|
});
|
|
87678
89009
|
return openai2(config4.model);
|
|
87679
89010
|
}
|
|
89011
|
+
case "openai-compatible" /* OpenAICompatible */: {
|
|
89012
|
+
if (!config4.baseUrl) {
|
|
89013
|
+
throw new Error("OpenAI-compatible providers require a baseUrl");
|
|
89014
|
+
}
|
|
89015
|
+
const openaiCompatible = createOpenAICompatible({
|
|
89016
|
+
apiKey: config4.apiKey,
|
|
89017
|
+
baseURL: config4.baseUrl,
|
|
89018
|
+
name: config4.name || "OpenAI Compatible",
|
|
89019
|
+
fetch: fetchOverride
|
|
89020
|
+
});
|
|
89021
|
+
return openaiCompatible(config4.model);
|
|
89022
|
+
}
|
|
87680
89023
|
case "google-vertex" /* GoogleVertex */: {
|
|
87681
89024
|
const vertex2 = createVertex2({
|
|
87682
89025
|
fetch: fetchOverride,
|
|
@@ -87698,13 +89041,14 @@ var AiProvider, getModel = (config4, debugLogging = false) => {
|
|
|
87698
89041
|
}
|
|
87699
89042
|
};
|
|
87700
89043
|
var init_getModel = __esm(() => {
|
|
87701
|
-
init_dist18();
|
|
87702
89044
|
init_dist19();
|
|
87703
89045
|
init_dist20();
|
|
87704
|
-
init_dist8();
|
|
87705
89046
|
init_dist21();
|
|
89047
|
+
init_dist9();
|
|
87706
89048
|
init_dist22();
|
|
87707
89049
|
init_dist23();
|
|
89050
|
+
init_dist24();
|
|
89051
|
+
init_dist25();
|
|
87708
89052
|
init_env();
|
|
87709
89053
|
((AiProvider2) => {
|
|
87710
89054
|
AiProvider2["Anthropic"] = "anthropic";
|
|
@@ -87712,6 +89056,7 @@ var init_getModel = __esm(() => {
|
|
|
87712
89056
|
AiProvider2["DeepSeek"] = "deepseek";
|
|
87713
89057
|
AiProvider2["OpenRouter"] = "openrouter";
|
|
87714
89058
|
AiProvider2["OpenAI"] = "openai";
|
|
89059
|
+
AiProvider2["OpenAICompatible"] = "openai-compatible";
|
|
87715
89060
|
AiProvider2["GoogleVertex"] = "google-vertex";
|
|
87716
89061
|
AiProvider2["Google"] = "google";
|
|
87717
89062
|
})(AiProvider ||= {});
|
|
@@ -87741,7 +89086,7 @@ class ApiProviderConfig {
|
|
|
87741
89086
|
if (!finalProvider) {
|
|
87742
89087
|
return;
|
|
87743
89088
|
}
|
|
87744
|
-
const { apiKey, defaultModel, defaultParameters, location, project, keyFile, baseUrl } = this.providers[finalProvider] ?? {};
|
|
89089
|
+
const { apiKey, defaultModel, defaultParameters, location, project, keyFile, baseUrl, name: name18 } = this.providers[finalProvider] ?? {};
|
|
87745
89090
|
const finalModel = model ?? defaultModel ?? defaultModels[finalProvider];
|
|
87746
89091
|
const finalParameters = {
|
|
87747
89092
|
...this.defaultParameters,
|
|
@@ -87756,6 +89101,7 @@ class ApiProviderConfig {
|
|
|
87756
89101
|
project,
|
|
87757
89102
|
keyFile,
|
|
87758
89103
|
baseUrl,
|
|
89104
|
+
name: name18,
|
|
87759
89105
|
parameters: finalParameters,
|
|
87760
89106
|
budget,
|
|
87761
89107
|
rules
|
|
@@ -87771,6 +89117,7 @@ var init_ApiProviderConfig = __esm(() => {
|
|
|
87771
89117
|
["deepseek" /* DeepSeek */]: "deepseek-chat",
|
|
87772
89118
|
["openrouter" /* OpenRouter */]: "google/gemini-2.5-pro",
|
|
87773
89119
|
["openai" /* OpenAI */]: "gpt-5-2025-08-07",
|
|
89120
|
+
["openai-compatible" /* OpenAICompatible */]: "gpt-4o",
|
|
87774
89121
|
["google-vertex" /* GoogleVertex */]: "gemini-2.5-pro",
|
|
87775
89122
|
["google" /* Google */]: "gemini-2.5-pro"
|
|
87776
89123
|
};
|
|
@@ -89173,18 +90520,46 @@ function quoteForShell(str) {
|
|
|
89173
90520
|
}
|
|
89174
90521
|
|
|
89175
90522
|
// src/workflows/git-file-tools.ts
|
|
90523
|
+
function getMediaType2(path2) {
|
|
90524
|
+
const lastDotIndex = path2.lastIndexOf(".");
|
|
90525
|
+
const ext = lastDotIndex > 0 && lastDotIndex < path2.length - 1 ? path2.slice(lastDotIndex + 1).toLowerCase() : undefined;
|
|
90526
|
+
const mediaTypes = {
|
|
90527
|
+
png: "image/png",
|
|
90528
|
+
jpg: "image/jpeg",
|
|
90529
|
+
jpeg: "image/jpeg",
|
|
90530
|
+
gif: "image/gif",
|
|
90531
|
+
svg: "image/svg+xml",
|
|
90532
|
+
webp: "image/webp",
|
|
90533
|
+
ico: "image/x-icon",
|
|
90534
|
+
bmp: "image/bmp",
|
|
90535
|
+
woff: "font/woff",
|
|
90536
|
+
woff2: "font/woff2",
|
|
90537
|
+
ttf: "font/ttf",
|
|
90538
|
+
otf: "font/otf",
|
|
90539
|
+
eot: "application/vnd.ms-fontobject",
|
|
90540
|
+
pdf: "application/pdf",
|
|
90541
|
+
mp3: "audio/mpeg",
|
|
90542
|
+
wav: "audio/wav",
|
|
90543
|
+
ogg: "audio/ogg",
|
|
90544
|
+
mp4: "video/mp4",
|
|
90545
|
+
webm: "video/webm",
|
|
90546
|
+
avi: "video/x-msvideo"
|
|
90547
|
+
};
|
|
90548
|
+
return mediaTypes[ext || ""] || "application/octet-stream";
|
|
90549
|
+
}
|
|
89176
90550
|
function extractTargetCommit(range, pr2) {
|
|
89177
90551
|
if (pr2) {
|
|
89178
90552
|
return null;
|
|
89179
90553
|
}
|
|
89180
|
-
if (!range) {
|
|
90554
|
+
if (!range || range.trim() === "") {
|
|
89181
90555
|
return null;
|
|
89182
90556
|
}
|
|
89183
90557
|
const parts = range.split(/\.\.\.?/);
|
|
89184
90558
|
if (parts.length > 1) {
|
|
89185
90559
|
return parts[1].trim() || null;
|
|
89186
90560
|
}
|
|
89187
|
-
|
|
90561
|
+
const trimmed = range.trim();
|
|
90562
|
+
return trimmed || null;
|
|
89188
90563
|
}
|
|
89189
90564
|
function createGitReadFile(commit2) {
|
|
89190
90565
|
const toolInfo20 = {
|
|
@@ -89341,7 +90716,8 @@ function createGitReadBinaryFile(commit2) {
|
|
|
89341
90716
|
{
|
|
89342
90717
|
type: "media",
|
|
89343
90718
|
url: url2,
|
|
89344
|
-
data: base64Data
|
|
90719
|
+
data: base64Data,
|
|
90720
|
+
mediaType: getMediaType2(url2)
|
|
89345
90721
|
}
|
|
89346
90722
|
]
|
|
89347
90723
|
}
|
|
@@ -89468,6 +90844,12 @@ var reviewWorkflow = async (input, context) => {
|
|
|
89468
90844
|
});
|
|
89469
90845
|
const changedFiles = filterAndWarn(allChangedFiles, `PR #${pr2}`);
|
|
89470
90846
|
printChangedFiles(logger, changedFiles);
|
|
90847
|
+
if (changedFiles.length === 0) {
|
|
90848
|
+
return {
|
|
90849
|
+
overview: normalizedFiles ? `No changes to review. The specified file(s) were not found in PR #${pr2}: ${normalizedFiles.join(", ")}` : `No changes to review in PR #${pr2}.`,
|
|
90850
|
+
specificReviews: []
|
|
90851
|
+
};
|
|
90852
|
+
}
|
|
89471
90853
|
changeInfo = {
|
|
89472
90854
|
commitRange: prCommitRange,
|
|
89473
90855
|
pullRequestTitle: prDetails.title,
|
|
@@ -89506,6 +90888,12 @@ var reviewWorkflow = async (input, context) => {
|
|
|
89506
90888
|
});
|
|
89507
90889
|
const rangeChangedFiles = filterAndWarn(allRangeChangedFiles, `range '${range}'`);
|
|
89508
90890
|
printChangedFiles(logger, rangeChangedFiles);
|
|
90891
|
+
if (rangeChangedFiles.length === 0) {
|
|
90892
|
+
return {
|
|
90893
|
+
overview: normalizedFiles ? `No changes to review. The specified file(s) were not found in range '${range}': ${normalizedFiles.join(", ")}` : `No changes to review in range '${range}'.`,
|
|
90894
|
+
specificReviews: []
|
|
90895
|
+
};
|
|
90896
|
+
}
|
|
89509
90897
|
const logResult = await tools3.executeCommand({
|
|
89510
90898
|
command: "git",
|
|
89511
90899
|
args: ["log", "--format=%B", range]
|
|
@@ -89563,6 +90951,12 @@ var reviewWorkflow = async (input, context) => {
|
|
|
89563
90951
|
}
|
|
89564
90952
|
const changedFiles = filterAndWarn(allChangedFiles, "local changes");
|
|
89565
90953
|
printChangedFiles(logger, changedFiles);
|
|
90954
|
+
if (changedFiles.length === 0) {
|
|
90955
|
+
return {
|
|
90956
|
+
overview: normalizedFiles ? `No changes to review. The specified file(s) were not found in local changes: ${normalizedFiles.join(", ")}` : "No changes to review.",
|
|
90957
|
+
specificReviews: []
|
|
90958
|
+
};
|
|
90959
|
+
}
|
|
89566
90960
|
changeInfo = {
|
|
89567
90961
|
staged: hasStagedChanges,
|
|
89568
90962
|
changedFiles,
|
|
@@ -89618,6 +91012,12 @@ var reviewWorkflow = async (input, context) => {
|
|
|
89618
91012
|
});
|
|
89619
91013
|
const branchChangedFiles = filterAndWarn(allBranchChangedFiles, "branch changes");
|
|
89620
91014
|
printChangedFiles(logger, branchChangedFiles);
|
|
91015
|
+
if (branchChangedFiles.length === 0) {
|
|
91016
|
+
return {
|
|
91017
|
+
overview: normalizedFiles ? `No changes to review. The specified file(s) were not found in branch changes: ${normalizedFiles.join(", ")}` : `No changes to review. The current branch has no differences from ${defaultBranch}.`,
|
|
91018
|
+
specificReviews: []
|
|
91019
|
+
};
|
|
91020
|
+
}
|
|
89621
91021
|
changeInfo = {
|
|
89622
91022
|
commitRange: branchCommitRange,
|
|
89623
91023
|
changedFiles: branchChangedFiles,
|
|
@@ -89628,6 +91028,9 @@ var reviewWorkflow = async (input, context) => {
|
|
|
89628
91028
|
if (!changeInfo) {
|
|
89629
91029
|
return { overview: "No changes to review.", specificReviews: [] };
|
|
89630
91030
|
}
|
|
91031
|
+
if (!changeInfo?.changedFiles || changeInfo.changedFiles.length === 0) {
|
|
91032
|
+
return { overview: "No changes to review.", specificReviews: [] };
|
|
91033
|
+
}
|
|
89631
91034
|
const targetCommit = extractTargetCommit(range, pr2);
|
|
89632
91035
|
const isReviewingCommit = targetCommit !== null;
|
|
89633
91036
|
const finalChangeInfo = targetCommit ? { ...changeInfo, targetCommit } : changeInfo;
|
|
@@ -89684,7 +91087,7 @@ var commitWorkflow = async (input, context) => {
|
|
|
89684
91087
|
await step("stage-files", async () => {
|
|
89685
91088
|
const result2 = await tools3.executeCommand({
|
|
89686
91089
|
command: "git",
|
|
89687
|
-
args: ["add", ...input.files]
|
|
91090
|
+
args: ["add", ...input.files ?? []]
|
|
89688
91091
|
});
|
|
89689
91092
|
if (result2.exitCode !== 0) {
|
|
89690
91093
|
throw new Error(`Failed to stage files: ${result2.stderr}`);
|
|
@@ -94994,9 +96397,9 @@ var require_keyword = __commonJS((exports) => {
|
|
|
94994
96397
|
const passSchema = !(("compile" in def) && !$data || def.schema === false);
|
|
94995
96398
|
gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
|
|
94996
96399
|
}
|
|
94997
|
-
function reportErrs(
|
|
96400
|
+
function reportErrs(errors6) {
|
|
94998
96401
|
var _a19;
|
|
94999
|
-
gen.if((0, codegen_1.not)((_a19 = def.valid) !== null && _a19 !== undefined ? _a19 : valid),
|
|
96402
|
+
gen.if((0, codegen_1.not)((_a19 = def.valid) !== null && _a19 !== undefined ? _a19 : valid), errors6);
|
|
95000
96403
|
}
|
|
95001
96404
|
}
|
|
95002
96405
|
exports.funcKeywordCode = funcKeywordCode;
|
|
@@ -95914,9 +97317,9 @@ var require_validation_error = __commonJS((exports) => {
|
|
|
95914
97317
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
95915
97318
|
|
|
95916
97319
|
class ValidationError2 extends Error {
|
|
95917
|
-
constructor(
|
|
97320
|
+
constructor(errors6) {
|
|
95918
97321
|
super("validation failed");
|
|
95919
|
-
this.errors =
|
|
97322
|
+
this.errors = errors6;
|
|
95920
97323
|
this.ajv = this.validation = true;
|
|
95921
97324
|
}
|
|
95922
97325
|
}
|
|
@@ -96611,23 +98014,23 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
96611
98014
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
96612
98015
|
function normalize5(uri, options) {
|
|
96613
98016
|
if (typeof uri === "string") {
|
|
96614
|
-
uri = serialize(
|
|
98017
|
+
uri = serialize(parse6(uri, options), options);
|
|
96615
98018
|
} else if (typeof uri === "object") {
|
|
96616
|
-
uri =
|
|
98019
|
+
uri = parse6(serialize(uri, options), options);
|
|
96617
98020
|
}
|
|
96618
98021
|
return uri;
|
|
96619
98022
|
}
|
|
96620
98023
|
function resolve5(baseURI, relativeURI, options) {
|
|
96621
98024
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
96622
|
-
const resolved = resolveComponent(
|
|
98025
|
+
const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
96623
98026
|
schemelessOptions.skipEscape = true;
|
|
96624
98027
|
return serialize(resolved, schemelessOptions);
|
|
96625
98028
|
}
|
|
96626
98029
|
function resolveComponent(base, relative3, options, skipNormalization) {
|
|
96627
98030
|
const target = {};
|
|
96628
98031
|
if (!skipNormalization) {
|
|
96629
|
-
base =
|
|
96630
|
-
relative3 =
|
|
98032
|
+
base = parse6(serialize(base, options), options);
|
|
98033
|
+
relative3 = parse6(serialize(relative3, options), options);
|
|
96631
98034
|
}
|
|
96632
98035
|
options = options || {};
|
|
96633
98036
|
if (!options.tolerant && relative3.scheme) {
|
|
@@ -96679,13 +98082,13 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
96679
98082
|
function equal(uriA, uriB, options) {
|
|
96680
98083
|
if (typeof uriA === "string") {
|
|
96681
98084
|
uriA = unescape(uriA);
|
|
96682
|
-
uriA = serialize(normalizeComponentEncoding(
|
|
98085
|
+
uriA = serialize(normalizeComponentEncoding(parse6(uriA, options), true), { ...options, skipEscape: true });
|
|
96683
98086
|
} else if (typeof uriA === "object") {
|
|
96684
98087
|
uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
|
|
96685
98088
|
}
|
|
96686
98089
|
if (typeof uriB === "string") {
|
|
96687
98090
|
uriB = unescape(uriB);
|
|
96688
|
-
uriB = serialize(normalizeComponentEncoding(
|
|
98091
|
+
uriB = serialize(normalizeComponentEncoding(parse6(uriB, options), true), { ...options, skipEscape: true });
|
|
96689
98092
|
} else if (typeof uriB === "object") {
|
|
96690
98093
|
uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
|
|
96691
98094
|
}
|
|
@@ -96755,7 +98158,7 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
96755
98158
|
return uriTokens.join("");
|
|
96756
98159
|
}
|
|
96757
98160
|
var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
96758
|
-
function
|
|
98161
|
+
function parse6(uri, opts) {
|
|
96759
98162
|
const options = Object.assign({}, opts);
|
|
96760
98163
|
const parsed = {
|
|
96761
98164
|
scheme: undefined,
|
|
@@ -96849,7 +98252,7 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
96849
98252
|
resolveComponent,
|
|
96850
98253
|
equal,
|
|
96851
98254
|
serialize,
|
|
96852
|
-
parse:
|
|
98255
|
+
parse: parse6
|
|
96853
98256
|
};
|
|
96854
98257
|
module.exports = fastUri;
|
|
96855
98258
|
module.exports.default = fastUri;
|
|
@@ -97239,10 +98642,10 @@ var require_core = __commonJS((exports) => {
|
|
|
97239
98642
|
this.formats[name18] = format;
|
|
97240
98643
|
return this;
|
|
97241
98644
|
}
|
|
97242
|
-
errorsText(
|
|
97243
|
-
if (!
|
|
98645
|
+
errorsText(errors6 = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
98646
|
+
if (!errors6 || errors6.length === 0)
|
|
97244
98647
|
return "No errors";
|
|
97245
|
-
return
|
|
98648
|
+
return errors6.map((e2) => `${dataVar}${e2.instancePath} ${e2.message}`).reduce((text2, msg) => text2 + separator + msg);
|
|
97246
98649
|
}
|
|
97247
98650
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
97248
98651
|
const rules = this.RULES.all;
|
|
@@ -98491,13 +99894,13 @@ var require_additionalProperties = __commonJS((exports) => {
|
|
|
98491
99894
|
}
|
|
98492
99895
|
}
|
|
98493
99896
|
}
|
|
98494
|
-
function applyAdditionalSchema(key, valid,
|
|
99897
|
+
function applyAdditionalSchema(key, valid, errors6) {
|
|
98495
99898
|
const subschema = {
|
|
98496
99899
|
keyword: "additionalProperties",
|
|
98497
99900
|
dataProp: key,
|
|
98498
99901
|
dataPropType: util_1.Type.Str
|
|
98499
99902
|
};
|
|
98500
|
-
if (
|
|
99903
|
+
if (errors6 === false) {
|
|
98501
99904
|
Object.assign(subschema, {
|
|
98502
99905
|
compositeRule: true,
|
|
98503
99906
|
createErrors: false,
|
|
@@ -101349,9 +102752,9 @@ var require_keyword2 = __commonJS((exports) => {
|
|
|
101349
102752
|
const passSchema = !(("compile" in def) && !$data || def.schema === false);
|
|
101350
102753
|
gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
|
|
101351
102754
|
}
|
|
101352
|
-
function reportErrs(
|
|
102755
|
+
function reportErrs(errors6) {
|
|
101353
102756
|
var _a19;
|
|
101354
|
-
gen.if((0, codegen_1.not)((_a19 = def.valid) !== null && _a19 !== undefined ? _a19 : valid),
|
|
102757
|
+
gen.if((0, codegen_1.not)((_a19 = def.valid) !== null && _a19 !== undefined ? _a19 : valid), errors6);
|
|
101355
102758
|
}
|
|
101356
102759
|
}
|
|
101357
102760
|
exports.funcKeywordCode = funcKeywordCode;
|
|
@@ -102144,9 +103547,9 @@ var require_validation_error2 = __commonJS((exports) => {
|
|
|
102144
103547
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
102145
103548
|
|
|
102146
103549
|
class ValidationError2 extends Error {
|
|
102147
|
-
constructor(
|
|
103550
|
+
constructor(errors6) {
|
|
102148
103551
|
super("validation failed");
|
|
102149
|
-
this.errors =
|
|
103552
|
+
this.errors = errors6;
|
|
102150
103553
|
this.ajv = this.validation = true;
|
|
102151
103554
|
}
|
|
102152
103555
|
}
|
|
@@ -102525,7 +103928,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
102525
103928
|
var regexPunycode = /^xn--/;
|
|
102526
103929
|
var regexNonASCII = /[^\0-\x7E]/;
|
|
102527
103930
|
var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
|
|
102528
|
-
var
|
|
103931
|
+
var errors6 = {
|
|
102529
103932
|
overflow: "Overflow: input needs wider integers to process",
|
|
102530
103933
|
"not-basic": "Illegal input >= 0x80 (not a basic code point)",
|
|
102531
103934
|
"invalid-input": "Invalid input"
|
|
@@ -102534,7 +103937,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
102534
103937
|
var floor = Math.floor;
|
|
102535
103938
|
var stringFromCharCode = String.fromCharCode;
|
|
102536
103939
|
function error$1(type) {
|
|
102537
|
-
throw new RangeError(
|
|
103940
|
+
throw new RangeError(errors6[type]);
|
|
102538
103941
|
}
|
|
102539
103942
|
function map3(array3, fn) {
|
|
102540
103943
|
var result = [];
|
|
@@ -102913,7 +104316,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
102913
104316
|
}
|
|
102914
104317
|
var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
|
|
102915
104318
|
var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;
|
|
102916
|
-
function
|
|
104319
|
+
function parse6(uriString) {
|
|
102917
104320
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
102918
104321
|
var components = {};
|
|
102919
104322
|
var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
|
|
@@ -103083,8 +104486,8 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
103083
104486
|
var skipNormalization = arguments[3];
|
|
103084
104487
|
var target = {};
|
|
103085
104488
|
if (!skipNormalization) {
|
|
103086
|
-
base2 =
|
|
103087
|
-
relative3 =
|
|
104489
|
+
base2 = parse6(serialize(base2, options), options);
|
|
104490
|
+
relative3 = parse6(serialize(relative3, options), options);
|
|
103088
104491
|
}
|
|
103089
104492
|
options = options || {};
|
|
103090
104493
|
if (!options.tolerant && relative3.scheme) {
|
|
@@ -103135,24 +104538,24 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
103135
104538
|
}
|
|
103136
104539
|
function resolve5(baseURI, relativeURI, options) {
|
|
103137
104540
|
var schemelessOptions = assign({ scheme: "null" }, options);
|
|
103138
|
-
return serialize(resolveComponents(
|
|
104541
|
+
return serialize(resolveComponents(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
103139
104542
|
}
|
|
103140
104543
|
function normalize5(uri, options) {
|
|
103141
104544
|
if (typeof uri === "string") {
|
|
103142
|
-
uri = serialize(
|
|
104545
|
+
uri = serialize(parse6(uri, options), options);
|
|
103143
104546
|
} else if (typeOf(uri) === "object") {
|
|
103144
|
-
uri =
|
|
104547
|
+
uri = parse6(serialize(uri, options), options);
|
|
103145
104548
|
}
|
|
103146
104549
|
return uri;
|
|
103147
104550
|
}
|
|
103148
104551
|
function equal(uriA, uriB, options) {
|
|
103149
104552
|
if (typeof uriA === "string") {
|
|
103150
|
-
uriA = serialize(
|
|
104553
|
+
uriA = serialize(parse6(uriA, options), options);
|
|
103151
104554
|
} else if (typeOf(uriA) === "object") {
|
|
103152
104555
|
uriA = serialize(uriA, options);
|
|
103153
104556
|
}
|
|
103154
104557
|
if (typeof uriB === "string") {
|
|
103155
|
-
uriB = serialize(
|
|
104558
|
+
uriB = serialize(parse6(uriB, options), options);
|
|
103156
104559
|
} else if (typeOf(uriB) === "object") {
|
|
103157
104560
|
uriB = serialize(uriB, options);
|
|
103158
104561
|
}
|
|
@@ -103397,7 +104800,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
103397
104800
|
exports2.SCHEMES = SCHEMES;
|
|
103398
104801
|
exports2.pctEncChar = pctEncChar;
|
|
103399
104802
|
exports2.pctDecChars = pctDecChars;
|
|
103400
|
-
exports2.parse =
|
|
104803
|
+
exports2.parse = parse6;
|
|
103401
104804
|
exports2.removeDotSegments = removeDotSegments;
|
|
103402
104805
|
exports2.serialize = serialize;
|
|
103403
104806
|
exports2.resolveComponents = resolveComponents;
|
|
@@ -103793,10 +105196,10 @@ var require_core3 = __commonJS((exports) => {
|
|
|
103793
105196
|
this.formats[name18] = format;
|
|
103794
105197
|
return this;
|
|
103795
105198
|
}
|
|
103796
|
-
errorsText(
|
|
103797
|
-
if (!
|
|
105199
|
+
errorsText(errors6 = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
105200
|
+
if (!errors6 || errors6.length === 0)
|
|
103798
105201
|
return "No errors";
|
|
103799
|
-
return
|
|
105202
|
+
return errors6.map((e2) => `${dataVar}${e2.instancePath} ${e2.message}`).reduce((text2, msg) => text2 + separator + msg);
|
|
103800
105203
|
}
|
|
103801
105204
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
103802
105205
|
const rules = this.RULES.all;
|
|
@@ -105045,13 +106448,13 @@ var require_additionalProperties2 = __commonJS((exports) => {
|
|
|
105045
106448
|
}
|
|
105046
106449
|
}
|
|
105047
106450
|
}
|
|
105048
|
-
function applyAdditionalSchema(key, valid,
|
|
106451
|
+
function applyAdditionalSchema(key, valid, errors6) {
|
|
105049
106452
|
const subschema = {
|
|
105050
106453
|
keyword: "additionalProperties",
|
|
105051
106454
|
dataProp: key,
|
|
105052
106455
|
dataPropType: util_1.Type.Str
|
|
105053
106456
|
};
|
|
105054
|
-
if (
|
|
106457
|
+
if (errors6 === false) {
|
|
105055
106458
|
Object.assign(subschema, {
|
|
105056
106459
|
compositeRule: true,
|
|
105057
106460
|
createErrors: false,
|
|
@@ -105972,7 +107375,7 @@ var require_limit = __commonJS((exports) => {
|
|
|
105972
107375
|
});
|
|
105973
107376
|
|
|
105974
107377
|
// ../../node_modules/ajv-formats/dist/index.js
|
|
105975
|
-
var
|
|
107378
|
+
var require_dist4 = __commonJS((exports, module) => {
|
|
105976
107379
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105977
107380
|
var formats_1 = require_formats();
|
|
105978
107381
|
var limit_1 = require_limit();
|
|
@@ -106050,7 +107453,7 @@ class AjvJsonSchemaValidator {
|
|
|
106050
107453
|
var import_ajv, import_ajv_formats;
|
|
106051
107454
|
var init_ajv_provider = __esm(() => {
|
|
106052
107455
|
import_ajv = __toESM(require_ajv(), 1);
|
|
106053
|
-
import_ajv_formats = __toESM(
|
|
107456
|
+
import_ajv_formats = __toESM(require_dist4(), 1);
|
|
106054
107457
|
});
|
|
106055
107458
|
|
|
106056
107459
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
|
|
@@ -106992,7 +108395,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
106992
108395
|
}
|
|
106993
108396
|
return parsed;
|
|
106994
108397
|
}
|
|
106995
|
-
function
|
|
108398
|
+
function parse6(command, args, options) {
|
|
106996
108399
|
if (args && !Array.isArray(args)) {
|
|
106997
108400
|
options = args;
|
|
106998
108401
|
args = null;
|
|
@@ -107011,7 +108414,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
107011
108414
|
};
|
|
107012
108415
|
return options.shell ? parsed : parseNonShell(parsed);
|
|
107013
108416
|
}
|
|
107014
|
-
module.exports =
|
|
108417
|
+
module.exports = parse6;
|
|
107015
108418
|
});
|
|
107016
108419
|
|
|
107017
108420
|
// ../../node_modules/cross-spawn/lib/enoent.js
|
|
@@ -107064,16 +108467,16 @@ var require_enoent = __commonJS((exports, module) => {
|
|
|
107064
108467
|
// ../../node_modules/cross-spawn/index.js
|
|
107065
108468
|
var require_cross_spawn = __commonJS((exports, module) => {
|
|
107066
108469
|
var cp = __require("child_process");
|
|
107067
|
-
var
|
|
108470
|
+
var parse6 = require_parse2();
|
|
107068
108471
|
var enoent = require_enoent();
|
|
107069
108472
|
function spawn3(command, args, options) {
|
|
107070
|
-
const parsed =
|
|
108473
|
+
const parsed = parse6(command, args, options);
|
|
107071
108474
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
107072
108475
|
enoent.hookChildProcess(spawned, parsed);
|
|
107073
108476
|
return spawned;
|
|
107074
108477
|
}
|
|
107075
108478
|
function spawnSync2(command, args, options) {
|
|
107076
|
-
const parsed =
|
|
108479
|
+
const parsed = parse6(command, args, options);
|
|
107077
108480
|
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
107078
108481
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
107079
108482
|
return result;
|
|
@@ -107081,7 +108484,7 @@ var require_cross_spawn = __commonJS((exports, module) => {
|
|
|
107081
108484
|
module.exports = spawn3;
|
|
107082
108485
|
module.exports.spawn = spawn3;
|
|
107083
108486
|
module.exports.sync = spawnSync2;
|
|
107084
|
-
module.exports._parse =
|
|
108487
|
+
module.exports._parse = parse6;
|
|
107085
108488
|
module.exports._enoent = enoent;
|
|
107086
108489
|
});
|
|
107087
108490
|
|
|
@@ -107424,9 +108827,10 @@ var {
|
|
|
107424
108827
|
Help
|
|
107425
108828
|
} = import__.default;
|
|
107426
108829
|
// package.json
|
|
107427
|
-
var version = "0.9.
|
|
108830
|
+
var version = "0.9.88";
|
|
107428
108831
|
|
|
107429
108832
|
// src/commands/agent.ts
|
|
108833
|
+
init_src();
|
|
107430
108834
|
import { exec as exec3 } from "node:child_process";
|
|
107431
108835
|
import { randomUUID } from "node:crypto";
|
|
107432
108836
|
import * as fs12 from "node:fs/promises";
|
|
@@ -107670,8 +109074,8 @@ class TaskExecutionError extends AgentError {
|
|
|
107670
109074
|
|
|
107671
109075
|
class WorkflowInvocationError extends AgentError {
|
|
107672
109076
|
originalError;
|
|
107673
|
-
constructor(
|
|
107674
|
-
const details = { workflow, originalError: originalError?.message };
|
|
109077
|
+
constructor(workflow2, message, originalError) {
|
|
109078
|
+
const details = { workflow: workflow2, originalError: originalError?.message };
|
|
107675
109079
|
const suggestions = {
|
|
107676
109080
|
suggestions: [
|
|
107677
109081
|
`Verify the workflow name is correct`,
|
|
@@ -107685,10 +109089,10 @@ class WorkflowInvocationError extends AgentError {
|
|
|
107685
109089
|
`Review workflow input/output format`,
|
|
107686
109090
|
`Test the workflow manually using the CLI`
|
|
107687
109091
|
],
|
|
107688
|
-
files: ["packages/cli/src/agent/workflow-adapter.ts", `packages/cli/src/workflows/${
|
|
109092
|
+
files: ["packages/cli/src/agent/workflow-adapter.ts", `packages/cli/src/workflows/${workflow2}.workflow.ts`],
|
|
107689
109093
|
docs: ["Workflows: packages/cli/src/agent/ARCHITECTURE.md#workflow-adapter"]
|
|
107690
109094
|
};
|
|
107691
|
-
super(`Workflow ${
|
|
109095
|
+
super(`Workflow ${workflow2} failed: ${message}`, "WORKFLOW_INVOCATION_FAILED", details, suggestions);
|
|
107692
109096
|
this.originalError = originalError;
|
|
107693
109097
|
this.name = "WorkflowInvocationError";
|
|
107694
109098
|
}
|
|
@@ -107830,29 +109234,29 @@ var AgentConfigSchema = exports_external.object({
|
|
|
107830
109234
|
interval: exports_external.number().int().positive().default(60000)
|
|
107831
109235
|
}).optional()
|
|
107832
109236
|
});
|
|
107833
|
-
function validateConfig(
|
|
109237
|
+
function validateConfig(config3) {
|
|
107834
109238
|
try {
|
|
107835
|
-
return AgentConfigSchema.parse(
|
|
109239
|
+
return AgentConfigSchema.parse(config3);
|
|
107836
109240
|
} catch (error48) {
|
|
107837
109241
|
if (error48 instanceof exports_external.ZodError) {
|
|
107838
|
-
const
|
|
107839
|
-
throw new ConfigValidationError("Configuration validation failed",
|
|
109242
|
+
const errors5 = error48.issues.map((e) => `${e.path.join(".")}: ${e.message}`);
|
|
109243
|
+
throw new ConfigValidationError("Configuration validation failed", errors5);
|
|
107840
109244
|
}
|
|
107841
109245
|
throw error48;
|
|
107842
109246
|
}
|
|
107843
109247
|
}
|
|
107844
109248
|
async function loadConfig(cliOptions, configPath) {
|
|
107845
|
-
let
|
|
109249
|
+
let config3 = { ...DEFAULT_AGENT_CONFIG };
|
|
107846
109250
|
if (cliOptions.preset && CONFIG_PRESETS[cliOptions.preset]) {
|
|
107847
|
-
|
|
107848
|
-
|
|
109251
|
+
config3 = mergeConfig(config3, CONFIG_PRESETS[cliOptions.preset]);
|
|
109252
|
+
config3.preset = cliOptions.preset;
|
|
107849
109253
|
}
|
|
107850
109254
|
if (configPath) {
|
|
107851
109255
|
const fileConfig = await loadConfigFromFile(configPath);
|
|
107852
|
-
|
|
109256
|
+
config3 = mergeConfig(config3, fileConfig);
|
|
107853
109257
|
}
|
|
107854
|
-
|
|
107855
|
-
return validateConfig(
|
|
109258
|
+
config3 = mergeConfig(config3, cliOptions);
|
|
109259
|
+
return validateConfig(config3);
|
|
107856
109260
|
}
|
|
107857
109261
|
function mergeConfig(base, override) {
|
|
107858
109262
|
return {
|
|
@@ -107878,8 +109282,8 @@ function mergeConfig(base, override) {
|
|
|
107878
109282
|
}
|
|
107879
109283
|
async function loadConfigFromFile(configPath) {
|
|
107880
109284
|
try {
|
|
107881
|
-
const
|
|
107882
|
-
const content = await
|
|
109285
|
+
const fs2 = await import("node:fs/promises");
|
|
109286
|
+
const content = await fs2.readFile(configPath, "utf-8");
|
|
107883
109287
|
return JSON.parse(content);
|
|
107884
109288
|
} catch (error48) {
|
|
107885
109289
|
if (error48.code === "ENOENT") {
|
|
@@ -107961,21 +109365,21 @@ function encodeRandom(len, prng) {
|
|
|
107961
109365
|
}
|
|
107962
109366
|
return str;
|
|
107963
109367
|
}
|
|
107964
|
-
function encodeTime(
|
|
107965
|
-
if (isNaN(
|
|
107966
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be a number: ${
|
|
107967
|
-
} else if (
|
|
107968
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${TIME_MAX}: ${
|
|
107969
|
-
} else if (
|
|
107970
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeNegative, `Time must be positive: ${
|
|
107971
|
-
} else if (Number.isInteger(
|
|
107972
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be an integer: ${
|
|
109368
|
+
function encodeTime(now2, len = TIME_LEN) {
|
|
109369
|
+
if (isNaN(now2)) {
|
|
109370
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be a number: ${now2}`);
|
|
109371
|
+
} else if (now2 > TIME_MAX) {
|
|
109372
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${TIME_MAX}: ${now2}`);
|
|
109373
|
+
} else if (now2 < 0) {
|
|
109374
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeNegative, `Time must be positive: ${now2}`);
|
|
109375
|
+
} else if (Number.isInteger(now2) === false) {
|
|
109376
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be an integer: ${now2}`);
|
|
107973
109377
|
}
|
|
107974
109378
|
let mod, str = "";
|
|
107975
109379
|
for (let currentLen = len;currentLen > 0; currentLen--) {
|
|
107976
|
-
mod =
|
|
109380
|
+
mod = now2 % ENCODING_LEN;
|
|
107977
109381
|
str = ENCODING.charAt(mod) + str;
|
|
107978
|
-
|
|
109382
|
+
now2 = (now2 - mod) / ENCODING_LEN;
|
|
107979
109383
|
}
|
|
107980
109384
|
return str;
|
|
107981
109385
|
}
|
|
@@ -108518,6 +109922,15 @@ Return your response as a JSON object following the provided schema.`;
|
|
|
108518
109922
|
}
|
|
108519
109923
|
}
|
|
108520
109924
|
|
|
109925
|
+
// src/agent/planner.constants.ts
|
|
109926
|
+
var PLANNER_CONSTANTS = {
|
|
109927
|
+
MAX_DEPENDENCIES: 5,
|
|
109928
|
+
LONG_TASK_MINUTES: 120,
|
|
109929
|
+
FILE_HEAVY_THRESHOLD: 10,
|
|
109930
|
+
HIGH_PRIORITY: 800,
|
|
109931
|
+
CRITICAL_PRIORITY: 1000
|
|
109932
|
+
};
|
|
109933
|
+
|
|
108521
109934
|
// src/agent/planner.ts
|
|
108522
109935
|
function resolveDependencies(tasks, context) {
|
|
108523
109936
|
const taskMap = new Map(tasks.map((t2) => [t2.id, t2]));
|
|
@@ -108571,23 +109984,23 @@ function createExecutionPhases(tasks, _context) {
|
|
|
108571
109984
|
function identifyRisks(tasks) {
|
|
108572
109985
|
const risks = [];
|
|
108573
109986
|
for (const task of tasks) {
|
|
108574
|
-
if (task.dependencies.length >
|
|
109987
|
+
if (task.dependencies.length > PLANNER_CONSTANTS.MAX_DEPENDENCIES) {
|
|
108575
109988
|
risks.push(`Task "${task.title}" has ${task.dependencies.length} dependencies - could become blocked`);
|
|
108576
109989
|
}
|
|
108577
109990
|
}
|
|
108578
|
-
const longTasks = tasks.filter((t2) => t2.estimatedTime >
|
|
109991
|
+
const longTasks = tasks.filter((t2) => t2.estimatedTime > PLANNER_CONSTANTS.LONG_TASK_MINUTES);
|
|
108579
109992
|
if (longTasks.length > 0) {
|
|
108580
109993
|
risks.push(`${longTasks.length} tasks have long estimated time (>2 hours)`);
|
|
108581
109994
|
}
|
|
108582
|
-
const riskyTasks = tasks.filter((t2) => t2.priority >=
|
|
109995
|
+
const riskyTasks = tasks.filter((t2) => t2.priority >= PLANNER_CONSTANTS.HIGH_PRIORITY && t2.complexity === "high");
|
|
108583
109996
|
if (riskyTasks.length > 0) {
|
|
108584
109997
|
risks.push(`${riskyTasks.length} high-priority, high-complexity tasks`);
|
|
108585
109998
|
}
|
|
108586
|
-
const fileHeavyTasks = tasks.filter((t2) => t2.files.length >
|
|
109999
|
+
const fileHeavyTasks = tasks.filter((t2) => t2.files.length > PLANNER_CONSTANTS.FILE_HEAVY_THRESHOLD);
|
|
108587
110000
|
if (fileHeavyTasks.length > 0) {
|
|
108588
110001
|
risks.push(`${fileHeavyTasks.length} tasks affect >10 files - potential for merge conflicts`);
|
|
108589
110002
|
}
|
|
108590
|
-
const criticalTasks = tasks.filter((t2) => t2.priority ===
|
|
110003
|
+
const criticalTasks = tasks.filter((t2) => t2.priority === PLANNER_CONSTANTS.CRITICAL_PRIORITY);
|
|
108591
110004
|
if (criticalTasks.length > 3) {
|
|
108592
110005
|
risks.push(`${criticalTasks.length} critical-priority tasks - consider prioritizing`);
|
|
108593
110006
|
}
|
|
@@ -110758,8 +112171,8 @@ class TaskHistory {
|
|
|
110758
112171
|
totalTasks: 0
|
|
110759
112172
|
};
|
|
110760
112173
|
}
|
|
110761
|
-
const
|
|
110762
|
-
const avgError =
|
|
112174
|
+
const errors6 = this.history.map((r2) => Math.abs(r2.estimatedTime - r2.actualTime));
|
|
112175
|
+
const avgError = errors6.reduce((sum, e2) => sum + e2, 0) / errors6.length;
|
|
110763
112176
|
const errorPercentages = this.history.map((r2) => Math.abs((r2.estimatedTime - r2.actualTime) / r2.estimatedTime) * 100);
|
|
110764
112177
|
const _avgErrorPercentage = errorPercentages.reduce((sum, e2) => sum + e2, 0) / errorPercentages.length;
|
|
110765
112178
|
return {
|
|
@@ -111559,25 +112972,32 @@ var createLogger = (options) => {
|
|
|
111559
112972
|
};
|
|
111560
112973
|
|
|
111561
112974
|
// src/commands/agent.ts
|
|
112975
|
+
function validateCommandName(command) {
|
|
112976
|
+
const safeCommandPattern = /^[a-zA-Z0-9_\-./:]+$/;
|
|
112977
|
+
if (!safeCommandPattern.test(command)) {
|
|
112978
|
+
throw new Error(`Invalid command: '${command}' contains unsafe characters. ` + `Commands must not contain spaces. If you need to pass arguments, use the 'args' array parameter instead. ` + `Only alphanumeric, hyphen, underscore, slash, dot, and colon are allowed in the command field.`);
|
|
112979
|
+
}
|
|
112980
|
+
}
|
|
111562
112981
|
async function runAgent(goal, options, _command) {
|
|
111563
|
-
|
|
111564
|
-
|
|
111565
|
-
|
|
112982
|
+
const globalOpts = (_command.parent ?? _command).opts();
|
|
112983
|
+
const verbose = typeof globalOpts.verbose === "number" ? globalOpts.verbose : 0;
|
|
112984
|
+
const logger = createLogger({ verbose });
|
|
112985
|
+
logger.info("\uD83E\uDD16 Polka Agent");
|
|
112986
|
+
logger.info("=".repeat(60));
|
|
112987
|
+
const strategy = options.continuous ? "continuous-improvement" : options.strategy ?? "goal-directed";
|
|
112988
|
+
const requireApprovalFor = options.approvalLevel ?? "destructive";
|
|
111566
112989
|
const configOptions = {
|
|
111567
|
-
|
|
111568
|
-
|
|
111569
|
-
approval: {
|
|
111570
|
-
level: options.approvalLevel
|
|
111571
|
-
}
|
|
112990
|
+
strategy,
|
|
112991
|
+
approval: { level: requireApprovalFor, autoApproveSafeTasks: true, maxAutoApprovalCost: 5 }
|
|
111572
112992
|
};
|
|
111573
112993
|
const config4 = await loadConfig(configOptions, options.config);
|
|
111574
|
-
const logger = createLogger({ verbose: options.verbose || 0 });
|
|
111575
112994
|
const workingDir = process.cwd();
|
|
111576
112995
|
const stateDir = path10.join(workingDir, ".polka", "agent-state");
|
|
111577
112996
|
const sessionId = `agent-${Date.now()}-${randomUUID()}`;
|
|
111578
112997
|
const asyncExec = promisify3(exec3);
|
|
111579
112998
|
const tools3 = {
|
|
111580
112999
|
executeCommand: async (input) => {
|
|
113000
|
+
validateCommandName(input.command);
|
|
111581
113001
|
let fullCommand;
|
|
111582
113002
|
if (input.args && input.args.length > 0) {
|
|
111583
113003
|
const quotedArgs = input.args.map(quoteForShell);
|
|
@@ -111590,20 +113010,29 @@ async function runAgent(goal, options, _command) {
|
|
|
111590
113010
|
cwd: workingDir,
|
|
111591
113011
|
maxBuffer: 10 * 1024 * 1024
|
|
111592
113012
|
});
|
|
111593
|
-
return
|
|
113013
|
+
return createSuccessResponse(`Command executed successfully
|
|
113014
|
+
Exit code: 0
|
|
113015
|
+
Stdout:
|
|
113016
|
+
${stdout}
|
|
113017
|
+
${stderr ? `Stderr:
|
|
113018
|
+
${stderr}` : ""}`);
|
|
111594
113019
|
} catch (error48) {
|
|
111595
|
-
|
|
111596
|
-
|
|
111597
|
-
|
|
111598
|
-
|
|
111599
|
-
|
|
111600
|
-
}
|
|
113020
|
+
const errorCode = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : undefined;
|
|
113021
|
+
const errorErrno = error48 && typeof error48 === "object" && "errno" in error48 ? String(error48.errno) : undefined;
|
|
113022
|
+
const errorMessage = error48 instanceof Error ? error48.message : String(error48);
|
|
113023
|
+
if (errorErrno === "ENOBUFS" || errorCode === "ENOBUFS") {
|
|
113024
|
+
const errorStdout2 = error48 && typeof error48 === "object" && "stdout" in error48 ? String(error48.stdout) : "";
|
|
113025
|
+
return createErrorResponse(`Command output exceeded buffer limit (10MB). The command produced too much output. Try using different arguments or redirecting output to a file. Original error: ${errorMessage}
|
|
113026
|
+
Stdout:
|
|
113027
|
+
${errorStdout2}`);
|
|
111601
113028
|
}
|
|
111602
|
-
|
|
111603
|
-
|
|
111604
|
-
|
|
111605
|
-
|
|
111606
|
-
|
|
113029
|
+
const errorStdout = error48 && typeof error48 === "object" && "stdout" in error48 ? String(error48.stdout) : "";
|
|
113030
|
+
const errorStderr = error48 && typeof error48 === "object" && "stderr" in error48 ? String(error48.stderr) : errorMessage;
|
|
113031
|
+
return createErrorResponse(`Command failed with exit code ${errorCode || "1"}
|
|
113032
|
+
${errorStderr ? `Stderr:
|
|
113033
|
+
${errorStderr}` : errorMessage}${errorStdout ? `
|
|
113034
|
+
Stdout:
|
|
113035
|
+
${errorStdout}` : ""}`);
|
|
111607
113036
|
}
|
|
111608
113037
|
},
|
|
111609
113038
|
readFile: async ({ path: filePath }) => {
|
|
@@ -111611,20 +113040,12 @@ async function runAgent(goal, options, _command) {
|
|
|
111611
113040
|
const normalizedPath = path10.normalize(fullPath);
|
|
111612
113041
|
const normalizedWorkingDir = path10.normalize(workingDir);
|
|
111613
113042
|
if (!normalizedPath.startsWith(normalizedWorkingDir + path10.sep) && normalizedPath !== normalizedWorkingDir) {
|
|
111614
|
-
|
|
113043
|
+
return createErrorResponse(`Path "${filePath}" is outside working directory "${workingDir}"`);
|
|
111615
113044
|
}
|
|
111616
113045
|
const content = await fs12.readFile(fullPath, "utf-8");
|
|
111617
|
-
return
|
|
113046
|
+
return createSuccessResponse(content);
|
|
111618
113047
|
}
|
|
111619
113048
|
};
|
|
111620
|
-
const toolsWithGuard = new Proxy(tools3, {
|
|
111621
|
-
get(_target, prop) {
|
|
111622
|
-
if (prop in tools3) {
|
|
111623
|
-
return tools3[prop];
|
|
111624
|
-
}
|
|
111625
|
-
throw new Error(`Tool "${prop}" is not available in agent context. ` + `Available tools: executeCommand, readFile. ` + `See packages/cli/src/commands/agent.ts for details on how to enable full tool support.`);
|
|
111626
|
-
}
|
|
111627
|
-
});
|
|
111628
113049
|
const step = async (_name, optionsOrFn, fn) => {
|
|
111629
113050
|
const actualFn = fn || optionsOrFn;
|
|
111630
113051
|
if (typeof actualFn === "function") {
|
|
@@ -111638,43 +113059,42 @@ async function runAgent(goal, options, _command) {
|
|
|
111638
113059
|
workingDir,
|
|
111639
113060
|
stateDir,
|
|
111640
113061
|
sessionId,
|
|
111641
|
-
tools:
|
|
113062
|
+
tools: tools3,
|
|
111642
113063
|
env: process.env
|
|
111643
113064
|
};
|
|
111644
113065
|
const agent2 = new AutonomousAgent(config4, context);
|
|
111645
113066
|
try {
|
|
111646
113067
|
await agent2.initialize();
|
|
111647
113068
|
if (options.continuous) {
|
|
111648
|
-
|
|
111649
|
-
console.log("");
|
|
113069
|
+
logger.info("\uD83D\uDD04 Mode: Continuous Improvement");
|
|
111650
113070
|
await agent2.runContinuous();
|
|
111651
113071
|
} else {
|
|
111652
113072
|
if (!goal) {
|
|
111653
|
-
|
|
111654
|
-
|
|
111655
|
-
|
|
111656
|
-
|
|
113073
|
+
logger.error("❌ Error: Goal is required for goal-directed mode");
|
|
113074
|
+
logger.error('Usage: bun run agent "your goal here"');
|
|
113075
|
+
logger.error("");
|
|
113076
|
+
logger.error("Or use --continuous for autonomous improvement mode");
|
|
111657
113077
|
await agent2.cleanup();
|
|
111658
|
-
|
|
113078
|
+
return;
|
|
111659
113079
|
}
|
|
111660
|
-
|
|
111661
|
-
console.log("");
|
|
113080
|
+
logger.info(`\uD83D\uDCDD Goal: ${goal}`);
|
|
111662
113081
|
await agent2.setGoal(goal);
|
|
111663
113082
|
await agent2.run();
|
|
111664
113083
|
}
|
|
111665
113084
|
await agent2.cleanup();
|
|
111666
|
-
|
|
111667
|
-
|
|
111668
|
-
|
|
111669
|
-
process.exit(0);
|
|
113085
|
+
logger.info("");
|
|
113086
|
+
logger.info("✅ Agent session complete");
|
|
113087
|
+
logger.info("");
|
|
111670
113088
|
} catch (error48) {
|
|
111671
|
-
|
|
111672
|
-
|
|
111673
|
-
|
|
113089
|
+
const errorMessage = error48 instanceof Error ? error48.message : String(error48);
|
|
113090
|
+
logger.error("");
|
|
113091
|
+
logger.error(`❌ Agent failed: ${errorMessage}`);
|
|
113092
|
+
logger.error("");
|
|
111674
113093
|
try {
|
|
111675
113094
|
await agent2.cleanup();
|
|
111676
|
-
} catch {
|
|
111677
|
-
|
|
113095
|
+
} catch (cleanupError) {
|
|
113096
|
+
logger.warn(`Warning: Error during agent cleanup: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
|
|
113097
|
+
}
|
|
111678
113098
|
}
|
|
111679
113099
|
}
|
|
111680
113100
|
var agentCommand = new Command("agent").description("Run autonomous agent (experimental)").argument("[goal]", "Goal to achieve", "").option("--continuous", "Run in continuous improvement mode").option("--preset <name>", "Configuration preset", "balanced").option("--config <path>", "Configuration file path").option("--approval-level <level>", "Approval level (none|destructive|commits|all)", "destructive").action(runAgent);
|
|
@@ -111746,6 +113166,7 @@ var prices_default = {
|
|
|
111746
113166
|
"gpt-5.1-2025-11-13": { inputPrice: 1.25, outputPrice: 10, cacheWritesPrice: 0, cacheReadsPrice: 0.125, supportsThinking: true },
|
|
111747
113167
|
"gpt-5.1-codex": { inputPrice: 1.25, outputPrice: 10, cacheWritesPrice: 0, cacheReadsPrice: 0.125, supportsThinking: true }
|
|
111748
113168
|
},
|
|
113169
|
+
["openai-compatible" /* OpenAICompatible */]: {},
|
|
111749
113170
|
["google-vertex" /* GoogleVertex */]: googleModelPrices,
|
|
111750
113171
|
["google" /* Google */]: googleModelPrices
|
|
111751
113172
|
};
|
|
@@ -112049,9 +113470,9 @@ async function parseOptions(options, { cwdArg, commandName } = {}, home = os3.ho
|
|
|
112049
113470
|
}
|
|
112050
113471
|
|
|
112051
113472
|
// src/tool-implementations.ts
|
|
112052
|
-
|
|
113473
|
+
init_dist18();
|
|
112053
113474
|
init_src();
|
|
112054
|
-
|
|
113475
|
+
init_dist7();
|
|
112055
113476
|
init_errors5();
|
|
112056
113477
|
init_errors6();
|
|
112057
113478
|
import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
|
|
@@ -112116,7 +113537,7 @@ function applyCacheControl(messages, provider3, modelId) {
|
|
|
112116
113537
|
}
|
|
112117
113538
|
|
|
112118
113539
|
// src/utils/userInput.ts
|
|
112119
|
-
|
|
113540
|
+
init_dist18();
|
|
112120
113541
|
init_src3();
|
|
112121
113542
|
init_source();
|
|
112122
113543
|
init_errors5();
|
|
@@ -112235,7 +113656,13 @@ async function select(input2, context) {
|
|
|
112235
113656
|
async function writeToFile(input2) {
|
|
112236
113657
|
await mkdir7(dirname5(input2.path), { recursive: true });
|
|
112237
113658
|
await fs13.writeFile(input2.path, input2.content);
|
|
112238
|
-
return {
|
|
113659
|
+
return {
|
|
113660
|
+
success: true,
|
|
113661
|
+
message: {
|
|
113662
|
+
type: "text",
|
|
113663
|
+
value: `Successfully wrote to ${input2.path}`
|
|
113664
|
+
}
|
|
113665
|
+
};
|
|
112239
113666
|
}
|
|
112240
113667
|
async function readFile11(input2) {
|
|
112241
113668
|
try {
|
|
@@ -112249,7 +113676,10 @@ async function readFile11(input2) {
|
|
|
112249
113676
|
}
|
|
112250
113677
|
async function executeCommand(input2) {
|
|
112251
113678
|
return new Promise((resolve5, reject) => {
|
|
112252
|
-
const child = input2.shell === true ? spawn4(input2.
|
|
113679
|
+
const child = input2.shell === true ? spawn4(input2.args && input2.args.length > 0 ? `${input2.command} ${input2.args.map(quoteForShell).join(" ")}` : input2.command, {
|
|
113680
|
+
shell: true,
|
|
113681
|
+
stdio: "pipe"
|
|
113682
|
+
}) : spawn4(input2.command, input2.args, {
|
|
112253
113683
|
shell: false,
|
|
112254
113684
|
stdio: "pipe"
|
|
112255
113685
|
});
|
|
@@ -112637,7 +114067,7 @@ async function initializeSkillContext(cwd) {
|
|
|
112637
114067
|
|
|
112638
114068
|
// src/runWorkflow.ts
|
|
112639
114069
|
async function runWorkflow(workflow2, workflowInput, options) {
|
|
112640
|
-
const { commandName, context, logger,
|
|
114070
|
+
const { commandName, context, logger, interactive } = options;
|
|
112641
114071
|
const { providerConfig, config: config4, verbose } = await parseOptions(context, {});
|
|
112642
114072
|
const yes = context.yes;
|
|
112643
114073
|
const additionalTools = {};
|
|
@@ -112645,21 +114075,12 @@ async function runWorkflow(workflow2, workflowInput, options) {
|
|
|
112645
114075
|
additionalTools.search = search_default;
|
|
112646
114076
|
}
|
|
112647
114077
|
const mcpManager = new McpManager(logger);
|
|
114078
|
+
const resolvedInteractive = workflowInput?.interactive ?? interactive ?? yes !== true;
|
|
112648
114079
|
const finalWorkflowInput = {
|
|
112649
114080
|
...workflowInput,
|
|
112650
|
-
interactive:
|
|
114081
|
+
interactive: resolvedInteractive,
|
|
112651
114082
|
additionalTools
|
|
112652
114083
|
};
|
|
112653
|
-
if (requiresProvider) {
|
|
112654
|
-
const commandConfig2 = providerConfig.getConfigForCommand(commandName);
|
|
112655
|
-
if (!commandConfig2 || !commandConfig2.provider || !commandConfig2.model) {
|
|
112656
|
-
const error48 = new Error(`No provider specified for ${commandName}. Please run "polka init" to configure your AI provider.`);
|
|
112657
|
-
logger.error(`Error: ${error48.message}`);
|
|
112658
|
-
throw error48;
|
|
112659
|
-
}
|
|
112660
|
-
logger.info("Provider:", commandConfig2.provider);
|
|
112661
|
-
logger.info("Model:", commandConfig2.model);
|
|
112662
|
-
}
|
|
112663
114084
|
const usage = new UsageMeter(merge_default(prices_default, config4.prices ?? {}), {
|
|
112664
114085
|
maxMessages: config4.maxMessageCount,
|
|
112665
114086
|
maxCost: config4.budget
|
|
@@ -112667,9 +114088,13 @@ async function runWorkflow(workflow2, workflowInput, options) {
|
|
|
112667
114088
|
options.onUsageMeterCreated?.(usage);
|
|
112668
114089
|
const onEvent = printEvent(verbose, usage, process.stderr);
|
|
112669
114090
|
const commandConfig = providerConfig.getConfigForCommand(commandName);
|
|
112670
|
-
if (!commandConfig) {
|
|
112671
|
-
|
|
114091
|
+
if (!commandConfig || !commandConfig.provider || !commandConfig.model) {
|
|
114092
|
+
const error48 = new Error(`No provider configured for command: ${commandName}. Please run "polka init" to configure your AI provider.`);
|
|
114093
|
+
logger.error(`Error: ${error48.message}`);
|
|
114094
|
+
throw error48;
|
|
112672
114095
|
}
|
|
114096
|
+
logger.info("Provider:", commandConfig.provider);
|
|
114097
|
+
logger.info("Model:", commandConfig.model);
|
|
112673
114098
|
const model = getModel(commandConfig);
|
|
112674
114099
|
const excludeFiles = [...config4.excludeFiles ?? []];
|
|
112675
114100
|
const toolProvider = (options.getProvider ?? getProvider)({
|
|
@@ -112708,10 +114133,13 @@ async function runWorkflow(workflow2, workflowInput, options) {
|
|
|
112708
114133
|
};
|
|
112709
114134
|
let workflowContext;
|
|
112710
114135
|
const tools3 = new Proxy({}, {
|
|
112711
|
-
get: (_target,
|
|
114136
|
+
get: (_target, prop) => {
|
|
114137
|
+
if (typeof prop !== "string" || prop === "then" || prop === "toJSON") {
|
|
114138
|
+
return;
|
|
114139
|
+
}
|
|
112712
114140
|
return async (input2) => {
|
|
112713
|
-
logger.debug(`Running tool: ${
|
|
112714
|
-
return await toolCall({ tool:
|
|
114141
|
+
logger.debug(`Running tool: ${prop}`);
|
|
114142
|
+
return await toolCall({ tool: prop, input: input2 }, {
|
|
112715
114143
|
parameters,
|
|
112716
114144
|
model,
|
|
112717
114145
|
agentCallback: onEvent,
|
|
@@ -112840,9 +114268,9 @@ init_fix_workflow();
|
|
|
112840
114268
|
// src/workflows/init.workflow.ts
|
|
112841
114269
|
init_src3();
|
|
112842
114270
|
init_src();
|
|
114271
|
+
init_dist();
|
|
112843
114272
|
init_zod();
|
|
112844
114273
|
init_prompts2();
|
|
112845
|
-
var import_yaml4 = __toESM(require_dist(), 1);
|
|
112846
114274
|
var initWorkflow = async (input2, context) => {
|
|
112847
114275
|
const { step, logger, tools: tools3 } = context;
|
|
112848
114276
|
const { configPath } = input2;
|
|
@@ -112863,7 +114291,7 @@ var initWorkflow = async (input2, context) => {
|
|
|
112863
114291
|
let generatedConfig = {};
|
|
112864
114292
|
if (result.type === "Exit" && result.object) {
|
|
112865
114293
|
const yamlConfig = result.object.yaml;
|
|
112866
|
-
generatedConfig = yamlConfig ?
|
|
114294
|
+
generatedConfig = yamlConfig ? $parse(yamlConfig) : {};
|
|
112867
114295
|
}
|
|
112868
114296
|
await step("save-config", async () => {
|
|
112869
114297
|
const existingConfig = loadConfigAtPath(configPath) ?? {};
|
|
@@ -112871,7 +114299,7 @@ var initWorkflow = async (input2, context) => {
|
|
|
112871
114299
|
...existingConfig,
|
|
112872
114300
|
...generatedConfig
|
|
112873
114301
|
};
|
|
112874
|
-
await tools3.writeToFile({ path: configPath, content:
|
|
114302
|
+
await tools3.writeToFile({ path: configPath, content: $stringify(finalConfig) });
|
|
112875
114303
|
logger.info(`Configuration updated with analysis results at ${configPath}`);
|
|
112876
114304
|
});
|
|
112877
114305
|
return { configPath };
|
|
@@ -113149,8 +114577,27 @@ async function plan3(options = {}) {
|
|
|
113149
114577
|
});
|
|
113150
114578
|
}
|
|
113151
114579
|
|
|
114580
|
+
// src/commands/command.constants.ts
|
|
114581
|
+
var COMMAND_CONSTANTS = {
|
|
114582
|
+
DEFAULT_STDIN_TIMEOUT_MS: 1000,
|
|
114583
|
+
DEFAULT_CONTEXT_LINES: 5,
|
|
114584
|
+
SUMMARY_THRESHOLD: 5000
|
|
114585
|
+
};
|
|
114586
|
+
|
|
114587
|
+
// src/utils/command.ts
|
|
114588
|
+
function getGlobalOptions(command) {
|
|
114589
|
+
return (command.parent ?? command).opts();
|
|
114590
|
+
}
|
|
114591
|
+
function getBaseWorkflowOptions(command) {
|
|
114592
|
+
const globalOpts = getGlobalOptions(command);
|
|
114593
|
+
return {
|
|
114594
|
+
interactive: !globalOpts.yes,
|
|
114595
|
+
...globalOpts
|
|
114596
|
+
};
|
|
114597
|
+
}
|
|
114598
|
+
|
|
113152
114599
|
// src/commands/code.ts
|
|
113153
|
-
var readStdin = async (timeoutMs =
|
|
114600
|
+
var readStdin = async (timeoutMs = COMMAND_CONSTANTS.DEFAULT_STDIN_TIMEOUT_MS) => {
|
|
113154
114601
|
if (process.stdin.isTTY) {
|
|
113155
114602
|
return "";
|
|
113156
114603
|
}
|
|
@@ -113227,51 +114674,49 @@ async function runCode(task2, _options, command) {
|
|
|
113227
114674
|
console.error("No task provided. Aborting.");
|
|
113228
114675
|
return;
|
|
113229
114676
|
}
|
|
113230
|
-
const
|
|
114677
|
+
const workflowOpts = getBaseWorkflowOptions(command);
|
|
113231
114678
|
await code2({
|
|
113232
114679
|
task: taskInput,
|
|
113233
114680
|
files: fileContents,
|
|
113234
|
-
|
|
113235
|
-
...globalOpts
|
|
114681
|
+
...workflowOpts
|
|
113236
114682
|
});
|
|
113237
114683
|
}
|
|
113238
114684
|
var codeCommand = new Command("code").description("Plan and implement a feature or task using architect and coder agents.").argument("[task]", "The task to plan and implement.").action(runCode);
|
|
113239
114685
|
|
|
113240
114686
|
// src/commands/commit.ts
|
|
113241
114687
|
var commitCommand = new Command("commit").description("Create a commit with AI-generated message").option("-a, --all", "Stage all files before committing").argument("[message]", "Optional context for the commit message generation").action(async (message, localOptions, command) => {
|
|
113242
|
-
const
|
|
114688
|
+
const workflowOpts = getBaseWorkflowOptions(command);
|
|
113243
114689
|
await commit3({
|
|
113244
114690
|
all: localOptions.all,
|
|
113245
114691
|
context: message,
|
|
113246
|
-
files:
|
|
113247
|
-
|
|
114692
|
+
files: workflowOpts.file,
|
|
114693
|
+
...workflowOpts
|
|
113248
114694
|
});
|
|
113249
114695
|
});
|
|
113250
114696
|
|
|
113251
114697
|
// src/commands/fix.ts
|
|
113252
114698
|
var fixCommand = new Command("fix").description("Fix issues by running a command and letting an agent fix it.").argument("[command]", "The command to run").option("-p, --prompt <prompt>", "Additional prompt for the agent.").action(async (commandArg, options, cmd) => {
|
|
113253
|
-
const
|
|
114699
|
+
const workflowOpts = getBaseWorkflowOptions(cmd);
|
|
113254
114700
|
await fix3({
|
|
113255
114701
|
command: commandArg,
|
|
113256
114702
|
prompt: options.prompt,
|
|
113257
|
-
|
|
113258
|
-
...globalOpts
|
|
114703
|
+
...workflowOpts
|
|
113259
114704
|
});
|
|
113260
114705
|
});
|
|
113261
114706
|
|
|
113262
114707
|
// src/commands/init.ts
|
|
113263
|
-
|
|
114708
|
+
init_dist18();
|
|
113264
114709
|
init_src3();
|
|
113265
114710
|
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
113266
|
-
import { join as
|
|
114711
|
+
import { join as join14 } from "node:path";
|
|
113267
114712
|
init_lodash();
|
|
113268
|
-
|
|
114713
|
+
init_dist();
|
|
113269
114714
|
|
|
113270
114715
|
// src/builtin-commands.ts
|
|
113271
114716
|
var BUILT_IN_COMMANDS = ["code", "commit", "pr", "review", "fix", "plan", "workflow", "run", "init", "meta", "skills"];
|
|
113272
114717
|
|
|
113273
114718
|
// src/configPrompt.ts
|
|
113274
|
-
|
|
114719
|
+
init_dist18();
|
|
113275
114720
|
init_getModel();
|
|
113276
114721
|
var fetchOllamaModels = async () => {
|
|
113277
114722
|
try {
|
|
@@ -113337,6 +114782,196 @@ async function configPrompt(existingConfig) {
|
|
|
113337
114782
|
return { provider: provider3, model, apiKey, baseURL };
|
|
113338
114783
|
}
|
|
113339
114784
|
|
|
114785
|
+
// src/workflows/init-interactive.workflow.ts
|
|
114786
|
+
init_src3();
|
|
114787
|
+
init_src();
|
|
114788
|
+
init_dist();
|
|
114789
|
+
init_zod();
|
|
114790
|
+
init_prompts2();
|
|
114791
|
+
import { join as join13 } from "node:path";
|
|
114792
|
+
var scriptGenerationSystemPrompt = `Role: Expert TypeScript Developer and Automation Specialist
|
|
114793
|
+
|
|
114794
|
+
Goal: Generate a custom polka script based on user requirements.
|
|
114795
|
+
|
|
114796
|
+
You have access to:
|
|
114797
|
+
- readFile: Read any file in the project
|
|
114798
|
+
- listFiles: Discover project structure
|
|
114799
|
+
- searchFiles: Find specific patterns
|
|
114800
|
+
- askFollowupQuestion: Ask the user for clarification
|
|
114801
|
+
|
|
114802
|
+
Your task:
|
|
114803
|
+
1. Understand the user's automation requirements
|
|
114804
|
+
2. Analyze the project structure to understand the codebase
|
|
114805
|
+
3. Ask clarifying questions if requirements are unclear
|
|
114806
|
+
4. Generate a TypeScript script that combines polka workflows
|
|
114807
|
+
5. Present the plan to the user and confirm before generating
|
|
114808
|
+
|
|
114809
|
+
Script Guidelines:
|
|
114810
|
+
- Use existing polka workflows: code, fix, review, commit, plan
|
|
114811
|
+
- Include proper error handling and logging
|
|
114812
|
+
- Add comments explaining each step
|
|
114813
|
+
- Make scripts configurable via command-line arguments
|
|
114814
|
+
- Export a main() function that accepts args: string[]
|
|
114815
|
+
- Include usage examples in comments
|
|
114816
|
+
|
|
114817
|
+
Available Workflows:
|
|
114818
|
+
- code({ task, interactive }): Implement coding tasks
|
|
114819
|
+
- fix({ task }): Fix bugs and issues
|
|
114820
|
+
- review({ range, pr, files, context }): Review code changes
|
|
114821
|
+
- commit({ message, stageFiles }): Create git commits
|
|
114822
|
+
- plan({ task }): Create implementation plans
|
|
114823
|
+
|
|
114824
|
+
Script Template:
|
|
114825
|
+
\`\`\`typescript
|
|
114826
|
+
// Generated by polka.codes
|
|
114827
|
+
import { code, fix, review, commit } from '@polka-codes/cli'
|
|
114828
|
+
|
|
114829
|
+
export interface ScriptOptions {
|
|
114830
|
+
// Add your options here
|
|
114831
|
+
}
|
|
114832
|
+
|
|
114833
|
+
export async function main(args: string[]) {
|
|
114834
|
+
// Parse arguments if needed
|
|
114835
|
+
// Your automation logic here
|
|
114836
|
+
|
|
114837
|
+
console.log('Script completed successfully')
|
|
114838
|
+
}
|
|
114839
|
+
|
|
114840
|
+
// Only run main if this is the entry point
|
|
114841
|
+
if (import.meta.main) {
|
|
114842
|
+
main(process.argv.slice(2))
|
|
114843
|
+
}
|
|
114844
|
+
\`\`\`
|
|
114845
|
+
|
|
114846
|
+
Response Format:
|
|
114847
|
+
Return a JSON object with:
|
|
114848
|
+
- plan: string describing the script approach
|
|
114849
|
+
- questions: array of questions to ask the user (if needed)
|
|
114850
|
+
- script: the generated TypeScript code
|
|
114851
|
+
- config: any additional configuration needed
|
|
114852
|
+
|
|
114853
|
+
Example response format:
|
|
114854
|
+
\`\`\`json
|
|
114855
|
+
{
|
|
114856
|
+
"plan": "Step-by-step plan for the script",
|
|
114857
|
+
"script": "// Generated TypeScript code"
|
|
114858
|
+
}
|
|
114859
|
+
\`\`\``;
|
|
114860
|
+
var initInteractiveWorkflow = async (input2, context) => {
|
|
114861
|
+
const { step, logger, tools: tools3 } = context;
|
|
114862
|
+
const { configPath, scriptName, scriptInstructions, generateScript = false, skipConfirmation = false } = input2;
|
|
114863
|
+
let generatedConfig = {};
|
|
114864
|
+
let generatedScriptPath;
|
|
114865
|
+
const analyzeResult = await step("analyze-project", async () => {
|
|
114866
|
+
logger.info("Analyzing project structure and configuration...");
|
|
114867
|
+
return await agentWorkflow({
|
|
114868
|
+
systemPrompt: INIT_WORKFLOW_ANALYZE_SYSTEM_PROMPT,
|
|
114869
|
+
userMessage: [
|
|
114870
|
+
{
|
|
114871
|
+
role: "user",
|
|
114872
|
+
content: "Please provide a valid polkacodes YAML configuration for the project."
|
|
114873
|
+
}
|
|
114874
|
+
],
|
|
114875
|
+
tools: [readFile_default, listFiles_default, searchFiles_default],
|
|
114876
|
+
outputSchema: exports_external.object({ yaml: exports_external.string() })
|
|
114877
|
+
}, { logger, tools: tools3, step });
|
|
114878
|
+
});
|
|
114879
|
+
if (analyzeResult.type === "Exit" && analyzeResult.object) {
|
|
114880
|
+
const yamlConfig = analyzeResult.object.yaml;
|
|
114881
|
+
generatedConfig = yamlConfig ? $parse(yamlConfig) : {};
|
|
114882
|
+
}
|
|
114883
|
+
await step("save-config", async () => {
|
|
114884
|
+
const existingConfig = loadConfigAtPath(configPath) ?? {};
|
|
114885
|
+
const finalConfig = {
|
|
114886
|
+
...existingConfig,
|
|
114887
|
+
...generatedConfig
|
|
114888
|
+
};
|
|
114889
|
+
await tools3.writeToFile({ path: configPath, content: $stringify(finalConfig) });
|
|
114890
|
+
logger.info(`✅ Configuration saved to ${configPath}`);
|
|
114891
|
+
if (generatedConfig.scripts) {
|
|
114892
|
+
logger.info(`
|
|
114893
|
+
\uD83D\uDCDD Generated scripts:`);
|
|
114894
|
+
Object.entries(generatedConfig.scripts).forEach(([name18, scriptConfig]) => {
|
|
114895
|
+
if (typeof scriptConfig === "string") {
|
|
114896
|
+
logger.info(` - ${name18}: ${scriptConfig}`);
|
|
114897
|
+
} else if (typeof scriptConfig === "object" && scriptConfig !== null) {
|
|
114898
|
+
logger.info(` - ${name18}: ${scriptConfig.description || JSON.stringify(scriptConfig)}`);
|
|
114899
|
+
}
|
|
114900
|
+
});
|
|
114901
|
+
}
|
|
114902
|
+
if (generatedConfig.rules) {
|
|
114903
|
+
const rules = Array.isArray(generatedConfig.rules) ? generatedConfig.rules : [generatedConfig.rules];
|
|
114904
|
+
logger.info(`
|
|
114905
|
+
\uD83D\uDCCB Identified project rules:`);
|
|
114906
|
+
rules.forEach((rule) => {
|
|
114907
|
+
if (typeof rule === "string") {
|
|
114908
|
+
logger.info(` - ${rule}`);
|
|
114909
|
+
}
|
|
114910
|
+
});
|
|
114911
|
+
}
|
|
114912
|
+
});
|
|
114913
|
+
if (generateScript && scriptName && scriptInstructions) {
|
|
114914
|
+
const scriptResult = await step("generate-script", async () => {
|
|
114915
|
+
logger.info(`
|
|
114916
|
+
\uD83D\uDD27 Generating custom script: ${scriptName}`);
|
|
114917
|
+
logger.info(`Requirements: ${scriptInstructions}`);
|
|
114918
|
+
return await agentWorkflow({
|
|
114919
|
+
systemPrompt: scriptGenerationSystemPrompt,
|
|
114920
|
+
userMessage: [
|
|
114921
|
+
{
|
|
114922
|
+
role: "user",
|
|
114923
|
+
content: `Generate a polka script with these requirements:
|
|
114924
|
+
Script name: ${scriptName}
|
|
114925
|
+
|
|
114926
|
+
Instructions: ${scriptInstructions}
|
|
114927
|
+
|
|
114928
|
+
Please:
|
|
114929
|
+
1. Ask clarifying questions if needed
|
|
114930
|
+
2. Analyze the project structure
|
|
114931
|
+
3. Present your plan before generating the script
|
|
114932
|
+
4. Generate a complete, working TypeScript script`
|
|
114933
|
+
}
|
|
114934
|
+
],
|
|
114935
|
+
tools: [readFile_default, listFiles_default, searchFiles_default, askFollowupQuestion_default],
|
|
114936
|
+
outputSchema: exports_external.object({
|
|
114937
|
+
plan: exports_external.string(),
|
|
114938
|
+
script: exports_external.string(),
|
|
114939
|
+
config: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
114940
|
+
})
|
|
114941
|
+
}, { logger, tools: tools3, step });
|
|
114942
|
+
});
|
|
114943
|
+
if (scriptResult.type === "Exit" && scriptResult.object) {
|
|
114944
|
+
const { plan: plan4, script, config: scriptConfig } = scriptResult.object;
|
|
114945
|
+
if (!skipConfirmation) {
|
|
114946
|
+
logger.info(`
|
|
114947
|
+
\uD83D\uDCCB Script Generation Plan:`);
|
|
114948
|
+
logger.info(plan4);
|
|
114949
|
+
}
|
|
114950
|
+
const scriptDir = ".polka-scripts";
|
|
114951
|
+
const scriptFileName = `${scriptName}.ts`;
|
|
114952
|
+
const scriptFilePath = join13(scriptDir, scriptFileName);
|
|
114953
|
+
await step("save-script", async () => {
|
|
114954
|
+
await tools3.writeToFile({ path: scriptFilePath, content: script });
|
|
114955
|
+
logger.info(`
|
|
114956
|
+
✅ Script generated: ${scriptFilePath}`);
|
|
114957
|
+
logger.info(`
|
|
114958
|
+
Run with: bun run polka run ${scriptName}`);
|
|
114959
|
+
if (scriptConfig && Object.keys(scriptConfig).length > 0) {
|
|
114960
|
+
logger.warn(`⚠️ AI suggested config updates, but they were not merged for safety:`);
|
|
114961
|
+
logger.warn(JSON.stringify(scriptConfig, null, 2));
|
|
114962
|
+
logger.warn(`To apply these changes, manually edit ${configPath}`);
|
|
114963
|
+
}
|
|
114964
|
+
});
|
|
114965
|
+
generatedScriptPath = scriptFilePath;
|
|
114966
|
+
}
|
|
114967
|
+
}
|
|
114968
|
+
return {
|
|
114969
|
+
configPath,
|
|
114970
|
+
scriptPath: generatedScriptPath,
|
|
114971
|
+
generatedConfig
|
|
114972
|
+
};
|
|
114973
|
+
};
|
|
114974
|
+
|
|
113340
114975
|
// src/commands/init.ts
|
|
113341
114976
|
async function createSkill(name18, logger, interactive) {
|
|
113342
114977
|
const nameRegex = /^[a-z0-9-]+$/;
|
|
@@ -113349,7 +114984,7 @@ async function createSkill(name18, logger, interactive) {
|
|
|
113349
114984
|
if (BUILT_IN_COMMANDS.includes(name18)) {
|
|
113350
114985
|
throw new Error(`Skill name '${name18}' conflicts with a built-in command. ` + `Please choose a different name (e.g., '${name18}-skill' or 'my-${name18}')`);
|
|
113351
114986
|
}
|
|
113352
|
-
const skillDir =
|
|
114987
|
+
const skillDir = join14(".claude", "skills", name18);
|
|
113353
114988
|
if (existsSync3(skillDir)) {
|
|
113354
114989
|
if (interactive) {
|
|
113355
114990
|
const proceed = await dist_default4({
|
|
@@ -113367,7 +115002,7 @@ async function createSkill(name18, logger, interactive) {
|
|
|
113367
115002
|
mkdirSync(skillDir, { recursive: true });
|
|
113368
115003
|
logger.info(`Created skill directory: ${skillDir}`);
|
|
113369
115004
|
const template = generateSkillTemplate(name18);
|
|
113370
|
-
writeFileSync(
|
|
115005
|
+
writeFileSync(join14(skillDir, "SKILL.md"), template);
|
|
113371
115006
|
logger.info(`Created SKILL.md`);
|
|
113372
115007
|
logger.info("");
|
|
113373
115008
|
logger.info(`Skill '${name18}' created successfully!`);
|
|
@@ -113435,16 +115070,10 @@ Add additional files like:
|
|
|
113435
115070
|
- \`templates/\` - File templates
|
|
113436
115071
|
`;
|
|
113437
115072
|
}
|
|
113438
|
-
async function createScript(name18, logger, interactive) {
|
|
113439
|
-
if (name18.includes("/") || name18.includes("\\")) {
|
|
113440
|
-
throw new Error('Script name cannot contain slashes. Use a simple name (e.g., "deploy" not "utils/deploy")');
|
|
113441
|
-
}
|
|
113442
|
-
if (BUILT_IN_COMMANDS.includes(name18)) {
|
|
113443
|
-
throw new Error(`Script name '${name18}' conflicts with a built-in command. ` + `Please choose a different name (e.g., '${name18}-script' or 'my-${name18}')`);
|
|
113444
|
-
}
|
|
115073
|
+
async function createScript(name18, logger, interactive, isGlobal = false) {
|
|
113445
115074
|
const scriptDir = ".polka-scripts";
|
|
113446
115075
|
const scriptPathConfig = `${scriptDir}/${name18}.ts`;
|
|
113447
|
-
const scriptPathActual =
|
|
115076
|
+
const scriptPathActual = join14(scriptDir, `${name18}.ts`);
|
|
113448
115077
|
if (existsSync3(scriptPathActual)) {
|
|
113449
115078
|
if (interactive) {
|
|
113450
115079
|
const proceed = await dist_default4({
|
|
@@ -113485,9 +115114,10 @@ if (import.meta.main) {
|
|
|
113485
115114
|
`;
|
|
113486
115115
|
writeFileSync(scriptPathActual, template);
|
|
113487
115116
|
logger.info(`Created script: ${scriptPathActual}`);
|
|
113488
|
-
|
|
115117
|
+
const configPath = isGlobal ? getGlobalConfigPath() : localConfigFileName;
|
|
115118
|
+
if (existsSync3(configPath)) {
|
|
113489
115119
|
try {
|
|
113490
|
-
const config4 = readConfig(
|
|
115120
|
+
const config4 = readConfig(configPath);
|
|
113491
115121
|
if (!config4.scripts) {
|
|
113492
115122
|
config4.scripts = {};
|
|
113493
115123
|
}
|
|
@@ -113495,7 +115125,7 @@ if (import.meta.main) {
|
|
|
113495
115125
|
script: scriptPathConfig,
|
|
113496
115126
|
description: `Custom script: ${name18}`
|
|
113497
115127
|
};
|
|
113498
|
-
const configContent = readFileSync2(
|
|
115128
|
+
const configContent = readFileSync2(configPath, "utf-8");
|
|
113499
115129
|
let newContent = configContent;
|
|
113500
115130
|
if (!configContent.includes("scripts:")) {
|
|
113501
115131
|
newContent = `${configContent.trimEnd()}
|
|
@@ -113507,8 +115137,7 @@ scripts:
|
|
|
113507
115137
|
`;
|
|
113508
115138
|
} else {
|
|
113509
115139
|
try {
|
|
113510
|
-
const
|
|
113511
|
-
const doc2 = yaml.parseDocument(configContent);
|
|
115140
|
+
const doc2 = $parseDocument(configContent);
|
|
113512
115141
|
if (!doc2.has("scripts")) {
|
|
113513
115142
|
doc2.set("scripts", {});
|
|
113514
115143
|
}
|
|
@@ -113529,8 +115158,8 @@ scripts:
|
|
|
113529
115158
|
return;
|
|
113530
115159
|
}
|
|
113531
115160
|
}
|
|
113532
|
-
writeFileSync(
|
|
113533
|
-
logger.info(`Added script to config: ${
|
|
115161
|
+
writeFileSync(configPath, newContent);
|
|
115162
|
+
logger.info(`Added script to config: ${configPath}`);
|
|
113534
115163
|
logger.info(`Run with: polka run ${name18}`);
|
|
113535
115164
|
} catch (error48) {
|
|
113536
115165
|
logger.warn("Could not update config file. Add the script manually:");
|
|
@@ -113550,9 +115179,9 @@ scripts:
|
|
|
113550
115179
|
logger.info(` description: Custom script: ${name18}`);
|
|
113551
115180
|
}
|
|
113552
115181
|
}
|
|
113553
|
-
var initCommand = new Command("init").description("Initialize polkacodes configuration, generate scripts, or create skills").argument("[type]", "Type of resource to initialize (config, script, skill)").argument("[name]", "Name of the script or skill (only for type=script|skill)").option("-g, --global", "Use global config").action(async (type, name18, options, command) => {
|
|
113554
|
-
const
|
|
113555
|
-
const { verbose, yes } =
|
|
115182
|
+
var initCommand = new Command("init").description("Initialize polkacodes configuration, generate scripts, or create skills").argument("[type]", "Type of resource to initialize (config, script, skill)").argument("[name]", "Name of the script or skill (only for type=script|skill)").option("-g, --global", "Use global config").option("-i, --instructions <string>", "Script description for AI-assisted generation (only for type=script)").action(async (type, name18, options, command) => {
|
|
115183
|
+
const workflowOpts = getBaseWorkflowOptions(command);
|
|
115184
|
+
const { verbose, yes } = workflowOpts;
|
|
113556
115185
|
const logger = createLogger({
|
|
113557
115186
|
verbose
|
|
113558
115187
|
});
|
|
@@ -113576,15 +115205,83 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
113576
115205
|
if (!name18) {
|
|
113577
115206
|
logger.error("Error: Script name is required when type=script");
|
|
113578
115207
|
logger.info("Usage: polka init script <script-name>");
|
|
115208
|
+
logger.info("");
|
|
115209
|
+
logger.info("For AI-assisted script generation:");
|
|
115210
|
+
logger.info(' polka init script <name> -i "description"');
|
|
115211
|
+
logger.info("");
|
|
115212
|
+
logger.info("For basic template generation:");
|
|
115213
|
+
logger.info(" polka init script <name>");
|
|
113579
115214
|
process.exit(1);
|
|
113580
115215
|
}
|
|
113581
|
-
|
|
113582
|
-
|
|
113583
|
-
|
|
113584
|
-
|
|
113585
|
-
|
|
115216
|
+
if (name18.includes("/") || name18.includes("\\")) {
|
|
115217
|
+
logger.error('Error: Script name cannot contain slashes. Use a simple name (e.g., "deploy" not "utils/deploy")');
|
|
115218
|
+
process.exit(1);
|
|
115219
|
+
}
|
|
115220
|
+
if (BUILT_IN_COMMANDS.includes(name18)) {
|
|
115221
|
+
logger.error(`Error: Script name '${name18}' conflicts with a built-in command. ` + `Please choose a different name (e.g., '${name18}-script' or 'my-${name18}')`);
|
|
113586
115222
|
process.exit(1);
|
|
113587
115223
|
}
|
|
115224
|
+
const useAI = options.instructions !== undefined;
|
|
115225
|
+
if (useAI) {
|
|
115226
|
+
try {
|
|
115227
|
+
let scriptInstructions = options.instructions;
|
|
115228
|
+
if (!scriptInstructions && interactive) {
|
|
115229
|
+
scriptInstructions = await dist_default5({
|
|
115230
|
+
message: "Describe what this script should do:",
|
|
115231
|
+
validate: (input2) => input2.length > 0 || "Please provide a description"
|
|
115232
|
+
});
|
|
115233
|
+
}
|
|
115234
|
+
if (!scriptInstructions) {
|
|
115235
|
+
logger.error("Error: Script instructions are required for AI generation");
|
|
115236
|
+
logger.info('Usage: polka init script <name> -i "your instructions"');
|
|
115237
|
+
process.exit(1);
|
|
115238
|
+
}
|
|
115239
|
+
const scriptDir = ".polka-scripts";
|
|
115240
|
+
const scriptPath = join14(scriptDir, `${name18}.ts`);
|
|
115241
|
+
if (existsSync3(scriptPath)) {
|
|
115242
|
+
if (interactive) {
|
|
115243
|
+
const proceed = await dist_default4({
|
|
115244
|
+
message: `Script '${scriptPath}' already exists. Overwrite?`,
|
|
115245
|
+
default: false
|
|
115246
|
+
});
|
|
115247
|
+
if (!proceed) {
|
|
115248
|
+
logger.info("Script generation cancelled");
|
|
115249
|
+
return;
|
|
115250
|
+
}
|
|
115251
|
+
} else {
|
|
115252
|
+
throw new Error(`Script already exists: ${scriptPath}`);
|
|
115253
|
+
}
|
|
115254
|
+
}
|
|
115255
|
+
const globalConfigPath2 = getGlobalConfigPath();
|
|
115256
|
+
const isGlobal2 = options.global ?? false;
|
|
115257
|
+
const configPath2 = isGlobal2 ? globalConfigPath2 : localConfigFileName;
|
|
115258
|
+
await runWorkflow(initInteractiveWorkflow, {
|
|
115259
|
+
configPath: configPath2,
|
|
115260
|
+
scriptName: name18,
|
|
115261
|
+
scriptInstructions,
|
|
115262
|
+
generateScript: true,
|
|
115263
|
+
skipConfirmation: !interactive
|
|
115264
|
+
}, {
|
|
115265
|
+
commandName: "init",
|
|
115266
|
+
context: workflowOpts,
|
|
115267
|
+
logger,
|
|
115268
|
+
interactive
|
|
115269
|
+
});
|
|
115270
|
+
} catch (error48) {
|
|
115271
|
+
const message = error48 instanceof Error ? error48.message : String(error48);
|
|
115272
|
+
logger.error(`AI script generation failed: ${message}`);
|
|
115273
|
+
process.exit(1);
|
|
115274
|
+
}
|
|
115275
|
+
} else {
|
|
115276
|
+
try {
|
|
115277
|
+
const isGlobal2 = Boolean(options.global);
|
|
115278
|
+
await createScript(name18, logger, interactive, isGlobal2);
|
|
115279
|
+
} catch (error48) {
|
|
115280
|
+
const message = error48 instanceof Error ? error48.message : String(error48);
|
|
115281
|
+
logger.error(`Script generation failed: ${message}`);
|
|
115282
|
+
process.exit(1);
|
|
115283
|
+
}
|
|
115284
|
+
}
|
|
113588
115285
|
return;
|
|
113589
115286
|
}
|
|
113590
115287
|
if (type && type !== "config") {
|
|
@@ -113650,7 +115347,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
113650
115347
|
case "global": {
|
|
113651
115348
|
const globalConfig2 = loadConfigAtPath(globalConfigPath) ?? {};
|
|
113652
115349
|
set_default(globalConfig2, ["providers", provider3, "apiKey"], apiKey);
|
|
113653
|
-
writeFileSync(globalConfigPath,
|
|
115350
|
+
writeFileSync(globalConfigPath, $stringify(globalConfig2));
|
|
113654
115351
|
logger.info(`API key saved to global config file: ${globalConfigPath}`);
|
|
113655
115352
|
providerConfig.apiKey = undefined;
|
|
113656
115353
|
break;
|
|
@@ -113685,7 +115382,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
113685
115382
|
if (providerConfig.apiKey) {
|
|
113686
115383
|
set_default(finalConfig, ["providers", provider3, "apiKey"], providerConfig.apiKey);
|
|
113687
115384
|
}
|
|
113688
|
-
writeFileSync(configPath,
|
|
115385
|
+
writeFileSync(configPath, $stringify(finalConfig));
|
|
113689
115386
|
logger.info(`Configuration saved to ${configPath}`);
|
|
113690
115387
|
let shouldAnalyze = false;
|
|
113691
115388
|
if (!isGlobal && interactive) {
|
|
@@ -113699,9 +115396,8 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
113699
115396
|
configPath
|
|
113700
115397
|
}, {
|
|
113701
115398
|
commandName: "init",
|
|
113702
|
-
context:
|
|
113703
|
-
logger
|
|
113704
|
-
requiresProvider: true
|
|
115399
|
+
context: workflowOpts,
|
|
115400
|
+
logger
|
|
113705
115401
|
});
|
|
113706
115402
|
}
|
|
113707
115403
|
});
|
|
@@ -115021,7 +116717,10 @@ function createExecutionContext(_logger) {
|
|
|
115021
116717
|
cwd: projectRoot,
|
|
115022
116718
|
yes: true,
|
|
115023
116719
|
verbose: 0,
|
|
115024
|
-
file: undefined
|
|
116720
|
+
file: undefined,
|
|
116721
|
+
provider: undefined,
|
|
116722
|
+
model: undefined,
|
|
116723
|
+
apiProvider: undefined
|
|
115025
116724
|
};
|
|
115026
116725
|
}
|
|
115027
116726
|
async function executeWorkflow(workflow3, input2, commandName, logger) {
|
|
@@ -115036,7 +116735,6 @@ async function executeWorkflow(workflow3, input2, commandName, logger) {
|
|
|
115036
116735
|
commandName,
|
|
115037
116736
|
context,
|
|
115038
116737
|
logger,
|
|
115039
|
-
requiresProvider: true,
|
|
115040
116738
|
interactive: false
|
|
115041
116739
|
});
|
|
115042
116740
|
if (!result) {
|
|
@@ -115096,7 +116794,7 @@ Parameters:
|
|
|
115096
116794
|
description: `Perform comprehensive code review with actionable, structured feedback.
|
|
115097
116795
|
|
|
115098
116796
|
This workflow can review:
|
|
115099
|
-
- Uncommitted local changes (
|
|
116797
|
+
- Uncommitted local changes (staged and/or unstaged files) - DEFAULT BEHAVIOR when no parameters provided
|
|
115100
116798
|
- Branch comparisons (e.g., feature branch vs main)
|
|
115101
116799
|
- Specific git ranges (e.g., HEAD~3..HEAD, origin/main..HEAD)
|
|
115102
116800
|
- Pull requests from GitHub/GitLab by number
|
|
@@ -115117,7 +116815,7 @@ Output is structured with:
|
|
|
115117
116815
|
|
|
115118
116816
|
Parameters:
|
|
115119
116817
|
- pr (optional): Pull request number to review
|
|
115120
|
-
- range (optional): Git range to review (e.g., HEAD~3..HEAD, origin/main..HEAD)
|
|
116818
|
+
- range (optional): Git range to review (e.g., HEAD~3..HEAD, origin/main..HEAD). When omitted, reviews staged and unstaged local changes
|
|
115121
116819
|
- files (optional): Specific files to review
|
|
115122
116820
|
- context (optional): Additional context about the changes (purpose, constraints, technical background)`,
|
|
115123
116821
|
inputSchema: exports_external.object({
|
|
@@ -115166,11 +116864,10 @@ Parameters:
|
|
|
115166
116864
|
logger.info(`MCP: Executing plan workflow - task: "${task2}"`);
|
|
115167
116865
|
try {
|
|
115168
116866
|
const context = createExecutionContext(logger);
|
|
115169
|
-
const result = await runWorkflow(planWorkflow, { task: task2 }, {
|
|
116867
|
+
const result = await runWorkflow(planWorkflow, { task: task2, interactive: false }, {
|
|
115170
116868
|
commandName: "plan",
|
|
115171
116869
|
context,
|
|
115172
116870
|
logger,
|
|
115173
|
-
requiresProvider: true,
|
|
115174
116871
|
interactive: false
|
|
115175
116872
|
});
|
|
115176
116873
|
if (result && typeof result === "object") {
|
|
@@ -115577,8 +117274,8 @@ async function executeScript(script, name18, logger, args = []) {
|
|
|
115577
117274
|
|
|
115578
117275
|
// src/commands/meta.ts
|
|
115579
117276
|
async function runMeta(task2, command) {
|
|
115580
|
-
const
|
|
115581
|
-
const { verbose } =
|
|
117277
|
+
const workflowOpts = getBaseWorkflowOptions(command);
|
|
117278
|
+
const { verbose } = workflowOpts;
|
|
115582
117279
|
const logger = createLogger({
|
|
115583
117280
|
verbose
|
|
115584
117281
|
});
|
|
@@ -115613,15 +117310,13 @@ async function runMeta(task2, command) {
|
|
|
115613
117310
|
}
|
|
115614
117311
|
const workflowInput2 = {
|
|
115615
117312
|
task: task2,
|
|
115616
|
-
|
|
115617
|
-
additionalTools: {}
|
|
117313
|
+
...workflowOpts
|
|
115618
117314
|
};
|
|
115619
117315
|
await runWorkflow(metaWorkflow, workflowInput2, {
|
|
115620
117316
|
commandName: "meta",
|
|
115621
|
-
context:
|
|
117317
|
+
context: workflowOpts,
|
|
115622
117318
|
logger,
|
|
115623
|
-
|
|
115624
|
-
interactive: !globalOpts.yes
|
|
117319
|
+
...workflowOpts
|
|
115625
117320
|
});
|
|
115626
117321
|
return;
|
|
115627
117322
|
}
|
|
@@ -115650,15 +117345,13 @@ async function runMeta(task2, command) {
|
|
|
115650
117345
|
}
|
|
115651
117346
|
const workflowInput = {
|
|
115652
117347
|
task: input2,
|
|
115653
|
-
|
|
115654
|
-
additionalTools: {}
|
|
117348
|
+
...workflowOpts
|
|
115655
117349
|
};
|
|
115656
117350
|
await runWorkflow(metaWorkflow, workflowInput, {
|
|
115657
117351
|
commandName: "meta",
|
|
115658
|
-
context:
|
|
117352
|
+
context: workflowOpts,
|
|
115659
117353
|
logger,
|
|
115660
|
-
|
|
115661
|
-
interactive: !globalOpts.yes
|
|
117354
|
+
...workflowOpts
|
|
115662
117355
|
});
|
|
115663
117356
|
}
|
|
115664
117357
|
async function tryExecuteCommand(commandName, logger) {
|
|
@@ -115705,28 +117398,26 @@ var planCommand = new Command("plan").description("Create or update a plan for a
|
|
|
115705
117398
|
return;
|
|
115706
117399
|
}
|
|
115707
117400
|
}
|
|
115708
|
-
const
|
|
117401
|
+
const workflowOpts = getBaseWorkflowOptions(command);
|
|
115709
117402
|
await plan3({
|
|
115710
117403
|
task: taskInput,
|
|
115711
117404
|
fileContent,
|
|
115712
117405
|
planFile: options.planFile,
|
|
115713
|
-
|
|
115714
|
-
...globalOpts
|
|
117406
|
+
...workflowOpts
|
|
115715
117407
|
});
|
|
115716
117408
|
});
|
|
115717
117409
|
|
|
115718
117410
|
// src/commands/pr.ts
|
|
115719
117411
|
var prCommand = new Command("pr").description("Create a GitHub pull request").argument("[message]", "Optional context for the pull request generation").action(async (message, _options, command) => {
|
|
115720
|
-
const
|
|
117412
|
+
const workflowOpts = getBaseWorkflowOptions(command);
|
|
115721
117413
|
await createPr({
|
|
115722
117414
|
context: message,
|
|
115723
|
-
|
|
115724
|
-
...globalOpts
|
|
117415
|
+
...workflowOpts
|
|
115725
117416
|
});
|
|
115726
117417
|
});
|
|
115727
117418
|
|
|
115728
117419
|
// src/commands/review.ts
|
|
115729
|
-
|
|
117420
|
+
init_dist18();
|
|
115730
117421
|
import { existsSync as existsSync5 } from "node:fs";
|
|
115731
117422
|
init_workflow_utils();
|
|
115732
117423
|
var reviewCommand = new Command("review").description("Review a GitHub pull request or local changes").argument("[files...]", "Specific files to review (use --context for review instructions)").option("--pr <pr>", "The pull request number to review", (value) => {
|
|
@@ -115757,8 +117448,11 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
115757
117448
|
context = files[0];
|
|
115758
117449
|
filesToReview = [];
|
|
115759
117450
|
}
|
|
115760
|
-
const
|
|
115761
|
-
|
|
117451
|
+
const workflowOpts = getBaseWorkflowOptions(command);
|
|
117452
|
+
if (json2) {
|
|
117453
|
+
workflowOpts.interactive = false;
|
|
117454
|
+
}
|
|
117455
|
+
const { verbose } = workflowOpts;
|
|
115762
117456
|
const logger = createLogger({
|
|
115763
117457
|
verbose: json2 ? -1 : verbose
|
|
115764
117458
|
});
|
|
@@ -115772,8 +117466,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
115772
117466
|
range,
|
|
115773
117467
|
files: filesToReview.length > 0 ? filesToReview : undefined,
|
|
115774
117468
|
context,
|
|
115775
|
-
|
|
115776
|
-
...globalOpts
|
|
117469
|
+
...workflowOpts
|
|
115777
117470
|
});
|
|
115778
117471
|
if (reviewResult) {
|
|
115779
117472
|
let formattedReview = formatReviewForConsole(reviewResult);
|
|
@@ -115833,8 +117526,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
115833
117526
|
${formattedReview}`;
|
|
115834
117527
|
await code2({
|
|
115835
117528
|
task: taskInstruction,
|
|
115836
|
-
|
|
115837
|
-
...globalOpts
|
|
117529
|
+
...workflowOpts
|
|
115838
117530
|
});
|
|
115839
117531
|
}
|
|
115840
117532
|
}
|
|
@@ -116025,8 +117717,8 @@ skillsCommand.command("validate").description("Validate a skill's structure and
|
|
|
116025
117717
|
let skillHasErrors = false;
|
|
116026
117718
|
try {
|
|
116027
117719
|
const skill = await service.loadSkill(skillRef.path, skillRef.source);
|
|
116028
|
-
const
|
|
116029
|
-
for (const error48 of
|
|
117720
|
+
const errors6 = validateSkillMetadata(skill);
|
|
117721
|
+
for (const error48 of errors6) {
|
|
116030
117722
|
logger.error(` ❌ ${error48}`);
|
|
116031
117723
|
hasErrors = true;
|
|
116032
117724
|
skillHasErrors = true;
|
|
@@ -116068,8 +117760,8 @@ skillsCommand.command("validate").description("Validate a skill's structure and
|
|
|
116068
117760
|
init_src();
|
|
116069
117761
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
116070
117762
|
async function runWorkflowCommand(task2, _options, command) {
|
|
116071
|
-
const
|
|
116072
|
-
const { verbose } =
|
|
117763
|
+
const workflowOpts = getBaseWorkflowOptions(command);
|
|
117764
|
+
const { verbose } = workflowOpts;
|
|
116073
117765
|
const logger = createLogger({ verbose });
|
|
116074
117766
|
const { file: file2, workflow: workflowName } = command.opts();
|
|
116075
117767
|
if (!file2) {
|
|
@@ -116080,8 +117772,9 @@ async function runWorkflowCommand(task2, _options, command) {
|
|
|
116080
117772
|
let content;
|
|
116081
117773
|
try {
|
|
116082
117774
|
content = await readFile13(file2, "utf-8");
|
|
116083
|
-
} catch (
|
|
116084
|
-
|
|
117775
|
+
} catch (error48) {
|
|
117776
|
+
const errorMessage = error48 instanceof Error ? error48.message : String(error48);
|
|
117777
|
+
logger.error(`Error reading file '${file2}': ${errorMessage}`);
|
|
116085
117778
|
return;
|
|
116086
117779
|
}
|
|
116087
117780
|
const parsedResult = parseDynamicWorkflowDefinition(content);
|
|
@@ -116114,7 +117807,7 @@ async function runWorkflowCommand(task2, _options, command) {
|
|
|
116114
117807
|
}
|
|
116115
117808
|
logger.info(`Using workflow '${workflowId}'`);
|
|
116116
117809
|
}
|
|
116117
|
-
const tools3 = [listFiles_default, askFollowupQuestion_default];
|
|
117810
|
+
const tools3 = [listFiles_default, askFollowupQuestion_default, searchFiles_default];
|
|
116118
117811
|
let dynamicRunner;
|
|
116119
117812
|
try {
|
|
116120
117813
|
dynamicRunner = createDynamicWorkflow(workflowDef, {
|
|
@@ -116128,7 +117821,8 @@ async function runWorkflowCommand(task2, _options, command) {
|
|
|
116128
117821
|
}
|
|
116129
117822
|
});
|
|
116130
117823
|
} catch (error48) {
|
|
116131
|
-
|
|
117824
|
+
const errorMessage = error48 instanceof Error ? error48.message : String(error48);
|
|
117825
|
+
logger.error(`Failed to parse workflow: ${errorMessage}`);
|
|
116132
117826
|
return;
|
|
116133
117827
|
}
|
|
116134
117828
|
const workflowFn = async (input2, context) => {
|
|
@@ -116152,7 +117846,7 @@ async function runWorkflowCommand(task2, _options, command) {
|
|
|
116152
117846
|
}
|
|
116153
117847
|
return "id" in s2 ? String(s2.id) : "(unnamed step)";
|
|
116154
117848
|
}).join(", ")}`);
|
|
116155
|
-
await runWorkflow(workflowFn, workflowInput, { commandName: "workflow", context:
|
|
117849
|
+
await runWorkflow(workflowFn, workflowInput, { commandName: "workflow", context: workflowOpts, logger });
|
|
116156
117850
|
}
|
|
116157
117851
|
var workflowCommand = new Command("workflow").description("Run custom workflows.").argument("[task]", "The task input for the workflow.").option("-f, --file <path>", "Path to the workflow file (required)").option("-w, --workflow <name>", "The name of the workflow to run").action(runWorkflowCommand);
|
|
116158
117852
|
// src/index.ts
|