sil-openclaw 0.6.0 → 0.7.0

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +12 -11
  3. package/SECURITY.md +3 -3
  4. package/dist/lib/shopping-call.js +5 -1
  5. package/dist/lib/sil-client.js +34 -62
  6. package/dist/lib/tool-result.js +1 -1
  7. package/dist/tools/catalog.js +83 -239
  8. package/dist/tools/identity.js +74 -87
  9. package/openclaw.plugin.json +11 -6
  10. package/package.json +1 -1
  11. package/schema/PROVENANCE.md +7 -4
  12. package/schema/shopping-brief-write-request.schema.json +225 -0
  13. package/schema/{shopping-brief-create-response.schema.json → shopping-brief-write-response.schema.json} +3 -3
  14. package/schema/shopping-content-request.schema.json +4 -7
  15. package/schema/shopping-content-response.schema.json +234 -108
  16. package/schema/shopping-domain-get-request.schema.json +18 -0
  17. package/schema/shopping-domain-get-response.schema.json +124 -86
  18. package/schema/shopping-offers-request.schema.json +174 -23
  19. package/schema/shopping-offers-response.schema.json +20 -10
  20. package/schema/shopping-product-get-request.schema.json +2 -2
  21. package/schema/shopping-product-get-response.schema.json +113 -16
  22. package/schema/shopping-search-request.schema.json +16 -25
  23. package/schema/shopping-search-response.schema.json +95 -21
  24. package/schema/shopping-seller-get-response.schema.json +249 -221
  25. package/schema/shopping-user-forget-request.schema.json +43 -0
  26. package/schema/shopping-user-forget-response.schema.json +74 -0
  27. package/schema/shopping-user-read-request.schema.json +36 -0
  28. package/schema/shopping-user-read-response.schema.json +372 -0
  29. package/schema/shopping-user-remember-request.schema.json +340 -0
  30. package/schema/shopping-user-remember-response.schema.json +66 -0
  31. package/schema/sil-whoami-request.schema.json +8 -0
  32. package/schema/sil-whoami-response.schema.json +90 -0
  33. package/sil-shopping/SKILL.md +149 -203
  34. package/schema/shopping-brief-create-request.schema.json +0 -98
  35. package/schema/shopping-brief-edit-request.schema.json +0 -125
  36. package/schema/shopping-brief-edit-response.schema.json +0 -24
  37. package/schema/shopping-profile-edit-request.schema.json +0 -97
  38. package/schema/shopping-profile-edit-response.schema.json +0 -17
package/CHANGELOG.md CHANGED
@@ -10,6 +10,21 @@ release (`clawhub package publish --changelog`). See [README](./README.md#releas
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.7.0] - 2026-10-12
14
+
15
+ ### Changed
16
+
17
+ - **Fifteen tools on sil's signed contract.** `shopping_brief_create`, `shopping_brief_edit` and
18
+ `shopping_profile_edit` are gone; `shopping_brief_write`, `shopping_user_read`,
19
+ `shopping_user_remember` and `shopping_user_forget` replace them. `sil_whoami` answers the
20
+ lean shape (name, country, currency, gender, language, one default address). Replies are
21
+ compact JSON. `shopping_domain_get` pages with `keys` and `after`; `shopping_product_get`
22
+ takes at most three ids and an optional `page`. The skill is rewritten to match.
23
+ - **`sil_whoami` answers flat**, exactly the contract's shape: no `identity` wrapper, no
24
+ `web_origin` fields. `shopping_product_get` names ids sil does not hold in `not_held`.
25
+ - **sil refuses a plugin older than 0.7.0** (HTTP 426); its message reaches the agent as it
26
+ stands.
27
+
13
28
  ## [0.6.0] - 2026-10-08
14
29
 
15
30
  ### Added
package/README.md CHANGED
@@ -135,7 +135,7 @@ agent [shopping_domain_search "backpacking tent" → shopping_domain_get]
135
135
 
136
136
  ## Tools
137
137
 
