pi-smart-fetch 0.2.13 → 0.2.14

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/README.md CHANGED
@@ -17,7 +17,7 @@ Compared with naive Node.js `fetch()`, this package gives you:
17
17
  - **useful metadata** like title, author, published date, site, and language when available
18
18
  - **multiple output formats**: `markdown`, `html`, `text`, or `json`
19
19
  - **single and batch tools**: `web_fetch` for one URL, `batch_web_fetch` for many
20
- - **pi-specific behavior** including an optional `verbose` flag and defaults from pi settings
20
+ - **pi-specific behavior** including full metadata for agents, a compact history preview for users, and defaults from pi settings
21
21
  - **bounded batch fan-out** with a configurable default concurrency of `8`
22
22
  - **a richer pi TUI for batch mode** with per-item rows, truncated URLs, statuses, small progress bars, and timer-driven spinner animation
23
23
  - **attachment and binary download support** when a response is an attachment or non-text payload
@@ -69,18 +69,15 @@ For `batch_web_fetch`, `requests` is an array of objects, and **each item accept
69
69
 
70
70
  ### `web_fetch`
71
71
 
72
- By default, the tool returns a compact response containing non-empty:
73
- - URL
72
+ Agent-facing tool output always includes the full non-empty metadata header plus the extracted document body.
73
+
74
+ In the pi TUI backlog/history preview, user-facing metadata is intentionally brief and only shows:
74
75
  - Title
75
- - Author
76
76
  - Published
77
- - content
78
77
 
79
- Set `verbose: true` to include fuller metadata such as:
80
- - site
81
- - language
82
- - word count
83
- - browser profile info
78
+ The duplicated `URL:` line is hidden from the preview because the tool call line already shows the URL.
79
+
80
+ The optional `verbose` flag is retained for compatibility, but pi now always returns the full metadata header to the agent.
84
81
 
85
82
  ### `batch_web_fetch`
86
83
 
@@ -99,36 +96,35 @@ In the pi TUI, batch mode also streams per-item progress rows showing:
99
96
 
100
97
  ## Example tool outputs
101
98
 
102
- ### Compact `web_fetch` output (default)
99
+ ### Agent-facing `web_fetch` output
103
100
 
104
101
  ```text
105
102
  > URL: https://example.com/blog/some-article
106
103
  > Title: Some Article
107
104
  > Author: Jane Doe
108
105
  > Published: 2026-03-12
106
+ > Site: Example Blog
107
+ > Language: en
108
+ > Words: 1284
109
+ > Browser: chrome_145/windows
109
110
 
110
111
  # Some Article
111
112
 
112
113
  This is the cleaned readable content extracted from the page.
113
- It omits most navigation, footer, and unrelated chrome.
114
+ It includes the body plus the full metadata header available to the agent.
114
115
  ```
115
116
 
116
- ### Verbose `web_fetch` output (`verbose: true`)
117
+ ### pi history/backlog preview for `web_fetch`
117
118
 
118
119
  ```text
119
- > URL: https://example.com/blog/some-article
120
- > Title: Some Article
121
- > Author: Jane Doe
122
- > Published: 2026-03-12
123
- > Site: Example Blog
124
- > Language: en
125
- > Words: 1284
126
- > Browser: chrome_145/windows
120
+ web_fetch https://example.com/blog/some-article
121
+ Title: Some Article
122
+ Published: 2026-03-12
127
123
 
128
124
  # Some Article
129
125
 
130
126
  This is the cleaned readable content extracted from the page.
131
- It includes the same body content, but with a richer metadata header.
127
+ ... (more lines, Ctrl+O to expand)
132
128
  ```
133
129
 
134
130
  ### Attachment/binary `web_fetch` output
@@ -185,14 +181,14 @@ Error: Invalid URL: not-a-url
185
181
  | `removeImages` | boolean | `false` | Strip image references from output |
186
182
  | `includeReplies` | boolean \| `extractors` | `extractors` | Include replies/comments |
187
183
  | `proxy` | string | none | Proxy URL |
