omnius 1.0.303 → 1.0.304

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 CHANGED
@@ -570676,6 +570676,134 @@ Rewrite it now for ${ctx3.model}.`;
570676
570676
  }
570677
570677
  return null;
570678
570678
  }
570679
+ buildToolArgumentRepairFeedback(toolName, args, tool, validationError) {
570680
+ const parameters = tool.parameters ?? {};
570681
+ const props = this.schemaProperties(parameters);
570682
+ const required = this.schemaRequired(parameters);
570683
+ const providedKeys = Object.keys(args ?? {}).filter((key) => !key.startsWith("_"));
570684
+ const missingRequired = required.filter((field) => args[field] === void 0 || args[field] === null);
570685
+ const unknownKeys = providedKeys.filter((key) => !props.has(key));
570686
+ const aliases = this.suggestArgumentAliases(missingRequired, providedKeys, args, props);
570687
+ const corrected = this.buildCorrectedArgsPreview(args, props, aliases);
570688
+ const siblingMatches = this.findSiblingToolSchemaMatches(toolName, providedKeys);
570689
+ const lines = [
570690
+ `[RUNTIME TOOL ARGUMENT REPAIR]`,
570691
+ `Tool call failed before execution: ${toolName}`,
570692
+ `Validation error: ${validationError}`
570693
+ ];
570694
+ if (required.length > 0) {
570695
+ lines.push(`Required keys for ${toolName}: ${required.join(", ")}`);
570696
+ }
570697
+ if (providedKeys.length > 0) {
570698
+ lines.push(`Provided keys: ${providedKeys.join(", ")}`);
570699
+ }
570700
+ if (unknownKeys.length > 0) {
570701
+ lines.push(`Keys not accepted by ${toolName}: ${unknownKeys.join(", ")}`);
570702
+ }
570703
+ if (aliases.length > 0) {
570704
+ for (const alias of aliases) {
570705
+ lines.push(`Repair: use \`${alias.to}\` instead of \`${alias.from}\` for ${toolName}.`);
570706
+ }
570707
+ lines.push(`Corrected argument shape: ${JSON.stringify(corrected)}`);
570708
+ } else if (missingRequired.length > 0) {
570709
+ lines.push(`Repair: include missing required key(s): ${missingRequired.join(", ")}.`);
570710
+ }
570711
+ if (siblingMatches.length > 0) {
570712
+ lines.push(`Schema mismatch hint: these arguments match ${siblingMatches.map((name10) => `\`${name10}\``).join(", ")} better than \`${toolName}\`. Either call the matching tool, or rewrite the arguments to the ${toolName} schema.`);
570713
+ }
570714
+ lines.push(`Do not repeat ${toolName} with the same invalid key set. The previous call did not reach the tool implementation.`);
570715
+ const systemGuidance = lines.join("\n");
570716
+ return {
570717
+ error: `Invalid arguments for ${toolName}: ${validationError}. Runtime repair guidance was injected for the next turn.`,
570718
+ llmContent: systemGuidance,
570719
+ systemGuidance
570720
+ };
570721
+ }
570722
+ schemaProperties(parameters) {
570723
+ const raw = parameters.properties;
570724
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
570725
+ return /* @__PURE__ */ new Set();
570726
+ }
570727
+ return new Set(Object.keys(raw));
570728
+ }
570729
+ schemaRequired(parameters) {
570730
+ const raw = parameters.required;
570731
+ return Array.isArray(raw) ? raw.filter((item) => typeof item === "string") : [];
570732
+ }
570733
+ suggestArgumentAliases(missingRequired, providedKeys, args, acceptedKeys) {
570734
+ const suggestions = [];
570735
+ const provided = new Set(providedKeys);
570736
+ const aliasMap = {
570737
+ task: ["prompt", "description", "message", "query", "input", "instructions"],
570738
+ prompt: ["task", "message", "query", "input", "text", "instructions"],
570739
+ background: ["run_in_background", "background_run", "async"],
570740
+ run_in_background: ["background", "background_run", "async"],
570741
+ max_turns: ["maxTurns", "turns"],
570742
+ timeout_ms: ["timeoutMs", "timeout"],
570743
+ path: ["file", "filepath", "file_path", "filename"],
570744
+ command: ["cmd", "shell_command"],
570745
+ query: ["prompt", "task", "message", "input", "text"]
570746
+ };
570747
+ for (const required of missingRequired) {
570748
+ for (const alias of aliasMap[required] ?? []) {
570749
+ if (provided.has(alias) && args[alias] !== void 0) {
570750
+ suggestions.push({ from: alias, to: required });
570751
+ break;
570752
+ }
570753
+ }
570754
+ }
570755
+ for (const key of providedKeys) {
570756
+ if (acceptedKeys.has(key))
570757
+ continue;
570758
+ for (const accepted of acceptedKeys) {
570759
+ const aliases = aliasMap[accepted] ?? [];
570760
+ if (aliases.includes(key) && args[key] !== void 0) {
570761
+ if (!suggestions.some((s2) => s2.from === key && s2.to === accepted)) {
570762
+ suggestions.push({ from: key, to: accepted });
570763
+ }
570764
+ break;
570765
+ }
570766
+ }
570767
+ }
570768
+ return suggestions;
570769
+ }
570770
+ buildCorrectedArgsPreview(args, acceptedKeys, aliases) {
570771
+ const corrected = {};
570772
+ for (const [key, value2] of Object.entries(args ?? {})) {
570773
+ if (acceptedKeys.has(key))
570774
+ corrected[key] = value2;
570775
+ }
570776
+ for (const alias of aliases) {
570777
+ if (corrected[alias.to] === void 0 && args[alias.from] !== void 0) {
570778
+ corrected[alias.to] = args[alias.from];
570779
+ }
570780
+ }
570781
+ return corrected;
570782
+ }
570783
+ findSiblingToolSchemaMatches(requestedToolName, providedKeys) {
570784
+ if (providedKeys.length === 0)
570785
+ return [];
570786
+ const provided = new Set(providedKeys);
570787
+ const matches = [];
570788
+ for (const candidate of this.tools.values()) {
570789
+ if (candidate.name === requestedToolName)
570790
+ continue;
570791
+ const props = this.schemaProperties(candidate.parameters ?? {});
570792
+ if (props.size === 0)
570793
+ continue;
570794
+ const required = this.schemaRequired(candidate.parameters ?? {});
570795
+ const matched = providedKeys.filter((key) => props.has(key)).length;
570796
+ if (matched === 0)
570797
+ continue;
570798
+ const requiredPresent = required.filter((key) => provided.has(key)).length;
570799
+ const requiredSatisfied = required.length === 0 || requiredPresent === required.length;
570800
+ const score = matched * 2 + requiredPresent * 3 + (requiredSatisfied ? 3 : 0) - Math.max(0, required.length - requiredPresent);
570801
+ if (score >= 5 || matched >= 2 && requiredSatisfied) {
570802
+ matches.push({ name: candidate.name, score });
570803
+ }
570804
+ }
570805
+ return matches.sort((a2, b) => b.score - a2.score).slice(0, 3).map((match) => match.name);
570806
+ }
570679
570807
  unknownToolError(name10) {
570680
570808
  const names = Array.from(this.tools.values()).map((tool) => tool.aliases?.length ? `${tool.name} (aliases: ${tool.aliases.join("|")})` : tool.name).sort();
570681
570809
  const preview = names.slice(0, 80).join(", ");
@@ -574012,6 +574140,7 @@ Corrective action: try a different approach first: read relevant files, adjust a
574012
574140
  const resolvedTool = this.lookupRegisteredTool(tc.name);
574013
574141
  const tool = resolvedTool?.tool;
574014
574142
  let result;
574143
+ let runtimeSystemGuidance = null;
574015
574144
  if (repeatShortCircuit) {
574016
574145
  result = repeatShortCircuit;
574017
574146
  } else if (tc.arguments && "_raw" in tc.arguments) {
@@ -574046,10 +574175,14 @@ Corrective action: try a different approach first: read relevant files, adjust a
574046
574175
  validationError = await this.validateToolInput(tool, tc.arguments, resolvedTool?.name ?? tc.name);
574047
574176
  }
574048
574177
  if (validationError) {
574178
+ const repair = this.buildToolArgumentRepairFeedback(tc.name, tc.arguments, tool, validationError);
574179
+ runtimeSystemGuidance = repair.systemGuidance;
574049
574180
  result = {
574050
574181
  success: false,
574051
574182
  output: "",
574052
- error: `Invalid arguments for ${tc.name}: ${validationError}. Check the parameter types and try again.`
574183
+ error: repair.error,
574184
+ llmContent: repair.llmContent,
574185
+ runtimeAuthored: true
574053
574186
  };
574054
574187
  } else {
574055
574188
  const violations = checkConstraints(tc.name, tc.arguments);
@@ -575402,7 +575535,12 @@ Then use file_read on individual FILES inside it.`);
575402
575535
  outputPreview: (result.output ?? result.error ?? "").toString().slice(0, 500),
575403
575536
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
575404
575537
  });
575405
- return { tc, output, success: result.success };
575538
+ return {
575539
+ tc,
575540
+ output,
575541
+ success: result.success,
575542
+ ...runtimeSystemGuidance ? { systemGuidance: runtimeSystemGuidance } : {}
575543
+ };
575406
575544
  };
575407
575545
  const rawToolCalls = msg.toolCalls;
575408
575546
  if (this.options.streamEnabled && this._streamingExecutor.hasTools) {
@@ -575436,7 +575574,8 @@ Then use file_read on individual FILES inside it.`);
575436
575574
  return {
575437
575575
  success: r2.success,
575438
575576
  output: r2.output,
575439
- error: r2.success ? void 0 : r2.output
575577
+ error: r2.success ? void 0 : r2.output,
575578
+ systemGuidance: r2.systemGuidance
575440
575579
  };
575441
575580
  })();