138
- Fourteen tools. The eleven the shopping loop calls are named `shopping_*` — for what
138
+ Fifteen tools. The twelve the shopping loop calls are named `shopping_*` — for what
139
139
  they do for you — and the three account tools keep the `sil_` name. Your agent calls them
140
140
  for you; you just say what you want.
141
141
 
@@ -144,17 +144,18 @@ for you; you just say what you want.
144
144
  | Tool | What it does |
145
145
  |---|---|
146
146
  | `sil_register` | Start a browser sign-in and link your agent to your sil identity. Takes no arguments. |
147
- | `sil_whoami` | Read your sil identity — name, country, the currency you price in, saved addresses, and the measurements and preferences sil holds for you — as the agent sees it. Takes no arguments. |
147
+ | `sil_whoami` | Read your sil identity — name, country, the currency you price in, language, gender and your default address — as the agent sees it. Takes no arguments. |
148
148
  | `sil_doctor` | Check the install: file modes, credential health, host wiring, and whether a newer plugin is published. Reports; repairs only what is safe. |
149
149
 
150
- **Your brief and your profile**
150
+ **What sil keeps about you, and your briefs**
151
151
 
152
152
  | Tool | What it does |
153
153
  |---|---|
154
- | `shopping_brief_create` | Open the shopping job this conversation works from — a title and what you are after in your own words, plus any wants you have already stated. One brief per conversation, across every category it covers. |
155
- | `shopping_brief_edit` | Write a want, a change of mind or the end of the job into that brief: the values you want under the category they belong to, the seller terms under `seller`, the keys you have given up, and one sentence saying what you changed and why. |
156
- | `shopping_brief_read` | With no arguments, your shopping jobs, newest first — so a new chat carries on where the last one stopped. With an `id`, that whole brief: what you are after, every want under its category, and the decisions you have already taken. |
157
- | `shopping_profile_edit` | Write what is true of you whatever you are buying: a measurement with its unit, a size as it is printed, a lasting taste in your own words, or the currency you price in. Writing the same name again replaces it; `sil_whoami` reads it all back. A new currency changes which offers come first, never a price: sil converts nothing. |
154
+ | `shopping_user_read` | Everything sil keeps about you — measurements, memories, preferences, purchases — each with what it gives you back. |
155
+ | `shopping_user_remember` | Keep what lasts, in the turn you say it, with "forget that" as the undo. |
156
+ | `shopping_user_forget` | Erase rows you name, or everything, on your word. |
157
+ | `shopping_brief_write` | Open a brief for a buy with requirements, or update one: a title, what you are after in your own words, specs by domain, decisions and the end of the job. |
158
+ | `shopping_brief_read` | With no arguments, your shopping jobs, newest first. With an `id`, that whole brief. |
158
159
 
159
160
  **Shopping**
160
161
 
@@ -162,10 +163,10 @@ for you; you just say what you want.
162
163
  |---|---|
163
164
  | `shopping_domain_search` | Say what the thing is called, in your own words, and get back up to three leaves (buyable kinds of thing), best first: each with its name, which of sil's words matched, and `under` — the places above it. Empty when nothing fits, or when the best fit is an area sil does not carry yet. |
164
165
  | `shopping_content` | Grep sil's own documents on the line through a node — the node, its kinds, beneath it and above it — by words, never by meaning. Answers whole passages within a token budget, every-word matches first, each with the words it matched; filled passages carry none. |
