@trawlme/skills 1.4.6 → 1.4.7

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.6",
3
+ "version": "1.4.7",
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; 300000 for `scraps run`, `data --fresh`, `trigger --wait` since CLI 1.18.4, and `create` since 2.0.0 — these hit the server-side scrap-execute/AI-wizard paths, which legitimately run 30-250s; 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; 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)
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 the 300s long-run timeout; 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 + 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.
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** — currently on the npm `next` dist-tag (`npm i -g @trawlme/cli@next`), not yet on `latest` (3.12.7).
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 the run then fails).
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).
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. Arms a 300s timeout (since CLI 1.18.4 — see `TRAWL_TIMEOUT` above) instead of the generic 30s default, because this endpoint legitimately runs 30-250s 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 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.
175
175
  - `trawl scraps run <id> --watch` — same, then polls for progress (since CLI 1.18.4 — see below; it does **not** stream)
176
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 300s timeout as `run`, since CLI 1.18.4.
177
+ - `trawl scraps trigger <id> --wait` — synchronous: block until the run completes (legacy behaviour). Same timeout as `run` (660s since CLI 3.12.6).
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+, `next` tag)
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 300s: `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 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:
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 300s 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 300s 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 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.
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
 
@@ -81,10 +81,12 @@ returnData([
81
81
  ## Params
82
82
 
83
83
  - **`TRAWL.url`** — the target URL, set by the scrap schedule. Treat as immutable; never override it.
84
- - **`TRAWL.<custom>`** — a custom parameter of the run. Where it comes from: the scrap's stored params (Settings → Parameters, or `trawl scraps update <id> -p/--params '[{"TRAWL.<name>":"<value>"}]'`, or `--params-file <path>` for bulk — see the `trawl-cli` skill) or the caller's own values (`trawl trigger <id> --param name=value`, CLI 3.15.0+, npm `next` tag for now).
85
- - **Stored params are scenarios.** The array holds alternative param sets, and each scheduled, dashboard or `trawl run` run receives **one set picked at random**. The script never sees the whole array, so every set must carry every key the script needs. A `--param` run replaces the pick with the caller's values for that run only.
86
- - **`RANDOM(...)`** — a value generator, unrelated to the scenario pick above: a helper that returns a random value from a list (see Trawl params docs). *Signature not independently re-verified against the worker runtime as part of this pass — treat as provisional.*
87
- - **`DATE(±N, unit, format)`** — a value generator too: a date helper that returns a formatted date offset from now. *Signature not independently re-verified against the worker runtime as part of this pass — treat as provisional.*
84
+ - **`TRAWL.<custom>`** — a custom parameter of the run. Where it comes from: the scrap's stored params (Settings → Parameters, or `trawl scraps update <id> -p/--params '[{"TRAWL.<name>":"<value>"}]'`, or `--params-file <path>` for bulk — see the `trawl-cli` skill) or the caller's own values (`trawl trigger <id> --param name=value`, CLI 3.15.0+, npm `next` tag for now). An on-demand run (`trawl trigger`, the public API, MCP) receives the caller's values instead of a stored set, limited to the keys of the FIRST stored set. Either way the script sees one flat value per key, never the array.
85
+ - **Stored params are scenarios.** The array holds alternative param sets, and each scheduled, dashboard or `trawl run` run receives **one set picked at random**. The script never sees the whole array, so every set must carry every key the script needs, and every set must use the same keys as set 0. A `--param` run replaces the pick with the caller's values for that run only.
86
+ - **Value generators** (written as a param VALUE and resolved server-side on every run before the script starts; the script only reads `TRAWL.<name>`). They are unrelated to the random pick of the stored set above.
87
+ - `RANDOM(a,b,c)` returns one of the comma-separated values, e.g. `{"TRAWL.city":"RANDOM(paris,lyon)"}`. Values are not trimmed, so `RANDOM(a, b)` can yield `" b"`: write no spaces.
88
+ - `DATE(N,unit,format)` returns now + N `unit` (a moment unit, e.g. `days`) in the given moment format, e.g. `DATE(7,days,YYYY-MM-DD)`. N must be a non-negative integer. A `-` in N switches to a random-offset form, not a negative offset, so `DATE(-7,...)` gives today to +6 days: DATE cannot produce past dates.
89
+ - Parsing limits: the whole param value must be exactly the call, with no text before or after it (any prefix disables the generator; the last character is dropped as the `)`). The call is cut at the first `(`, so a value containing a second `(` is truncated. Neither the values nor the DATE format may contain a comma, so a format like `MMM D, YYYY` is cut off.
88
90
 
89
91
  Validate inputs early — throw before any network call if a required param is missing.
90
92