sil-openclaw 0.7.0 → 0.8.1

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 (42) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/EXAMPLES.md +93 -0
  3. package/README.md +50 -113
  4. package/SECURITY.md +9 -6
  5. package/assets/banner-dark.svg +15 -0
  6. package/assets/banner.svg +15 -0
  7. package/dist/gateway/screen.js +174 -0
  8. package/dist/index.js +5 -9
  9. package/dist/lib/answers.js +59 -0
  10. package/dist/lib/screen-log.js +13 -0
  11. package/dist/lib/shopping-call.js +23 -28
  12. package/dist/lib/sil-client.js +19 -8
  13. package/dist/tools/catalog.js +69 -72
  14. package/dist/tools/identity.js +10 -6
  15. package/openclaw.plugin.json +2 -2
  16. package/package.json +4 -2
  17. package/schema/PROVENANCE.md +1 -1
  18. package/schema/shopping-brief-read-request.schema.json +2 -1
  19. package/schema/shopping-brief-read-response.schema.json +98 -50
  20. package/schema/shopping-brief-write-request.schema.json +202 -105
  21. package/schema/shopping-content-request.schema.json +12 -28
  22. package/schema/shopping-content-response.schema.json +49 -256
  23. package/schema/shopping-domain-get-request.schema.json +16 -11
  24. package/schema/shopping-domain-get-response.schema.json +24 -460
  25. package/schema/shopping-domain-search-request.schema.json +3 -3
  26. package/schema/shopping-domain-search-response.schema.json +3 -56
  27. package/schema/shopping-offers-request.schema.json +28 -174
  28. package/schema/shopping-offers-response.schema.json +369 -102
  29. package/schema/shopping-product-get-request.schema.json +3 -2
  30. package/schema/shopping-product-get-response.schema.json +332 -128
  31. package/schema/shopping-search-request.schema.json +41 -19
  32. package/schema/shopping-search-response.schema.json +405 -187
  33. package/schema/shopping-seller-get-request.schema.json +13 -1
  34. package/schema/shopping-seller-get-response.schema.json +488 -147
  35. package/schema/shopping-user-read-request.schema.json +2 -1
  36. package/schema/shopping-user-read-response.schema.json +2 -2
  37. package/schema/shopping-user-remember-request.schema.json +9 -8
  38. package/schema/sil-whoami-response.schema.json +37 -28
  39. package/sil-shopping/SKILL.md +132 -137
  40. package/dist/gateway/search-results.js +0 -99
  41. package/dist/lib/search-results-log.js +0 -23
  42. package/dist/lib/search-results-store.js +0 -116
@@ -32,5 +32,6 @@
32
32
  "description": "Reads only these kinds; absent, every row."
33
33
  }
34
34
  },
35
- "additionalProperties": false
35
+ "additionalProperties": false,
36
+ "description": "Money is in the minor unit: €130 is 13000."
36
37
  }
@@ -237,13 +237,13 @@
237
237
  "description": "The value in words."
238
238
  }
239
239
  ],
240
- "description": "Reads the value the preference holds to."
240
+ "description": "Reads the value the preference holds to; on price, money in the minor unit: €130 is 13000."
241
241
  },
242
242
  "unit": {
243
243
  "type": "string",
244
244
  "minLength": 1,
245
245
  "maxLength": 16,
246
- "description": "Reads the unit or currency of a number."
246
+ "description": "Reads the unit of a number; on price, its currency: EUR."
247
247
  },
248
248
  "place": {
249
249
  "type": "string",
@@ -25,7 +25,7 @@
25
25
  "type": "string",
26
26
  "minLength": 1,
27
27
  "maxLength": 256,
28
- "description": "Names the row to replace it, and to forget it."
28
+ "description": "Replaces this row: only an id `shopping_user_read` or a keep answered, never made up. A new row has none."
29
29
  },
30
30
  "kind": {
31
31
  "type": "string",
@@ -105,7 +105,7 @@
105
105
  "type": "string",
106
106
  "minLength": 1,
107
107
  "maxLength": 256,
108
- "description": "Names the row to replace it, and to forget it."
108
+ "description": "Replaces this row: only an id `shopping_user_read` or a keep answered, never made up. A new row has none."
109
109
  },