165
- | `shopping_domain_get` | Read a leaf's specs: every key it is bought by with the operators, unit and allowed values each takes, plus its kinds, parts and how its products are bought (`record`). On a kind it also lists its `leaves`. A shelf or domain is refused as `not_a_leaf`; an area sil does not carry yet as `not_carried`. |
166
- | `shopping_search` | Search one settled category, under the brief this conversation is working from. Send the brief's id, the domain, your own shopping words, how many products you want, the brief's own values for that category as `specs`, and `ship_to` — the label of one of your saved addresses, which localizes the search (your default one when it is left off) and rules no seller out. Products come back best-first with `fit` (what sil verified), their variants, a price range, and `webpage_info` where sil has not read the page yet. |
167
- | `shopping_product_get` | Open the whole of what sil holds on 1–10 shortlisted variants: the description, the images, every key sil holds, and where each reading came from and when. |
168
- | `shopping_offers` | Price 1–10 picked variants live, on your own terms: send the brief's id and the variant ids, and sil reads the rest — the brief's `seller` terms and price ceiling, your default address and your currency. It looks on the web for shops it does not hold yet, and each offer comes back with the price exactly as the page prints it, its currency, availability, the listing URL, the moment sil read it, and `seller_fit` — whether that seller ships to your address (`serviceable`, `not_serviceable` or `unknown`) and what it holds for each term on the brief. Shops in your currency and market come first. |
166
+ | `shopping_domain_get` | Read a leaf's specs, in pages when it is wide (`keys` reads chosen ones whole, `after` reads on): every key it is bought by with the operators, unit and allowed values each takes, plus its kinds, parts and how its products are bought (`record`). On a kind it also lists its `leaves`. A shelf or domain is refused as `not_a_leaf`; an area sil does not carry yet as `not_carried`. |
167
+ | `shopping_search` | Search a leaf, or the kind above its leaves, on every want the buyer settled: each a spec with the operator it needs, words only for what no spec holds. No brief or earlier call is needed. Products come back in sil's order with `fit` (what sil verified, or `unknown`), and every search answers sil's receipt: shops and products weighed, how many fit, how many it could not tell, and what was set aside and why. |
168
+ | `shopping_product_get` | Open the whole of what sil holds on up to three shortlisted variants (or one product's whole page): the description, the images, every key sil holds, and where each reading came from and when. |
169
+ | `shopping_offers` | Who sells it, at what price and on what terms: send 1–10 picked variant ids or a product's `name` for a price check, optionally the `seller_specs` the buyer settled and a `brief` id. Each offer comes back with the seller, the price in its own currency, availability, the listing URL, when sil read it, and `seller_fit` — whether that seller ships to your default address (`serviceable`, `not_serviceable` or `unknown`) and its value for each seller spec asked. Shops in your currency and market come first. |
169
170
  | `shopping_seller_get` | One seller's whole terms, for 1–10 of them: `specs` (every seller key sil holds a value for), whether it ships to you, and the shipping routes and return terms sil has read. `unknown` keeps the seller; it just means sil has not read that policy. |
170
171
 
171
172
  **The wire is a contract, not a convention.** Each shopping tool's input schema IS the
package/SECURITY.md CHANGED
@@ -31,9 +31,9 @@ The plugin talks to these hosts and no others:
31
31
  the published `@4gpts/sil` version: no token, no PII, bounded timeout, redirects
32
32
  refused, silent on any failure.
33
33
 
34
- The `shopping_*` tools are read-only, except `shopping_brief_create` /
35
- `shopping_brief_edit` / `shopping_profile_edit` (write the buyer's own brief and
36
- profile under their sil account). On a `401`, every sil call refreshes once and retries once. A second
34
+ The `shopping_*` tools are read-only, except `shopping_brief_write` /
35
+ `shopping_user_remember` / `shopping_user_forget` (write or erase the buyer's own brief
36
+ and rows under their sil account). On a `401`, every sil call refreshes once and retries once. A second
37
37
  `401` or a dead refresh token clears `tokens.json`.
38
38
 
39
39
  ### Filesystem and credentials
@@ -9,7 +9,11 @@ import { callShopping, refreshAndRetryOnce, } from "./sil-client.js";
9
9
  import { jsonResult } from "./tool-result.js";
10
10
  /** The guide read, as one route constant: two spellings of one path is a route nobody
11
11
  * owns. */
12
- export const DOMAIN_GET_ROUTE = { method: "GET", path: "/catalog/domains/:path" };
12
+ export const DOMAIN_GET_ROUTE = {
13
+ method: "GET",
14
+ path: "/catalog/domains/:path",
15
+ query: ["keys", "after"],
16
+ };
13
17
  function refused(status, result) {
14
18
  return { kind: "refused", status, result };
15
19
  }
@@ -36,11 +36,14 @@
36
36
  * request body:
37
37
  *
38
38
  * GET <silApiUrl>/identity Authorization: Bearer <access_token>
39
- * 200 { name, country?, addresses, measurements?, preferences? } → ok
39
+ * 200 { status, name, country?, currency?, gender?, language?, address? } → ok
40
40
  * 401 → unauthorized (→ refresh)
41
41
  * 403 { error: user_not_provisioned | principal_mismatch } → forbidden (terminal)
42
+ * 426 plugin older than sil accepts → refused (carries sil's message)
42
43
  * 5xx / network / abort → retryable
43
44
  *
45
+ * Shopping routes: 426 (plugin too old) → invalid_request, carrying sil's message.
46
+ *
44
47
  * THE SHOPPING WIRE IS NOT MIRRORED HERE. Each tool's request shape is the committed
45
48
  * artifact under `schema/`, registered as the tool's own `parameters`; each 200 body is
46
49
  * the agent contract's, handed back VERBATIM. So this file declares no product type at
@@ -61,7 +64,7 @@
61
64
  * The VERB is load-bearing: only `GET /identity` is the self-read — `POST` is the
62
65
  * agent enrich route and carries no name. The identity rides in the envelope's
63
66
  * `result`, and a 200 with no usable identity (no `name`) falls to `retryable`,
64
- * never to a false `ok`. An EMPTY `addresses: []` IS a valid identity.
67
+ * never to a false `ok`. A buyer with no `address` is a valid identity.
65
68
  *
66
69
  * Tokens never appear in a log line here (mirrors sil-web's invariant) — they
67
70
  * only travel inside the returned union variant.
@@ -74,15 +77,6 @@ import { readTokens, writeTokens } from "./credentials.js";
74
77
  * route that answers from what sil already holds — at 15 s the plugin refused 7 of 12 live
75
78
  * calls sil-api went on to finish (2026-09-15). */
76
79
  const REQUEST_TIMEOUT_MS = 45_000;
77
- /** The search alone waits out its web leg, which the agent contract gives 120 s. Aborting
78
- * short of that changes nothing sil does — the index is billed, the pages are read and the
79
- * row is written — it only hides the answer from the agent that asked for it. */
80
- const SEARCH_TIMEOUT_MS = 130_000;
81
- /** The search route, the one call that waits out a web leg. Resolved by PATH so a route
82
- * renamed in the tool table falls back to the shared ceiling loudly — `lib/sil-client.test.ts`
83
- * reads this off the production table. */
84
- const SEARCH_PATH = "/catalog/search";
85
- export const requestTimeoutMs = (route) => route.path === SEARCH_PATH ? SEARCH_TIMEOUT_MS : REQUEST_TIMEOUT_MS;
86
80
  /**
87
81
  * Classify a shopping response. One classifier for all ten routes — the contract
88
82
  * gives them one error vocabulary, so a second one could only drift.
@@ -94,8 +88,10 @@ export const requestTimeoutMs = (route) => route.path === SEARCH_PATH ? SEARCH_T
94
88
  * source, and a second opinion here would be the copy that drifts from it.
95
89
  */
96
90
  function classifyShoppingResponse(status, body) {
97
- if (status === 400)
91
+ // 426: sil refuses a plugin older than it accepts; its message says to update.
92
+ if (status === 400 || status === 426) {
98
93
  return { kind: "invalid_request", message: extractApiError(body).message };
94
+ }
99
95
  if (status === 401)
100
96
  return { kind: "unauthorized" };
101
97
  if (status === 403)
@@ -185,7 +181,7 @@ export function classifyRefreshResponse(status, body) {
185
181
  * 401 → unauthorized (the ONLY refresh trigger)
186
182
  * 403 → forbidden (terminal; carries user_not_provisioned/principal_mismatch)
187
183
  * 5xx / non-200 → retryable
188
- * 200 → unwrap the envelope `result` and narrow to {name, addresses}; a 200
184
+ * 200 → unwrap the envelope `result` and narrow to {name, …}; a 200
189
185
  * that yields no usable identity (no `name`) is `retryable`, NEVER `ok`
190
186
  * (the anti-false-green guard — a partial/garbage 200, or the current
191
187
  * /identity STUB shape with no name, must not read as success).
@@ -195,6 +191,9 @@ export function classifyRefreshResponse(status, body) {
195
191
  * auth-branch bug in this flow.
196
192
  */
197
193
  export function classifyIdentityResponse(status, body) {
194
+ // Not `invalid_request`: IdentityOutcome has no such variant; the tool surfaces it as one.
195
+ if (status === 426)
196
+ return { kind: "refused", message: extractApiError(body).message };
198
197
  if (status === 401)
199
198
  return { kind: "unauthorized" };
200
199
  if (status === 403)
@@ -244,17 +243,17 @@ export async function refreshSession(apiUrl, refreshToken) {
244
243
  }
245
244
  /**
246
245
  * Read the authenticated user's identity from sil-api (the SECOND origin, not
247
- * sil-web): a BODYLESS `GET /identity` answering `{ id, name, country?, addresses }`.
246
+ * sil-web): a BODYLESS `GET /identity` answering `{ status, name, country?, currency?, gender?, language?, address? }`.
248
247
  * Bodyless is the point — the principal is the token subject and nothing else, so
249
248
  * no `agent_id` is sendable and the `principal_mismatch` 403 cannot arise.
250
249
  *
251
250
  * The Bearer header is built HERE and never logged.
252
251
  */
253
- export async function fetchIdentity(silApiUrl, token) {
252
+ export async function fetchIdentity(silApiUrl, token, caller, attempt) {
254
253
  const url = `${stripTrailingSlash(silApiUrl)}/identity`;
255
254
  let res;
256
255
  try {
257
- res = await getJson(url, { authorization: `Bearer ${token}` });
256
+ res = await getJson(url, { authorization: `Bearer ${token}`, ...callerHeaders(caller, attempt) });
258
257
  }
259
258
  catch {
260
259
  return { kind: "retryable" };
@@ -286,7 +285,7 @@ export async function callShopping(silApiUrl, token, route, args, caller, attemp
286
285
  const headers = { authorization: `Bearer ${token}`, ...callerHeaders(caller, attempt) };
287
286
  let res;
288
287
  try {
289
- const timeoutMs = requestTimeoutMs(route);
288
+ const timeoutMs = REQUEST_TIMEOUT_MS;
290
289
  res =
291
290
  route.method === "GET"
292
291
  ? await getJson(url, headers, timeoutMs)
@@ -345,6 +344,11 @@ function routePath(route, args) {
345
344
  const value = args[key];
346
345
  if (typeof value === "string")
347
346
  query.set(key, value);
347
+ else if (Array.isArray(value)) {
348
+ for (const item of value)
349
+ if (typeof item === "string")
350
+ query.append(key, item);
351
+ }
348
352
  }
349
353
  const search = query.toString();
350
354
  return search === "" ? path : `${path}?${search}`;
@@ -441,53 +445,30 @@ export async function refreshAndRetryOnce(first, isUnauthorized, retryWithToken)
441
445
  }
442
446
  /**
443
447
  * Unwrap + narrow a sil-api identity body to a typed `Identity`, or null when it
444
- * carries none. The body may wrap the identity in `result` or return it bare.
445
- *
446
- * An EMPTY `addresses` is a real identity (a provisioned user who has not added
447
- * an address yet) — rejecting it would strand them on a `retryable` no retry can
448
- * clear. The non-empty `name` gate is what keeps a nameless body off `ok`.
448
+ * carries none. The body may wrap the identity in `result` or return it bare. The
449
+ * non-empty `name` gate is what keeps a nameless body off `ok`.
449
450
  */
450
451
  function extractIdentity(body) {
451
452
  const envelope = asRecord(body);
452
453
  if (envelope === null)
453
454
  return null;
454
- const result = asRecord(envelope["result"]);
455
- const source = result ?? envelope;
455
+ const source = asRecord(envelope["result"]) ?? envelope;
456
456
  const name = source["name"];
457
457
  if (typeof name !== "string" || name.length === 0)
458
458
  return null;
459
- const rawAddresses = source["addresses"];
460
- if (!Array.isArray(rawAddresses))
461
- return null;
462
- const addresses = rawAddresses.filter((a) => asRecord(a) !== null);
463
- // The profile halves are NOT a gate: a read that carries neither is a buyer who
464
- // has told sil nothing yet, and `[]` says exactly that — refusing here would
465
- // strand them on a `retryable` no retry can clear.
466
- const measurements = plainObjects(source["measurements"]);
467
- const preferences = plainObjects(source["preferences"]);
468
- // `country`, `gender` and `currency` are optional on the read and pass through only as
469
- // strings — an absent or non-string one is dropped, never coerced or inferred. The VALUE
470
- // is the route's to decide: a literal allow-list here would drop a vocabulary sil adds.
471
- const country = source["country"];
472
- const gender = source["gender"];
473
- const currency = source["currency"];
459
+ // Optional fields pass through only as the right shape — an absent or malformed one is
460
+ // dropped, never coerced. The VALUES are the route's to decide.
461
+ const address = asRecord(source["address"]);
462
+ const optional = (key) => typeof source[key] === "string" ? { [key]: source[key] } : {};
474
463
  return {
475
464
  name,
476
- addresses,
477
- measurements,
478
- preferences,
479
- ...(typeof country === "string" ? { country } : {}),
480
- ...(typeof gender === "string" ? { gender } : {}),
481
- ...(typeof currency === "string" ? { currency } : {}),
465
+ ...optional("country"),
466
+ ...optional("gender"),
467
+ ...optional("currency"),
468
+ ...optional("language"),
469
+ ...(address !== null ? { address: address } : {}),
482
470
  };
483
471
  }
484
- /** The elements of `value` that are plain objects, as `addresses` are filtered:
485
- * absent or shapeless is `[]`, never a partial read of a malformed entry. */
486
- function plainObjects(value) {
487
- if (!Array.isArray(value))
488
- return [];
489
- return value.filter((e) => asRecord(e) !== null);
490
- }
491
472
  /** Pull the actionable reason out of a 403 body (`user_not_provisioned` /
492
473
  * `principal_mismatch`), defaulting to a generic marker when the shape is
493
474
  * unexpected — the tool surfaces this to drive the right recovery hint. */
@@ -559,16 +540,7 @@ function extractUser(raw) {
559
540
  ...(typeof name === "string" ? { name } : {}),
560
541
  };
561
542
  }
562
- /**
563
- * A non-null plain object, or null for anything else (incl. arrays/primitives).
564
- *
565
- * The array arm decides an OUTCOME at exactly one site, and it is not a body gate:
566
- * {@link extractIdentity} filters `addresses` through this PER ELEMENT, so the return
567
- * value is membership rather than a branch — without the arm a bare array survives and
568
- * ships as one of the buyer's own addresses (pinned in `whoami.integration.test.ts`).
569
- * At the body sites it changes nothing, because each reads a named key and a parsed
570
- * array has none; the element site is the whole reason it stays.
571
- */
543
+ /** A non-null plain object, or null for anything else (incl. arrays/primitives). */
572
544
  function asRecord(value) {
573
545
  return value !== null && typeof value === "object" && !Array.isArray(value)
574
546
  ? value
@@ -17,7 +17,7 @@ export function jsonResult(data, ...extra) {
17
17
  return {
18
18
  content: [data, ...extra].map((part) => ({
19
19
  type: "text",
20
- text: JSON.stringify(part, null, 2),
20
+ text: JSON.stringify(part),
21
21
  })),
22
22
  };
23
23
  }