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,301 +1,171 @@
1
1
  /**
2
- * The eleven `shopping_*` tools, 1:1 with the sil-api catalog, brief and profile routes.
3
- *
4
- * A projection on the way back would drop exactly the fields the agent's honesty reading
5
- * is computed from (`fit`, `unknown`, `variants`, `printed`) while looking healthy, so the
6
- * body crosses verbatim. A new `registerXTools` group has to be hand-wired into three guards
7
- * or it silently NARROWS them (CLAUDE.md), which is why all eleven live in one group.
2
+ * The twelve `shopping_*` tools, 1:1 with the sil-api user, brief and catalog routes.
3
+ * Bodies cross verbatim: sil's answer is the agent's answer, and the screen's.
8
4
  */
5
+ import { keepAnswer } from "../lib/answers.js";
9
6
  import { requestSchema } from "../lib/artifacts.js";
10
- import { readConfig } from "../lib/credentials.js";
11
7
  import { readHostVersion, wiringAdvisoryBlocks } from "../lib/host-wiring.js";
12
- import { logSearchResults } from "../lib/search-results-log.js";
13
- import { putSearchResult } from "../lib/search-results-store.js";
14
8
  import { DOMAIN_GET_ROUTE, callRoute } from "../lib/shopping-call.js";
15
9
  import { jsonResult } from "../lib/tool-result.js";
16
10
  import { readInstalledVersion } from "../lib/version-advisory.js";
