@polka-codes/runner 0.9.62 → 0.9.64
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 +114 -32
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -21331,7 +21331,7 @@ var require_src6 = __commonJS((exports) => {
|
|
|
21331
21331
|
var jws = require_jws();
|
|
21332
21332
|
var path = __require("path");
|
|
21333
21333
|
var util_1 = __require("util");
|
|
21334
|
-
var
|
|
21334
|
+
var readFile2 = fs.readFile ? (0, util_1.promisify)(fs.readFile) : async () => {
|
|
21335
21335
|
throw new ErrorWithCode("use key rather than keyFile.", "MISSING_CREDENTIALS");
|
|
21336
21336
|
};
|
|
21337
21337
|
var GOOGLE_TOKEN_URL = "https://www.googleapis.com/oauth2/v4/token";
|
|
@@ -21402,7 +21402,7 @@ var require_src6 = __commonJS((exports) => {
|
|
|
21402
21402
|
const ext = path.extname(keyFile);
|
|
21403
21403
|
switch (ext) {
|
|
21404
21404
|
case ".json": {
|
|
21405
|
-
const key = await
|
|
21405
|
+
const key = await readFile2(keyFile, "utf8");
|
|
21406
21406
|
const body = JSON.parse(key);
|
|
21407
21407
|
const privateKey = body.private_key;
|
|
21408
21408
|
const clientEmail = body.client_email;
|
|
@@ -21414,7 +21414,7 @@ var require_src6 = __commonJS((exports) => {
|
|
|
21414
21414
|
case ".der":
|
|
21415
21415
|
case ".crt":
|
|
21416
21416
|
case ".pem": {
|
|
21417
|
-
const privateKey = await
|
|
21417
|
+
const privateKey = await readFile2(keyFile, "utf8");
|
|
21418
21418
|
return { privateKey };
|
|
21419
21419
|
}
|
|
21420
21420
|
case ".p12":
|
|
@@ -22545,7 +22545,7 @@ var require_filesubjecttokensupplier = __commonJS((exports) => {
|
|
|
22545
22545
|
exports.FileSubjectTokenSupplier = undefined;
|
|
22546
22546
|
var util_1 = __require("util");
|
|
22547
22547
|
var fs = __require("fs");
|
|
22548
|
-
var
|
|
22548
|
+
var readFile2 = (0, util_1.promisify)((_a16 = fs.readFile) !== null && _a16 !== undefined ? _a16 : () => {});
|
|
22549
22549
|
var realpath = (0, util_1.promisify)((_b8 = fs.realpath) !== null && _b8 !== undefined ? _b8 : () => {});
|
|
22550
22550
|
var lstat = (0, util_1.promisify)((_c = fs.lstat) !== null && _c !== undefined ? _c : () => {});
|
|
22551
22551
|
|
|
@@ -22569,7 +22569,7 @@ var require_filesubjecttokensupplier = __commonJS((exports) => {
|
|
|
22569
22569
|
throw err;
|
|
22570
22570
|
}
|
|
22571
22571
|
let subjectToken;
|
|
22572
|
-
const rawText = await
|
|
22572
|
+
const rawText = await readFile2(parsedFilePath, { encoding: "utf8" });
|
|
22573
22573
|
if (this.formatType === "text") {
|
|
22574
22574
|
subjectToken = rawText;
|
|
22575
22575
|
} else if (this.formatType === "json" && this.subjectTokenFieldName) {
|
|
@@ -38418,7 +38418,7 @@ var {
|
|
|
38418
38418
|
Help
|
|
38419
38419
|
} = import__.default;
|
|
38420
38420
|
// package.json
|
|
38421
|
-
var version = "0.9.
|
|
38421
|
+
var version = "0.9.64";
|
|
38422
38422
|
|
|
38423
38423
|
// src/runner.ts
|
|
38424
38424
|
import { execSync } from "node:child_process";
|
|
@@ -38426,6 +38426,7 @@ import { promises as fs2 } from "node:fs";
|
|
|
38426
38426
|
|
|
38427
38427
|
// ../cli-shared/src/config.ts
|
|
38428
38428
|
import { existsSync, readFileSync } from "node:fs";
|
|
38429
|
+
import { readFile } from "node:fs/promises";
|
|
38429
38430
|
import { homedir } from "node:os";
|
|
38430
38431
|
import { join } from "node:path";
|
|
38431
38432
|
// ../core/src/Agent/prompts.ts
|
|
@@ -50959,6 +50960,18 @@ var providerModelSchema = exports_external.object({
|
|
|
50959
50960
|
parameters: exports_external.record(exports_external.string(), exports_external.any()).optional(),
|
|
50960
50961
|
budget: exports_external.number().positive().optional()
|
|
50961
50962
|
});
|
|
50963
|
+
var ruleSchema = exports_external.union([
|
|
50964
|
+
exports_external.string(),
|
|
50965
|
+
exports_external.object({ path: exports_external.string() }).strict(),
|
|
50966
|
+
exports_external.object({ url: exports_external.string() }).strict(),
|
|
50967
|
+
exports_external.object({
|
|
50968
|
+
repo: exports_external.string(),
|
|
50969
|
+
path: exports_external.string(),
|
|
50970
|
+
tag: exports_external.string().optional(),
|
|
50971
|
+
commit: exports_external.string().optional(),
|
|
50972
|
+
branch: exports_external.string().optional()
|
|
50973
|
+
}).strict()
|
|
50974
|
+
]);
|
|
50962
50975
|
var configSchema = exports_external.object({
|
|
50963
50976
|
prices: exports_external.record(exports_external.string(), exports_external.record(exports_external.string(), exports_external.object({
|
|
50964
50977
|
inputPrice: exports_external.number().optional(),
|
|
@@ -50987,7 +51000,10 @@ var configSchema = exports_external.object({
|
|
|
50987
51000
|
description: exports_external.string()
|
|
50988
51001
|
}))).optional(),
|
|
50989
51002
|
commands: exports_external.record(exports_external.string(), providerModelSchema).optional(),
|
|
50990
|
-
|
|
51003
|
+
tools: exports_external.object({
|
|
51004
|
+
search: providerModelSchema.or(exports_external.boolean()).optional()
|
|
51005
|
+
}).optional(),
|
|
51006
|
+
rules: exports_external.array(ruleSchema).optional().or(exports_external.string()).optional(),
|
|
50991
51007
|
excludeFiles: exports_external.array(exports_external.string()).optional()
|
|
50992
51008
|
}).strict();
|
|
50993
51009
|
// ../core/src/tools/askFollowupQuestion.ts
|
|
@@ -51967,9 +51983,30 @@ var replaceInFile_default = {
|
|
|
51967
51983
|
// ../core/src/tools/search.ts
|
|
51968
51984
|
var toolInfo14 = {
|
|
51969
51985
|
name: "search",
|
|
51970
|
-
description: "Search the web for information.",
|
|
51986
|
+
description: "Search the web for information using Google Search. Use this tool to find current information, facts, news, documentation, or research that is not available in your training data. Returns comprehensive search results with relevant content extracted from the web.",
|
|
51971
51987
|
parameters: exports_external.object({
|
|
51972
|
-
query: exports_external.string().describe("The query to search for")
|
|
51988
|
+
query: exports_external.string().describe("The query to search for").meta({ usageValue: "Your search query here" })
|
|
51989
|
+
}).meta({
|
|
51990
|
+
examples: [
|
|
51991
|
+
{
|
|
51992
|
+
description: "Search for current events or news",
|
|
51993
|
+
input: {
|
|
51994
|
+
query: "latest developments in AI language models 2024"
|
|
51995
|
+
}
|
|
51996
|
+
},
|
|
51997
|
+
{
|
|
51998
|
+
description: "Look up technical documentation",
|
|
51999
|
+
input: {
|
|
52000
|
+
query: "TypeScript advanced type system features"
|
|
52001
|
+
}
|
|
52002
|
+
},
|
|
52003
|
+
{
|
|
52004
|
+
description: "Research specific information",
|
|
52005
|
+
input: {
|
|
52006
|
+
query: "Node.js performance optimization best practices"
|
|
52007
|
+
}
|
|
52008
|
+
}
|
|
52009
|
+
]
|
|
51973
52010
|
})
|
|
51974
52011
|
};
|
|
51975
52012
|
var handler14 = async (provider, args) => {
|
|
@@ -63106,21 +63143,60 @@ function mergeConfigs(configs) {
|
|
|
63106
63143
|
}
|
|
63107
63144
|
const mergedConfig = configs.reduce((acc, config3) => {
|
|
63108
63145
|
const merged = merge_default({}, acc, config3);
|
|
63109
|
-
|
|
63110
|
-
|
|
63111
|
-
accRules = [accRules];
|
|
63112
|
-
}
|
|
63113
|
-
let configRules = config3.rules ?? [];
|
|
63114
|
-
if (typeof configRules === "string") {
|
|
63115
|
-
configRules = [configRules];
|
|
63116
|
-
}
|
|
63146
|
+
const accRules = acc.rules ? Array.isArray(acc.rules) ? acc.rules : [acc.rules] : undefined;
|
|
63147
|
+
const configRules = config3.rules ? Array.isArray(config3.rules) ? config3.rules : [config3.rules] : undefined;
|
|
63117
63148
|
merged.rules = mergeArray(accRules, configRules);
|
|
63118
63149
|
merged.excludeFiles = mergeArray(acc.excludeFiles, config3.excludeFiles);
|
|
63119
63150
|
return merged;
|
|
63120
63151
|
});
|
|
63121
63152
|
return mergedConfig;
|
|
63122
63153
|
}
|
|
63123
|
-
function
|
|
63154
|
+
async function resolveRules(rules) {
|
|
63155
|
+
if (!rules) {
|
|
63156
|
+
return;
|
|
63157
|
+
}
|
|
63158
|
+
if (typeof rules === "string") {
|
|
63159
|
+
return rules;
|
|
63160
|
+
}
|
|
63161
|
+
const resolvedRules = await Promise.all(rules.map(async (rule) => {
|
|
63162
|
+
if (typeof rule === "string") {
|
|
63163
|
+
return rule;
|
|
63164
|
+
}
|
|
63165
|
+
if ("url" in rule) {
|
|
63166
|
+
try {
|
|
63167
|
+
const response = await fetch(rule.url);
|
|
63168
|
+
if (response.ok) {
|
|
63169
|
+
return await response.text();
|
|
63170
|
+
}
|
|
63171
|
+
console.warn(`Failed to fetch rule from ${rule.url}: ${response.statusText}`);
|
|
63172
|
+
} catch (error46) {
|
|
63173
|
+
console.warn(`Error fetching rule from ${rule.url}: ${error46}`);
|
|
63174
|
+
}
|
|
63175
|
+
} else if ("repo" in rule) {
|
|
63176
|
+
const ref = rule.commit ?? rule.tag ?? rule.branch ?? "main";
|
|
63177
|
+
const url2 = `https://raw.githubusercontent.com/${rule.repo}/${ref}/${rule.path}`;
|
|
63178
|
+
try {
|
|
63179
|
+
const response = await fetch(url2);
|
|
63180
|
+
if (response.ok) {
|
|
63181
|
+
return await response.text();
|
|
63182
|
+
}
|
|
63183
|
+
console.warn(`Failed to fetch rule from ${url2}: ${response.statusText}`);
|
|
63184
|
+
} catch (error46) {
|
|
63185
|
+
console.warn(`Error fetching rule from ${url2}: ${error46}`);
|
|
63186
|
+
}
|
|
63187
|
+
} else if ("path" in rule) {
|
|
63188
|
+
if (existsSync(rule.path)) {
|
|
63189
|
+
return await readFile(rule.path, "utf-8");
|
|
63190
|
+
}
|
|
63191
|
+
console.warn(`Rule file not found: ${rule.path}`);
|
|
63192
|
+
}
|
|
63193
|
+
return;
|
|
63194
|
+
}));
|
|
63195
|
+
return resolvedRules.filter((rule) => rule !== undefined).join(`
|
|
63196
|
+
|
|
63197
|
+
`);
|
|
63198
|
+
}
|
|
63199
|
+
async function loadConfig(paths, cwd = process.cwd(), home = homedir()) {
|
|
63124
63200
|
const configs = [];
|
|
63125
63201
|
const globalConfigPath = getGlobalConfigPath(home);
|
|
63126
63202
|
if (existsSync(globalConfigPath)) {
|
|
@@ -63157,7 +63233,15 @@ ${error46}`);
|
|
|
63157
63233
|
}
|
|
63158
63234
|
}
|
|
63159
63235
|
}
|
|
63160
|
-
|
|
63236
|
+
const mergedConfig = configs.length > 0 ? mergeConfigs(configs) : undefined;
|
|
63237
|
+
if (!mergedConfig) {
|
|
63238
|
+
return;
|
|
63239
|
+
}
|
|
63240
|
+
const resolvedRules = await resolveRules(mergedConfig.rules);
|
|
63241
|
+
return {
|
|
63242
|
+
...mergedConfig,
|
|
63243
|
+
rules: resolvedRules
|
|
63244
|
+
};
|
|
63161
63245
|
}
|
|
63162
63246
|
var readConfig = (path) => {
|
|
63163
63247
|
const file2 = readFileSync(path, "utf8");
|
|
@@ -63166,7 +63250,7 @@ var readConfig = (path) => {
|
|
|
63166
63250
|
};
|
|
63167
63251
|
// ../cli-shared/src/provider.ts
|
|
63168
63252
|
import { spawn as spawn2 } from "node:child_process";
|
|
63169
|
-
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
63253
|
+
import { mkdir, readFile as readFile2, rename, unlink, writeFile } from "node:fs/promises";
|
|
63170
63254
|
import { dirname, normalize, resolve as resolve3 } from "node:path";
|
|
63171
63255
|
|
|
63172
63256
|
// ../../node_modules/.bun/@ai-sdk+google-vertex@3.0.68+5954958163efbb2a/node_modules/@ai-sdk/google-vertex/dist/index.mjs
|
|
@@ -66215,6 +66299,7 @@ var getProvider = (options = {}) => {
|
|
|
66215
66299
|
const memoryStore = options.memoryStore ?? new InMemoryStore;
|
|
66216
66300
|
const todoItemStore = options.todoItemStore ?? new InMemoryStore;
|
|
66217
66301
|
const defaultMemoryTopic = ":default:";
|
|
66302
|
+
const searchModel = options.getModel?.("search");
|
|
66218
66303
|
const provider2 = {
|
|
66219
66304
|
listTodoItems: async (id, status) => {
|
|
66220
66305
|
const todoItems = await todoItemStore.read() ?? [];
|
|
@@ -66348,7 +66433,7 @@ ${content}`;
|
|
|
66348
66433
|
throw new Error(`Not allow to access file ${path}`);
|
|
66349
66434
|
}
|
|
66350
66435
|
try {
|
|
66351
|
-
return await
|
|
66436
|
+
return await readFile2(path, "utf8");
|
|
66352
66437
|
} catch (_e) {
|
|
66353
66438
|
return;
|
|
66354
66439
|
}
|
|
@@ -66382,7 +66467,7 @@ ${content}`;
|
|
|
66382
66467
|
if (!resolvedPath.startsWith(process.cwd())) {
|
|
66383
66468
|
throw new Error(`Access to file path "${filePath}" is restricted.`);
|
|
66384
66469
|
}
|
|
66385
|
-
const data2 = await
|
|
66470
|
+
const data2 = await readFile2(resolvedPath);
|
|
66386
66471
|
const mediaType2 = $lookup(resolvedPath) || "application/octet-stream";
|
|
66387
66472
|
return {
|
|
66388
66473
|
base64Data: data2.toString("base64"),
|
|
@@ -66479,13 +66564,10 @@ ${content}`;
|
|
|
66479
66564
|
throw error46;
|
|
66480
66565
|
}
|
|
66481
66566
|
},
|
|
66482
|
-
search:
|
|
66483
|
-
const model = options.getModel?.("search");
|
|
66484
|
-
if (!model) {
|
|
66485
|
-
throw new Error("Unable to get model for search");
|
|
66486
|
-
}
|
|
66567
|
+
search: searchModel && (async (query) => {
|
|
66487
66568
|
const resp = await generateText({
|
|
66488
|
-
model,
|
|
66569
|
+
model: searchModel,
|
|
66570
|
+
system: "You are a web search assistant. When searching for information, provide comprehensive and detailed results. Include relevant facts, statistics, dates, and key details from the search results. Synthesize information from multiple sources when available. Structure your response clearly with the most relevant information first. Reference or cite sources when presenting specific claims or data.",
|
|
66489
66571
|
tools: {
|
|
66490
66572
|
google_search: vertex.tools.googleSearch({})
|
|
66491
66573
|
},
|
|
@@ -66722,9 +66804,8 @@ class Runner {
|
|
|
66722
66804
|
wsManager;
|
|
66723
66805
|
provider;
|
|
66724
66806
|
availableTools;
|
|
66725
|
-
constructor(options) {
|
|
66807
|
+
constructor(options, config4) {
|
|
66726
66808
|
this.options = options;
|
|
66727
|
-
const config4 = loadConfig() ?? {};
|
|
66728
66809
|
this.provider = getProvider({
|
|
66729
66810
|
command: {
|
|
66730
66811
|
onStarted(command) {
|
|
@@ -66743,7 +66824,7 @@ class Runner {
|
|
|
66743
66824
|
console.log(`$ <<<< $ Command error: ${error46}`);
|
|
66744
66825
|
}
|
|
66745
66826
|
},
|
|
66746
|
-
excludeFiles: config4
|
|
66827
|
+
excludeFiles: config4?.excludeFiles
|
|
66747
66828
|
});
|
|
66748
66829
|
this.availableTools = {
|
|
66749
66830
|
[executeCommand_default.name]: executeCommand_default,
|
|
@@ -67052,7 +67133,8 @@ async function runRunner(options) {
|
|
|
67052
67133
|
console.error("Error: API URL is required.");
|
|
67053
67134
|
process.exit(1);
|
|
67054
67135
|
}
|
|
67055
|
-
const
|
|
67136
|
+
const config4 = await loadConfig();
|
|
67137
|
+
const runner = new Runner(options, config4);
|
|
67056
67138
|
runner.start();
|
|
67057
67139
|
}
|
|
67058
67140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/runner",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.64",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@ai-sdk/provider": "^2.0.0",
|
|
21
|
-
"@polka-codes/cli-shared": "0.9.
|
|
22
|
-
"@polka-codes/core": "0.9.
|
|
21
|
+
"@polka-codes/cli-shared": "0.9.63",
|
|
22
|
+
"@polka-codes/core": "0.9.63",
|
|
23
23
|
"commander": "^14.0.2",
|
|
24
24
|
"dotenv": "^17.2.3",
|
|
25
25
|
"ignore": "^7.0.5",
|