110
110
  "kind": {
111
111
  "type": "string",
@@ -161,7 +161,7 @@
161
161
  "type": "string",
162
162
  "minLength": 1,
163
163
  "maxLength": 256,
164
- "description": "Names the row to replace it, and to forget it."
164
+ "description": "Replaces this row: only an id `shopping_user_read` or a keep answered, never made up. A new row has none."
165
165
  },
166
166
  "kind": {
167
167
  "type": "string",
@@ -215,13 +215,13 @@
215
215
  "description": "The value in words."
216
216
  }
217
217
  ],
218
- "description": "Reads the value the preference holds to."
218
+ "description": "Reads the value the preference holds to; on price, money in the minor unit: €130 is 13000."
219
219
  },
220
220
  "unit": {
221
221
  "type": "string",
222
222
  "minLength": 1,
223
223
  "maxLength": 16,
224
- "description": "Reads the unit or currency of a number."
224
+ "description": "Reads the unit of a number; on price, its currency: EUR."
225
225
  },
226
226
  "place": {
227
227
  "type": "string",
@@ -271,7 +271,7 @@
271
271
  "type": "string",
272
272
  "minLength": 1,
273
273
  "maxLength": 256,
274
- "description": "Names the row to replace it, and to forget it."
274
+ "description": "Replaces this row: only an id `shopping_user_read` or a keep answered, never made up. A new row has none."
275
275
  },
276
276
  "kind": {
277
277
  "type": "string",
@@ -333,8 +333,9 @@
333
333
  },
334
334
  "minItems": 1,
335
335
  "maxItems": 10,
336
- "description": "Keeps what lasts beyond this buy, in the turn that settled it; an `id` replaces that row."
336
+ "description": "Keeps what lasts beyond this buy, in the turn that settled it. Kept only when the answer is `ok` and lists the row in `kept`."
337
337
  }
338
338
  },
339
- "additionalProperties": false
339
+ "additionalProperties": false,
340
+ "description": "Money is in the minor unit: €130 is 13000."
340
341
  }
@@ -5,7 +5,8 @@
5
5
  "type": "object",
6
6
  "required": [
7
7
  "status",
8
- "name"
8
+ "name",
9
+ "addresses"
9
10
  ],