17
- /** The tool whose page a paired client can pull back by `callId`. */
18
- const SEARCH_TOOL = "shopping_search";
19
11
  export const SHOPPING_TOOLS = [
20
12
  {
21
- name: "shopping_domain_search",
22
- method: "GET",
23
- path: "/catalog/domains",
24
- query: ["q"],
25
- label: "Find the place for a thing",
26
- description: "The first call for any buy: send `q`, what the thing is called, in English — "
27
- + "translate the buyer first — and get up to three LEAVES — buyable kinds of thing — best first. Each has "
28
- + "its `path`, `name`, `matched` (which of sil's words your ask matched) and `under`, "
29
- + "the places above it, outermost first down to its parent, each with a `role`: `under`"
30
- + " tells same-named leaves apart. Choose from what the ask already says; when the "
31
- + "three share one kind, ask the buyer which. Take the path verbatim to "
32
- + "shopping_domain_get. An empty answer, or no leaf that fits, means sil does not carry"
33
- + " it yet: tell the buyer so — it is in the pipeline — and do not search; never shop "
34
- + "around.",
35
- },
36
- {
37
- name: "shopping_domain_get",
38
- ...DOMAIN_GET_ROUTE,
39
- label: "Read a place's specs",
40
- recovery: { not_found: "shopping_domain_search" },
41
- description: "A leaf's specs, from a path shopping_domain_search answered. `name` is its one "
42
- + "English name and `labels` the market's own words for it — never send them. `specs` "
43
- + "are the keys it is bought by and `seller_specs` the seller terms it is bought with. "
44
- + "Each key's `description` says how it moves the fit: what it decides, what goes wrong"
45
- + " at either end, and how a buyer's fact becomes its value. Each key states its type, "
46
- + "operators, unit, any closed set, the `step` a number moves by, and `forms` — printed"
47
- + " forms mapped to the value. Send that key and one of those operators, never a "
48
- + "synonym you coined: `specs` go on the brief and to shopping_search, `seller_specs` "
49
- + "on the brief's `seller` domain, where shopping_offers reads them. variant_spec marks"
50
- + " the key an option is picked on (a size, a colour), answered under each product's "
51
- + "variants; product_spec tells one product from the next; `several`, a key held many-"
52
- + "valued — `eq`/`in` meet any, `neq`/`nin` none. `reach` says where each key comes "
53
- + "from, `kinds` every kind it is, `parts` what it has, `made_for` what a part or "
54
- + "consumable fits. `record` is how a leaf's products are bought: `specs` — on measures"
55
- + " alone; `full` — on measures and their record (purpose, story, pros and cons, for "
56
- + "and not for). On a kind, `leaves` lists what to choose from. A shelf or domain is "
57
- + "refused `not_a_leaf`, naming leaves; one sil does not carry yet, `not carried`.",
13
+ name: "shopping_user_read",
14
+ method: "POST",
15
+ path: "/user/read",
16
+ label: "Read what sil keeps about the buyer",
17
+ description: "Know the buyer: everything kept about them is here, never in your own memory files."
18
+ + " Read once per conversation before asking anything, when they ask what you keep, and"
19
+ + " before a forget. A price row is `value` with `unit` its currency; money is in the"
20
+ + " minor unit: €130 is 13000.",
58
21
  },
59
22
  {
60
- name: "shopping_content",
23
+ name: "shopping_user_remember",
61
24
  method: "POST",
62
- path: "/catalog/content",
63
- label: "Grep what sil holds about it",
64
- recovery: { not_found: "shopping_domain_search" },
65
- description: "Grep sil's library for a thing: its own guides and the sources it read, quoted "
66
- + "verbatim — label law, producers' technical sheets, writers on the trade. Send `path` (the "
67
- + "leaf you chose, or any place above it) and `q`, the terms: each word matched stemmed, "
68
- + "a \"quoted phrase\" as one term, never by meaning. It reads every document on the "
69
- + "line through that node, up to the root, and answers whole passages: every term "
70
- + "first, then more terms, then the densest. `total` says how many passages hold a "
71
- + "term; more than came back means grep narrower, add a phrase, or set `kinds`. Each "
72
- + "passage carries `part` and `of`: send `document` (its `id`) with `from` to read that "
73
- + "document on. `max_passages` and `max_tokens` bound the answer, the last passage cut "
74
- + "and marked `truncated`; an empty `matched` only fills the minimum. Search like an "
75
- + "agent: grep, read on, grep again in other words. Once the leaf is chosen, grep it "
76
- + "before your first question to the buyer, and again whenever they ask how or why. "
77
- + "A passage with `author` is that author's words — quote and name them, with `url`; "
78
- + "without it, the words are sil's. Empty `passages`: say sil holds nothing on it, "
79
- + "and never fill the gap from the open web.",
25
+ path: "/user/remember",
26
+ label: "Keep what lasts about the buyer",
27
+ description: "Keep what will matter next time about the buyer (how they use it, what they value, a"
28
+ + " cap for this kind of thing, a measurement) in the turn you learn it, before any"
29
+ + " search, and say so with the undo. This is the only place the buyer is kept: \"remember"
30
+ + " this\" means this call, not a note or memory file. A one-off wish for this buy rides on"
31
+ + " its calls instead. Each row's `place` is the `name` of the kind you are shopping, from"
32
+ + " the domain read. A price is `value` with `unit` its currency; money is in the minor"
33
+ + " unit: €130 is 13000.",
80
34
  },
81
35
  {
82
- name: "shopping_brief_create",
36
+ name: "shopping_user_forget",
83
37
  method: "POST",
84
- path: "/briefs/create",
85
- label: "Open the session's brief",
86
- description: "Once per SESSION: open the one brief this conversation works from — across"
87
- + " every domain the buyer asks about, never one per domain — and hold the `id`"
88
- + " it answers for the rest of the session, because every search and every offers"
89
- + " call names it. A new chat opens its own AFTER shopping_brief_read has shown what"
90
- + " is on file: carry every spec an earlier brief still holds true into this one, then"
91
- + " name that carry in the first shopping_brief_edit `decision`. `title` names the job"
92
- + " in a few words. `narrative` is the spec of the buy in the buyer's own terms — what"
93
- + " a good buy looks like for THEM, what it has to do for them, what would make it a"
94
- + " bad one — and a want no keyed spec can carry lives there and still counts. An"
95
- + " optional first `domain` with `specs` writes what they have already said: a"
96
- + " domain path carries that domain's product specs, `seller` carries the seller"
97
- + " specs, and each spec is a key and an operator shopping_domain_get listed whose"
98
- + " `reason` quotes the buyer VERBATIM, in English — their own words, or the measurement the"
99
- + " key's `description` converted — never a paraphrase and never a want they did not state. On"
100
- + " anything worn, the `gender` sil_whoami holds is a product spec in the registry's"
101
- + " own spelling — male → `gender eq mens`, female → `gender eq womens` — asked once"
102
- + " where the profile answers none or `other`, and never inferred. Everything after"
103
- + " this is shopping_brief_edit.",
38
+ path: "/user/forget",
39
+ label: "Erase what sil keeps, on the buyer's word",
40
+ description: "Erase what sil keeps, only after saying what goes and the buyer saying yes.",
104
41
  },
105
42
  {
106
- name: "shopping_brief_edit",
43
+ name: "shopping_brief_write",
107
44
  method: "POST",
108
- path: "/briefs/edit",
109
- label: "Write a want or a decision into the brief",
110
- // The id is the only thing a 404 can be about here, and the bare read lists what is.
45
+ path: "/briefs/write",
46
+ label: "Open or update a brief",
111
47
  recovery: { not_found: "shopping_brief_read" },
112
- description: "The brief's write: put every want the buyer states into the brief as it is settled,"
113
- + " with `reason` quoting their own words VERBATIM — never a"
114
- + " paraphrase, never a want they did not state. A want that reaches"
115
- + " no brief is a want the next call drops. A MEASUREMENT is never the spec: 27.2 cm is"
116
- + " the buyer's, and the spec is the size the thing is sold in —"
117
- + " `mondo_size in [27, 27.5]`, with that measurement as its `reason`; the key's"
118
- + " `description` says how one becomes the other."
119
- + " One write per `domain`: a domain path carries"
120
- + " that domain's product specs, `price` among them, and `seller` carries the"
121
- + " seller specs, which belong to the whole brief. `specs` REPLACE every spec on the"
122
- + " keys they name — a range is the two rows on its key — `remove` names the keys"
123
- + " whose specs go, and `narrative` replaces the whole narrative. When the buyer"
124
- + " changes their mind — and only then — send the new spec together with `decision`:"
125
- + " one sentence ABOUT them, never in their voice, saying what they changed and"
126
- + " why. A new want's words are its spec's `reason`, never a `decision`, and never a"
127
- + " log of what you have just written down."
128
- + " Send `status: \"closed\"` when the job is over. An"
129
- + " invalid_request names the key and shows a spec on it that passes — fix that row"
130
- + " and send it again, and never give the want up. A brief id that is not the"
131
- + " buyer's answers not_found; shopping_brief_read with no `id` lists their briefs.",
48
+ description: "Write down a buy that spans asks or conversations; no other call needs one. Spec rows"
49
+ + " are `{ spec, op, value }`, a money row `{ spec: \"price\", range: { min?, max?, currency"
50
+ + " } }`; money is in the minor unit: €130 is 13000.",
132
51
  },
133
52
  {
134
53
  name: "shopping_brief_read",
135
54
  method: "POST",
136
55
  path: "/briefs/read",
137
- label: "Read the brief, or list the buyer's briefs",
138
- description: "The first read of a new chat: with no `id` it answers the buyer's briefs,"
139
- + " newest first, each with its title, its domains and when it was last written."
140
- + " Call it with sil_whoami before you ask the buyer anything, so a job already"
141
- + " under way is continued rather than interviewed a second time. With an `id` it"
142
- + " answers that brief whole: the title, the narrative, every spec under the domain"
143
- + " it sits on (`seller` for the seller specs), and the decisions already taken with"
144
- + " the time of each. What comes back is a READ: it says what the buyer has already"
145
- + " settled so you ask none of it again, and the specs still true are carried into"
146
- + " this session's own brief with shopping_brief_create — the search runs on that"
147
- + " one, never on an earlier session's. New wants go in through shopping_brief_edit.",
56
+ label: "Read a brief, or list the buyer's briefs",
57
+ description: "Pick a written-down buy up again; money is in the minor unit: €130 is 13000.",
58
+ },
59
+ {
60
+ name: "shopping_domain_search",
61
+ method: "GET",
62
+ path: "/catalog/domains",
63
+ query: ["query"],
64
+ label: "Place the thing",
65
+ description: "Place the thing the buyer named: the leaves sil holds for it.",
148
66
  },
149
67
  {
150
- name: "shopping_profile_edit",
68
+ name: "shopping_domain_get",
69
+ ...DOMAIN_GET_ROUTE,
70
+ label: "Read how to search a place",
71
+ recovery: { not_found: "shopping_domain_search" },
72
+ description: "Learn what decides a leaf or the kind above its leaves, and how to search it: send"
73
+ + " `path`, the buyer's words in English as `query`, and a word per spec you are after."
74
+ + " Back come the place's `name` and one line per spec (`spec`, `type`, `unit`, `values`,"
75
+ + " `operators`), and a spec marked `decides` carries its `why`, to teach and ask from."
76
+ + " The first `reached` lines answer the buyer's words; when `reached` is every line on"
77
+ + " the page and `next_page` is there, more of what they asked for is past it. Send `page`"
78
+ + " = `next_page` then, and when a spec you need is not on the page.",
79
+ },
80
+ {
81
+ name: "shopping_content",
151
82
  method: "POST",
152
- path: "/profile/edit",
153
- label: "Write what is true of the buyer",
154
- description: "The person rather than the job: write what is true of the buyer whatever"
155
- + " they are buying, the moment they say it and BEFORE the next search — only what"
156
- + " they stated UNAMBIGUOUSLY about themselves. A phrase that could mean two things"
157
- + " (\"wide forefoot and bit short\" — the foot, or the buyer?) is asked about, never"
158
- + " written here, because a lasting fact written wrong follows them into every"
159
- + " domain. Every `name` is lower snake_case: `foot_length`, never \"foot length\"."
160
- + " A"
161
- + " `measurements` entry is a number with its `unit`, or a size exactly as it is"
162
- + " printed; a `preferences` entry is a lasting taste in the buyer's own words."
163
- + " An entry replaces the one of the same `name`, and `remove` names the entries"
164
- + " that stopped being true. `currency` is the ISO 4217 code they price in, and"
165
- + " every money row naming none means it: \"my prices in dollars from now on\" is"
166
- + " `currency: \"USD\"`, which changes which offers come first and never a price —"
167
- + " sil converts nothing. sil_whoami reads all of it back, so a fact written here"
168
- + " is one you never ask for again. What belongs to THIS job — a budget, a size for"
169
- + " these boots — is the brief's, through shopping_brief_edit: a measurement is the"
170
- + " buyer's, and the spec the domain's key turns it into carries that"
171
- + " measurement as its `reason`.",
83
+ path: "/catalog/content",
84
+ label: "Read what sil holds about it",
85
+ recovery: { not_found: "shopping_domain_search" },
86
+ description: "Teach before you ask: the passages sil holds on a place that bear on `about`. Send the"
87
+ + " buyer's own taste words as `about` (clarity, texture, quiet), then turn the passage"
88
+ + " into specs from the domain read or into the question that decides. A question's why"
89
+ + " comes from here or from a spec's `why`.",
172
90
  },
173
91
  {
174
- name: SEARCH_TOOL,
92
+ name: "shopping_search",
175
93
  method: "POST",
176
94
  path: "/catalog/search",
177
- label: "Search sil in one settled domain",
178
- // A 404 here is the `brief` id and nothing else: a domain that does not stand is
179
- // refused as `invalid_request`, naming the path.
95
+ label: "Search sil's products",
180
96
  recovery: { not_found: "shopping_brief_read" },
181
- description: "The products that fit the brief, in one settled domain. Search as often as the job"
182
- + " needs — a re-worded `query`, a different `n` — it is cheap and it is how you learn"
183
- + " what is out there. Send `brief` (the session's brief id) on EVERY call,"
184
- + " the domain path, and `query` — the thing as a shop lists it and the numbers"
185
- + " that pick the product, never a sentence; a budget, a market, a unit, a standard's"
186
- + " name, \"in stock\" and \"online\" are specs, and cost most of the offers."
187
- + " `n` counts VARIANTS — one size, one option — max 10. `specs`: every product"
188
- + " spec the brief holds for this domain, all of them and UNCHANGED — never a looser"
189
- + " bound, never one it does not hold — money a decimal STRING (`\"300\"`, never 300)."
190
- + " The brief's `seller` specs are shopping_offers' to read off the brief, never on"
191
- + " the search. Keep the server's order, never re-rank; quote each variant's OWN"
192
- + " `price` with its size. `fit` answers the ask key by key: the value sil verified"
193
- + " (a list on a `several` key), or \"unknown\" where it holds none — a gap to dig"
194
- + " into with shopping_product_get, never a failed one."
195
- + " `host` is the shop; `printed` is that page's own pairs, never verified —"
196
- + " say \"the page says\". A `variants` entry with no option"
197
- + " values is a listing whose sizes sil has not read: say so — it prices like any"
198
- + " other. sil never says what it left out, so a want left off `specs` is one you will"
199
- + " not know you missed.",
97
+ description: "Search once per settled ask: `specs` `{ spec, op, value }` from the domain read and"
98
+ + " `price` the range `{ min?, max?, currency }`, each a want the buyer said or sil keeps;"
99
+ + " money is in the minor unit: €130 is 13000. `query` holds only the buyer's own words"
100
+ + " for what no spec holds, and no brand, model or product they did not name: good `query:"
101
+ + " \"clarity\"` when no spec holds clarity, bad `query: \"Eureka Mignon\"` when the buyer"
102
+ + " never said it. Back come `asked` numbered, `search_stats` to explain the shortlist,"
103
+ + " and the closest cards with `holds`, `misses` and `unknown` as ask numbers,"
104
+ + " `price_range` and `variants`, each with its own `price_range`, one `recommended`. When"
105
+ + " few fit or many are unknown, tell the buyer what came back and ask the one question"
106
+ + " that would change it, or ask before relaxing a want, rather than searching again in"
107
+ + " other words.",
200
108
  },
201
109
  {
202
110
  name: "shopping_product_get",
203
111
  method: "POST",
204
112
  path: "/catalog/product",
205
- label: "Read the whole dossier on a shortlisted variant",
206
- description: "The dossier: send 1–10 variant ids from a shopping_search answer and get"
207
- + " the whole of what sil holds for each — the title, the maker, the page's own"
208
- + " description, the images, every key sil holds for it (not only the ones you"
209
- + " asked about; a `several` key as a list), and `sources` naming which site each"
210
- + " reading came from and when."
211
- + " This is where a key the search answered \"unknown\" is dug out. A variant with no"
212
- + " option values is a listing whose sizes sil has not read, and its id opens here"
213
- + " like any other: the answer carries that page whole, so the sizes it prints are"
214
- + " the page's own words — say the size is unread, never that it is in stock."
215
- + " Compare the shortlist on this before recommending, and quote a source's date"
216
- + " rather than implying sil read it just now. An id sil cannot place is simply"
217
- + " absent from the answer — say that listing could not be placed, and never"
218
- + " substitute another product. Ids are opaque: pass them back exactly as sil"
219
- + " minted them, and never read one.",
113
+ label: "Read shortlisted products whole",
114
+ description: "Read the products the buyer leans to whole: values once, reviews, every picture, and"
115
+ + " each variant with what sets it apart and its `price_range`, cheapest to dearest offer."
116
+ + " Pick the variants to buy here; money is in the minor unit: €130 is 13000.",
220
117
  },
221
118
  {
222
119
  name: "shopping_offers",
223
120
  method: "POST",
224
121
  path: "/catalog/offers",
225
- label: "List who sells a variant, at what price and on what terms",
226
- // Same as the search: the only 404 this route answers is a brief that is not
227
- // the buyer's.
122
+ label: "Where to buy the picked variants",
228
123
  recovery: { not_found: "shopping_brief_read" },
229
- description: "Who sells it, at what price, on what terms — the only live read of a price."
230
- + " Worth a call once the buyer wants something: pricing a whole shortlist buries the"
231
- + " fit answer they asked for. Send `brief` (the session's brief id) and 1–10 picked"
232
- + " variant ids, and nothing else: sil reads the brief's `seller` specs, its `price`"
233
- + " ceiling, the buyer's default address and their currency itself, so a seller term"
234
- + " the buyer states goes on the brief. The first three picks are also looked for on"
235
- + " the web, so put the one they want first; the rest answer from shops sil holds. A"
236
- + " variant with no option values is priced as its page prints. An offer is the pick"
237
- + " at one shop, read live: the seller, the price in its own currency (sil converts"
238
- + " nothing), its availability, the listing URL, `observed_at`, and `seller_fit`:"
239
- + " `ships` always — serviceable, not_serviceable or unknown for that address — and"
240
- + " each brief seller key where sil holds the seller's value. An offer over the"
241
- + " brief's price in that price's currency is left out; one in another currency was"
242
- + " not tested against it — say so. `unknown` keeps the offer: say sil could not"
243
- + " confirm shipping. A key absent from `seller_fit` is a term sil has not read. The"
244
- + " order is the buyer's currency and market first, then sellers known to reach them,"
245
- + " then the rest — keep it, never re-rank. Several offers ARE the price spread, and"
246
- + " the spread is the answer.",
124
+ description: "Where to buy: variant ids from `shopping_product_get`, never product ids, and"
125
+ + " `ship_to`, one of the buyer's addresses by name (the default when absent). Every"
126
+ + " offer, shops shipping there first, each with its shop's `name`, whether it `ships`, its"
127
+ + " `delivery` there, `returns_days` and own `promotions`, then `price`, `was`, `pack` or"
128
+ + " `plan`, and its stock; nothing marks a best. A promotion is its shop's alone: quote it"
129
+ + " on that shop's offers only. Money is in the minor unit: €130 is 13000. Send `page` ="
130
+ + " `next_page` only when a shop the buyer needs may be past it. Warranty, policies,"
131
+ + " reviews and other terms come from `shopping_seller_get`.",
247
132
  },
248
133
  {
249
134
  name: "shopping_seller_get",
250
135
  method: "POST",
251
136
  path: "/catalog/sellers",
252
- label: "Read one seller's whole terms",
253
- description: "One seller's WHOLE terms: send 1–10 seller ids from shopping_offers, and"
254
- + " nothing else. Each seller comes back with its name, host and country, `specs` —"
255
- + " every seller key sil holds a value for, base and branch, as the dossier's `specs`"
256
- + " are a product's — and `ships`, which answers for the buyer's default address:"
257
- + " serviceable (sil read a route covering it), not_serviceable (sil read this"
258
- + " seller's policy and it excludes it), or unknown (sil has read nothing about this"
259
- + " seller). `unknown` is an ordinary answer that keeps the seller — say sil could not"
260
- + " confirm shipping, and hand the buyer the listing; an empty `specs` is the same"
261
- + " answer about its terms. Where sil has read them, `shipping` carries the routes"
262
- + " with their cost, free-over threshold and days, and `returns` the window and any"
263
- + " restocking fee; a term the page never stated is simply absent, which is never zero"
264
- + " and never free. A `policy_url` of null means the terms were read off a product"
265
- + " page and sil holds no policy page. This is the details read: whether an offer"
266
- + " meets the buyer's own seller rows is `seller_fit` on that offer, from"
267
- + " shopping_offers.",
137
+ label: "Read the shops' terms",
138
+ description: "Every term of the shops the offers named, delivered to `ship_to` (the default address"
139
+ + " when absent): the delivery, returns and promotions the offers carry, and warranty,"
140
+ + " policies, reviews and other terms; money is in the minor unit: €130 is 13000. A"
141
+ + " promotion is its shop's alone: quote it on that shop's offers only. Ask whether they"
142
+ + " qualify; a reduced price only from its `discount`, on their yes. Send `page` ="
143
+ + " `next_page` only when a shop the buyer needs may be past it.",
268
144
  },
269
145
  ];
