@yoqa/runner 0.3.20 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +248 -121
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16801,7 +16801,7 @@ function getCatalogDb() {
16801
16801
  // package.json
16802
16802
  var package_default = {
16803
16803
  name: "@yoqa/runner",
16804
- version: "0.3.20",
16804
+ version: "0.3.22",
16805
16805
  description: "Yoqa local runner \u2014 Appium + catalog HTTP API (Bun). Start with yoqa serve or the yoqa-runner bin.",
16806
16806
  license: "UNLICENSED",
16807
16807
  type: "module",
@@ -24167,6 +24167,8 @@ var updateCaseRequestSchema = exports_external.object({
24167
24167
  capabilities: exports_external.array(capabilitySchema).optional(),
24168
24168
  script: caseScriptSchema.nullable().optional()
24169
24169
  });
24170
+ var createCaseFlowsSchema = exports_external.array(createCaseRequestSchema.shape.flows.unwrap().element.strict());
24171
+ var updateCaseFlowsSchema = exports_external.array(updateCaseRequestSchema.shape.flows.unwrap().element.strict());
24170
24172
  var catalogFlowSchema = exports_external.object({
24171
24173
  id: exports_external.string().min(1),
24172
24174
  appId: exports_external.string().min(1),
@@ -57544,6 +57546,195 @@ var originalGenerateCallId6 = createIdGenerator3({
57544
57546
  });
57545
57547
  var defaultDownload2 = createDownload();
57546
57548
 
57549
+ // src/domains/providers/json-salvage.ts
57550
+ function charAt(raw2, index) {
57551
+ return raw2[index];
57552
+ }
57553
+ function coerceLooseJson(raw2) {
57554
+ let out = "";
57555
+ let i = 0;
57556
+ while (i < raw2.length) {
57557
+ const c = charAt(raw2, i);
57558
+ if (c === undefined)
57559
+ break;
57560
+ if (c === '"') {
57561
+ out += c;
57562
+ i += 1;
57563
+ while (i < raw2.length) {
57564
+ const d = charAt(raw2, i);
57565
+ if (d === undefined)
57566
+ break;
57567
+ out += d;
57568
+ i += 1;
57569
+ if (d === "\\") {
57570
+ const escaped = charAt(raw2, i);
57571
+ if (escaped !== undefined) {
57572
+ out += escaped;
57573
+ i += 1;
57574
+ }
57575
+ continue;
57576
+ }
57577
+ if (d === '"')
57578
+ break;
57579
+ }
57580
+ continue;
57581
+ }
57582
+ if (c === "'") {
57583
+ i += 1;
57584
+ let content = "";
57585
+ while (i < raw2.length) {
57586
+ const d = charAt(raw2, i);
57587
+ if (d === undefined)
57588
+ break;
57589
+ if (d === "\\" && i + 1 < raw2.length) {
57590
+ const next = charAt(raw2, i + 1);
57591
+ if (next === undefined)
57592
+ break;
57593
+ if (next === "n")
57594
+ content += `
57595
+ `;
57596
+ else if (next === "t")
57597
+ content += "\t";
57598
+ else if (next === "r")
57599
+ content += "\r";
57600
+ else
57601
+ content += next;
57602
+ i += 2;
57603
+ continue;
57604
+ }
57605
+ if (d === "'") {
57606
+ i += 1;
57607
+ break;
57608
+ }
57609
+ content += d;
57610
+ i += 1;
57611
+ }
57612
+ out += JSON.stringify(content);
57613
+ continue;
57614
+ }
57615
+ if (c === ",") {
57616
+ let j = i + 1;
57617
+ while (j < raw2.length) {
57618
+ const ws = charAt(raw2, j);
57619
+ if (ws === undefined || !/\s/.test(ws))
57620
+ break;
57621
+ j += 1;
57622
+ }
57623
+ const closer = charAt(raw2, j);
57624
+ if (closer === "}" || closer === "]") {
57625
+ i += 1;
57626
+ continue;
57627
+ }
57628
+ }
57629
+ out += c;
57630
+ i += 1;
57631
+ }
57632
+ return out;
57633
+ }
57634
+ function tryParseJson(text3) {
57635
+ try {
57636
+ return JSON.parse(text3);
57637
+ } catch {
57638
+ return;
57639
+ }
57640
+ }
57641
+ function closeTruncatedJson(raw2) {
57642
+ let inString = false;
57643
+ let escaped = false;
57644
+ const stack = [];
57645
+ for (let i = 0;i < raw2.length; i += 1) {
57646
+ const c = charAt(raw2, i);
57647
+ if (c === undefined)
57648
+ break;
57649
+ if (inString) {
57650
+ if (escaped) {
57651
+ escaped = false;
57652
+ continue;
57653
+ }
57654
+ if (c === "\\") {
57655
+ escaped = true;
57656
+ continue;
57657
+ }
57658
+ if (c === '"')
57659
+ inString = false;
57660
+ continue;
57661
+ }
57662
+ if (c === '"') {
57663
+ inString = true;
57664
+ continue;
57665
+ }
57666
+ if (c === "{")
57667
+ stack.push("{");
57668
+ else if (c === "[")
57669
+ stack.push("[");
57670
+ else if (c === "}" || c === "]")
57671
+ stack.pop();
57672
+ }
57673
+ let out = raw2;
57674
+ if (inString) {
57675
+ if (escaped)
57676
+ out = out.slice(0, -1);
57677
+ out += '"';
57678
+ }
57679
+ while (stack.length > 0) {
57680
+ const open = stack.pop();
57681
+ out += open === "{" ? "}" : "]";
57682
+ }
57683
+ return out;
57684
+ }
57685
+ function salvageAgentJsonText(text3) {
57686
+ const trimmed = text3.trim();
57687
+ const fenced = trimmed.match(/```(?:json)?\s*([\s\S]*?)```/);
57688
+ const inner = fenced?.[1]?.trim() ?? trimmed;
57689
+ const start = inner.indexOf("{");
57690
+ if (start < 0)
57691
+ return trimmed;
57692
+ const fromBrace = inner.slice(start);
57693
+ const lastBrace = fromBrace.lastIndexOf("}");
57694
+ const candidates = lastBrace > 0 ? [fromBrace.slice(0, lastBrace + 1), fromBrace] : [fromBrace];
57695
+ for (const candidate of candidates) {
57696
+ const variants = [
57697
+ candidate,
57698
+ coerceLooseJson(candidate),
57699
+ closeTruncatedJson(candidate),
57700
+ closeTruncatedJson(coerceLooseJson(candidate))
57701
+ ];
57702
+ for (const variant of variants) {
57703
+ if (tryParseJson(variant) !== undefined)
57704
+ return variant;
57705
+ }
57706
+ }
57707
+ return closeTruncatedJson(coerceLooseJson(fromBrace));
57708
+ }
57709
+ function clampNormCoord(n) {
57710
+ if (!Number.isFinite(n))
57711
+ return n;
57712
+ return Math.min(1000, Math.max(0, n));
57713
+ }
57714
+ function normalizeVisionJson(value) {
57715
+ if (!value || typeof value !== "object" || Array.isArray(value))
57716
+ return value;
57717
+ const out = { ...value };
57718
+ if (typeof out.x === "number")
57719
+ out.x = clampNormCoord(out.x);
57720
+ if (typeof out.y === "number")
57721
+ out.y = clampNormCoord(out.y);
57722
+ if (typeof out.ms === "number" && Number.isFinite(out.ms)) {
57723
+ out.ms = Math.min(1e4, Math.max(0, out.ms));
57724
+ }
57725
+ const reason = typeof out.reason === "string" ? out.reason.trim() : "";
57726
+ const thoughts = typeof out.thoughts === "string" ? out.thoughts.trim() : "";
57727
+ if (reason)
57728
+ out.reason = reason;
57729
+ if (thoughts)
57730
+ out.thoughts = thoughts;
57731
+ if (reason && !thoughts)
57732
+ out.thoughts = reason;
57733
+ if (thoughts && !reason)
57734
+ out.reason = thoughts;
57735
+ return out;
57736
+ }
57737
+
57547
57738
  // src/domains/providers/vision-model.ts
57548
57739
  class AgentProviderError extends Error {
57549
57740
  constructor(message) {
@@ -57644,20 +57835,27 @@ function mapProviderError(label, error40) {
57644
57835
  }
57645
57836
  throw new AgentProviderError(`Model did not return JSON (got: ${snippet}${text3.length > 160 ? "\u2026" : ""})`);
57646
57837
  }
57838
+ if (error40 instanceof exports_external.ZodError) {
57839
+ const first = error40.issues[0];
57840
+ const detail = first ? `${first.path.length > 0 ? `${first.path.join(".")}: ` : ""}${first.message}` : error40.message;
57841
+ throw new AgentProviderError(`${label} JSON was not a valid action: ${detail}`);
57842
+ }
57647
57843
  if (error40 instanceof Error) {
57648
57844
  throw new AgentProviderError(error40.message);
57649
57845
  }
57650
57846
  throw new AgentProviderError(String(error40));
57651
57847
  }
57652
- function repairModelJsonText(text3) {
57653
- const trimmed = text3.trim();
57654
- const fenced = trimmed.match(/```(?:json)?\s*([\s\S]*?)```/);
57655
- const candidate = fenced?.[1]?.trim() ?? trimmed;
57656
- const start = candidate.indexOf("{");
57657
- const end = candidate.lastIndexOf("}");
57658
- if (start < 0 || end <= start)
57659
- return trimmed;
57660
- return candidate.slice(start, end + 1);
57848
+ function parseVisionSchema(schema, raw2, label) {
57849
+ try {
57850
+ return schema.parse(normalizeVisionJson(raw2));
57851
+ } catch (error40) {
57852
+ if (error40 instanceof exports_external.ZodError) {
57853
+ const first = error40.issues[0];
57854
+ const detail = first ? `${first.path.length > 0 ? `${first.path.join(".")}: ` : ""}${first.message}` : error40.message;
57855
+ throw new AgentProviderError(`${label} JSON was not a valid action: ${detail}`);
57856
+ }
57857
+ throw error40;
57858
+ }
57661
57859
  }
57662
57860
  async function completeWithAiSdk(input) {
57663
57861
  const run = async (prompt) => {
@@ -57667,7 +57865,7 @@ async function completeWithAiSdk(input) {
57667
57865
  schema: input.schema,
57668
57866
  system: input.system,
57669
57867
  maxOutputTokens: VISION_MAX_TOKENS,
57670
- experimental_repairText: async ({ text: text3 }) => repairModelJsonText(text3),
57868
+ experimental_repairText: async ({ text: text3 }) => salvageAgentJsonText(text3),
57671
57869
  messages: [
57672
57870
  {
57673
57871
  role: "user",
@@ -57682,12 +57880,18 @@ async function completeWithAiSdk(input) {
57682
57880
  }
57683
57881
  ]
57684
57882
  });
57685
- return object3;
57883
+ return parseVisionSchema(input.schema, object3, input.label);
57686
57884
  } catch (error40) {
57885
+ if (error40 instanceof AgentProviderError)
57886
+ throw error40;
57687
57887
  if (NoObjectGeneratedError.isInstance(error40) && error40.text?.trim()) {
57688
57888
  try {
57689
- return input.schema.parse(JSON.parse(repairModelJsonText(error40.text)));
57690
- } catch {}
57889
+ const salvaged = salvageAgentJsonText(error40.text);
57890
+ return parseVisionSchema(input.schema, JSON.parse(salvaged), input.label);
57891
+ } catch (salvageError) {
57892
+ if (salvageError instanceof AgentProviderError)
57893
+ throw salvageError;
57894
+ }
57691
57895
  }
57692
57896
  mapProviderError(input.label, error40);
57693
57897
  }
@@ -67599,108 +67803,37 @@ var google = createGoogle();
67599
67803
 
67600
67804
  // src/domains/providers/agent-json.ts
67601
67805
  function extractAgentJsonObject(text3, providerLabel) {
67602
- const trimmed = text3.trim();
67603
- const fenced = trimmed.match(/```(?:json)?\s*([\s\S]*?)```/);
67604
- const candidate = fenced?.[1]?.trim() ?? trimmed;
67605
- const start = candidate.indexOf("{");
67606
- const end = candidate.lastIndexOf("}");
67607
- if (start < 0 || end <= start) {
67608
- throw new AgentProviderError(`${providerLabel} did not return JSON (got: ${trimmed.replace(/\s+/g, " ").slice(0, 160)})`);
67609
- }
67610
- const slice = candidate.slice(start, end + 1);
67806
+ const snippet = text3.trim().replace(/\s+/g, " ").slice(0, 160);
67807
+ const fail = () => {
67808
+ throw new AgentProviderError(`${providerLabel} did not return JSON (got: ${snippet})`);
67809
+ };
67810
+ const salvaged = salvageAgentJsonText(text3);
67811
+ let parsed;
67611
67812
  try {
67612
- return JSON.parse(slice);
67613
- } catch (strictError) {
67813
+ parsed = JSON.parse(salvaged);
67814
+ } catch {
67614
67815
  try {
67615
- return JSON.parse(coerceLooseJson(slice));
67816
+ parsed = JSON.parse(coerceLooseJson(salvaged));
67616
67817
  } catch {
67617
- throw strictError;
67818
+ fail();
67618
67819
  }
67619
67820
  }
67821
+ if (parsed === undefined || parsed === null || typeof parsed !== "object") {
67822
+ fail();
67823
+ }
67824
+ return parsed;
67620
67825
  }
67621
- function charAt(raw2, index) {
67622
- return raw2[index];
67623
- }
67624
- function coerceLooseJson(raw2) {
67625
- let out = "";
67626
- let i = 0;
67627
- while (i < raw2.length) {
67628
- const c = charAt(raw2, i);
67629
- if (c === undefined)
67630
- break;
67631
- if (c === '"') {
67632
- out += c;
67633
- i += 1;
67634
- while (i < raw2.length) {
67635
- const d = charAt(raw2, i);
67636
- if (d === undefined)
67637
- break;
67638
- out += d;
67639
- i += 1;
67640
- if (d === "\\") {
67641
- const escaped = charAt(raw2, i);
67642
- if (escaped !== undefined) {
67643
- out += escaped;
67644
- i += 1;
67645
- }
67646
- continue;
67647
- }
67648
- if (d === '"')
67649
- break;
67650
- }
67651
- continue;
67652
- }
67653
- if (c === "'") {
67654
- i += 1;
67655
- let content = "";
67656
- while (i < raw2.length) {
67657
- const d = charAt(raw2, i);
67658
- if (d === undefined)
67659
- break;
67660
- if (d === "\\" && i + 1 < raw2.length) {
67661
- const next = charAt(raw2, i + 1);
67662
- if (next === undefined)
67663
- break;
67664
- if (next === "n")
67665
- content += `
67666
- `;
67667
- else if (next === "t")
67668
- content += "\t";
67669
- else if (next === "r")
67670
- content += "\r";
67671
- else
67672
- content += next;
67673
- i += 2;
67674
- continue;
67675
- }
67676
- if (d === "'") {
67677
- i += 1;
67678
- break;
67679
- }
67680
- content += d;
67681
- i += 1;
67682
- }
67683
- out += JSON.stringify(content);
67684
- continue;
67685
- }
67686
- if (c === ",") {
67687
- let j = i + 1;
67688
- while (j < raw2.length) {
67689
- const ws = charAt(raw2, j);
67690
- if (ws === undefined || !/\s/.test(ws))
67691
- break;
67692
- j += 1;
67693
- }
67694
- const closer = charAt(raw2, j);
67695
- if (closer === "}" || closer === "]") {
67696
- i += 1;
67697
- continue;
67698
- }
67826
+ function parseVisionObject(schema, raw2, providerLabel) {
67827
+ try {
67828
+ return schema.parse(normalizeVisionJson(raw2));
67829
+ } catch (error40) {
67830
+ if (error40 instanceof exports_external.ZodError) {
67831
+ const first = error40.issues[0];
67832
+ const detail = first ? `${first.path.length > 0 ? `${first.path.join(".")}: ` : ""}${first.message}` : error40.message;
67833
+ throw new AgentProviderError(`${providerLabel} JSON was not a valid action: ${detail}`);
67699
67834
  }
67700
- out += c;
67701
- i += 1;
67835
+ throw error40;
67702
67836
  }
67703
- return out;
67704
67837
  }
67705
67838
 
67706
67839
  // src/domains/providers/drivers/antigravity-vision.ts
@@ -67746,13 +67879,10 @@ ${result.stderr}`.trim();
67746
67879
  if (result.exitCode !== 0 && !result.stdout.trim()) {
67747
67880
  throw new AgentProviderError(combined ? `Antigravity CLI failed: ${combined.slice(0, 400)}` : `Antigravity CLI exited ${result.exitCode}`);
67748
67881
  }
67749
- return input.schema.parse(extractAgentJsonObject(result.stdout || combined, "Antigravity CLI"));
67882
+ return parseVisionObject(input.schema, extractAgentJsonObject(result.stdout || combined, "Antigravity CLI"), "Antigravity CLI");
67750
67883
  } catch (error40) {
67751
67884
  if (error40 instanceof AgentProviderError)
67752
67885
  throw error40;
67753
- if (error40 instanceof exports_external.ZodError) {
67754
- throw new AgentProviderError(`Antigravity JSON was not a valid action: ${error40.message}`);
67755
- }
67756
67886
  if (error40 instanceof SyntaxError) {
67757
67887
  throw new AgentProviderError(`Antigravity CLI returned invalid JSON: ${error40.message}`);
67758
67888
  }
@@ -76310,13 +76440,10 @@ Screenshot file (open and look at it): ${shotName}`,
76310
76440
  imageBase64: image.base64,
76311
76441
  mediaType: image.mediaType
76312
76442
  });
76313
- return input.schema.parse(extractAgentJsonObject(stdout, "Cursor Agent CLI"));
76443
+ return parseVisionObject(input.schema, extractAgentJsonObject(stdout, "Cursor Agent CLI"), "Cursor Agent CLI");
76314
76444
  } catch (error40) {
76315
76445
  if (error40 instanceof AgentProviderError)
76316
76446
  throw error40;
76317
- if (error40 instanceof exports_external.ZodError) {
76318
- throw new AgentProviderError(`Cursor JSON was not a valid action: ${error40.message}`);
76319
- }
76320
76447
  if (error40 instanceof SyntaxError) {
76321
76448
  throw new AgentProviderError(`Cursor Agent CLI returned invalid JSON: ${error40.message}`);
76322
76449
  }
@@ -97457,10 +97584,10 @@ var agentDecisionSchema = exports_external.object({
97457
97584
  exports_external.literal("done"),
97458
97585
  exports_external.literal("fail")
97459
97586
  ]),
97460
- x: exports_external.number().min(0).max(1000).optional(),
97461
- y: exports_external.number().min(0).max(1000).optional(),
97587
+ x: exports_external.number().optional(),
97588
+ y: exports_external.number().optional(),
97462
97589
  text: exports_external.string().optional(),
97463
- ms: exports_external.number().min(0).max(1e4).optional(),
97590
+ ms: exports_external.number().optional(),
97464
97591
  reason: exports_external.string().min(1),
97465
97592
  thoughts: exports_external.string().min(1)
97466
97593
  });
@@ -97656,8 +97783,8 @@ function cleanPageSource(xml, window2) {
97656
97783
 
97657
97784
  // src/domains/devices/grounding.ts
97658
97785
  var groundResultSchema = exports_external.object({
97659
- x: exports_external.number().min(0).max(1000),
97660
- y: exports_external.number().min(0).max(1000)
97786
+ x: exports_external.number(),
97787
+ y: exports_external.number()
97661
97788
  });
97662
97789
  var GROUND_SYSTEM = `You locate UI elements on a mobile screen.
97663
97790
  Respond with ONLY JSON: {"x":0-1000,"y":0-1000} for the center of the best match.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoqa/runner",
3
- "version": "0.3.20",
3
+ "version": "0.3.22",
4
4
  "description": "Yoqa local runner — Appium + catalog HTTP API (Bun). Start with yoqa serve or the yoqa-runner bin.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",