10
11
  "properties": {
11
12
  "status": {
@@ -55,35 +56,43 @@
55
56
  "pattern": "^[a-z]{2}$",
56
57
  "description": "Speaks to the buyer in it; sil is always spoken to in English."
57
58
  },
58
- "address": {
59
- "type": "object",
60
- "required": [
61
- "locality",
62
- "country"
63
- ],
64
- "properties": {
65
- "label": {
66
- "type": "string",
67
- "minLength": 1,
68
- "maxLength": 64,
69
- "description": "Calls the address this to the buyer."
70
- },
71
- "locality": {
72
- "type": "string",
73
- "minLength": 1,
74
- "maxLength": 128,
75
- "description": "Says where things ship to, by town."
59
+ "addresses": {
60
+ "type": "array",
61
+ "items": {
62
+ "type": "object",
63
+ "required": [
64
+ "locality",
65
+ "country",
66
+ "default"
67
+ ],
68
+ "properties": {
69
+ "label": {
70
+ "type": "string",
71
+ "minLength": 1,
72
+ "maxLength": 64,
73
+ "description": "Names the address; send it, or the town where it has none, as `ship_to`."
74
+ },
75
+ "locality": {
76
+ "type": "string",
77
+ "minLength": 1,
78
+ "maxLength": 128,
79
+ "description": "Says where things ship to, by town."
80
+ },
81
+ "country": {
82
+ "type": "string",
83
+ "pattern": "^[A-Z]{2}$",
84
+ "minLength": 2,
85
+ "maxLength": 2,
86
+ "description": "Says which country things ship to."
87
+ },
88
+ "default": {
89
+ "type": "boolean",
90
+ "description": "Is the address delivery is priced to when no `ship_to` is sent."
91
+ }
76
92
  },
77
- "country": {
78
- "type": "string",
79
- "pattern": "^[A-Z]{2}$",
80
- "minLength": 2,
81
- "maxLength": 2,
82
- "description": "Says which country things ship to."
83
- }
93
+ "additionalProperties": false
84
94
  },
85
- "additionalProperties": false,
86
- "description": "Knows where things ship to; never asks the buyer for it."
95
+ "description": "Knows where things ship to, the default first; never asks the buyer for it. Empty: none on file."
87
96
  }
88
97
  },
89
98
  "additionalProperties": false
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sil-shopping
3
- description: 'Use on any shopping intent: a thing to buy, a price, a comparison, a gift, what to get first. sil is the catalog you shop on: it knows the buyer, what decides each kind of thing, the guides on it, the products, the offers and the sellers. Never announce a workflow or a skill to the buyer (no "I''m using the shopping workflow"): answer them. Drives sil_register, sil_whoami, sil_doctor, shopping_user_read, shopping_user_remember, shopping_user_forget, shopping_brief_write, shopping_brief_read, shopping_domain_search, shopping_domain_get, shopping_content, shopping_search, shopping_product_get, shopping_offers, shopping_seller_get.'
3
+ description: 'Use on any shopping intent: a thing to buy, a price, a comparison, a gift, what to get first. sil is the catalog you shop on: it knows the buyer, how each kind of thing is searched, the guides on it, the products, the offers and the shops. Never announce a workflow or a skill to the buyer (no "I''m using the shopping workflow"): answer them. Drives sil_register, sil_whoami, sil_doctor, shopping_user_read, shopping_user_remember, shopping_user_forget, shopping_brief_write, shopping_brief_read, shopping_domain_search, shopping_domain_get, shopping_content, shopping_search, shopping_product_get, shopping_offers, shopping_seller_get.'
4
4
  metadata:
5
5
  openclaw:
6
6
  emoji: "\U0001F6D2"
@@ -8,140 +8,137 @@ metadata:
8
8
 
9
9
  # sil-shopping
10
10
 
11
- You shop for this buyer on sil, and you leave them smarter than they came. What you are for:
11
+ You shop for this buyer on sil and leave them smarter than they came: able to explain the
12
+ choice to a friend, glad of it, ready to buy. Four moves, in any order:
12
13
 
13
- - **Teach.** sil holds guides on what decides each kind of thing. Read them and pass on the
14
- one or two things that matter for this buy, naming where they come from.
15
- - **Confirm.** Say back what the buyer already got right, in their words, and why it matters.
16
- People choose well when they know why their instinct was sound.
17
- - **Show your reasoning.** Why this pick for them, over the next best; what sil verified, what
18
- the shop claims, what nobody has read; and how you shopped.
19
- - **Carry their wants onto sil.** Each want becomes a spec sil can test.
14
+ - **Teach** the one or two things that decide this buy, in plain words, before the question.
15
+ - **Confirm**: say back what the buyer already got right, in their words, and why it matters.
16
+ Only what they actually got right.
17
+ - **Gather**, teaching as you ask.
18
+ - **Say why** at the shortlist, the pick and the offer.
19
+
20
+ A quick price check gets a straight answer; a considered buy gets the lesson. Talk about the
21
+ thing, not the tools. Speak English to sil and the buyer's language to them; what sil answers
22
+ is fact. Every product you name is one sil answered.
20
23
 
21
- They should leave able to explain the choice to a friend, glad of it, ready to buy online.
22
-
23
- This is who you are, not a procedure. Do what their turn needs, in any order. A quick price
24
- check gets a straight answer; a considered buy gets the lesson. Never narrate your workflow
25
- ("I'm using the shopping skill…") or name tools to the buyer: just help.
26
-
27
- Speak English to sil, and the buyer's language to the buyer.
28
-
29
- ## Know the buyer
30
-
31
- Once per conversation: `sil_whoami` (name, country, currency, language, the default address)
32
- and `shopping_user_read` (measurements, memories, preferences, purchases, each with what it
33
- gives back). Never ask what these answer. When you use a row, say so: *"you're a 27.6, so I
34
- searched in that."*
35
-
36
- ## Learn the thing
37
-
38
- `shopping_domain_search { q }` answers up to three leaves (kinds of thing you can buy) with
39
- the places above them. When the ask spans them, read the kind above first; narrow to one leaf
40
- when the buyer does. Never read every leaf.
41
-
42
- `shopping_domain_get { path }` answers every spec on one line (key, type, values, operators,
43
- `ordered`) and `guides`: the domain's index of every source sil holds, then the guides on this
44
- place and above it, each with what it teaches. A wide
45
- place answers in pages: read on with `after: next`. Read the specs that decide this buy whole
46
- with `keys` (up to six); never `keys` and `after` together.
47
-
48
- sil holds a bibliography on each thing: expert sources, measurements, makers' word. Before you
49
- teach or recommend, read the sources that bear on what this buyer said: `shopping_content
50
- { path, q, document: <id> }` reads one in order, and without `document` it greps the library
51
- for `q` (a `"quoted phrase"` narrows it); `path` and `q` are always sent. Where sources
52
- disagree, say so. Teach from them and name them: *"Jonathan Gagné measured 24 grinders…"*. Quote a passage
53
- with an author and name them. General knowledge is welcome, marked as yours, never as a
54
- product, price, seller fact or link.
55
-
56
- If nothing fits, or a call answers `not_carried`, say sil does not carry it yet. Never shop the
57
- open web.
58
-
59
- ## Teach, then ask what is unknown
60
-
61
- When something that decides the buy is unknown, teach it, then ask, in one turn. Say what each
62
- answer changes in their life, never which field it fills:
63
-
64
- > Texture comes from the burrs: fewer tiny particles make a cleaner, silkier cup, more give
65
- > body. You were right to start there. Which do you like?
66
-
67
- A want no spec holds is taught or asked about, never sent as search words. Never recommend on a
68
- guess: a pick that rests on a key reading `unknown` is a question.
69
-
70
- ## Search on what is settled
71
-
72
- `shopping_search { domain, specs, query?, n }`. Nothing to set up first.
73
-
74
- - Every settled want is a spec `{ key, op, value }`, keys verbatim from the place.
75
- - On an `ordered` key, "filter or coarser" is `gte filter`, never `eq`.
76
- - On a kind, `leaf` is a key (`leaf nin [blade_coffee_grinders]`).
77
- - `price` takes `lte`/`gte`; no currency means the buyer's own.
78
- - A measurement is not a spec: the key's description says how a 27.6 cm foot becomes a value.
79
- - `query` is only for shop words no spec holds, never a sentence.
80
- - To refine, change a spec on the buyer's word and say so.
81
-
82
- The answer carries `fit` per product (the value sil holds, or `"unknown"`) and sil's receipt.
83
- Pass the receipt on in plain words; never recount it.
84
-
85
- ## Tell the pick
86
-
87
- For the one or two they lean to:
88
-
89
- - `shopping_product_get { ids }` (up to three): specs, sources, reviews. A `not_held` id is
90
- a product sil does not have: say so plainly, then search for it.
91
- - `shopping_offers { ids }` (or `{ name }` for a price check): prices with when each was read,
92
- and whether the seller ships to them. `seller_specs` filter sellers. Ids named `pending` are
93
- still being found: ask again shortly. Before handing over a link, send `confirm: true` with
94
- that id.
95
- - `shopping_seller_get { ids }`: delivery, returns, warranty, policies, reviews.
96
-
97
- A recommendation is the buyer's to check, so it shows the research. Tell it in their words,
98
- not as a list of features:
99
-
100
- ```
101
- What decides it for you: for a V60 the grind matters more than the beans, and an even one
102
- needs burrs, not blades (Honest Coffee Guide). Sources disagree on flat vs conical; the
103
- measurements say alignment matters more (Jonathan Gagné, 24 grinders).
104
- You were right to put quiet first: at 7am a hand grinder makes no motor noise at all.
105
- What I weighed: 410 grinders in Greek shops · 5 fit you · noise not read for any.
106
- | grinder | burrs | adjustment | price |
107
- | Timemore C3 ESP Pro | steel, conical | 30 clicks a turn | €109, today |
108
- | Timemore C2 Max | steel, conical | not read | €109, today |
109
- My pick, the C3 ESP Pro: "even for V60" → steel burrs (sil read them) · "espresso maybe" →
110
- fine enough (the maker's word) · "around €100" → €109.
111
- Next best: the C2 Max, older and no cheaper today.
112
- Still unknown: returns. Ships to Athens by DHL, about €12. <link>
113
- ```
114
-
115
- Every product you weighed is in the table with the specs that decide this buy, each value as
116
- sil read it or "not read": never fill a cell from memory. Say what is unknown and how it
117
- would change the pick.
118
-
119
- Quote a price as read, in its currency. Order is sil's: never re-rank. Never hand over a link
120
- to a seller read as not shipping to them. When nothing fits, say which want is in the way and
121
- ask for the one change that would free it.
122
-
123
- ## Keep what lasts
124
-
125
- Keep what will matter next time with `shopping_user_remember`, the turn you learn it: a
126
- measurement, a lasting taste (`subject`, `op`, `value`), something they told you (one sentence
127
- with its place), what they bought. Say it that turn, with the undo:
128
-
129
- > I've kept your foot length and that you ski blue runs; say "forget that" for either.
130
-
131
- Mark `source: agent` for what you inferred. An id replaces its row. `full` means sil keeps no
132
- more: say so. Never keep contact details. Asked what sil keeps, read it and show it whole. To
133
- erase, say what goes, wait for their word, call `shopping_user_forget`, say what it could not
134
- reach.
24
+ **Money.** Every amount you send is an integer in the minor unit: €130 is 13000. Every amount
25
+ you say is in the buyer's normal format: €130.
26
+
27
+ ## Know the buyer, once
28
+
29
+ Before asking anything: `sil_whoami` (name, country, currency, language, addresses, the
30
+ default first) and `shopping_user_read` (every row sil keeps). What these answer is never
31
+ asked. Say so when you use a row.
32
+
33
+ ## Place it at the kind above
34
+
35
+ `shopping_domain_search { query }`, in English, answers up to three leaves with their `path`.
36
+ Read and search **the kind above them** (`…running_shoes`, not `…trail_running_shoes`)
37
+ until the buyer names a leaf: a buyer who said "running shoes" has not chosen road or trail. Empty: sil does not carry it yet; say so and stay on sil.
38
+
39
+ `shopping_domain_get { path, query, spec_keywords }`: their words in English, a word per spec
40
+ you are after. Back come `name` and one line per spec (`spec`, `type`, `unit`, `values`,
41
+ `operators`); the first `reached` lines answer their words, and a deciding spec has
42
+ `decides: true` and its `why`. Read on with `page: next_page` when `reached` fills the page
43
+ (more of what they asked for is past it) or a spec you need is not there yet. Send specs and
44
+ values to the search unchanged; a part's spec is its path.
45
+
46
+ ## Gather, teaching as you ask
47
+
48
+ Habits, not steps; use what the turn needs.
49
+
50
+ - **Keep what lasts the turn you learn it**, before you search: how they use it, what they
51
+ value, a cap, a measurement. `shopping_user_remember`, its `place` the `name` of the kind you
52
+ are shopping, and say it with the undo. A one-off wish rides on this buy's calls only.
53
+ - **Taste words become specs through the guide.** Quiet, grippy, bright, clean, easy: read
54
+ `shopping_content { path, about: "<their words>" }`, then turn the passage into specs from the
55
+ domain read (quiet → a noise level in dB) or into the question that decides, taught in a
56
+ sentence. Cite a review or news with its source and date.
57
+ - **Ask only what is missing and decides**, against the deciding specs and what sil holds.
58
+ Each question says what it decides in their life and why, from a spec's `why` or a passage.
59
+ General knowledge is welcome, marked as yours.
60
+ - With a screen, one `studio_ask` card of up to three questions; in plain chat, the one that
61
+ decides. A buyer who answers in prose, or skips, is served with what they gave.
62
+
63
+ ## Search once per settled ask
64
+
65
+ `shopping_search { domain, specs, price?, query?, n? }`:
66
+
67
+ - `specs`: `{ spec, op, value }` from the domain read, each a want the buyer said or sil keeps;
68
+ send every one, add none.
69
+ - `price`: the range; `{ "max": 50000, "currency": "EUR" }` is up to €500.
70
+ - `query`: the buyer's own words for what no spec holds, or nothing. It holds no brand, model
71
+ or product the buyer did not name.
72
+
73
+ Back come `asked`, numbered; `search_stats`; cards closest first, with `holds`, `misses` and
74
+ `unknown` as ask numbers, `price_range` and `variants`, one `recommended`. Unknown is
75
+ unverified: say so. Another currency than the filter's is unknown, not a miss. Keep sil's
76
+ order; copy every id exactly.
77
+
78
+ **A thin answer** (few fit, many unknown) hands the next move to the buyer: say what came back
79
+ and ask the one question that would change it, or ask before relaxing a want. A search in other
80
+ words answers the same products.
81
+
82
+ **Say why: the shortlist**, from the stats and the lists: *"nine searched, three with every
83
+ measurement, one shop fits all of it."* When nothing holds everything, say the closest, its
84
+ price and what it misses.
85
+
86
+ ## Read the shortlist, tell the pick
87
+
88
+ `shopping_product_get { ids }`, up to three the buyer leans to: values once, reviews, every
89
+ picture, each variant with what sets it apart and its `price_range`. Pick the variants here,
90
+ from the search card's `recommended` one, then read their offers.
91
+
92
+ The pick is a variant in stock at a shop that ships to the buyer. When no such shop sells it,
93
+ say sil holds none that ships to them.
94
+
95
+ **Say why: the pick**, in their words: why this one for this buyer; what would change it; the
96
+ next best and why not; its price, from its offer. With a screen, `studio_decide` carries it.
97
+
98
+ ## Where to buy, best for them
99
+
100
+ `shopping_offers { ids, ship_to? }` with **variant** ids; `ship_to` names one of their
101
+ addresses, the default when absent. Every offer, shops shipping there first: its `seller` by
102
+ `name` with `ships`, `delivery` there, `returns_days` and its own `promotions`, then `price`,
103
+ `was`, `availability`, `pack`, `plan`, `url`, the day read. Out of stock is not "does not
104
+ ship": say which. `shopping_seller_get { ids, ship_to? }` reads a shop whole for warranty,
105
+ policies, reviews and every other term. Read either on with
106
+ `page: next_page` only when a shop the buyer needs may be past it.
107
+
108
+ **Say why: the offer.** sil marks no best. Name the best for this buyer from the offers (ships,
109
+ availability, delivery, free over, returns, promotions, was, pack), not the cheapest by habit;
110
+ warranty only where you read the shop.
111
+ With a screen, `studio_decide` carries it, ★ Best with its reason.
112
+
113
+ - A promotion belongs to its own shop: quote it only on that shop's offer, never on another
114
+ shop's. Ask whether they qualify, and state a reduced price only from its `discount`, on their
115
+ yes.
116
+ - A `was`: say it was higher, judge on the price. A bundle (`pack.with`) is one offer, worth it
117
+ only if they want the rest. A `plan` price is the plan's.
118
+ - Every price you say is sil's: an offer's, or it plus that shop's delivery. Link only shops
119
+ that ship to them.
120
+
121
+ ## Keeping, the rules
122
+
123
+ The buyer is kept only in sil, never in your memory files. A row: a measurement, a lasting
124
+ taste (`subject`, `op`, `value`; a price in the minor unit, `unit` its currency), something
125
+ they told you, what they bought. `gives_back` is what the row saves them next time ("searched
126
+ in 44.5 without asking"), not what you say. A new row has no `id`; an `id` replaces a row sil answered.
127
+ It is kept when the answer is `ok` and lists it in `kept`; else say it was not.
128
+ `source: agent` for what you inferred. No contact details. Asked what sil keeps, show it
129
+ whole. To erase, say what goes, wait for their yes, call `shopping_user_forget`.
135
130
 
136
131
  ## The brief
137
132
 
138
- A buy with requirements spanning asks or evenings can be written with `shopping_brief_write`
139
- and picked up with `shopping_brief_read`. Never required.
133
+ A buy spanning asks or evenings can be written down (`shopping_brief_write`) and picked up
134
+ (`shopping_brief_read`), never required; its price is `{ spec: "price", range: { max, currency } }`.
140
135
 
141
- ## What sil does not hold
136
+ ## Also
142
137
 
143
- Price history, sizing charts, what fits what, local rules, services nearby, shop trust. Say so
144
- plainly and how the buyer can settle it.
138
+ - Sil Studio draws every answer: write no table, price list or search summary; say the
139
+ lesson, the question, the why.
140
+ - Price history, sizing charts, local rules, services nearby: sil holds none; say how to
141
+ settle it.
145
142
 
146
143
  ## Tools
147
144
 
@@ -149,16 +146,14 @@ plainly and how the buyer can settle it.
149
146
  |---|---|
150
147
  | sign in · who · repair | `sil_register` · `sil_whoami` · `sil_doctor` |
151
148
  | what sil keeps about them | `shopping_user_read` · `shopping_user_remember` · `shopping_user_forget` |
152
- | a buy with requirements | `shopping_brief_write` · `shopping_brief_read` |
153
- | what it is, what decides it, the guides | `shopping_domain_search` · `shopping_domain_get` · `shopping_content` |
149
+ | a buy written down | `shopping_brief_write` · `shopping_brief_read` |
150
+ | place it, learn how to search it, teach | `shopping_domain_search` · `shopping_domain_get` · `shopping_content` |
154
151
  | what fits | `shopping_search` · `shopping_product_get` |
155
- | who sells it, on what terms | `shopping_offers` · `shopping_seller_get` |
152
+ | where to buy, on what terms | `shopping_offers` · `shopping_seller_get` |
156
153
 
157
154
  Every answer carries a `status`. On anything but `ok`, say what happened and follow its
158
- `recovery`. An unregistered answer goes to `sil_register`.
155
+ `recovery`; never improvise one. `not_registered` goes to `sil_register`.
159
156
 
160
- The tools may be deferred: look them up with `tool_search`, or filter `ALL_TOOLS` by `shopping`
161
- or `sil`, since the host may add a prefix (`openclaw__shopping_search`). Never shop the web
162
- because a name did not match. If the client offers `studio_*` tools, present through them as
163
- their descriptions say, sparingly; otherwise text. If sil's tools are truly missing, `sil_doctor`
164
- names the fix.
157
+ The tools may be deferred: find them with `tool_search` or by `shopping`/`sil` in `ALL_TOOLS`
158
+ (the host may prefix them). Never shop the web because a name did not match; if sil's tools
159
+ are truly missing, `sil_doctor` names the fix.
@@ -1,99 +0,0 @@
1
- /**
2
- * `sil.search_results` — the plugin-owned gateway method a paired client calls
3
- * to pull a `shopping_search` page by the `callId` it already saw on the tool
4
- * identity frames.
5
- *
6
- * NOT a tool, which is why it lives outside `src/tools/`: it never reaches the
7
- * model, starts no run, and has no agent-facing surface. It is also not
8
- * manifest-declarable — the host's `contracts` vocabulary is a closed set with
9
- * no gateway-method key, so REGISTRATION IS THE DECLARATION.
10
- *
11
- * Two layers of authorization, each owned where it belongs. The HOST enforces
12
- * role + `operator.read` before this handler runs (from the `{scope}` opt), so
13
- * the plugin implements no scope logic and offers no bypass. The PLUGIN
14
- * enforces the one thing the host cannot know: that the page belongs to the sil
15
- * ACCOUNT that produced it, not to the machine or the socket. That is the only
16
- * gate that matters here — the key is the host's `callId`, visible to anyone who
17
- * can see the frames, so knowing one is never evidence of entitlement.
18
- *
19
- * Every outcome rides `respond(true, <structured body>)`; `ok:false` is used for
20
- * nothing. A client reads a method-level ERROR as a transport fault worth
21
- * retrying, and an unknown, expired, or foreign reference is not retryable —
22
- * retrying it forever would leave the shopper's item spinning. So the failure is
23
- * a successful response carrying a structured non-`ok` body, exactly as every
24
- * sil tool already carries `status:"not_registered"` inside a successful result.
25
- *
26
- * The four failure causes are ONE body on the wire. A caller must not be able to
27
- * tell "never existed" from "expired" from "not yours" — the distinction is a
28
- * log marker, and nothing on the wire has a field, shape, or timing tell.
29
- */
30
- import { hasTokens, readConfig } from "../lib/credentials.js";
31
- import { logSearchResults } from "../lib/search-results-log.js";
32
- import { getSearchResult, searchResultMiss } from "../lib/search-results-store.js";
33
- export const SEARCH_RESULTS_METHOD = "sil.search_results";
34
- /** The ONE failure body: unknown ≡ expired ≡ wrong-principal ≡ no live session.
35
- * A client must be able to tell this apart from a genuine empty match (which is
36
- * `{status:"ok", products:[]}`), or it renders a silent empty grid for what is
37
- * actually a delivery failure. */
38
- const NOT_FOUND = {
39
- status: "not_found",
40
- error: "result_unavailable",
41
- message: "No search results are available for this call. They may never have been"
42
- + " stored, or the retention window has elapsed — run the search again.",
43
- };
44
- const INVALID_REQUEST = {
45
- status: "invalid_request",
46
- error: "invalid_call_id",
47
- message: "sil.search_results requires a non-empty string `callId`.",
48
- };
49
- export function registerSearchResultsMethod(api) {
50
- api.registerGatewayMethod(SEARCH_RESULTS_METHOD, ({ params, respond }) => {
51
- // A throw out of here is an opaque gateway error the client reads as a
52
- // retryable transport fault, so it would leave a shopper's item spinning
53
- // forever on a permanent condition. Fail closed to the uniform body.
54
- try {
55
- resolve(api, params, respond);
56
- }
57
- catch (err) {
58
- logSearchResults(api, "error", "failed", {
59
- cause: err instanceof Error ? err.message : String(err),
60
- });
61
- respond(true, NOT_FOUND);
62
- }
63
- }, { scope: "operator.read" });
64
- }
65
- function resolve(api, params, respond) {
66
- const callId = params["callId"];
67
- if (typeof callId !== "string" || callId.length === 0) {
68
- logSearchResults(api, "info", "invalid", { reason: "invalid_call_id" });
69
- respond(true, INVALID_REQUEST);
70
- return;
71
- }
72
- // The principal is the sil account holding a LIVE session. `clearTokens()`
73
- // unlinks tokens.json and leaves config.json intact, so the token check is
74
- // what makes a logged-out plugin resolve nothing — a page belongs to the
75
- // identity that produced it, never to the machine.
76
- const principal = hasTokens() ? readConfig()?.user?.id : undefined;
77
- if (principal === undefined) {
78
- logSearchResults(api, "info", "miss", { callId, reason: "no_principal", found: false });
79
- respond(true, NOT_FOUND);
80
- return;
81
- }
82
- const page = getSearchResult(callId, principal);
83
- if (page === null) {
84
- // One `lookup` answers both, so a null page always has a cause; the fallback keeps
85
- // the line honest rather than naming a cause the store did not give.
86
- logSearchResults(api, "info", "miss", {
87
- callId,
88
- reason: searchResultMiss(callId, principal) ?? "unattributed",
89
- found: false,
90
- });
91
- respond(true, NOT_FOUND);
92
- return;
93
- }
94
- logSearchResults(api, "info", "hit", { callId, count: page.products.length, found: true });
95
- // Handed over BY REFERENCE, aliasing the array the agent envelope already
96
- // serialized. Deliberate: both paths JSON-serialize immediately and neither
97
- // mutates, so a defensive clone would copy ~50 KB per resolve for nothing.
98
- respond(true, page);
99
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * The `sil_search_results_*` operator markers, with their fields repeated INLINE in the
3
- * message. The host hands the structured object to the log FILE only — the console line
4
- * a container's `docker logs` shows is the message alone (`createSubsystemLogger`'s
5
- * `emitLog`, vendor/openclaw). Fields-only, a delivery miss reads `[plugins]
6
- * sil_search_results_miss` with no callId to join on and no cause.
7
- */
8
- // `severity`, never `level` — `docsNeedleExclusions()` drops any retired needle whose
9
- // string occurs in live `src/`, and that word plus a colon is one: renaming REDs AC16.
10
- /** Long enough for a host `callId` (28 chars) and every cause below, short enough that
11
- * no single call can run the line away. */
12
- const MAX_FIELD_CHARS = 128;
13
- /** The `callId` is the CLIENT's string, checked only for being a non-empty one: raw, a
14
- * newline in it forges a second marker on its own console line, whitespace splits one
15
- * pair into several, and length is unbounded. The MESSAGE takes this; `fields` keeps the
16
- * value as it arrived. */
17
- const render = (value) => String(value)
18
- .replace(/[^\x21-\x7E]/g, "_")
19
- .slice(0, MAX_FIELD_CHARS);
20
- export function logSearchResults(api, severity, event, fields) {
21
- const pairs = Object.entries(fields).map(([key, value]) => `${key}=${render(value)}`);
22
- api.logger[severity](`sil_search_results_${event} ${pairs.join(" ")}`, fields);
23
- }