270
146
  /**
271
- * Registers the eleven, reading each one's request artifact off disk as it goes.
272
- *
273
- * That read is the ONE exception to "register() opens nothing": eleven synchronous
274
- * `readFileSync`s that return immediately and hold no resource open, exactly as
275
- * `ensureDataDir`'s `mkdirSync` does. It is deliberately eager — an unreadable artifact
276
- * is a broken build, and failing loud at load beats a tool whose `parameters` the host
277
- * has already published by the time anyone finds out.
278
- *
279
- * Each tool is a factory because the host hands the conversation and the model only to a
280
- * factory, once per agent run; every call that run makes says who is calling.
147
+ * Registers the twelve, reading each request artifact off disk eagerly: an unreadable
148
+ * artifact is a broken build and should fail at load. Each tool is a factory because the
149
+ * host hands the conversation and model only to a factory, once per agent run.
281
150
  */
282
151
  export function registerCatalogTools(api) {
283
152
  const pluginVersion = readInstalledVersion();
284
153
  const openclawVersion = readHostVersion(api) ?? undefined;
285
154
  for (const tool of SHOPPING_TOOLS) {
286
155
  const parameters = requestSchema(tool.name);
287
- api.registerTool((ctx) => {
288
- const { provider, modelId } = ctx.activeModel ?? {};
289
- const run = {
290
- pluginVersion,
291
- ...(openclawVersion !== undefined ? { openclawVersion } : {}),
292
- ...(ctx.sessionId ? { sessionId: ctx.sessionId } : {}),
293
- ...(provider && modelId ? { model: `${provider}/${modelId}` } : {}),
294
- };
295
- return defineTool(api, tool, parameters, run);
296
- }, { name: tool.name });
156
+ api.registerTool((ctx) => defineTool(api, tool, parameters, runOf(ctx, pluginVersion, openclawVersion)), { name: tool.name });
297
157
  }
298
158
  }