188
- | `verbose` | boolean | `false` | Include the full metadata header. Can default from `smartFetchVerboseByDefault` |
184
+ | `verbose` | boolean | `false` | Compatibility flag. pi currently returns the full metadata header to the agent regardless; user history preview stays compact |
189
185
 
190
186
  ### `batch_web_fetch`
191
187
 
192
188
  | Parameter | Type | Default | Description |
193
189
  |-------------|---------------------|-----------|-------------|
194
190
  | `requests` | array of objects | required | Array of fetch requests. Each item accepts the same parameters as `web_fetch` except `verbose` |
195
- | `verbose` | boolean | `false` | Include the full metadata header for each successful result |
191
+ | `verbose` | boolean | `false` | Compatibility flag. pi currently returns the full metadata header for successful results regardless |
196
192
 
197
193
  ## pi settings
198
194
 
@@ -213,7 +209,7 @@ Optional custom settings in `~/.pi/agent/settings.json` or `.pi/settings.json`:
213
209
  ```
214
210
 
215
211
  Behavior:
216
- - `smartFetchVerboseByDefault` sets the default for `verbose`
212
+ - `smartFetchVerboseByDefault` sets the stored default for the compatibility `verbose` flag
217
213
  - `smartFetchDefaultMaxChars` sets the runtime default for `maxChars`
218
214
  - `smartFetchDefaultTimeoutMs` sets the runtime request timeout
219
215
  - `smartFetchDefaultBrowser` sets the default browser fingerprint profile
package/dist/index.js CHANGED
@@ -10635,13 +10635,13 @@ async function loadPiSmartFetchSettings(cwd, agentDir = getAgentDir()) {
10635
10635
  var toolDescription = [
10636
10636
  "Fetch a URL with browser-grade TLS fingerprinting and extract clean, readable content.",
10637
10637
  "Uses wreq-js for browser-like TLS/HTTP2 impersonation and Defuddle for article extraction.",
10638
- "Supports the same fetch parameters as the OpenClaw tool, plus an optional verbose flag.",
10638
+ "Returns full metadata plus the extracted document to the agent while keeping the pi history preview brief.",
10639
10639
  "Does NOT execute JavaScript \u2014 use a browser automation tool for JS-heavy pages."
10640
10640
  ].join(" ");
10641
10641
  var batchToolDescription = [
10642
10642
  "Fetch multiple URLs with browser-grade TLS fingerprinting and readable extraction.",
10643
10643
  "Each request accepts the same parameters as web_fetch and fans out with bounded concurrency.",
10644
- "Streams per-item progress in the pi TUI with truncated URLs, statuses, and small progress bars.",
10644
+ "Returns full per-item metadata to the agent and streams compact per-item progress in the pi TUI.",
10645
10645
  "Does NOT execute JavaScript \u2014 use a browser automation tool for JS-heavy pages."
10646
10646
  ].join(" ");
10647
10647
  var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
@@ -10746,27 +10746,24 @@ function renderBatchProgressText(snapshot, width, expanded, theme, spinnerTick =
10746
10746
  });
10747
10747
  return [summary, ...rows].join("\n");
10748
10748
  }
10749
+ function renderUserMetadataLine(label, value, theme) {
10750
+ return theme.fg("syntaxKeyword", `${label}: `) + theme.fg("syntaxString", String(value));
10751
+ }
10749
10752
  function buildWebFetchMetadataLines(details, theme) {
10750
10753
  const fetchResult = details.fetchResult;
10751
10754
  if (!fetchResult) {
10752
10755
  return [];
10753
10756
  }
10754
- const metadata = details.verbose ? [
10755
- ["URL", fetchResult.finalUrl],
10756
- ["Title", fetchResult.title],
10757
- ["Author", fetchResult.author],
10758
- ["Published", fetchResult.published],
10759
- ["Site", fetchResult.site],
10760
- ["Language", fetchResult.language],
10761
- ["Words", fetchResult.wordCount],
10762
- ["Browser", `${fetchResult.browser}/${fetchResult.os}`]
10763
- ] : [
10764
- ["URL", fetchResult.finalUrl],
10757
+ const metadata = [
10765
10758
  ["Title", fetchResult.title],
10766
- ["Author", fetchResult.author],
10767
10759
  ["Published", fetchResult.published]
10768
10760
  ];
10769
- return metadata.filter(([, value]) => value !== void 0 && value !== "").map(([label, value]) => theme.fg("accent", `${label}: ${value}`));
10761
+ return metadata.flatMap(([label, value]) => {
10762
+ if (value === void 0 || value === "") {
10763
+ return [];
10764
+ }
10765
+ return [renderUserMetadataLine(label, value, theme)];
10766
+ });
10770
10767
  }
10771
10768
  function shouldRenderHighlightedContent(format) {
10772
10769
  return format === "markdown" || format === "json" || format === "html";
@@ -10913,12 +10910,12 @@ function piSmartFetchExtension(pi) {
10913
10910
  name: "web_fetch",
10914
10911
  label: "web_fetch",
10915
10912
  description: toolDescription,
10916
- promptSnippet: "web_fetch(url, browser?, os?, headers?, maxChars?, timeoutMs?, format?, removeImages?, includeReplies?, proxy?, verbose?): fetch browser-fingerprinted readable web content",
10913
+ promptSnippet: "web_fetch(url, browser?, os?, headers?, maxChars?, timeoutMs?, format?, removeImages?, includeReplies?, proxy?, verbose?): fetch browser-fingerprinted readable web content with full agent metadata and a compact pi preview",
10917
10914
  parameters: Type.Object({
10918
10915
  ...createBaseFetchToolParameterProperties(defaults),
10919
10916
  verbose: Type.Optional(
10920
10917
  Type.Boolean({
10921
- description: "Include the full metadata header (site, language, word count, browser fingerprint info). Default: false, or smartFetchVerboseByDefault from pi settings."
10918
+ description: "Compatibility flag. pi currently returns the full metadata header to the agent regardless, while keeping the history preview compact. Default: false, or smartFetchVerboseByDefault from pi settings."
10922
10919
  })
10923
10920
  )
10924
10921
  }),
@@ -10998,7 +10995,10 @@ function piSmartFetchExtension(pi) {
10998
10995
  }
10999
10996
  return {
11000
10997
  content: [
11001
- { type: "text", text: buildFetchResponseText(result, { verbose }) }
10998
+ {
10999
+ type: "text",
11000
+ text: buildFetchResponseText(result, { verbose: true })
11001
+ }
11002
11002
  ],
11003
11003
  details: {
11004
11004
  verbose,
@@ -11070,12 +11070,12 @@ ${message}`;
11070
11070
  name: "batch_web_fetch",
