omnius 1.0.213 → 1.0.214
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 +221 -69
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4896,6 +4896,29 @@ var init_shell = __esm({
|
|
|
4896
4896
|
hasSudoPassword() {
|
|
4897
4897
|
return this._sudoPassword !== null;
|
|
4898
4898
|
}
|
|
4899
|
+
isConcurrencySafe(args) {
|
|
4900
|
+
return this.isReadOnly(args);
|
|
4901
|
+
}
|
|
4902
|
+
isReadOnly(args) {
|
|
4903
|
+
const command = String(args["command"] ?? "").trim();
|
|
4904
|
+
if (!command || args["stdin"] !== void 0)
|
|
4905
|
+
return false;
|
|
4906
|
+
const normalized = command.replace(/\s+/g, " ");
|
|
4907
|
+
if (/\bcd\b/.test(normalized))
|
|
4908
|
+
return false;
|
|
4909
|
+
if (/[<>]|\|\s*(?:tee|xargs)\b|\btee\b/.test(normalized))
|
|
4910
|
+
return false;
|
|
4911
|
+
if (/\b(?:sudo|su|rm|mv|cp|touch|mkdir|rmdir|chmod|chown|ln|truncate|dd|patch|apply_patch)\b/.test(normalized)) {
|
|
4912
|
+
return false;
|
|
4913
|
+
}
|
|
4914
|
+
if (/\bgit\s+(?:add|commit|checkout|switch|reset|clean|push|pull|merge|rebase|apply|am|stash|tag)\b/.test(normalized)) {
|
|
4915
|
+
return false;
|
|
4916
|
+
}
|
|
4917
|
+
if (/\b(?:npm|pnpm|yarn|bun)\s+(?:install|i|ci|add|remove|run|test|build)\b/.test(normalized)) {
|
|
4918
|
+
return false;
|
|
4919
|
+
}
|
|
4920
|
+
return /^(?:pwd|ls\b|find\b|rg\b|grep\b|cat\b|head\b|tail\b|wc\b|sed\s+-n\b|awk\b|git\s+(?:status|diff|log|show|branch|rev-parse|ls-files|grep)\b|which\b|command\s+-v\b|node\s+--version\b|node\s+-v\b|python(?:3)?\s+--version\b)/.test(normalized);
|
|
4921
|
+
}
|
|
4899
4922
|
async execute(args) {
|
|
4900
4923
|
const start2 = performance.now();
|
|
4901
4924
|
const command = args["command"];
|
|
@@ -6112,6 +6135,7 @@ var init_file_read = __esm({
|
|
|
6112
6135
|
];
|
|
6113
6136
|
FileReadTool = class {
|
|
6114
6137
|
name = "file_read";
|
|
6138
|
+
aliases = ["read_file", "read", "cat"];
|
|
6115
6139
|
description = "Read the contents of a file. For large files (200+ lines), returns a structural preview with signatures — use offset/limit to read specific sections.";
|
|
6116
6140
|
parameters = {
|
|
6117
6141
|
type: "object",
|
|
@@ -6127,6 +6151,12 @@ var init_file_read = __esm({
|
|
|
6127
6151
|
constructor(workingDir) {
|
|
6128
6152
|
this.workingDir = workingDir;
|
|
6129
6153
|
}
|
|
6154
|
+
isConcurrencySafe() {
|
|
6155
|
+
return true;
|
|
6156
|
+
}
|
|
6157
|
+
isReadOnly() {
|
|
6158
|
+
return true;
|
|
6159
|
+
}
|
|
6130
6160
|
/** Set actual context window size for proportional auto-windowing */
|
|
6131
6161
|
setContextWindowSize(size) {
|
|
6132
6162
|
this._contextWindowSize = size;
|
|
@@ -6662,6 +6692,7 @@ var init_grep_search = __esm({
|
|
|
6662
6692
|
MAX_OUTPUT_LINES = 100;
|
|
6663
6693
|
GrepSearchTool = class {
|
|
6664
6694
|
name = "grep_search";
|
|
6695
|
+
aliases = ["grep", "ripgrep", "search_text"];
|
|
6665
6696
|
description = "Search file contents using regex patterns. Returns matching lines with file paths and line numbers.";
|
|
6666
6697
|
parameters = {
|
|
6667
6698
|
type: "object",
|
|
@@ -6685,6 +6716,12 @@ var init_grep_search = __esm({
|
|
|
6685
6716
|
constructor(workingDir) {
|
|
6686
6717
|
this.workingDir = workingDir;
|
|
6687
6718
|
}
|
|
6719
|
+
isConcurrencySafe() {
|
|
6720
|
+
return true;
|
|
6721
|
+
}
|
|
6722
|
+
isReadOnly() {
|
|
6723
|
+
return true;
|
|
6724
|
+
}
|
|
6688
6725
|
async execute(args) {
|
|
6689
6726
|
const pattern = args["pattern"];
|
|
6690
6727
|
const searchPath = resolve4(this.workingDir, args["path"] ?? ".");
|
|
@@ -6767,6 +6804,7 @@ var init_glob_find = __esm({
|
|
|
6767
6804
|
MAX_RESULTS = 50;
|
|
6768
6805
|
GlobFindTool = class {
|
|
6769
6806
|
name = "find_files";
|
|
6807
|
+
aliases = ["glob", "find"];
|
|
6770
6808
|
description = "Find files matching a glob pattern. Returns list of matching file paths.";
|
|
6771
6809
|
parameters = {
|
|
6772
6810
|
type: "object",
|
|
@@ -6786,6 +6824,12 @@ var init_glob_find = __esm({
|
|
|
6786
6824
|
constructor(workingDir) {
|
|
6787
6825
|
this.workingDir = workingDir;
|
|
6788
6826
|
}
|
|
6827
|
+
isConcurrencySafe() {
|
|
6828
|
+
return true;
|
|
6829
|
+
}
|
|
6830
|
+
isReadOnly() {
|
|
6831
|
+
return true;
|
|
6832
|
+
}
|
|
6789
6833
|
async execute(args) {
|
|
6790
6834
|
const pattern = args["pattern"];
|
|
6791
6835
|
const searchPath = resolve5(this.workingDir, args["path"] ?? ".");
|
|
@@ -24373,6 +24417,7 @@ var init_list_directory = __esm({
|
|
|
24373
24417
|
MAX_ENTRIES = 100;
|
|
24374
24418
|
ListDirectoryTool = class {
|
|
24375
24419
|
name = "list_directory";
|
|
24420
|
+
aliases = ["ls", "dir"];
|
|
24376
24421
|
description = "List files and directories at a given path. Shows file sizes and types. Output includes full relative paths you can use directly in subsequent tool calls.";
|
|
24377
24422
|
parameters = {
|
|
24378
24423
|
type: "object",
|
|
@@ -24388,6 +24433,12 @@ var init_list_directory = __esm({
|
|
|
24388
24433
|
constructor(workingDir) {
|
|
24389
24434
|
this.workingDir = workingDir;
|
|
24390
24435
|
}
|
|
24436
|
+
isConcurrencySafe() {
|
|
24437
|
+
return true;
|
|
24438
|
+
}
|
|
24439
|
+
isReadOnly() {
|
|
24440
|
+
return true;
|
|
24441
|
+
}
|
|
24391
24442
|
async execute(args) {
|
|
24392
24443
|
const rawPath = args["path"];
|
|
24393
24444
|
const dirPath = typeof rawPath === "string" && rawPath.trim() ? rawPath : ".";
|
|
@@ -555233,7 +555284,8 @@ function partitionToolCalls(calls, readOnlyHints) {
|
|
|
555233
555284
|
const batches = [];
|
|
555234
555285
|
let currentConcurrent = [];
|
|
555235
555286
|
for (const call of calls) {
|
|
555236
|
-
|
|
555287
|
+
const safe = typeof call.concurrencySafe === "boolean" ? call.concurrencySafe : isConcurrencySafe(call.name, readOnlyHints);
|
|
555288
|
+
if (safe) {
|
|
555237
555289
|
currentConcurrent.push(call);
|
|
555238
555290
|
} else {
|
|
555239
555291
|
if (currentConcurrent.length > 0) {
|
|
@@ -555891,13 +555943,18 @@ var init_streaming_executor = __esm({
|
|
|
555891
555943
|
executeFn = null;
|
|
555892
555944
|
constructor(config) {
|
|
555893
555945
|
this.config = {
|
|
555894
|
-
maxConcurrent: config?.maxConcurrent ?? 5
|
|
555946
|
+
maxConcurrent: config?.maxConcurrent ?? 5,
|
|
555947
|
+
concurrencyResolver: config?.concurrencyResolver
|
|
555895
555948
|
};
|
|
555896
555949
|
}
|
|
555897
555950
|
/** Set the tool execution function */
|
|
555898
555951
|
setExecutor(fn) {
|
|
555899
555952
|
this.executeFn = fn;
|
|
555900
555953
|
}
|
|
555954
|
+
/** Update the parsed-input concurrency classifier. */
|
|
555955
|
+
setConcurrencyResolver(fn) {
|
|
555956
|
+
this.config.concurrencyResolver = fn;
|
|
555957
|
+
}
|
|
555901
555958
|
/** Number of tools tracked */
|
|
555902
555959
|
get size() {
|
|
555903
555960
|
return this.tools.size;
|
|
@@ -555918,7 +555975,7 @@ var init_streaming_executor = __esm({
|
|
|
555918
555975
|
name: name10,
|
|
555919
555976
|
args: partialArgs ?? {},
|
|
555920
555977
|
state: "queued",
|
|
555921
|
-
concurrencySafe:
|
|
555978
|
+
concurrencySafe: this.resolveConcurrencySafe(name10, partialArgs ?? {}),
|
|
555922
555979
|
finalized: false,
|
|
555923
555980
|
queuedAt: Date.now()
|
|
555924
555981
|
});
|
|
@@ -555933,6 +555990,7 @@ var init_streaming_executor = __esm({
|
|
|
555933
555990
|
if (!entry)
|
|
555934
555991
|
return;
|
|
555935
555992
|
entry.args = args;
|
|
555993
|
+
entry.concurrencySafe = this.resolveConcurrencySafe(entry.name, args);
|
|
555936
555994
|
entry.finalized = true;
|
|
555937
555995
|
if (entry.state === "queued") {
|
|
555938
555996
|
this.processQueue();
|
|
@@ -556030,6 +556088,15 @@ var init_streaming_executor = __esm({
|
|
|
556030
556088
|
return true;
|
|
556031
556089
|
return false;
|
|
556032
556090
|
}
|
|
556091
|
+
resolveConcurrencySafe(name10, args) {
|
|
556092
|
+
try {
|
|
556093
|
+
const resolved = this.config.concurrencyResolver?.(name10, args);
|
|
556094
|
+
if (typeof resolved === "boolean")
|
|
556095
|
+
return resolved;
|
|
556096
|
+
} catch {
|
|
556097
|
+
}
|
|
556098
|
+
return isConcurrencySafe(name10);
|
|
556099
|
+
}
|
|
556033
556100
|
entryFingerprint(entry) {
|
|
556034
556101
|
return `${entry.name}:${stableValueKey(entry.args)}`;
|
|
556035
556102
|
}
|
|
@@ -559047,6 +559114,7 @@ var init_agenticRunner = __esm({
|
|
|
559047
559114
|
skipCrossTaskHandoff: options2?.skipCrossTaskHandoff ?? false
|
|
559048
559115
|
};
|
|
559049
559116
|
this._adversaryMode = this.options.adversaryMode;
|
|
559117
|
+
this._streamingExecutor.setConcurrencyResolver((name10, args) => this.resolveToolConcurrencySafe(name10, args));
|
|
559050
559118
|
}
|
|
559051
559119
|
/** Update context window size (e.g. after querying Ollama /api/show) */
|
|
559052
559120
|
setContextWindowSize(size) {
|
|
@@ -562048,7 +562116,8 @@ ${blob}
|
|
|
562048
562116
|
return Object.entries(args ?? {}).sort(([a2], [b]) => a2.localeCompare(b)).map(([k, v]) => `${k}=${this._formatExactArgValue(v)}`).join(",");
|
|
562049
562117
|
}
|
|
562050
562118
|
_buildToolFingerprint(name10, args) {
|
|
562051
|
-
|
|
562119
|
+
const canonical = this.lookupRegisteredTool(name10)?.name ?? name10;
|
|
562120
|
+
return `${canonical}:${this._buildExactArgsKey(args)}`;
|
|
562052
562121
|
}
|
|
562053
562122
|
_dedupeToolCallsForResponse(toolCalls, turn) {
|
|
562054
562123
|
if (toolCalls.length <= 1)
|
|
@@ -562254,32 +562323,45 @@ ${blob}
|
|
|
562254
562323
|
}
|
|
562255
562324
|
/** Register a tool for the agent to use */
|
|
562256
562325
|
registerTool(tool) {
|
|
562257
|
-
if (!this.isToolAllowedByProfile(tool.name))
|
|
562326
|
+
if (!this.isToolAllowedByProfile(tool.name, tool.aliases))
|
|
562258
562327
|
return;
|
|
562259
562328
|
this.tools.set(tool.name, tool);
|
|
562260
562329
|
if (tool.name === "generate_image") {
|
|
562261
562330
|
this.maybeInstallImagePromptExpander(tool);
|
|
562262
562331
|
}
|
|
562263
562332
|
}
|
|
562264
|
-
|
|
562265
|
-
const profile = this.options.toolProfile;
|
|
562266
|
-
if (!profile)
|
|
562267
|
-
return true;
|
|
562333
|
+
toolNameVariants(name10) {
|
|
562268
562334
|
const raw = String(name10 ?? "").trim();
|
|
562335
|
+
if (!raw)
|
|
562336
|
+
return [];
|
|
562269
562337
|
const lastSegment = raw.split(/[.:/]/).filter(Boolean).pop() ?? raw;
|
|
562270
|
-
|
|
562338
|
+
return Array.from(new Set([
|
|
562271
562339
|
raw,
|
|
562272
562340
|
raw.toLowerCase(),
|
|
562341
|
+
raw.replace(/[-\s]+/g, "_"),
|
|
562273
562342
|
raw.replace(/^functions[._:-]/i, ""),
|
|
562274
562343
|
raw.replace(/^tools[._:-]/i, ""),
|
|
562275
562344
|
lastSegment,
|
|
562276
|
-
lastSegment.toLowerCase()
|
|
562277
|
-
|
|
562345
|
+
lastSegment.toLowerCase(),
|
|
562346
|
+
lastSegment.replace(/[-\s]+/g, "_")
|
|
562347
|
+
].filter(Boolean)));
|
|
562348
|
+
}
|
|
562349
|
+
isToolAllowedByProfile(name10, aliases) {
|
|
562350
|
+
const profile = this.options.toolProfile;
|
|
562351
|
+
if (!profile)
|
|
562352
|
+
return true;
|
|
562353
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
562354
|
+
for (const value2 of [name10, ...aliases ?? []]) {
|
|
562355
|
+
for (const variant of this.toolNameVariants(value2)) {
|
|
562356
|
+
candidates.add(variant);
|
|
562357
|
+
}
|
|
562358
|
+
}
|
|
562278
562359
|
const allow = Array.isArray(profile.allow) ? profile.allow.filter(Boolean) : [];
|
|
562279
|
-
if (allow.length > 0)
|
|
562280
|
-
return allow.some((toolName) => candidates.has(
|
|
562360
|
+
if (allow.length > 0) {
|
|
562361
|
+
return allow.some((toolName) => this.toolNameVariants(toolName).some((candidate) => candidates.has(candidate)));
|
|
562362
|
+
}
|
|
562281
562363
|
const deny = Array.isArray(profile.deny) ? profile.deny.filter(Boolean) : [];
|
|
562282
|
-
return !deny.some((toolName) => candidates.has(
|
|
562364
|
+
return !deny.some((toolName) => this.toolNameVariants(toolName).some((candidate) => candidates.has(candidate)));
|
|
562283
562365
|
}
|
|
562284
562366
|
toolProfileDenial(name10) {
|
|
562285
562367
|
const profileName = this.options.toolProfile?.name || "active tool profile";
|
|
@@ -562357,20 +562439,14 @@ Rewrite it now for ${ctx3.model}.`;
|
|
|
562357
562439
|
const direct = this.tools.get(raw);
|
|
562358
562440
|
if (direct)
|
|
562359
562441
|
return { name: raw, tool: direct };
|
|
562360
|
-
const
|
|
562361
|
-
const candidates = /* @__PURE__ */ new Set([
|
|
562362
|
-
raw,
|
|
562363
|
-
raw.toLowerCase(),
|
|
562364
|
-
raw.replace(/[-\s]+/g, "_"),
|
|
562365
|
-
raw.replace(/^functions[._:-]/i, ""),
|
|
562366
|
-
raw.replace(/^tools[._:-]/i, ""),
|
|
562367
|
-
lastSegment,
|
|
562368
|
-
lastSegment.toLowerCase(),
|
|
562369
|
-
lastSegment.replace(/[-\s]+/g, "_")
|
|
562370
|
-
]);
|
|
562442
|
+
const candidates = new Set(this.toolNameVariants(raw));
|
|
562371
562443
|
const lowerIndex = /* @__PURE__ */ new Map();
|
|
562372
|
-
for (const registeredName of this.tools
|
|
562373
|
-
|
|
562444
|
+
for (const [registeredName, tool] of this.tools) {
|
|
562445
|
+
for (const value2 of [registeredName, ...tool.aliases ?? []]) {
|
|
562446
|
+
for (const variant of this.toolNameVariants(value2)) {
|
|
562447
|
+
lowerIndex.set(variant.toLowerCase(), registeredName);
|
|
562448
|
+
}
|
|
562449
|
+
}
|
|
562374
562450
|
}
|
|
562375
562451
|
for (const candidate of candidates) {
|
|
562376
562452
|
const exact = this.tools.get(candidate);
|
|
@@ -562382,8 +562458,47 @@ Rewrite it now for ${ctx3.model}.`;
|
|
|
562382
562458
|
}
|
|
562383
562459
|
return null;
|
|
562384
562460
|
}
|
|
562461
|
+
resolveToolConcurrencySafe(name10, args) {
|
|
562462
|
+
const resolved = this.lookupRegisteredTool(name10);
|
|
562463
|
+
const tool = resolved?.tool;
|
|
562464
|
+
try {
|
|
562465
|
+
if (typeof tool?.isConcurrencySafe === "function") {
|
|
562466
|
+
return !!tool.isConcurrencySafe(args);
|
|
562467
|
+
}
|
|
562468
|
+
if (typeof tool?.isReadOnly === "function") {
|
|
562469
|
+
return !!tool.isReadOnly(args);
|
|
562470
|
+
}
|
|
562471
|
+
} catch {
|
|
562472
|
+
}
|
|
562473
|
+
return isConcurrencySafe(resolved?.name ?? name10);
|
|
562474
|
+
}
|
|
562475
|
+
toolResultMaxSize(tool) {
|
|
562476
|
+
const max = tool?.maxResultSizeChars;
|
|
562477
|
+
return typeof max === "number" && Number.isFinite(max) && max > 0 ? max : void 0;
|
|
562478
|
+
}
|
|
562479
|
+
applyRegisteredToolResultTriage(result, toolName, tool) {
|
|
562480
|
+
return applyToolResultTriage(result, {
|
|
562481
|
+
workingDir: this._workingDirectory || process.cwd(),
|
|
562482
|
+
toolName,
|
|
562483
|
+
maxOutputSize: this.toolResultMaxSize(tool)
|
|
562484
|
+
});
|
|
562485
|
+
}
|
|
562486
|
+
async validateToolInput(tool, args, toolName) {
|
|
562487
|
+
if (typeof tool.validateInput !== "function")
|
|
562488
|
+
return null;
|
|
562489
|
+
const validation = await tool.validateInput(args, {
|
|
562490
|
+
toolName,
|
|
562491
|
+
workingDir: this._workingDirectory || process.cwd()
|
|
562492
|
+
});
|
|
562493
|
+
if (validation?.result === true)
|
|
562494
|
+
return null;
|
|
562495
|
+
if (validation?.result === false) {
|
|
562496
|
+
return validation.message || "custom validation failed";
|
|
562497
|
+
}
|
|
562498
|
+
return null;
|
|
562499
|
+
}
|
|
562385
562500
|
unknownToolError(name10) {
|
|
562386
|
-
const names = Array.from(this.tools.
|
|
562501
|
+
const names = Array.from(this.tools.values()).map((tool) => tool.aliases?.length ? `${tool.name} (aliases: ${tool.aliases.join("|")})` : tool.name).sort();
|
|
562387
562502
|
const preview = names.slice(0, 80).join(", ");
|
|
562388
562503
|
const suffix = names.length > 80 ? `, ... ${names.length - 80} more` : "";
|
|
562389
562504
|
return `Unknown tool: ${name10}. Registered tools (${names.length}): ${preview}${suffix}`;
|
|
@@ -562397,6 +562512,7 @@ Rewrite it now for ${ctx3.model}.`;
|
|
|
562397
562512
|
for (const t2 of this.tools.values()) {
|
|
562398
562513
|
list.push({
|
|
562399
562514
|
name: t2.name,
|
|
562515
|
+
...t2.aliases?.length ? { aliases: t2.aliases } : {},
|
|
562400
562516
|
description: t2.description,
|
|
562401
562517
|
parameters: t2.parameters
|
|
562402
562518
|
});
|
|
@@ -562408,10 +562524,10 @@ Rewrite it now for ${ctx3.model}.`;
|
|
|
562408
562524
|
* Validates against inputSchema if present and returns the tool result.
|
|
562409
562525
|
*/
|
|
562410
562526
|
async runToolByName(name10, args) {
|
|
562411
|
-
|
|
562527
|
+
const resolved = this.lookupRegisteredTool(name10);
|
|
562528
|
+
if (!this.isToolAllowedByProfile(resolved?.name ?? name10, resolved?.tool.aliases)) {
|
|
562412
562529
|
return this.toolProfileDenial(name10);
|
|
562413
562530
|
}
|
|
562414
|
-
const resolved = this.lookupRegisteredTool(name10);
|
|
562415
562531
|
if (!resolved) {
|
|
562416
562532
|
return { success: false, output: "", error: this.unknownToolError(name10) };
|
|
562417
562533
|
}
|
|
@@ -562427,12 +562543,17 @@ Rewrite it now for ${ctx3.model}.`;
|
|
|
562427
562543
|
error: `Invalid args for ${resolved.name}: ${e2?.message || String(e2)}`
|
|
562428
562544
|
};
|
|
562429
562545
|
}
|
|
562546
|
+
const validationError = await this.validateToolInput(tool, args, resolved.name);
|
|
562547
|
+
if (validationError) {
|
|
562548
|
+
return {
|
|
562549
|
+
success: false,
|
|
562550
|
+
output: "",
|
|
562551
|
+
error: `Invalid args for ${resolved.name}: ${validationError}. Check the parameter values and try again.`
|
|
562552
|
+
};
|
|
562553
|
+
}
|
|
562430
562554
|
try {
|
|
562431
562555
|
const result = await tool.execute(args);
|
|
562432
|
-
return
|
|
562433
|
-
workingDir: this._workingDirectory || process.cwd(),
|
|
562434
|
-
toolName: tool.name ?? "tool"
|
|
562435
|
-
});
|
|
562556
|
+
return this.applyRegisteredToolResultTriage(result, resolved.name, tool);
|
|
562436
562557
|
} catch (e2) {
|
|
562437
562558
|
return { success: false, output: "", error: e2?.message || String(e2) };
|
|
562438
562559
|
}
|
|
@@ -564804,19 +564925,17 @@ ${memoryLines.join("\n")}`
|
|
|
564804
564925
|
if (jsonMatch) {
|
|
564805
564926
|
try {
|
|
564806
564927
|
const parsed = JSON.parse(jsonMatch[1]);
|
|
564807
|
-
|
|
564808
|
-
|
|
564928
|
+
const resolvedParsedTool = parsed.tool ? this.lookupRegisteredTool(parsed.tool) : null;
|
|
564929
|
+
if (parsed.tool && resolvedParsedTool) {
|
|
564930
|
+
const tool = resolvedParsedTool.tool;
|
|
564809
564931
|
const rawResult = await tool.execute(parsed.args ?? {});
|
|
564810
|
-
const result =
|
|
564811
|
-
workingDir: this._workingDirectory || process.cwd(),
|
|
564812
|
-
toolName: parsed.tool
|
|
564813
|
-
});
|
|
564932
|
+
const result = this.applyRegisteredToolResultTriage(rawResult, resolvedParsedTool.name, tool);
|
|
564814
564933
|
messages2.push({ role: "assistant", content });
|
|
564815
564934
|
messages2.push({
|
|
564816
564935
|
role: "user",
|
|
564817
564936
|
content: `Tool result (${parsed.tool}): ${result.output.slice(0, 2e3)}`
|
|
564818
564937
|
});
|
|
564819
|
-
if (
|
|
564938
|
+
if (resolvedParsedTool.name === "task_complete") {
|
|
564820
564939
|
completed = true;
|
|
564821
564940
|
summary = String(parsed.args?.summary ?? content);
|
|
564822
564941
|
}
|
|
@@ -565473,6 +565592,9 @@ Corrective action: try a different approach first: read relevant files, adjust a
|
|
|
565473
565592
|
}
|
|
565474
565593
|
}
|
|
565475
565594
|
}
|
|
565595
|
+
if (!validationError) {
|
|
565596
|
+
validationError = await this.validateToolInput(tool, tc.arguments, resolvedTool?.name ?? tc.name);
|
|
565597
|
+
}
|
|
565476
565598
|
if (validationError) {
|
|
565477
565599
|
result = {
|
|
565478
565600
|
success: false,
|
|
@@ -565561,10 +565683,7 @@ Corrective action: try a different approach first: read relevant files, adjust a
|
|
|
565561
565683
|
} else {
|
|
565562
565684
|
result = await tool.execute(finalArgs);
|
|
565563
565685
|
}
|
|
565564
|
-
result =
|
|
565565
|
-
workingDir: this._workingDirectory || process.cwd(),
|
|
565566
|
-
toolName: tc.name
|
|
565567
|
-
});
|
|
565686
|
+
result = this.applyRegisteredToolResultTriage(result, resolvedTool?.name ?? tc.name, tool);
|
|
565568
565687
|
if (tc.name === "shell" && result.success === true) {
|
|
565569
565688
|
const semanticErr = this._detectSemanticShellFailure(result.output ?? "");
|
|
565570
565689
|
if (semanticErr) {
|
|
@@ -566808,10 +566927,8 @@ Then use file_read on individual FILES inside it.`);
|
|
|
566808
566927
|
await this._streamingExecutor.waitAll();
|
|
566809
566928
|
const streamResults = this._streamingExecutor.drainCompleted();
|
|
566810
566929
|
for (const sr of streamResults) {
|
|
566811
|
-
|
|
566812
|
-
|
|
566813
|
-
toolName: sr.name
|
|
566814
|
-
});
|
|
566930
|
+
const resolvedStreamTool = this.lookupRegisteredTool(sr.name);
|
|
566931
|
+
sr.result = this.applyRegisteredToolResultTriage(sr.result, resolvedStreamTool?.name ?? sr.name, resolvedStreamTool?.tool);
|
|
566815
566932
|
}
|
|
566816
566933
|
const handledIds = /* @__PURE__ */ new Set();
|
|
566817
566934
|
for (const sr of streamResults) {
|
|
@@ -566928,7 +567045,8 @@ ${sr.result.output}`;
|
|
|
566928
567045
|
const batchToolCalls = rawToolCalls.map((tc) => ({
|
|
566929
567046
|
name: tc.name,
|
|
566930
567047
|
args: tc.arguments,
|
|
566931
|
-
id: tc.id
|
|
567048
|
+
id: tc.id,
|
|
567049
|
+
concurrencySafe: this.resolveToolConcurrencySafe(tc.name, tc.arguments)
|
|
566932
567050
|
}));
|
|
566933
567051
|
const batches = partitionToolCalls(batchToolCalls);
|
|
566934
567052
|
for (const batch2 of batches) {
|
|
@@ -567206,6 +567324,9 @@ Call task_complete(summary="...") NOW with whatever you have.`
|
|
|
567206
567324
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
567207
567325
|
});
|
|
567208
567326
|
}
|
|
567327
|
+
const pendingBeforeAdversary = this.pendingUserMessages.length;
|
|
567328
|
+
this.adversaryObserve(messages2, turn);
|
|
567329
|
+
const adversaryAddedGuidance = this.pendingUserMessages.length > pendingBeforeAdversary;
|
|
567209
567330
|
if (/task.?complete|all tests pass/i.test(content)) {
|
|
567210
567331
|
const completionArgs = { summary: content };
|
|
567211
567332
|
if (holdNoProgressTaskComplete(completionArgs, turn) || holdProvenanceTaskComplete(completionArgs, turn)) {
|
|
@@ -567321,6 +567442,12 @@ Your most recent tool calls SUCCEEDED. If the task is complete, call task_comple
|
|
|
567321
567442
|
content: "Continue working. Use tools to read files, make changes, and run validation. Call task_complete when done."
|
|
567322
567443
|
});
|
|
567323
567444
|
}
|
|
567445
|
+
if (adversaryAddedGuidance) {
|
|
567446
|
+
while (this.pendingUserMessages.length > 0) {
|
|
567447
|
+
const userMsg = this.pendingUserMessages.shift();
|
|
567448
|
+
await this.appendInjectedUserMessage(userMsg, messages2, turn);
|
|
567449
|
+
}
|
|
567450
|
+
}
|
|
567324
567451
|
}
|
|
567325
567452
|
try {
|
|
567326
567453
|
const turnLogTail = toolCallLog.filter((t2) => t2.turn === turn || t2.turn === void 0);
|
|
@@ -567659,10 +567786,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
567659
567786
|
} else {
|
|
567660
567787
|
try {
|
|
567661
567788
|
result = await tool.execute(tc.arguments);
|
|
567662
|
-
result =
|
|
567663
|
-
workingDir: this._workingDirectory || process.cwd(),
|
|
567664
|
-
toolName: tc.name
|
|
567665
|
-
});
|
|
567789
|
+
result = this.applyRegisteredToolResultTriage(result, resolvedTool?.name ?? tc.name, tool);
|
|
567666
567790
|
} catch (err) {
|
|
567667
567791
|
result = {
|
|
567668
567792
|
success: false,
|
|
@@ -567681,10 +567805,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
567681
567805
|
if (pw2 && tool) {
|
|
567682
567806
|
try {
|
|
567683
567807
|
result = await tool.execute(tc.arguments);
|
|
567684
|
-
result =
|
|
567685
|
-
workingDir: this._workingDirectory || process.cwd(),
|
|
567686
|
-
toolName: tc.name
|
|
567687
|
-
});
|
|
567808
|
+
result = this.applyRegisteredToolResultTriage(result, resolvedTool?.name ?? tc.name, tool);
|
|
567688
567809
|
} catch (err) {
|
|
567689
567810
|
result = {
|
|
567690
567811
|
success: false,
|
|
@@ -569969,8 +570090,6 @@ ${trimmedNew}`;
|
|
|
569969
570090
|
* that already succeeded, the adversary nudges it to move on.
|
|
569970
570091
|
*/
|
|
569971
570092
|
adversaryObserve(messages2, turn) {
|
|
569972
|
-
if (this.options.modelTier === "large")
|
|
569973
|
-
return;
|
|
569974
570093
|
const recent = messages2.slice(-6);
|
|
569975
570094
|
for (const msg of recent) {
|
|
569976
570095
|
if (msg.role === "tool" && typeof msg.content === "string") {
|
|
@@ -569997,10 +570116,16 @@ ${trimmedNew}`;
|
|
|
569997
570116
|
}
|
|
569998
570117
|
const argsKey = toolArgs ? this._buildExactArgsKey(toolArgs) : void 0;
|
|
569999
570118
|
const fingerprint = toolArgs ? this._buildToolFingerprint(toolName, toolArgs) : void 0;
|
|
570000
|
-
|
|
570119
|
+
const alreadySeen = this._adversaryToolOutcomes.some((o2) => {
|
|
570120
|
+
if (msg.tool_call_id && o2.toolCallId === msg.tool_call_id)
|
|
570121
|
+
return true;
|
|
570122
|
+
return o2.turn === turn && o2.tool === toolName && o2.fingerprint === fingerprint;
|
|
570123
|
+
});
|
|
570124
|
+
if (!alreadySeen) {
|
|
570001
570125
|
this._adversaryToolOutcomes.push({
|
|
570002
570126
|
turn,
|
|
570003
570127
|
tool: toolName,
|
|
570128
|
+
toolCallId: msg.tool_call_id,
|
|
570004
570129
|
argsKey,
|
|
570005
570130
|
fingerprint,
|
|
570006
570131
|
succeeded,
|
|
@@ -570085,7 +570210,8 @@ ${input.alternatives.map((item) => `- ${item}`).join("\n")}` : "";
|
|
|
570085
570210
|
}
|
|
570086
570211
|
}
|
|
570087
570212
|
if (this.options.disableAdversaryCritic !== true) {
|
|
570088
|
-
const
|
|
570213
|
+
const newestAssistant = [...recent].reverse().find((m2) => m2.role === "assistant");
|
|
570214
|
+
const lastToolCalls = newestAssistant?.tool_calls ?? [];
|
|
570089
570215
|
for (const tc of lastToolCalls) {
|
|
570090
570216
|
const name10 = tc.function.name;
|
|
570091
570217
|
if (this._isStatefulBrowserTool(name10))
|
|
@@ -571193,6 +571319,7 @@ ${transcript}`
|
|
|
571193
571319
|
}
|
|
571194
571320
|
}
|
|
571195
571321
|
const getDesc = (tool) => dynamicDescs.get(tool.name) ?? tool.description;
|
|
571322
|
+
const aliasText = (tool) => Array.isArray(tool.aliases) && tool.aliases.length > 0 ? ` aliases:${tool.aliases.join(",")}` : "";
|
|
571196
571323
|
const getCustomToolMetadata = (tool) => {
|
|
571197
571324
|
const meta = tool.customToolMetadata;
|
|
571198
571325
|
return meta?.isCustomTool === true ? meta : void 0;
|
|
@@ -571229,7 +571356,7 @@ Example: ${tool.name}(${JSON.stringify(meta.examples[0].args ?? {})})` : "";
|
|
|
571229
571356
|
};
|
|
571230
571357
|
const getIndexLabel = (tool) => {
|
|
571231
571358
|
const meta = getCustomToolMetadata(tool);
|
|
571232
|
-
const desc = `${getDesc(tool)} ${customToolSearchText(tool)}`.toLowerCase().replace(/[`"'()[\]{}:;,.!?/\\|-]+/g, " ");
|
|
571359
|
+
const desc = `${getDesc(tool)} ${aliasText(tool)} ${customToolSearchText(tool)}`.toLowerCase().replace(/[`"'()[\]{}:;,.!?/\\|-]+/g, " ");
|
|
571233
571360
|
const keywords2 = Array.from(new Set(desc.split(/\s+/).filter((word2) => word2.length > 2 && !STOPWORDS3.has(word2) && !tool.name.toLowerCase().includes(word2)))).slice(0, 4);
|
|
571234
571361
|
const base3 = keywords2.length > 0 ? `${tool.name}(${keywords2.join(",")})` : tool.name;
|
|
571235
571362
|
if (!meta)
|
|
@@ -571263,7 +571390,7 @@ Example: ${tool.name}(${JSON.stringify(meta.examples[0].args ?? {})})` : "";
|
|
|
571263
571390
|
if (CORE_TOOLS3.has(tool.name))
|
|
571264
571391
|
continue;
|
|
571265
571392
|
const customMeta = getCustomToolMetadata(tool);
|
|
571266
|
-
const toolText = `${tool.name} ${getDesc(tool)} ${customToolSearchText(tool)}`.toLowerCase();
|
|
571393
|
+
const toolText = `${tool.name} ${aliasText(tool)} ${getDesc(tool)} ${customToolSearchText(tool)}`.toLowerCase();
|
|
571267
571394
|
const toolWords = toolText.split(/\s+/).filter((w) => w.length > 2);
|
|
571268
571395
|
let score = 0;
|
|
571269
571396
|
for (const tw of toolWords) {
|
|
@@ -571274,7 +571401,7 @@ Example: ${tool.name}(${JSON.stringify(meta.examples[0].args ?? {})})` : "";
|
|
|
571274
571401
|
score += 1;
|
|
571275
571402
|
}
|
|
571276
571403
|
}
|
|
571277
|
-
if (taskText.includes(tool.name.replace(/_/g, " ")) || taskText.includes(tool.name)) {
|
|
571404
|
+
if (taskText.includes(tool.name.replace(/_/g, " ")) || taskText.includes(tool.name) || (tool.aliases ?? []).some((alias) => taskText.includes(alias.toLowerCase()))) {
|
|
571278
571405
|
score += customMeta ? 16 : 10;
|
|
571279
571406
|
}
|
|
571280
571407
|
if (wants3dModelGeneration) {
|
|
@@ -571427,6 +571554,9 @@ ${catalog}`,
|
|
|
571427
571554
|
continue;
|
|
571428
571555
|
lines.push("");
|
|
571429
571556
|
lines.push(`## ${tool.name}`);
|
|
571557
|
+
if (tool.aliases?.length) {
|
|
571558
|
+
lines.push(`Aliases: ${tool.aliases.join(", ")}`);
|
|
571559
|
+
}
|
|
571430
571560
|
lines.push(`${getDesc(tool)}${customToolDetails(tool)}`);
|
|
571431
571561
|
lines.push(`Parameters: ${JSON.stringify(tool.parameters)}`);
|
|
571432
571562
|
}
|
|
@@ -571439,7 +571569,7 @@ ${catalog}`,
|
|
|
571439
571569
|
}
|
|
571440
571570
|
return { success: true, output: lines.join("\n") };
|
|
571441
571571
|
}
|
|
571442
|
-
const matches = deferred.filter((t2) => t2.name.toLowerCase().includes(query) || getDesc(t2).toLowerCase().includes(query) || customToolSearchText(t2).toLowerCase().includes(query)).sort((a2, b) => {
|
|
571572
|
+
const matches = deferred.filter((t2) => t2.name.toLowerCase().includes(query) || (t2.aliases ?? []).some((alias) => alias.toLowerCase().includes(query)) || getDesc(t2).toLowerCase().includes(query) || customToolSearchText(t2).toLowerCase().includes(query)).sort((a2, b) => {
|
|
571443
571573
|
const scoreTool = (tool) => {
|
|
571444
571574
|
const meta = getCustomToolMetadata(tool);
|
|
571445
571575
|
let score = 0;
|
|
@@ -571447,6 +571577,10 @@ ${catalog}`,
|
|
|
571447
571577
|
score += 30;
|
|
571448
571578
|
if (tool.name.toLowerCase().includes(query))
|
|
571449
571579
|
score += 10;
|
|
571580
|
+
if ((tool.aliases ?? []).some((alias) => alias.toLowerCase() === query))
|
|
571581
|
+
score += 24;
|
|
571582
|
+
if ((tool.aliases ?? []).some((alias) => alias.toLowerCase().includes(query)))
|
|
571583
|
+
score += 8;
|
|
571450
571584
|
if (getDesc(tool).toLowerCase().includes(query))
|
|
571451
571585
|
score += 4;
|
|
571452
571586
|
if (customToolSearchText(tool).toLowerCase().includes(query))
|
|
@@ -571477,7 +571611,9 @@ ${catalog}`,
|
|
|
571477
571611
|
activatedToolsRef.add(t2.name);
|
|
571478
571612
|
const result = matches.map((t2) => {
|
|
571479
571613
|
const paramsStr = JSON.stringify(t2.parameters, null, 2);
|
|
571480
|
-
|
|
571614
|
+
const aliases = t2.aliases?.length ? `
|
|
571615
|
+
Aliases: ${t2.aliases.join(", ")}` : "";
|
|
571616
|
+
return `## ${t2.name}${aliases}
|
|
571481
571617
|
${getDesc(t2)}${customToolDetails(t2)}
|
|
571482
571618
|
|
|
571483
571619
|
Parameters:
|
|
@@ -681081,15 +681217,31 @@ function adaptTool6(tool) {
|
|
|
681081
681217
|
}
|
|
681082
681218
|
return {
|
|
681083
681219
|
name: tool.name,
|
|
681220
|
+
aliases: tool.aliases,
|
|
681084
681221
|
description: tool.description,
|
|
681085
681222
|
parameters: tool.parameters,
|
|
681223
|
+
inputSchema: tool.inputSchema,
|
|
681224
|
+
prompt: tool.prompt,
|
|
681225
|
+
executeStream: tool.executeStream,
|
|
681226
|
+
validateInput: tool.validateInput,
|
|
681227
|
+
isConcurrencySafe: tool.isConcurrencySafe,
|
|
681228
|
+
isReadOnly: tool.isReadOnly,
|
|
681229
|
+
maxResultSizeChars: tool.maxResultSizeChars,
|
|
681086
681230
|
async execute(args) {
|
|
681087
681231
|
const result = await tool.execute(args);
|
|
681088
681232
|
return {
|
|
681089
681233
|
success: result.success,
|
|
681090
681234
|
output: result.output,
|
|
681091
681235
|
error: result.error,
|
|
681092
|
-
llmContent: result.llmContent
|
|
681236
|
+
llmContent: result.llmContent,
|
|
681237
|
+
mutated: result.mutated,
|
|
681238
|
+
mutatedFiles: result.mutatedFiles,
|
|
681239
|
+
diff: result.diff,
|
|
681240
|
+
dryRun: result.dryRun,
|
|
681241
|
+
noop: result.noop,
|
|
681242
|
+
partial: result.partial,
|
|
681243
|
+
beforeHash: result.beforeHash,
|
|
681244
|
+
afterHash: result.afterHash
|
|
681093
681245
|
};
|
|
681094
681246
|
}
|
|
681095
681247
|
};
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.214",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.214",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED