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.
- package/CHANGELOG.md +36 -0
- package/EXAMPLES.md +93 -0
- package/README.md +50 -113
- package/SECURITY.md +9 -6
- 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 +23 -28
- package/dist/lib/sil-client.js +19 -8
- package/dist/tools/catalog.js +69 -72
- package/dist/tools/identity.js +10 -6
- package/openclaw.plugin.json +2 -2
- package/package.json +4 -2
- package/schema/PROVENANCE.md +1 -1
- 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 +202 -105
- package/schema/shopping-content-request.schema.json +12 -28
- package/schema/shopping-content-response.schema.json +49 -256
- package/schema/shopping-domain-get-request.schema.json +16 -11
- package/schema/shopping-domain-get-response.schema.json +24 -460
- 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 +28 -174
- package/schema/shopping-offers-response.schema.json +369 -102
- package/schema/shopping-product-get-request.schema.json +3 -2
- package/schema/shopping-product-get-response.schema.json +332 -128
- package/schema/shopping-search-request.schema.json +41 -19
- package/schema/shopping-search-response.schema.json +405 -187
- package/schema/shopping-seller-get-request.schema.json +13 -1
- package/schema/shopping-seller-get-response.schema.json +488 -147
- package/schema/shopping-user-read-request.schema.json +2 -1
- package/schema/shopping-user-read-response.schema.json +2 -2
- package/schema/shopping-user-remember-request.schema.json +9 -8
- package/schema/sil-whoami-response.schema.json +37 -28
- package/sil-shopping/SKILL.md +132 -137
- 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
|
@@ -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
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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
|
|
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": "
|
|
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
|
|
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
|
-
"
|
|
59
|
-
"type": "
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
package/sil-shopping/SKILL.md
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- **
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
Every
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
|
139
|
-
|
|
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
|
-
##
|
|
136
|
+
## Also
|
|
142
137
|
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|
153
|
-
|
|
|
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
|
-
|
|
|
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
|
|
155
|
+
`recovery`; never improvise one. `not_registered` goes to `sil_register`.
|
|
159
156
|
|
|
160
|
-
The tools may be deferred:
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
}
|