@nexface/agent 0.1.21-alpha.8 → 0.1.22

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/agent.js CHANGED
@@ -17,6 +17,8 @@ import { getHistoryCompactionInput, HISTORY_COMPACTION_MIN_SAVINGS_BYTES, modelH
17
17
  import { validateContextCatalog, validateToolCatalog } from "./tool-catalog.js";
18
18
  import { getSnapshotTool, executeActionTool, applyActionTool } from "./shared/page-tools.js";
19
19
  const CALL_APPLICATION_TOOL_NAME = "nxf_callAppTool";
20
+ // Internal to the evals CLI. Browser definitions and dispatch belong to the same model step.
21
+ const stepToolsKey = Symbol.for("@nexface/evals/getStepTools");
20
22
  function systemPromptFor(useToolProxy) {
21
23
  return SYSTEM_PROMPT.replace("{{CURRENT_TOOLS}}", useToolProxy
22
24
  ? "The latest NEXFACE_RUNTIME_V1 checkpoint lists current application capabilities; ignore older catalogs."
@@ -40,7 +42,7 @@ const SYSTEM_PROMPT = "You are an application agent. Handle the latest user requ
40
42
  "- The catalog changes with the page. If a needed tool is missing and navigation to the relevant page is available, navigate there and inspect the updated catalog before using page automation or declaring the task unsupported. Do not batch navigation or opening UI with operations that depend on newly available tools.\n" +
41
43
  "- When an application tool reports a permission restriction, required user confirmation, or a blocked write, follow its recovery requirements. Do not bypass the restriction through page automation.\n" +
42
44
  "- Batch only independent calls. The host executes them in order and skips remaining calls after a failure.\n" +
43
- "- Provide progressLabel for application or page automation calls whose schemas accept it.\n\n" +
45
+ "- Supply a short progress label only when the schema describes a field for reporting action progress. Other fields, including fields named progressLabel, follow their own business descriptions.\n\n" +
44
46
  "Completion:\n" +
45
47
  "- Once tool execution is required, continue until the latest request is fulfilled or cannot safely proceed.\n" +
46
48
  "- Claim success only from Tool Results produced for the latest request or their explicitly confirmed execution records in a history summary attributed to that request. Do not repeat a confirmed operation merely because its original Tool Result was summarized.\n" +
@@ -752,6 +754,7 @@ class Nexface {
752
754
  #pageHistoryTruncated = false;
753
755
  #pageTransitions = [];
754
756
  #toolRuntime;
757
+ #getStepTools;
755
758
  #runtimeTools = new WeakMap();
756
759
  #registered = new Map();
757
760
  #request;
@@ -788,6 +791,7 @@ class Nexface {
788
791
  #hostConfirmation;
789
792
  #hasPageConfirmation = (_toolName) => false;
790
793
  constructor(options) {
794
+ this.#getStepTools = options[stepToolsKey];
791
795
  if (options.useToolProxy !== undefined && typeof options.useToolProxy !== "boolean")
792
796
  throw new Error("useToolProxy must be a boolean.");
793
797
  this.#useToolProxy = options.useToolProxy ?? false;
@@ -795,10 +799,6 @@ class Nexface {
795
799
  options.pageDecision === undefined ? undefined : resolvePageDecision(options.pageDecision);
796
800
  this.#skills = normalizeSkills(options.skills);
797
801
  this.#skillsByName = new Map(this.#skills.map((skill) => [skill.name, skill]));
798
- const systemPrompt = systemPromptFor(this.#useToolProxy) + (this.#pageDecision ? PAGE_DELEGATION_PROMPT : "");
799
- this.#systemPrompt = this.#skills.length
800
- ? `${systemPrompt} The NEXFACE_AVAILABLE_SKILLS_V1 catalog lists optional host-provided instructions. When a Skill matches the task, call nxf_loadSkill as the only tool call in the response, then follow its instructions starting in the next model step.\n\n${serializeSkillCatalog(this.#skills)}`
801
- : systemPrompt;
802
802
  const hasToolRuntime = "toolRuntime" in options && options.toolRuntime !== undefined;
803
803
  if ("toolBridge" in options) {
804
804
  throw new AgentError("AGENT_TOOL_RUNTIME_UNAVAILABLE", "toolBridge is no longer supported. Use toolRuntime locally or NexfaceProvider with HTTP + SSE.");
@@ -810,6 +810,11 @@ class Nexface {
810
810
  else {
811
811
  this.#toolRuntime = undefined;
812
812
  }
813
+ const systemPrompt = systemPromptFor(this.#useToolProxy) +
814
+ (this.#pageDecision ? PAGE_DELEGATION_PROMPT : "");
815
+ this.#systemPrompt = this.#skills.length
816
+ ? `${systemPrompt} The NEXFACE_AVAILABLE_SKILLS_V1 catalog lists optional host-provided instructions. When a Skill matches the task, call nxf_loadSkill as the only tool call in the response, then follow its instructions starting in the next model step.\n\n${serializeSkillCatalog(this.#skills)}`
817
+ : systemPrompt;
813
818
  for (const tool of options.tools ?? []) {
814
819
  if (!tool?.definition ||
815
820
  typeof tool.execute !== "function" ||
@@ -885,6 +890,8 @@ class Nexface {
885
890
  }
886
891
  async #getTools(signal) {
887
892
  signal.throwIfAborted();
893
+ if (this.#getStepTools)
894
+ return this.#getStepTools(signal);
888
895
  const runtimeTools = this.#toolRuntime?.getTools() ?? [];
889
896
  for (const tool of runtimeTools)
890
897
  this.#runtimeTools.set(tool.definition, tool);
@@ -2240,6 +2247,7 @@ class Nexface {
2240
2247
  if (prepared.preparationError)
2241
2248
  throw prepared.preparationError;
2242
2249
  let output;
2250
+ const executeStepTool = this.#getStepTools && applicationDefinitionsByName.get(prepared.displayName)?.execute;
2243
2251
  if (browserResult) {
2244
2252
  this.#requestResult = undefined;
2245
2253
  if (browserResult.confirmed)
@@ -2288,6 +2296,13 @@ class Nexface {
2288
2296
  skillToLoad = skill;
2289
2297
  output = { name: skillName, loaded };
2290
2298
  }
2299
+ else if (prepared.kind === "application" && executeStepTool) {
2300
+ toolInput =
2301
+ prepared.call.name === CALL_APPLICATION_TOOL_NAME
2302
+ ? prepared.input
2303
+ : parseArguments(prepared.call);
2304
+ output = await executeStepTool(toolInput, signal);
2305
+ }
2291
2306
  else if (prepared.kind === "application") {
2292
2307
  toolInput = prepared.input;
2293
2308
  const expectedDefinition = applicationDefinitionsByName.get(prepared.displayName);
@@ -1,4 +1,22 @@
1
1
  import { AgentModelError } from "./error.js";
2
+ const strictKeywords = new Set([
3
+ "type",
4
+ "description",
5
+ "properties",
6
+ "required",
7
+ "additionalProperties",
8
+ "items",
9
+ "enum",
10
+ "minLength",
11
+ "maxLength",
12
+ "pattern",
13
+ "minimum",
14
+ "maximum",
15
+ "exclusiveMinimum",
16
+ "exclusiveMaximum",
17
+ "minItems",
18
+ "maxItems",
19
+ ]);
2
20
  /** Convert only the model-facing schema; Runtime continues validating the original. */
3
21
  export function strictToolSchema(schema, path) {
4
22
  const fail = (reason) => {
@@ -13,6 +31,11 @@ export function strictToolSchema(schema, path) {
13
31
  // Keep the entire tool non-strict rather than dropping its Runtime constraint.
14
32
  if (schema.uniqueItems !== undefined)
15
33
  fail("uniqueItems is not supported.");
34
+ // Published WebMCP schemas may use presence constraints or explicit nullable unions.
35
+ // Requiring every property and restoring nulls would change those contracts.
36
+ if (typeof schema.type !== "string" ||
37
+ Object.keys(schema).some((key) => !strictKeywords.has(key)))
38
+ fail("cannot preserve this JSON Schema in strict mode.");
16
39
  const result = { ...schema };
17
40
  if (schema.type === "object") {
18
41
  if (schema.additionalProperties !== false) {
package/dist/models/k.js CHANGED
@@ -333,6 +333,24 @@ function selectModelHistory(messages, summary, options) {
333
333
  }
334
334
  return options?.pageDelegation ? projectPageDelegationHistory(entries) : entries;
335
335
  }
336
+ const strictKeywords = new Set([
337
+ "type",
338
+ "description",
339
+ "properties",
340
+ "required",
341
+ "additionalProperties",
342
+ "items",
343
+ "enum",
344
+ "minLength",
345
+ "maxLength",
346
+ "pattern",
347
+ "minimum",
348
+ "maximum",
349
+ "exclusiveMinimum",
350
+ "exclusiveMaximum",
351
+ "minItems",
352
+ "maxItems"
353
+ ]);
336
354
  function strictToolSchema(schema, path) {
337
355
  const fail = (reason)=>{
338
356
  throw new AgentModelError("MODEL_CONFIG_INVALID", `Strict tool schema at ${path}: ${reason}`);
@@ -340,6 +358,7 @@ function strictToolSchema(schema, path) {
340
358
  if (!schema.type) fail("an explicit type is required.");
341
359
  if (schema.enum?.some((value)=>null !== value && "object" == typeof value)) fail("object and array enum values are not supported.");
342
360
  if (void 0 !== schema.uniqueItems) fail("uniqueItems is not supported.");
361
+ if ("string" != typeof schema.type || Object.keys(schema).some((key)=>!strictKeywords.has(key))) fail("cannot preserve this JSON Schema in strict mode.");
343
362
  const result = {
344
363
  ...schema
345
364
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexface/agent",
3
- "version": "0.1.21-alpha.8",
3
+ "version": "0.1.22",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "engines": {
@@ -73,7 +73,7 @@
73
73
  }
74
74
  },
75
75
  "peerDependencies": {
76
- "@nexface/tools": "0.1.21-alpha.8"
76
+ "@nexface/tools": "0.1.22"
77
77
  },
78
78
  "repository": {
79
79
  "type": "git",