sil-openclaw 0.2.0 → 0.2.2

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to `@4gpts/sil` are documented here. The format follows
3
+ All notable changes to the `sil-openclaw` plugin (npm `sil-openclaw`, ClawHub `@4gpts/sil`) are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project adheres
5
5
  to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
@@ -10,6 +10,43 @@ release (`clawhub package publish --changelog`). See [README](./README.md#releas
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.2.2] - 2026-06-13
14
+
15
+ ### Fixed
16
+
17
+ - **`sil_register` no longer aborts registration on the first premature claim
18
+ `404`.** The claim poll's first tick fires seconds in, before the user opens
19
+ the auth URL — but the session row is created server-side only when they do, so
20
+ the endpoint returns `404` (`not_found`) until then. That first `not_found` was
21
+ grouped with the genuine terminals, killing registration before the human could
22
+ act. `not_found` is now a keep-polling state (like `pending`), bounded by the
23
+ 30-min deadline: a session that never appears settles as `timeout`, never as
24
+ `not_found`. Terminality now lives at the poll loop, not the wire classifier. (#18)
25
+ - **`400` / unexpected non-2xx claim responses now fail fast** via a new distinct
26
+ `invalid_request` outcome, instead of riding the keep-polling `not_found` path
27
+ and spinning to a misleading `timeout`. Unreachable from this client today (the
28
+ plugin always sends a valid verifier), so it logs at WARN as contract-drift
29
+ insurance.
30
+
31
+ ## [0.2.1] - 2026-06-11
32
+
33
+ ### Changed
34
+
35
+ - README restructured to be usage-first. Dropped the internal "How it works",
36
+ "Configuration", and "Files on disk" sections and reduced "Security" to a
37
+ pointer to [SECURITY.md](./SECURITY.md). Expanded the tool surface into a
38
+ **Tools** section (Identity + Catalog, including the `sil_search` ship-to /
39
+ serviceability filters), and added an **Identity & authentication** section
40
+ (sil gives the agent an identity and the capability to transact with UCP
41
+ merchants) and a **Skills** section documenting the bundled `sil` skill.
42
+ Implementation and security internals now live solely in `SECURITY.md` and
43
+ `openclaw.plugin.json#security`.
44
+ - Fixed `pnpm release`’s ClawHub upload: it now re-packs the built tarball under
45
+ the scoped name `@4gpts/sil` (the bare plugin id `sil` is unclaimable — already
46
+ owned by that package) instead of the failing `--name sil`, so npm
47
+ (`sil-openclaw`) and ClawHub (`@4gpts/sil`) publish the same contents from one
48
+ build.
49
+
13
50
  ## [0.2.0] - 2026-06-11
14
51
 
15
52
  ### Changed
package/README.md CHANGED
@@ -56,9 +56,9 @@ The agent loads the bundled skill on first commerce intent and takes it from the
56
56
 
57
57
  **A commerce catalog built for agents, not browsers.** That's sil.
58
58
 
59
- sil is a [UCP](https://github.com/universal-commerce-protocol/ucp) (Universal Commerce Protocol) commerce service. `sil-openclaw` wires it into your OpenClaw agent so it can hold a sil identity and shop the catalog for you — find products, compare prices and availability, pull up full detail, and surface a checkout link the moment you say *buy*. Powered by [4GPTs](https://4gpts.com).
59
+ sil is a [UCP](https://github.com/universal-commerce-protocol/ucp) (Universal Commerce Protocol) commerce service, and `sil-openclaw` wires it into your OpenClaw agent — so it can find products, compare prices and availability, pull up full detail, and surface a checkout link the moment you say *buy*. Powered by [4GPTs](https://4gpts.com).
60
60
 
61
- Today it covers **identity and catalog** — registration plus search and product lookup. The rest of the UCP journey (cart, checkout, order, fulfillment) lands as those domains ship, and the same plugin grows with them.
61
+ Today the plugin covers **identity and catalog** — registration plus search and product lookup. The rest of the UCP journey (cart, checkout, order, fulfillment) lands as those domains ship, and the same plugin grows with them.
62
62
 
63
63
  ---
64
64
 
@@ -94,82 +94,49 @@ agent done — here's your checkout link, ready to pay:
94
94
 
95
95
  ---
96
96
 
97
- ## How it works
97
+ ## Identity & authentication
98
98
 
99
- sil lives at **two origins**, and the plugin talks to each for one job: **sil-web** is the auth authority (registration + token refresh); **sil-api** is the domain service (your identity and the catalog).
99
+ **sil gives your agent an identity — and the capability to use it.** One browser sign-in links your OpenClaw agent to a sil identity it holds on your behalf — your name, your saved addresses. That identity is what lets the agent *transact*: it can search, compare, and surface checkout links with any merchant that speaks [UCP](https://github.com/universal-commerce-protocol/ucp) (the Universal Commerce Protocol), all under your account, without you ever touching a store login.
100
100
 
101
- ```
102
- you your agent (OpenClaw) sil
103
- ───── ───────────────────── ─────
104
- "register me ──▶ sil_register ──▶ sil-web PKCE sign-in +
105
- on sil" token refresh
106
- │ tokens.json (0600, on your disk)
107
- ▼
108
- "find me a ──▶ sil_search ──▶ sil-api catalog
109
- keyboard" sil_product_get search + lookup
110
- │
111
- ◀── ranked products · prices · availability · checkout links ──┘
112
- ```
101
+ Registering is the only manual step. After that the agent carries your identity for you — ask *"who am I on sil?"* anytime to see exactly what it's holding.
113
102
 
114
- Every tool returns the **same JSON envelope** — a `status` (`ok`, `not_registered`, `must_reregister`, `forbidden`, `invalid_request`, `retryable`) plus, on success, its payload — so your agent always knows whether to act, re-register, or retry. An expired access token is refreshed transparently against sil-web (one refresh, one retry); a confirmed-dead session clears your tokens and asks you to register again.
103
+ ---
115
104
 
116
- And **`register()` opens nothing** — no sockets, no timers, no background service. Every network and disk operation happens inside a tool call, so the plugin adds zero idle footprint to your host.
105
+ ## Tools
117
106
 
118
- ### Tool surface
107
+ Namespaced `sil_*` so they never collide with other plugins. Your agent calls them for you — you just say what you want.
119
108
 
120
- Namespaced `sil_*` so they never collide with other plugins:
109
+ **Identity**
121
110
 
122
111
  | Tool | What it does |
123
112
  |---|---|
124
- | `sil_register` | Start browser sign-in; returns an `auth_url`, polls in the background, stores credentials once you're done. |
125
- | `sil_whoami` | Your identity (name, addresses), refreshing an expired token transparently. |
126
- | `sil_search` | Ranked purchasable variants for a `query` / `category` / price range — each with `id`, `title`, `price`, `availability`, `checkout_url` — plus a pagination `cursor`. |
127
- | `sil_product_get` | Resolve `ids: string[]` to full products in UCP shape (description, options, featured variant); misses come back in `not_found`. |
128
-
129
- ---
113
+ | `sil_register` | Start a browser sign-in and link your agent to your sil identity. Returns an `auth_url` to open; once you've signed in, the agent is registered and can transact. Takes no arguments. |
114
+ | `sil_whoami` | Read your sil identity — name and saved addresses — as the agent sees it. Takes no arguments. |
130
115
 
131
- ## Configuration
116
+ **Catalog**
132
117
 
133
- Optional, under `plugins.entries.sil.config` in `~/.openclaw/openclaw.json`. Resolution is **override → env → default**.
134
-
135
- | Key | Env | Default | Origin |
136
- |---|---|---|---|
137
- | `sil_web_url` | `SIL_WEB_URL` | `https://sil.4gpts.com` | sil-web — auth (registration, refresh) |
138
- | `sil_api_url` | `SIL_API_URL` | `https://sil-api.4gpts.com` | sil-api — identity + catalog |
139
-
140
- If your host runs a restrictive tool profile (`coding`, `messaging`, `minimal`), let sil through and restart the gateway:
141
-
142
- ```json
143
- { "tools": { "profile": "coding", "alsoAllow": ["sil"] } }
144
- ```
145
-
146
- Use `alsoAllow`, not `allow` — `allow` runs *after* the profile filter and can't rescue a tool the profile already removed. The default `full` profile needs no patch.
118
+ | Tool | What it does |
119
+ |---|---|
120
+ | `sil_search` | Search for purchasable products. A free-text `query` plus optional filters: `category`, `price_min`/`price_max`, `ship_to` (delivery destination — leave empty to ship to your registered address), `ships_from` (merchant origin country), `condition` (`new` / `secondhand`), and `available`. Returns a ranked list of variants — each with `id`, `title`, `price`, `availability`, `checkout_url`, `source` — and a pagination `cursor`. Location filters take ISO codes (`US`, `CA`), not place names. |
121
+ | `sil_product_get` | Resolve `ids` you already hold to full products in UCP shape — description, options, and the featured purchasable variant with fresh `price`, `availability`, and `checkout_url`. Re-fetch right before buying; those values are point-in-time, not guarantees. Ids that no longer resolve come back in `not_found`. |
147
122
 
148
123
  ---
149
124
 
150
- ## Files on disk
125
+ ## Skills
151
126
 
152
- ```
153
- $SIL_DATA_DIR/ # default: $XDG_DATA_HOME/sil, else ~/.local/share/sil
154
- ├── tokens.json # access + refresh token (mode 0600)
155
- └── config.json # the registered user's identity
156
- ```
127
+ The plugin ships one bundled skill — **`sil`** 🛒 — that your agent loads automatically the first time you express a shopping intent. You don't invoke it; it's the playbook that makes the four tools work well together:
128
+
129
+ - **Routes intent to the right tool.** *"find me a keyboard"* → `sil_search`, *"look these up"* → `sil_product_get`, *"who am I?"* → `sil_whoami`, *"sign me up"* → `sil_register`.
130
+ - **Recovers the right way.** Every tool reports a status; the skill follows that tool's own recovery hint — re-register, fix the query, or retry — instead of guessing a fix that won't work.
131
+ - **Keeps prices honest.** It treats price, availability, and checkout links as point-in-time and re-checks an item right before you buy, so the link you get is the link you pay.
157
132
 
158
- The PKCE verifier never touches disk — it lives only in memory for the length of a sign-in. Uninstalling the plugin never touches this directory; your data stays where you can see and delete it.
133
+ Because the skill ships inside the plugin, installing the plugin installs the skill — there's nothing extra to set up.
159
134
 
160
135
  ---
161
136
 
162
137
  ## Security
163
138
 
164
- The plugin holds your tokens and talks to sil on your behalf — you shouldn't have to take that on faith.
165
-
166
- - **`register()` opens nothing.** No sockets, no timers, no daemon. All I/O is inside a tool call — zero idle footprint.
167
- - **PKCE, verifier in memory only.** Sign-in uses PKCE; the verifier is never written to disk. Tokens and identity PII are never logged.
168
- - **Credentials at `$SIL_DATA_DIR`, mode 0600.** The registration poll timer is bounded — it stops on the first terminal outcome or the session deadline.
169
- - **Two origins, nothing else.** sil-web (auth) and sil-api (identity + catalog). No inbound webhook, no public URL, no third-party beacons.
170
- - **No `child_process`, no native modules, no install scripts.** A minimal, auditable surface.
171
-
172
- > **Full policy:** [SECURITY.md](./SECURITY.md) · machine-readable disclosure in [`openclaw.plugin.json#security`](./openclaw.plugin.json). **Found an issue?** DM [@4gpts on X](https://x.com/4gpts).
139
+ The plugin holds your sil credentials and transacts on your behalf. The full disclosure — what it touches, what it stores, and how to report an issue — is in **[SECURITY.md](./SECURITY.md)**.
173
140
 
174
141
  ---
175
142
 
@@ -182,7 +149,7 @@ pnpm test # vitest (unit + integration)
182
149
  pnpm typecheck # tsc --noEmit
183
150
  ```
184
151
 
185
- Releasing is two steps: `pnpm version <patch|minor|major>` (bump → sync manifest → cut changelog → test → tag → push), then `pnpm release` (build → pack once → npm `sil-openclaw` + ClawHub `sil`, the **same** tarball to both). Full guide in [`CLAUDE.md`](./CLAUDE.md#releasing); release notes in [`CHANGELOG.md`](./CHANGELOG.md). Adding a tool is three steps, enforced by a drift-guard test — see [`CLAUDE.md`](./CLAUDE.md#how-to-add-a-tool).
152
+ Releasing is two steps: `pnpm version <patch|minor|major>` (bump → sync manifest → cut changelog → test → tag → push), then `pnpm release` (build → pack → npm `sil-openclaw` + ClawHub `@4gpts/sil` — the same contents, re-packed under each registry's name). Full guide in [`CLAUDE.md`](./CLAUDE.md#releasing); release notes in [`CHANGELOG.md`](./CHANGELOG.md). Adding a tool is three steps, enforced by a drift-guard test — see [`CLAUDE.md`](./CLAUDE.md#how-to-add-a-tool).
186
153
 
187
154
  ---
188
155
 
@@ -10,10 +10,17 @@
10
10
  * POST /api/v1/sessions/{id}/claim body { code_verifier }
11
11
  * 200 { access_token, refresh_token, user:{id} } → success (EXACTLY once)
12
12
  * 200 { status: "pending" } → pending
13
- * 409 → already_claimed
14
- * 410 → expired
13
+ * 409 → already_claimed (terminal)
14
+ * 410 → expired (terminal)
15
15
  * 404 → not_found (wrong verifier
16
- * ≡ unknown session, uniform)
16
+ * ≡ unknown session, uniform);
17
+ * the NORMAL pre-session early
18
+ * state — KEEP POLLING at the
19
+ * loop (non-terminal); only the
20
+ * deadline ends it (as timeout)
21
+ * 400 / other unexpected non-2xx → invalid_request (non-polling
22
+ * terminal — fail fast; a bad
23
+ * request can't be re-polled)
17
24
  * 5xx / network / abort → retryable
18
25
  *
19
26
  * POST /api/v1/auth/refresh body { refresh_token }
@@ -134,7 +141,16 @@ const REQUEST_TIMEOUT_MS = 15_000;
134
141
  * Classify a claim response from its HTTP status AND body. The discriminant for
135
142
  * the two-200s split is the PRESENCE OF BOTH TOKENS in the body — never the
136
143
  * status code. A 200 that is not a complete token pair is `pending` (the safe
137
- * non-terminal landing); 409/410/404 are distinct terminals; 5xx is retryable.
144
+ * non-terminal landing). 409/410 are distinct terminals; 5xx is retryable.
145
+ *
146
+ * 404 is `not_found` ON THE WIRE — but it is the NORMAL pre-session early state
147
+ * (the session row is INSERTed server-side only when the user opens the auth
148
+ * URL), so its terminality lives at the LOOP, not here: `claimStep` keeps polling
149
+ * on `not_found` and only the 30-min deadline ends a never-appearing session (as
150
+ * `timeout`). A 400 / any other unexpected non-{200,409,410,404,5xx} status is a
151
+ * structurally-malformed request that re-polling can never fix, so it is its OWN
152
+ * non-polling terminal `invalid_request` (fail fast) rather than riding the
153
+ * keep-polling `not_found` path and spinning for the full deadline.
138
154
  *
139
155
  * Pure and exported — this is the highest-risk subtle branch, unit-tested in
140
156
  * isolation (sil-client.test.ts).
@@ -149,9 +165,11 @@ export function classifyClaimResponse(status, body) {
149
165
  if (status >= 500)
150
166
  return { kind: "retryable" };
151
167
  if (status !== 200) {
152
- // 400 (malformed request) or any other unexpected 4xx: terminal not_found
153
- // (re-polling can't fix a bad request); surface a re-run hint, not a spin.
154
- return { kind: "not_found" };
168
+ // 400 (malformed request) or any other unexpected non-2xx: a NON-polling
169
+ // terminal — re-polling can't fix a structurally-bad request, so fail fast
170
+ // and loud rather than spinning to the deadline. Distinct from the early
171
+ // 404 `not_found`, which DOES keep polling.
172
+ return { kind: "invalid_request" };
155
173
  }
156
174
  // 200 — classify by body shape. Both tokens required for a clean success;
157
175
  // anything short of that is the safe non-terminal `pending`.
@@ -19,9 +19,11 @@
19
19
  * 4. Start a fire-and-forget bounded poll of the claim endpoint, then return
20
20
  * promptly with `{ status: "awaiting_browser", auth_url, session_id }`.
21
21
  * 5. On the poll's terminal success, persist tokens.json + config.json
22
- * atomically. Other terminals (expired / already_claimed / not_found /
22
+ * atomically. Other terminals (expired / already_claimed / invalid_request /
23
23
  * timeout) persist nothing; the agent learns the outcome by re-calling
24
- * sil_register (→ already_registered) or sil_whoami.
24
+ * sil_register (→ already_registered) or sil_whoami. A claim 404 (`not_found`)
25
+ * is NOT a terminal — it is the normal pre-session early state and keeps the
26
+ * poll ticking; a session that never appears ends as `timeout` at the deadline.
25
27
  *
26
28
  * register() must stay synchronous and side-effect-free beyond registering the
27
29
  * tool — no fetch, no timer, no unawaited promise here. The poll timer is armed
@@ -232,17 +234,22 @@ function transient() {
232
234
  }
233
235
  /**
234
236
  * One poll step: claim, then map the outcome to the loop's done/continue signal.
235
- * `pending`/`retryable` keep the loop alive (`done:false`). A successful claim
236
- * is persisted HERE — tokens.json + config.json written atomically inside this
237
- * awaited tick — so the files are on disk before the loop settles; the step then
238
- * carries only the user_id forward (the tokens never travel past this closure).
239
- * Other terminals (expired / already_claimed / not_found) persist nothing.
237
+ * `pending`/`retryable`/`not_found` keep the loop alive (`done:false`). The 404
238
+ * `not_found` is the NORMAL pre-session early state (the session row is INSERTed
239
+ * server-side only when the user opens the auth URL), so it keeps polling exactly
240
+ * like `pending`, bounded by the 30-min deadline — a session that never appears
241
+ * settles as `timeout`, never as `not_found`. A successful claim is persisted
242
+ * HERE — tokens.json + config.json written atomically inside this awaited tick —
243
+ * so the files are on disk before the loop settles; the step then carries only
244
+ * the user_id forward (the tokens never travel past this closure). The terminals
245
+ * (expired / already_claimed / invalid_request) persist nothing.
240
246
  */
241
247
  async function claimStep(apiUrl, sessionId, verifier) {
242
248
  const outcome = await claimSession(apiUrl, sessionId, verifier);
243
249
  switch (outcome.kind) {
244
250
  case "pending":
245
251
  case "retryable":
252
+ case "not_found":
246
253
  return { done: false };
247
254
  case "success":
248
255
  await writeTokens({
@@ -253,7 +260,7 @@ async function claimStep(apiUrl, sessionId, verifier) {
253
260
  return { done: true, outcome: "success", user_id: outcome.user.id };
254
261
  case "expired":
255
262
  case "already_claimed":
256
- case "not_found":
263
+ case "invalid_request":
257
264
  return { done: true, outcome: outcome.kind };
258
265
  }
259
266
  }
@@ -275,11 +282,14 @@ function handleDone(api, sessionId, result) {
275
282
  api.logger.info("sil_register_timeout", { session_id: sessionId });
276
283
  return;
277
284
  }
278
- // expired / already_claimed / not_found — log the terminal so the outcome is
279
- // never silent; the agent learns it on its next sil_register / sil_whoami.
285
+ // expired / already_claimed / invalid_request — log the terminal so the outcome
286
+ // is never silent; the agent learns it on its next sil_register / sil_whoami.
287
+ // `invalid_request` logs at WARN: a malformed claim request is unreachable from
288
+ // this client today, so it signals a contract-drift bug, not a user outcome —
289
+ // make it loud (the genuine `expired`/`already_claimed` are routine, at info).
280
290
  const outcome = typeof step.outcome === "string" ? step.outcome : "unknown";
281
291
  const marker = `sil_register_${outcome}`;
282
- if (outcome === "not_found") {
292
+ if (outcome === "invalid_request") {
283
293
  api.logger.warn(marker, { session_id: sessionId });
284
294
  }
285
295
  else {
@@ -2,7 +2,7 @@
2
2
  "id": "sil",
3
3
  "name": "sil",
4
4
  "description": "sil commerce plugin for OpenClaw — register on sil, read your identity, and search and look up products in the sil catalog.",
5
- "version": "0.2.0",
5
+ "version": "0.2.2",
6
6
  "skills": ["./skill"],
7
7
  "activation": {
8
8
  "onCapabilities": ["tool"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sil-openclaw",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "OpenClaw plugin for sil — register an identity and search and look up products in the sil commerce catalog from an agent.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {