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.
- package/CHANGELOG.md +44 -0
- package/EXAMPLES.md +93 -0
- package/README.md +58 -120
- package/SECURITY.md +12 -9
- package/assets/banner-dark.svg +15 -0
- package/assets/banner.svg +15 -0
- package/dist/gateway/screen.js +174 -0
- package/dist/index.js +5 -9
- package/dist/lib/answers.js +59 -0
- package/dist/lib/screen-log.js +13 -0
- package/dist/lib/shopping-call.js +27 -28
- package/dist/lib/sil-client.js +49 -66
- package/dist/lib/tool-result.js +1 -1
- package/dist/tools/catalog.js +113 -272
- package/dist/tools/identity.js +79 -88
- package/openclaw.plugin.json +12 -7
- package/package.json +4 -2
- package/schema/PROVENANCE.md +7 -4
- package/schema/shopping-brief-read-request.schema.json +2 -1
- package/schema/shopping-brief-read-response.schema.json +98 -50
- package/schema/shopping-brief-write-request.schema.json +322 -0
- package/schema/{shopping-brief-create-response.schema.json → shopping-brief-write-response.schema.json} +3 -3
- package/schema/shopping-content-request.schema.json +12 -31
- package/schema/shopping-content-response.schema.json +14 -95
- package/schema/shopping-domain-get-request.schema.json +24 -1
- package/schema/shopping-domain-get-response.schema.json +23 -421
- package/schema/shopping-domain-search-request.schema.json +3 -3
- package/schema/shopping-domain-search-response.schema.json +3 -56
- package/schema/shopping-offers-request.schema.json +14 -9
- package/schema/shopping-offers-response.schema.json +368 -91
- package/schema/shopping-product-get-request.schema.json +4 -3
- package/schema/shopping-product-get-response.schema.json +347 -46
- package/schema/shopping-search-request.schema.json +53 -40
- package/schema/shopping-search-response.schema.json +408 -116
- package/schema/shopping-seller-get-request.schema.json +13 -1
- package/schema/shopping-seller-get-response.schema.json +594 -225
- package/schema/shopping-user-forget-request.schema.json +43 -0
- package/schema/shopping-user-forget-response.schema.json +74 -0
- package/schema/shopping-user-read-request.schema.json +37 -0
- package/schema/shopping-user-read-response.schema.json +372 -0
- package/schema/shopping-user-remember-request.schema.json +341 -0
- package/schema/shopping-user-remember-response.schema.json +66 -0
- package/schema/sil-whoami-request.schema.json +8 -0
- package/schema/sil-whoami-response.schema.json +99 -0
- package/sil-shopping/SKILL.md +149 -208
- package/dist/gateway/search-results.js +0 -99
- package/dist/lib/search-results-log.js +0 -23
- package/dist/lib/search-results-store.js +0 -116
- package/schema/shopping-brief-create-request.schema.json +0 -98
- package/schema/shopping-brief-edit-request.schema.json +0 -125
- package/schema/shopping-brief-edit-response.schema.json +0 -24
- package/schema/shopping-profile-edit-request.schema.json +0 -97
- package/schema/shopping-profile-edit-response.schema.json +0 -17
package/sil-shopping/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sil-shopping
|
|
3
|
-
description: 'Use on any shopping intent
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
`
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
| what
|
|
94
|
-
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
}
|