imprint-mcp 0.4.6 → 0.4.8

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.
@@ -139,7 +139,7 @@ const WORKFLOW: Workflow = {
139
139
  "captures": [
140
140
  {
141
141
  "name": "f_sid",
142
- "required": false,
142
+ "required": true,
143
143
  "capability": "browser_bootstrap",
144
144
  "source": "html_regex",
145
145
  "pattern": "\"FdrFJe\":\"([^\"]+)\"",
@@ -147,7 +147,7 @@ const WORKFLOW: Workflow = {
147
147
  },
148
148
  {
149
149
  "name": "bl",
150
- "required": false,
150
+ "required": true,
151
151
  "capability": "browser_bootstrap",
152
152
  "source": "html_regex",
153
153
  "pattern": "\"cfb2h\":\"([^\"]+)\"",
@@ -147,6 +147,11 @@ export function extract(
147
147
  const frames = decodeBatchExecute(rawResponse);
148
148
  payload = frames[0]?.payload;
149
149
  }
150
+ if (payload == null) {
151
+ throw new Error(
152
+ 'Google Flights GetShoppingResults response did not contain a batchexecute payload',
153
+ );
154
+ }
150
155
  } else {
151
156
  payload = rawResponse;
152
157
  }
@@ -162,6 +167,11 @@ export function extract(
162
167
  }
163
168
 
164
169
  const itineraries = [...byToken.values()];
170
+ if (itineraries.length === 0) {
171
+ throw new Error(
172
+ 'Google Flights GetShoppingResults payload did not contain recognizable itineraries',
173
+ );
174
+ }
165
175
  return {
166
176
  count: itineraries.length,
167
177
  itineraries,
@@ -110,7 +110,7 @@
110
110
  "name": "f_sid",
111
111
  "pattern": "\"FdrFJe\":\"([^\"]+)\"",
112
112
  "group": 1,
113
- "required": false,
113
+ "required": true,
114
114
  "capability": "browser_bootstrap"
115
115
  },
116
116
  {
@@ -118,7 +118,7 @@
118
118
  "name": "bl",
119
119
  "pattern": "\"cfb2h\":\"([^\"]+)\"",
120
120
  "group": 1,
121
- "required": false,
121
+ "required": true,
122
122
  "capability": "browser_bootstrap"
123
123
  }
124
124
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imprint-mcp",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "description": "Teach an AI agent how to use any website. Once. Records a real browser session + narration; generates a deterministic MCP tool plus a DOM-replay playbook fallback.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -163,6 +163,10 @@ export function __resetCompileCdpPoolForTest(): void {
163
163
  compileCdpPool.clear();
164
164
  }
165
165
 
166
+ function cdpToolResultImpliesDeadSession(result: ToolResult): boolean {
167
+ return !result.ok && result.error === 'NETWORK';
168
+ }
169
+
166
170
  /** Freshness window for the file-backed compile-time stealth token. Matches
167
171
  * stealth-fetch's in-process `maxTokenAgeSeconds` default so a reused token is
168
172
  * not immediately considered stale by `createStealthFetch`. */
@@ -972,7 +976,7 @@ async function runCdpReplay(
972
976
  } else {
973
977
  if (ownsSession) {
974
978
  await cf.close();
975
- } else if (cdpPool) {
979
+ } else if (cdpPool && cdpToolResultImpliesDeadSession(result)) {
976
980
  cdpPool.delete(poolKey);
977
981
  log('cdp-replay: evicted degraded session from pool');
978
982
  await cf.close();