@trawlme/skills 1.4.9 → 1.4.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trawlme/skills",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "description": "Claude Code skills for the Trawl CLI — teaches Claude how to manage scraps via @trawlme/cli",
5
5
  "type": "module",
6
6
  "bin": {
@@ -39,7 +39,7 @@ If the user gets `Session expired or invalid. Run: trawl login`, their stored JW
39
39
  CI-relevant env vars. The first three are per-invocation session overrides — they take precedence over stored config without writing to disk (for normal commands; note `trawl login` itself still persists a token even when `TRAWL_TOKEN` is set):
40
40
  - `TRAWL_TOKEN` — session JWT, takes precedence over `trawl login`'s stored token
41
41
  - `TRAWL_API_URL` — API base URL, takes precedence over `trawl login --url`
42
- - `TRAWL_TIMEOUT` — per-request fetch timeout in ms (default 30000; 660000 for `scraps run`, `data --fresh`, `trigger --wait` (300000 from CLI 1.18.4, 660000 since 3.12.6), and a longer wizard budget for `create` since 2.0.0 — these hit the server-side scrap-execute/AI-wizard paths, which legitimately run for minutes; this env var still overrides that longer default too, higher or lower — beware: a low global value clamps `create` and triggers the duplicate-on-retry trap described below)
42
+ - `TRAWL_TIMEOUT` — per-request fetch timeout in ms (default 30000; 1380000 for `scraps run`, `data --fresh`, `trigger --wait` (300000 from CLI 1.18.4, 660000 since 3.12.6, 1380000 since 4.0.4), and 4800000 for `create` (a longer wizard budget since 2.0.0; 3600000 before 4.0.4) — these hit the server-side scrap-execute/AI-wizard paths, which legitimately run for minutes; this env var still overrides that longer default too, higher or lower — beware: a low global value clamps `create` and triggers the duplicate-on-retry trap described below)
43
43
  - `DEBUG` — any truthy value prints the full error stack trace to stderr, same effect as the global `--debug` flag
44
44
 
45
45
  `TRAWL_CONFIG_DIR` is different — it **redirects where the CLI reads and writes** its config file (so `trawl login` persists there). Point it at an ephemeral dir for hermetic runs, e.g. `TRAWL_CONFIG_DIR=$(mktemp -d)`.
@@ -63,7 +63,7 @@ One call: the server generates the extraction code (AI), creates a **persistent,
63
63
 
64
64
  Critical semantics for agents:
65
65
  - **Ask the user before running it** — `trawl create` sends the URL + prompt to Trawl, creates a persistent scrap, enables a DAILY schedule, and consumes quota (LLM generation + a real run). Obtain explicit user confirmation immediately before executing; never fire it speculatively.
66
- - **NOT idempotent + not instant** — generation + first run legitimately takes 30-250s (the CLI already uses a much longer timeout than the 30s default for `create`; a global `TRAWL_TIMEOUT` override clamps it). On a client-side timeout the scrap **may still have been created server-side**: run `trawl list` before retrying — a retry creates a DUPLICATE scrap and burns quota.
66
+ - **NOT idempotent + not instant** — generation + probes + first run legitimately take many minutes (since CLI 4.0.4 it arms a 4800s ceiling for `create`, far above the 30s default; a global `TRAWL_TIMEOUT` override clamps it). On a client-side timeout the scrap **may still have been created server-side**: run `trawl list` before retrying — a retry creates a DUPLICATE scrap and burns quota.
67
67
  - **Daily schedule by default** — a wizard scrap is created with a daily cron (07:00 UTC); it re-runs and meters every day until you change it (`trawl scraps update <id> --cron <expr>` or `--no-cron`).
68
68
  - **`success:false` (exit 1) ≠ retry** — the scrap EXISTS and auto-fix is retrying in the background: poll `trawl data <id>` / `trawl run-info <runId>`, never re-run `create`.
69
69
  - **On success, human mode proves the value (since 2.3.0)** — after a successful first run, `create` prints a small best-effort data sample (item count, field names, one truncated value) below the scrap summary, then `Next step: trawl data <id>` (with `trawl get <id>` noted as the secondary, metadata-only view). The sample is bonus output only: any fetch/parse failure is swallowed silently and never turns a successful create into an error. `--json` is unaffected — it always returns the raw `{ success, scrap, historyId }` payload (plus `runId` on newer servers) with no sample appended.
@@ -157,7 +157,7 @@ trawl scraps update <id> --tier tier2 --json # full scrap JSON, o
157
157
  - Params stored on a scrap (`-p` / `--params-file`) are **scenarios**: an array of param sets. Each scheduled, dashboard or `trawl run` run picks **one set at random** — never "the last saved set". Put everything a run needs in each set; sets are alternatives, not additions.
158
158
  - To run with your own values instead, use `trawl trigger <id> --param key=value` (repeatable). It is a one-off run: the stored scenarios are left untouched. **Since CLI 3.15.0.**
159
159
  - Rules: the first stored set defines the schema. Keys are that set's keys, `TRAWL.` prefix optional. Values are typed like the stored value: number, `true`/`false`, or string. Every key is required; blank values and unknown, duplicate or wrongly typed keys are refused with exit 2 (a number error says `must be a number`, a boolean one `must be true or false`; unknown or missing keys list the expected keys). Works with `--wait`, `--watch` and the async default.
160
- - A scrap without stored params takes no `--param`. A scrap that has params and is triggered without `--param` fails (422 under `--wait`; async, it is acked as queued and exits 0, then the run is dropped with no history row, and `--watch` polls until its 660s timeout, then prints "Timed out waiting for the run to finish" and exits 1; use `--wait` to see the error).
160
+ - A scrap without stored params takes no `--param`. A scrap that has params and is triggered without `--param` fails (422 under `--wait`; async, it is acked as queued and exits 0, then the run is dropped with no history row, and `--watch` polls until its 1380s timeout, then prints "Timed out waiting for the run to finish" and exits 1; use `--wait` to see the error).
161
161
  - `--param` reads the scrap first, so an API key needs `trawl:scraps:read` besides `trawl:scraps:run`. On a scrap without a cron, `trigger` prints a stderr warning that nothing runs it unattended.
162
162
 
163
163
  ### Proxy tiers
@@ -171,18 +171,18 @@ trawl scraps update <id> --tier tier2 --json # full scrap JSON, o
171
171
 
172
172
  ### Run / trigger / watch
173
173
 
174
- - `trawl scraps run <id>` — synchronous run via the load endpoint, blocks until done. Takes no params (see "Params are scenarios"). Arms a 660s timeout (300s from CLI 1.18.4, 660s since 3.12.6 — see `TRAWL_TIMEOUT` above) instead of the generic 30s default, because this endpoint can legitimately run for minutes server-side.
174
+ - `trawl scraps run <id>` — synchronous run via the load endpoint, blocks until done. Takes no params (see "Params are scenarios"). Arms a 1380s timeout (300s from CLI 1.18.4, 660s since 3.12.6, 1380s since 4.0.4 — see `TRAWL_TIMEOUT` above) instead of the generic 30s default, because this endpoint can legitimately run for minutes server-side.
175
175
  - `trawl scraps run <id> --watch` — same, then polls for progress (since CLI 1.18.4 — see below; it does **not** stream)
176
- - `trawl scraps trigger <id>` — **async by default**: queues the worker run and returns immediately (no waiting on the 30-250s run)
177
- - `trawl scraps trigger <id> --wait` — synchronous: block until the run completes (legacy behaviour). Same timeout as `run` (660s since CLI 3.12.6).
176
+ - `trawl scraps trigger <id>` — **async by default**: queues the worker run and returns immediately (no waiting on the run, which can take up to about 23 minutes with its digest)
177
+ - `trawl scraps trigger <id> --wait` — synchronous: block until the run completes (legacy behaviour). Same timeout as `run` (1380s since CLI 4.0.4: the server may wait up to 600s for a worker before the run's own 600s budget starts, then up to 180s for the digest).
178
178
  - `trawl scraps trigger <id> --param key=value` — one-off run with your own param values, see "Params are scenarios" (CLI 3.15.0+)
179
179
  - `trawl scraps trigger <id> --watch` — queue, then poll for progress (since CLI 1.18.4 — see below; it does **not** stream)
180
180
  - `trawl scraps watch <id>` — the standalone command: attach to an in-progress run's activity stream over SSE. **Unchanged** by any of the above — this is the one that actually streams.
181
181
 
182
- **`--watch` is poll-based, not a live stream (since CLI 1.18.4):** `scraps run --watch` and `scraps trigger --watch` used to open the activities SSE stream after launching the run — but that showed nothing either way: the activities SSE endpoint has no backlog, so by the time a *synchronous* run had already finished there was nothing left to emit, and for the default *async* `trigger` the run executes in a separate cron-consumer pod whose events never reach the API pod holding the SSE connection at all. Both flags now instead poll two Mongo-backed REST reads every 2s, up to 660s: `GET /api/scraps/:id` for terminal status, and the activities list endpoint for new lines — printing each new activity line as it appears, then the terminal status. Before doing so they print this notice:
182
+ **`--watch` is poll-based, not a live stream (since CLI 1.18.4):** `scraps run --watch` and `scraps trigger --watch` used to open the activities SSE stream after launching the run — but that showed nothing either way: the activities SSE endpoint has no backlog, so by the time a *synchronous* run had already finished there was nothing left to emit, and for the default *async* `trigger` the run executes in a separate cron-consumer pod whose events never reach the API pod holding the SSE connection at all. Both flags now instead poll two Mongo-backed REST reads every 2s, up to 1380s: `GET /api/scraps/:id` for terminal status, and the activities list endpoint for new lines — printing each new activity line as it appears, then the terminal status. Before doing so they print this notice:
183
183
  > Live activity streaming has no signal for this run (async/cross-pod) — polling for progress instead…
184
184
 
185
- Control flow depends on the path: for a **synchronous** run (`run`, or `trigger --wait`) the CLI first blocks on the run request itself (now with the 660s long-run timeout), and the poll runs *afterward* — so it's a one-pass replay of the recorded activity for a run that has already finished, not live-during-execution progress. For the default **async** `trigger` (`?wait=false`, returns immediately), the poll runs *concurrently* while a separate cron pod executes the run, so there the lines appear as the run progresses. Either way, a run that never reaches a terminal status within the 660s poll window prints an honest timeout notice pointing at `scraps doctor <id>`, instead of hanging silently or lying about completion. **Since CLI 1.18.5**, this poll also correctly tracks a `trigger --watch` call that deduped onto an already-in-flight worker job (i.e. the scrap was triggered again while a run was still executing) — before 1.18.5 that case could falsely time out waiting for a history id that would never change, because the dedup reuses the existing row instead of creating a new one. `--watch` is now safe to use on retry or concurrent `trigger` calls.
185
+ Control flow depends on the path: for a **synchronous** run (`run`, or `trigger --wait`) the CLI first blocks on the run request itself (now with the 1380s long-run timeout), and the poll runs *afterward* — so it's a one-pass replay of the recorded activity for a run that has already finished, not live-during-execution progress. For the default **async** `trigger` (`?wait=false`, returns immediately), the poll runs *concurrently* while a separate cron pod executes the run, so there the lines appear as the run progresses. Either way, a run that never reaches a terminal status within the 1380s poll window prints an honest timeout notice pointing at `scraps doctor <id>`, instead of hanging silently or lying about completion. **Since CLI 1.18.5**, this poll also correctly tracks a `trigger --watch` call that deduped onto an already-in-flight worker job (i.e. the scrap was triggered again while a run was still executing) — before 1.18.5 that case could falsely time out waiting for a history id that would never change, because the dedup reuses the existing row instead of creating a new one. `--watch` is now safe to use on retry or concurrent `trigger` calls.
186
186
 
187
187
  `scraps watch <id>` (the standalone command above) is a separate code path and is unaffected by any of this — it still opens the live SSE stream directly.
188
188
 
@@ -38,6 +38,7 @@ const price = await page.$eval(PRICE_SEL, (el) => el.textContent.trim());
38
38
  - module-CSS (stable prefix + hash suffix) → match the prefix: `[class*="ListingCard_price"]`
39
39
  - `aria-label` often encodes the value (`[aria-label*="Current price"]`) — more stable than any class
40
40
  - **JSON beats DOM**: `window.__NEXT_DATA__` (Next.js SSR) and JSON-LD (`script[type="application/ld+json"]`, schema.org) carry the data pre-render — use as primary, DOM as fallback.
41
+ - **An XHR is not the data**: before you build on a JSON call the page makes, open its response body in a local run (`trawl-scrap-local-test`) and check it holds the rows and fields the user asked for — many JSON calls are analytics, ads or tracking.
41
42
 
42
43
  ## Waits
43
44
 
@@ -123,7 +124,7 @@ try {
123
124
 
124
125
  ## Run budget
125
126
 
126
- One run has a **time budget**: about **10 minutes** from dispatch, and the clock starts before your script does (the run may queue first). Past it the worker stops the run and nothing is returned. Time is almost always the limit, not size: the whole output may reach tens of MB before a run fails with `output too large`.
127
+ One run has a **time budget**: about **10 minutes**. Count it from before your script starts: a scheduled or web-app run may queue for a worker first, inside that budget, and the guard below leaves about 3 minutes for it. A run you wait on through the API (`trawl scraps trigger --wait`, the n8n node) starts its 10 minutes when your script starts instead; keep the guard anyway, the same script also runs on a schedule. Past it the worker stops the run and nothing is returned. Time is almost always the limit, not size: the whole output may reach tens of MB before a run fails with `output too large`.
127
128
 
128
129
  - Add a **deadline guard**: note `Date.now()` at the start, stop about **7 minutes** in, and `returnData` the rows read so far, with `truncated: true` on the last one (the platform reads it as a marker that the run stopped early, not as a data column). The guard runs between requests, so also give each request its own timeout (e.g. `fetch(url, { signal: AbortSignal.timeout(20000) })` inside `page.evaluate`, with a `try`/`catch` that breaks the loop): one stuck page must not carry the run past its budget.
129
130
  - Read fewer, cheaper pages: each `page.goto` costs seconds on its own. For lists, prefer same-origin `fetch` from inside the page (`page.evaluate`) on JSON feeds, pagination or search APIs, sitemaps. One request at a time, never parallel tabs or `page.goto`s to the same site (several loads within a few seconds can get the run blocked). Space requests about 1 s apart: that pause is rate-limit politeness (`references/anti-patterns.md`), never a wait for the page.