575442
575581
  streamFpInFlight.set(_fp, _run);
@@ -575524,6 +575663,12 @@ ${sr.result.output}`;
575524
575663
  const r2 = await executeSingle(tc);
575525
575664
  if (r2) {
575526
575665
  messages2.push(this.buildToolMessage(r2.output, r2.tc.id, r2.tc.name));
575666
+ if (r2.systemGuidance) {
575667
+ messages2.push({
575668
+ role: "system",
575669
+ content: r2.systemGuidance
575670
+ });
575671
+ }
575527
575672
  if (r2.tc.name === "task_complete") {
575528
575673
  if (!r2.success) {
575529
575674
  messages2.push({
@@ -575629,6 +575774,12 @@ ${sr.result.output}`;
575629
575774
  for (const r2 of results) {
575630
575775
  if (r2) {
575631
575776
  messages2.push(this.buildToolMessage(r2.output, r2.tc.id, r2.tc.name));
575777
+ if (r2.systemGuidance) {
575778
+ messages2.push({
575779
+ role: "system",
575780
+ content: r2.systemGuidance
575781
+ });
575782
+ }
575632
575783
  if (r2.tc.name === "task_complete") {
575633
575784
  if (!r2.success) {
575634
575785
  messages2.push({
@@ -577501,6 +577652,11 @@ ${marker}` : marker);
577501
577652
  normalizeToolOutput(result, toolName, args, turn) {
577502
577653
  const { toolOutputMaxChars: maxLen } = this.contextLimits();
577503
577654
  const modelContent = result.llmContent ?? result.output;
577655
+ if (result.runtimeAuthored) {
577656
+ const errPrefix = result.success ? "" : `Error: ${result.error || "runtime-authored tool feedback"}
577657
+ `;
577658
+ return `${errPrefix}${modelContent}`;
577659
+ }
577504
577660
  if (!result.success) {
577505
577661
  const errOutput = modelContent.length > maxLen ? this.foldOutput(modelContent, maxLen) : modelContent;
577506
577662
  return this.wrapToolOutputForModel(toolName, `Error: ${result.error || "unknown error"}
@@ -703376,12 +703532,24 @@ function createSubAgentTool(config, repoRoot, ctxWindowSize) {
703376
703532
  properties: {
703377
703533
  task: {
703378
703534
  type: "string",
703379
- description: "The task to delegate to the sub-agent"
703535
+ description: "The task to delegate to the sub-agent. Prefer this key."
703536
+ },
703537
+ prompt: {
703538
+ type: "string",
703539
+ description: "Compatibility alias for task. Prefer task in new calls."
703380
703540
  },
703381
703541
  background: {
703382
703542
  type: "boolean",
703383
703543
  description: "Run in background (default: false). Returns task ID."
703384
703544
  },
703545
+ run_in_background: {
703546
+ type: "boolean",
703547
+ description: "Compatibility alias for background. Prefer background in new calls."
703548
+ },
703549
+ subagent_type: {
703550
+ type: "string",
703551
+ description: "Compatibility hint only. sub_agent does not change tool permissions by type; use agent(prompt, subagent_type) for typed agents."
703552
+ },
703385
703553
  max_turns: {
703386
703554
  type: "number",
703387
703555
  description: "Maximum turns for the sub-agent (default: 15). Use 0 to run until task_complete or timeout."
@@ -703391,14 +703559,35 @@ function createSubAgentTool(config, repoRoot, ctxWindowSize) {
703391
703559
  description: "If true, run with max_turns=0 so the sub-agent stops only at task_complete, abort, or timeout."
703392
703560
  }
703393
703561
  },
703394
- required: ["task"]
703562
+ required: []
703395
703563
  },
703396
703564
  async execute(args) {
703397
- const task = String(args["task"] ?? "");
703398
- const background = Boolean(args["background"]);
703565
+ const rawTask = args["task"] ?? args["prompt"] ?? args["message"] ?? args["query"] ?? "";
703566
+ const task = String(rawTask);
703567
+ const background = Boolean(
703568
+ args["background"] ?? args["run_in_background"]
703569
+ );
703570
+ const compatibilityNotes = [];
703571
+ if (args["task"] === void 0 && args["prompt"] !== void 0) {
703572
+ compatibilityNotes.push("normalized prompt -> task");
703573
+ }
703574
+ if (args["background"] === void 0 && args["run_in_background"] !== void 0) {
703575
+ compatibilityNotes.push("normalized run_in_background -> background");
703576
+ }
703577
+ if (args["subagent_type"] !== void 0) {
703578
+ compatibilityNotes.push(
703579
+ "sub_agent ignores subagent_type; use agent(prompt, subagent_type) when typed agent permissions matter"
703580
+ );
703581
+ }
703582
+ const compatibilityPrefix = compatibilityNotes.length > 0 ? `Compatibility note: ${compatibilityNotes.join("; ")}.
703583
+ ` : "";
703399
703584
  const maxTurns = args["until_task_complete"] === true ? 0 : typeof args["max_turns"] === "number" ? args["max_turns"] : 15;
703400
703585
  if (!task) {
703401
- return { success: false, output: "", error: "task is required" };
703586
+ return {
703587
+ success: false,
703588
+ output: "",
703589
+ error: "task is required; prompt is accepted as a compatibility alias"
703590
+ };
703402
703591
  }
703403
703592
  const agentId = `sub-agent-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
703404
703593
  const cleanedLabelTask = cleanForStorage(task) || task;
@@ -703473,7 +703662,7 @@ function createSubAgentTool(config, repoRoot, ctxWindowSize) {
703473
703662
  );
703474
703663
  return {
703475
703664
  success: true,
703476
- output: `Sub-agent started in background: ${taskId}
703665
+ output: `${compatibilityPrefix}Sub-agent started in background: ${taskId}
703477
703666
  Task: ${task}
703478
703667
  Use task_status(task_id="${taskId}") or task_output(task_id="${taskId}") to check progress.`
703479
703668
  };
@@ -703491,10 +703680,10 @@ Use task_status(task_id="${taskId}") or task_output(task_id="${taskId}") to chec
703491
703680
  if (onComplete) onComplete(agentId, task, 0, output2);
703492
703681
  return {
703493
703682
  success: true,
703494
- output: output2
703683
+ output: `${compatibilityPrefix}${output2}`
703495
703684
  };
703496
703685
  }
703497
- const output = `Sub-agent did not complete after ${result.turns} turns, ${result.toolCalls} tool calls.`;
703686
+ const output = `${compatibilityPrefix}Sub-agent did not complete after ${result.turns} turns, ${result.toolCalls} tool calls.`;
703498
703687
  if (onComplete) onComplete(agentId, task, 1, output);
703499
703688
  return {
703500
703689
  success: false,
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.303",
3
+ "version": "1.0.304",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "omnius",
9
- "version": "1.0.303",
9
+ "version": "1.0.304",
10
10
  "bundleDependencies": [
11
11
  "image-to-ascii"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.303",
3
+ "version": "1.0.304",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",