@maintainabilityai/research-runner 0.1.16 → 0.1.18

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.
@@ -67,17 +67,24 @@ async function callAnthropicTier(opts, tierModels) {
67
67
  };
68
68
  }
69
69
  /**
70
- * GitHub Models returns 401 / 403 / 404 when the token can't reach the
71
- * requested model (typically the workflow bot token hitting a "custom"-
72
- * tier model like gpt-5-chat). These are recoverable via fallback;
73
- * everything else (timeouts, 5xx, 413 cap, parse errors) should
74
- * propagate.
70
+ * GitHub Models returns these statuses when the token can't reach the
71
+ * requested model or is being throttled. All recoverable via the
72
+ * github-models→github-models fallback (custom-tier low-tier).
73
+ *
74
+ * 401 / 403 — token lacks `models:read` or hasn't been enrolled in
75
+ * the custom tier (workflow bot vs Copilot PAT)
76
+ * 404 — model id not visible to this token tier
77
+ * 429 — rate limited on the primary tier; the low-tier model
78
+ * has its own bucket so the fallback often succeeds
79
+ *
80
+ * Everything else (timeouts, 5xx, 413 token cap, parse errors)
81
+ * propagates — those are not "wrong model" problems.
75
82
  */
76
83
  function isModelAccessError(err) {
77
84
  if (!(err instanceof Error)) {
78
85
  return false;
79
86
  }
80
- return /GitHub Models returned 40[134]:/.test(err.message);
87
+ return /GitHub Models returned (?:401|403|404|429):/.test(err.message);
81
88
  }
82
89
  async function callGitHubModelsTier(opts, tierModels) {
83
90
  if (!opts.githubToken) {
@@ -100,11 +100,17 @@ async function usptoSearch(opts) {
100
100
  try {
101
101
  const xmlRes = await fetchImpl(r._xmlUri, {
102
102
  method: 'GET',
103
- // The signed XML URI lives on a CDN/storage host, not api.uspto.gov.
104
- // It accepts unauthenticated GETs; sending X-API-Key actually causes
105
- // some hosts to 403. Use a vanilla request with a polite User-Agent.
103
+ // Mirror the NCMS reference exactly: same headers dict on the
104
+ // search call AND the XML fetch (X-API-Key + Accept: json). My
105
+ // earlier "drop X-API-Key on stage 2" was wrong the CDN does
106
+ // gate on it, and removing it produced http403 across the
107
+ // board (seen in #49 logs: "0/5 fetched, failures: http403 ×5").
108
+ // The Accept header looks wrong-shape (json for an XML doc) but
109
+ // the upstream ignores it and returns XML regardless; matches
110
+ // the NCMS pattern that works in production.
106
111
  headers: {
107
- accept: 'application/xml,text/xml,*/*',
112
+ accept: 'application/json',
113
+ 'X-API-Key': opts.apiKey,
108
114
  'user-agent': 'maintainabilityai-research-runner/1.0',
109
115
  },
110
116
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maintainabilityai/research-runner",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Research + PRD agent runner — orchestrates the Archeologist and PRD pipelines for the MaintainabilityAI governance mesh",
5
5
  "license": "MIT",
6
6
  "author": "MaintainabilityAI",