159
+ /** Who is calling, as the host hands it to a tool factory once per agent run. */
160
+ export function runOf(ctx, pluginVersion, openclawVersion) {
161
+ const { provider, modelId } = ctx.activeModel ?? {};
162
+ return {
163
+ pluginVersion,
164
+ ...(openclawVersion !== undefined ? { openclawVersion } : {}),
165
+ ...(ctx.sessionId ? { sessionId: ctx.sessionId } : {}),
166
+ ...(provider && modelId ? { model: `${provider}/${modelId}` } : {}),
167
+ };
168
+ }
299
169
  function defineTool(api, tool, parameters, run) {
300
170
  return {
301
171
  name: tool.name,
@@ -304,40 +174,11 @@ function defineTool(api, tool, parameters, run) {
304
174
  parameters,
305
175
  async execute(callId, params) {
306
176
  const called = await callRoute(api, tool, params, { ...run, toolCallId: callId });
307
- if (called.kind === "refused") {
308
- if (tool.name === SEARCH_TOOL)
309
- skipped(api, callId, `refused:${called.status}`);
310
- return called.result;
311
- }
312
- if (tool.name === SEARCH_TOOL)
313
- bufferPage(api, callId, called.body);
314
- // VERBATIM, and the advisory rides its own block: the body's keys are the API's
315
- // contract, so nothing of ours may sit beside them.
177
+ if (called.kind === "refused")
178
+ return jsonResult(called.body);
179
+ keepAnswer(api, callId, run.sessionId, called.body);
180
+ // The advisory rides its own block: nothing of ours may sit beside the body's keys.
316
181
  return jsonResult(called.body, ...wiringAdvisoryBlocks(api));
317
182
  },
318
183
  };
319
184
  }
320
- /**
321
- * Buffer an `ok` search page for a paired client to pull by this exact `callId`
322
- * (`sil.search_results`). A PURE SIDE EFFECT: the result returned to the agent is
323
- * byte-identical to what every channel got before this existed. Only a body that
324
- * actually carries its `products` list is stored — the pull surface counts it.
325
- */
326
- function bufferPage(api, callId, body) {
327
- const principal = readConfig()?.user?.id;
328
- if (principal === undefined) {
329
- skipped(api, callId, "no_principal");
330
- return;
331
- }
332
- if (!Array.isArray(body["products"])) {
333
- skipped(api, callId, "no_products");
334
- return;
335
- }
336
- putSearchResult(callId, body, principal);
337
- }
338
- /** Why this `callId` will resolve nothing, logged where the decision is made. The pull
339
- * says only `not_found` — deliberately — so this line is the whole of an operator's
340
- * account of a search a client could not render. */
341
- function skipped(api, callId, reason) {
342
- logSearchResults(api, "info", "skipped", { callId, reason });
343
- }