11071
11071
  label: "batch_web_fetch",
11072
11072
  description: batchToolDescription,
11073
- promptSnippet: "batch_web_fetch(requests, verbose?): fetch multiple URLs concurrently with per-item progress in the pi TUI",
11073
+ promptSnippet: "batch_web_fetch(requests, verbose?): fetch multiple URLs concurrently with full agent metadata and per-item progress in the pi TUI",
11074
11074
  parameters: Type.Object({
11075
11075
  ...createBatchFetchToolParameterProperties(defaults),
11076
11076
  verbose: Type.Optional(
11077
11077
  Type.Boolean({
11078
- description: "Include the full metadata header for each successful result. Default: false, or smartFetchVerboseByDefault from pi settings."
11078
+ description: "Compatibility flag. pi currently returns the full metadata header for successful results regardless, while keeping the history preview compact. Default: false, or smartFetchVerboseByDefault from pi settings."
11079
11079
  })
11080
11080
  )
11081
11081
  }),
@@ -11139,7 +11139,9 @@ ${message}`;
11139
11139
  content: [
11140
11140
  {
11141
11141
  type: "text",
11142
- text: buildBatchFetchResponseText(batchResult, { verbose })
11142
+ text: buildBatchFetchResponseText(batchResult, {
11143
+ verbose: true
11144
+ })
11143
11145
  }
11144
11146
  ],
11145
11147
  details: {