sil-openclaw 0.6.0 → 0.8.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 (53) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/EXAMPLES.md +93 -0
  3. package/README.md +58 -120
  4. package/SECURITY.md +12 -9
  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 +27 -28
  12. package/dist/lib/sil-client.js +49 -66
  13. package/dist/lib/tool-result.js +1 -1
  14. package/dist/tools/catalog.js +113 -272
  15. package/dist/tools/identity.js +79 -88
  16. package/openclaw.plugin.json +12 -7
  17. package/package.json +4 -2
  18. package/schema/PROVENANCE.md +7 -4
  19. package/schema/shopping-brief-read-request.schema.json +2 -1
  20. package/schema/shopping-brief-read-response.schema.json +98 -50
  21. package/schema/shopping-brief-write-request.schema.json +322 -0
  22. package/schema/{shopping-brief-create-response.schema.json → shopping-brief-write-response.schema.json} +3 -3
  23. package/schema/shopping-content-request.schema.json +12 -31
  24. package/schema/shopping-content-response.schema.json +14 -95
  25. package/schema/shopping-domain-get-request.schema.json +24 -1
  26. package/schema/shopping-domain-get-response.schema.json +23 -421
  27. package/schema/shopping-domain-search-request.schema.json +3 -3
  28. package/schema/shopping-domain-search-response.schema.json +3 -56
  29. package/schema/shopping-offers-request.schema.json +14 -9
  30. package/schema/shopping-offers-response.schema.json +368 -91
  31. package/schema/shopping-product-get-request.schema.json +4 -3
  32. package/schema/shopping-product-get-response.schema.json +347 -46
  33. package/schema/shopping-search-request.schema.json +53 -40
  34. package/schema/shopping-search-response.schema.json +408 -116
  35. package/schema/shopping-seller-get-request.schema.json +13 -1
  36. package/schema/shopping-seller-get-response.schema.json +594 -225
  37. package/schema/shopping-user-forget-request.schema.json +43 -0
  38. package/schema/shopping-user-forget-response.schema.json +74 -0
  39. package/schema/shopping-user-read-request.schema.json +37 -0
  40. package/schema/shopping-user-read-response.schema.json +372 -0
  41. package/schema/shopping-user-remember-request.schema.json +341 -0
  42. package/schema/shopping-user-remember-response.schema.json +66 -0
  43. package/schema/sil-whoami-request.schema.json +8 -0
  44. package/schema/sil-whoami-response.schema.json +99 -0
  45. package/sil-shopping/SKILL.md +149 -208
  46. package/dist/gateway/search-results.js +0 -99
  47. package/dist/lib/search-results-log.js +0 -23
  48. package/dist/lib/search-results-store.js +0 -116
  49. package/schema/shopping-brief-create-request.schema.json +0 -98
  50. package/schema/shopping-brief-edit-request.schema.json +0 -125
  51. package/schema/shopping-brief-edit-response.schema.json +0 -24
  52. package/schema/shopping-profile-edit-request.schema.json +0 -97
  53. package/schema/shopping-profile-edit-response.schema.json +0 -17
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sil-shopping
3
- description: 'Use on any shopping intent, and to manage what sil holds for the buyer: register or check their sil account, find the place sil shelves the thing they are buying, read its specs and what sil has written about it, open and keep the session''s brief and the buyer''s profile, search for what fits, open a product, price a pick at every seller, and read a seller''s terms. Drives sil_register, sil_whoami, sil_doctor, shopping_domain_search, shopping_domain_get, shopping_content, shopping_brief_create, shopping_brief_edit, shopping_brief_read, shopping_profile_edit, 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,211 +8,152 @@ metadata:
8
8
 
9
9
  # sil-shopping
10
10
 
11
- sil is a catalog you shop on the buyer's behalf. You drive its tools in whatever order the
12
- conversation needs; only finding the place has a fixed order.
13
-
14
- **Speak English to sil, and the buyer's language to the buyer.** Everything you send sil — a
15
- `q`, a value, a narrative, a quoted reason — is English, translated from what they said; what sil
16
- answers you put back into their language.
17
-
18
- Three things carry the job, none on this agent's disk:
19
-
20
- - **The place** — where sil shelves the thing, and sil's own knowledge of how it is bought
21
- well. `shopping_domain_get` hands back the keys it is bought by, each key's `description`
22
- saying how it moves the fit. Read it before you ask the buyer anything: it is where you
23
- learn what decides the buy and what a bad buy costs them.
24
- - **The brief** — one per conversation, in sil. It is the shared scratchpad AND the spec of
25
- this buy: the narrative says what a good buy looks like for this person, the specs say it
26
- in the registry's keys, the decisions say what they changed and why. Write to it the
27
- moment something is settled, and judge every pick against it.
28
-
29
- Write the narrative as the buy succeeding, in their terms — *"a hand grinder with an even
30
- pour-over grind, fits a rucksack, €80 at most"* — never a description of the shopping
31
- (*"needs a good grind; requirements not yet settled"*).
32
- - **The profile** — the person, across sessions: their measurements, their gender, the
33
- currency they price in, their addresses, lasting preferences. `sil_whoami` reads it.
34
-
35
- ## Start by reading
36
-
37
- `sil_whoami` and `shopping_brief_read {}` are the two reads a new chat opens with. **Never
38
- ask what they already answer** — a size, a width, a budget, a market.
39
-
40
- **Then open this session's brief, as soon as you know what they are shopping for** — with
41
- `shopping_brief_create`, before you ask them anything. Their answers, the assumptions you
42
- say out loud, and every decision land in it as they happen: a turn that ends with nothing
43
- written is one no later turn can see.
44
-
45
- A past brief is read, never reused: carry forward what is still true, and say in the first
46
- `shopping_brief_edit` `decision` what you carried — not a second interview.
47
- An unregistered answer from any call routes to `sil_register`.
48
-
49
- ## Find the place
50
-
51
- 1. `shopping_domain_search { q }` — `q` is what the thing is called, in English.
52
- Up to three leaves (buyable kinds of thing), best first, each with `matched` and
53
- `under` — the places above it, outermost first down to its parent.
54
- 2. **Choose the leaf that fits the ask.** `under` tells *"boot liners"* under Vehicles › Car
55
- cargo from those under Skiing › Ski boot accessories. Ask nothing the ask already
56
- answers — but when the three share one kind (three ski boots under "Ski boots"), ask
57
- which. A leaf that does not fit (*"Hunting dog harnesses"* for a canicross harness) is
58
- no fit: say so, never shop it.
59
- 3. `shopping_domain_get { path }` — the specs: unit, allowed values, marks. `variant_spec` is
60
- settled before searching if the buyer has not said it, its values under `variants[]`;
61
- `product_spec` is written into the brief when the buyer names it, and two products
62
- differing on it are never one; `several` is a list, `eq`/`in` meet any, `neq`/`nin` none.
63
- `parts` are what it has, `kinds` what it is, `made_for` what a part fits. `record`:
64
- `specs` — bought on measures alone; `full` — on measures plus purpose, story, pros and
65
- cons, for and not for. A kind lists its `leaves`.
66
- 4. `shopping_content { path, q }` on that leaf, **before your first question to the buyer**:
67
- `q` is the thing and what the specs say decides it, in shop words (*"ski boot size width
68
- flex"*). It greps sil's library on the leaf and every place above it — sil's guides, and
69
- the sources sil read, verbatim. Let what it answers shape the question you ask.
70
- 5. `shopping_search` there, the path as `domain`. A shelf or domain, in either call, is
71
- refused `not_a_leaf`, naming leaves.
72
-
73
- **When the buyer asks how or why** — how to measure a foot, what a grand cru is — grep the
74
- leaf with their question in English, then work it like grep: narrow with a `"quoted phrase"` (*"premier
75
- cru"*), read a promising document on with `document` and `from`, grep again in other words
76
- when `total` says there is more. "what sil holds" answers a domain's whole library with each
77
- document's `id`. Answer from the passages: a passage with `author` is quoted and named with its
78
- `url`; one without is sil's. Nothing matches after a rephrase: say sil holds nothing on it, and
79
- answer only what the specs say — never the open web.
80
-
81
- **No leaf fits, `shopping_domain_search` answers empty, or a call answers `not carried`:** tell the buyer in
82
- your own words that sil cannot sell that at the moment, it is in the pipeline. List nothing,
83
- search nothing, never shop around.
84
-
85
- ## The tools
86
-
87
- | What you want | Tool |
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:
13
+
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.
23
+
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`.
130
+
131
+ ## The brief
132
+
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 } }`.
135
+
136
+ ## Also
137
+
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.
142
+
143
+ ## Tools
144
+
145
+ | For | Tool |
88
146
  |---|---|
89
- | sign up / log in / who am I | `sil_register` · `sil_whoami` |
90
- | where sil shelves this thing, and how it is bought | `shopping_domain_search` → `shopping_domain_get` |
91
- | what sil has written on choosing it, measuring for it, using it | `shopping_content` |
92
- | open this session's brief, write a want, log a decision | `shopping_brief_create` · `shopping_brief_edit` |
93
- | what is already on file | `shopping_brief_read` · `sil_whoami` |
94
- | a measurement, a lasting taste, their currency | `shopping_profile_edit` |
95
- | what fits | `shopping_search` |
96
- | everything sil holds on one product | `shopping_product_get` |
97
- | who sells it, at what price, on what terms | `shopping_offers` · `shopping_seller_get` |
98
- | sil looks broken | `sil_doctor` |
99
-
100
- Every tool answers a `status`. On anything but `ok`, say what happened and follow that
101
- tool's own `recovery` — never improvise around a refusal, and never loosen the brief to
102
- get past one.
103
-
104
- ## Using sil well
105
-
106
- - **Read the place's specs before the first search.** They name what the thing is bought
107
- on. A search that leaves one out is a shortlist about the category, not this buyer —
108
- and sil never says what it left out.
109
- - **A setup of several things is several places, each searched in its own.** *"Everything
110
- for pour-over at home"* is a dripper, a grinder and a kettle; a kettle searched under
111
- coffee makers runs on the wrong keys and comes back looking fine.
112
- - **Before a want you cannot write as a spec, read the place again.** The keys are fixed,
113
- but sil keeps learning the words pages print for them.
114
- - **Ask for what is missing in one question, with each thing's consequence.** Each
115
- key's `description` says what goes wrong when that key is wrong, in the buyer's own life.
116
- Say *that* — never which field it fills; naming fields is why buyers skip half of them.
117
-
118
- > Not *"What are your grind range and burr type?"* but: *"Three things decide a hand
119
- > grinder. How you brew — pour-over wants an even medium grind, and an espresso grinder
120
- > leaves it sour. How much you grind at once. And whether it travels, since the heavy
121
- > ones will not fit a rucksack. And your budget."*
122
- - **A spec traces to the buyer.** Every spec comes from something they said, or from a
123
- measurement on their profile, and its `reason` is their own words verbatim — never a
124
- paraphrase, never first-person words they did not say. Nothing said, no spec: ask, or say
125
- *"I'm assuming new, not used"* out loud and write it on their word.
126
- - **A measurement is not a spec.** A 27.2 cm foot is the buyer's; the spec is the size the
127
- thing is sold in. The key's own `description` says how to turn one into the other, and
128
- every place converts differently — a tolerance, a floor, a set of values that all work. Never the number as typed.
129
- - **A want no spec can carry goes in the narrative, said so in the same turn**, or the buyer
130
- thinks sil filters on it.
131
- - **What buying it online takes becomes a spec, not just narrative.** The place's
132
- `seller_specs` go on the brief's `seller` domain. `shopping_offers` answers the brief's
133
- seller rows and no others — until you write them there, every seller comes back equally
134
- good. *"Buy where it can go back"* does no work as a sentence: it is
135
- `return_window_days gte 14`, the window the buyer wants or one you name out loud.
136
- - **Your memory is sil, not a file:** the brief holds the job, the profile the person. Never
137
- read or write a workspace `MEMORY.md`.
138
- - **Gender is read, never guessed.** `sil_whoami` answers it; on anything worn it rides as a
139
- product spec. None on file: one question, never an inference from a name.
140
- - **Currency is the profile's.** A money row that means the buyer's own leaves `currency`
141
- off. *"My prices in dollars from now on"* is `shopping_profile_edit { currency: "USD" }`,
142
- never a conversion: it changes which offers come first, never a price.
143
- - **`query` is shop words** — the thing as a shop lists it, and the model or numbers that
144
- pick it out: `Timemore C3 grinder`, `hand coffee grinder 38 mm burr`. A sentence costs
145
- the buyer most of the offers. A budget, a market, a unit, a standard's name, *"in
146
- stock"* and *"online"* are specs, not query words.
147
- - **Search again freely** — a re-worded `query`, a narrower `n`. Never silently loosen a spec:
148
- a want changes in the brief, on the buyer's word, with a `decision`.
149
- - **Write the brief as you go.** A want the brief does not hold is a want the next call drops.
150
- - **An ambiguous phrase is asked about, or stays in the narrative in the buyer's own
151
- words.** *"wide forefoot and bit short"* is the foot or the person, and you cannot tell
152
- which. A fact written wrong on the profile follows them forever.
153
- - **Every pick comes out of a sil tool.** A product, price, seller or link that did not
154
- come back from sil never enters the shortlist — not from the open web, even if asked.
155
- Zero results is an answer.
156
-
157
- ## Don't take a seller's word
158
-
159
- - **A price range is not today's price.** Only `shopping_offers` reads live, and it stamps
160
- each price with the moment it read it. Quote that, never a range, and never convert a
161
- currency — sil holds no rate.
162
- - **The offers are a wide set, in sil's order:** the buyer's currency and market first,
163
- then shops known to reach them, then the rest, each with its link. Say which reach the
164
- buyer and in which currency each prices, keep the order, and hand a shop's details to
165
- `shopping_seller_get`. One over the brief's price is left out; one in another currency
166
- was never tested against it — say so.
167
- - **What a page prints is a claim, not a reading.** `printed` and `host` are the shop
168
- talking: say *"the shop's page says 102 mm"*. Their absence means sil read the page
169
- itself. `fit` is what sil verified, and `"unknown"` there is a gap to name — never a
170
- product that failed.
171
- - **An absent key is an unread term, not a missing one.** A key missing from `seller_fit`
172
- is a term sil has not read. `ships: unknown` keeps the offer: say sil could not confirm
173
- shipping and hand the buyer the listing.
174
- - **Read the return terms before you recommend.** A near-miss survives if it can go back;
175
- if sil has not read a seller's returns, say so.
176
- - **A variant with no option values is a listing whose sizes sil has not read.** Say so;
177
- price it like any other. Never read a printed size range as stock.
178
-
179
- ## Common traps
180
-
181
- - **Recommending on a key that reads `unknown`.** If what decides the buy is what sil could
182
- not verify, that is a question, not a recommendation.
183
- - **Sending the buyer to a shop.** The place's specs tell you what buying it online takes
184
- in place of handling it — a measurement, a return window. Use that; *"get it fitted in
185
- store"* is the one answer a buyer who came here cannot use.
186
- - **A spec sil holds no value for.** A synonym coined beside a domain key is a key nothing
187
- is stored under. Use the domain's keys verbatim.
188
- - **Quoting a product price for a size that costs something else.** Each variant carries
189
- its own price. Quote the price of the size you name.
190
- - **Pricing a whole shortlist.** Offers are worth a turn once the buyer is
191
- interested in something; pricing five they will not buy buries the fit answer.
192
-
193
- ## Showing a pick
194
-
195
- Say why this one, for this buyer, against their own brief — their words, not a spec table.
196
- For each thing they asked for, say what sil verified, what the shop claims, and what nobody
197
- has read. Then name the soft spot and what covers it.
198
-
199
- ```
200
- My pick: Timemore C3, €64 at kafeshop.gr.
201
- hand-cranked ........ yes — sil read it
202
- burr 38 mm or more .. 38 — the shop's page says so; sil has not checked it
203
- fits a rucksack ..... 520 g, 18 cm — sil read it
204
- €80 at most ......... €64, read a minute ago
205
- The soft spot is the burr size: it is the shop's word. kafeshop.gr takes returns for 14
206
- days, so if the grind is uneven, it goes back. Want the link?
207
- ```
208
-
209
- When nothing fits, say which want is in the way and ask for the one change that would give
210
- it up — then write their answer into the brief with a `decision` and search again: that is
211
- the only way to learn what giving it up reaches.
212
-
213
- ## When sil's tools are missing
214
-
215
- The host is filtering them: the admission helper repairs it (additively admitting sil at
216
- `plugins.allow` + `tools.alsoAllow`); reopen the session. If `sil_doctor` still runs, its
217
- `wiring.tools_not_admitted` finding names the exact `node "<absolute path>"` command. If no
218
- sil tool runs, run `node scripts/allowlist-openclaw.mjs` from the plugin's install directory.
147
+ | sign in · who · repair | `sil_register` · `sil_whoami` · `sil_doctor` |
148
+ | what sil keeps about them | `shopping_user_read` · `shopping_user_remember` · `shopping_user_forget` |
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` |
151
+ | what fits | `shopping_search` · `shopping_product_get` |
152
+ | where to buy, on what terms | `shopping_offers` · `shopping_seller_get` |
153
+
154
+ Every answer carries a `status`. On anything but `ok`, say what happened and follow its
155
+ `recovery`; never improvise one. `not_registered` goes to `sil_register`.
156
+
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
- }
@@ -1,116 +0,0 @@
1
- /**
2
- * The search-results delivery buffer.
3
- *
4
- * `shopping_search` returns its full page to the agent exactly as it always has —
5
- * this store is a pure SIDE EFFECT on the `ok` path, invisible to every
6
- * channel. It exists because the host's projection of a tool result is not a
7
- * dependable transport for structured data: under codex `data.result` is absent
8
- * from every frame, and the transcript that would otherwise carry it is both
9
- * provider-capped and rewritten under context pressure as a run grows. A client
10
- * that wants to render an intermediate search therefore needs its own way to
11
- * fetch it — `sil.search_results` (see `../gateway/search-results.ts`) reads
12
- * this map and answers over the paired `deviceToken` WS.
13
- *
14
- * The key is the HOST's `callId`, verbatim — never prefixed, hashed, or
15
- * re-minted. `execute()` receives it BEFORE any I/O, so a page can never be
16
- * orphaned by a failing search. A client joins on
17
- * `data.toolCallId ?? data.itemId`, in that order: the id is the same string on
18
- * every frame, but the FIELD NAME differs per family (`session.tool` carries
19
- * only `toolCallId`, the `agent`/`stream:"item"` frames only `itemId`) and on
20
- * the non-codex path `itemId` is `tool:`-prefixed — see
21
- * `docs/decisions/search-results-pull-surface.md`. Because that id is visible to
22
- * anyone who can see the frames, knowledge of a `callId` is NOT evidence of
23
- * entitlement: the principal check below is the only gate that matters.
24
- *
25
- * In-memory, by choice. Process death is the strongest retention ceiling
26
- * available and costs nothing; an on-disk buffer would put prices, seller
27
- * identity, and buy URLs at rest, widen the plugin's declared filesystem
28
- * scope, and — with no timers allowed — leave the last pages there forever once
29
- * the user stops searching.
30
- *
31
- * TIMER-FREE, and that is load-bearing: `register()` must stay synchronous and
32
- * open nothing, so eviction is lazy on write. Reads are pure — they never
33
- * evict, never reorder, and never consume, because a client remount or reload
34
- * re-resolves the same page and a one-shot read would blank the shopper's
35
- * screen on the first refresh.
36
- */
37
- /**
38
- * Fifteen minutes. A search result is point-in-time — the price range and the page it
39
- * was read off are exactly what a shopper must re-read before buying —
40
- * so this is long enough for the settle edge, a client reload, a reconnect, and
41
- * a short step-away, and short enough that nothing renders as stale truth. It
42
- * is a delivery buffer, not scrollback and not history.
43
- */
44
- export const RETENTION_MS = 15 * 60_000;
45
- /**
46
- * Sized against a whole RUN, not a single request: a real run issues 5–10 tool
47
- * calls and a client must be able to render EVERY intermediate search in it,
48
- * not just the last — so a "latest result" slot (or anything near the ≤4-call
49
- * fan-out one shopper request makes) would evict an early search before the run
50
- * ends. 32 leaves several runs' worth of headroom at a worst case of roughly
51
- * 32 × ~51 KB ≈ 1.6 MB, which is nothing against the gateway's own 25 MB frame
52
- * ceiling. Retention is a CEILING, not a guarantee: past it the product answer
53
- * is always the same — run a fresh search.
54
- */
55
- export const MAX_ENTRIES = 32;
56
- const entries = new Map();
57
- /** Store one `ok` page under the host's `callId`, bound to the sil account that
58
- * produced it. An empty principal is refused: a page has an owner or it is
59
- * unreachable, and an ownerless entry would only burn capacity. */
60
- export function putSearchResult(callId, page, principal) {
61
- if (principal.length === 0)
62
- return;
63
- evict();
64
- entries.set(callId, { principal, page, expiresAtMs: Date.now() + RETENTION_MS });
65
- }
66
- /** The stored page, or `null` for every miss — unknown, expired, and foreign are
67
- * ONE outcome to the caller. Pure: no eviction, no reordering, no consumption,
68
- * so a client remount re-resolves the same page and a foreign probe cannot deny
69
- * the owner theirs. */
70
- export function getSearchResult(callId, principal) {
71
- return lookup(callId, principal).page;
72
- }
73
- /** The miss cause, for the OPERATOR LOG only (criterion C3) — never the wire.
74
- * A separate query rather than a richer return, because the wire path must not
75
- * be able to reach the cause by accident: reading it is a deliberate call. */
76
- export function searchResultMiss(callId, principal) {
77
- return lookup(callId, principal).miss;
78
- }
79
- /** Reset for tests. Production never calls this — the process IS the lifetime. */
80
- export function __resetSearchResultsStore() {
81
- entries.clear();
82
- }
83
- function lookup(callId, principal) {
84
- const entry = entries.get(callId);
85
- if (entry === undefined)
86
- return { page: null, miss: "unknown" };
87
- if (entry.expiresAtMs <= Date.now())
88
- return { page: null, miss: "expired" };
89
- // An empty principal is the anonymous bucket, and there is no legitimate
90
- // anonymous owner — it must not match, not even an entry stored under one.
91
- if (principal.length === 0 || entry.principal !== principal) {
92
- return { page: null, miss: "principal_mismatch" };
93
- }
94
- return { page: entry.page, miss: null };
95
- }
96
- /** Lazy eviction, run on every write: drop what has expired, then trim to
97
- * capacity oldest-first. `Map` preserves insertion order and reads never touch
98
- * it, so "oldest" is insertion order — deliberately not LRU-on-read, which
99
- * would make a read mutate the store. */
100
- function evict() {
101
- const now = Date.now();
102
- for (const [callId, entry] of entries) {
103
- if (entry.expiresAtMs <= now)
104
- entries.delete(callId);
105
- }
106
- // `>=` because this runs BEFORE the `set`, so the store never exceeds the
107
- // ceiling. Re-writing an existing `callId` can trim one entry it did not need
108
- // to; a `callId` is unique per tool call, so that branch is unreachable in
109
- // practice and guarding it would cost more than it saves.
110
- while (entries.size >= MAX_ENTRIES) {
111
- const oldest = entries.keys().next();
112
- if (oldest.done === true)
113
- return;
114
- entries.delete(oldest.value);
115
- }
116
- }