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/dist/tools/catalog.js
CHANGED
|
@@ -1,301 +1,171 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
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: "
|
|
22
|
-
method: "
|
|
23
|
-
path: "/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
+ "
|
|
28
|
-
+ "
|
|
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: "
|
|
23
|
+
name: "shopping_user_remember",
|
|
61
24
|
method: "POST",
|
|
62
|
-
path: "/
|
|
63
|
-
label: "
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
+ "
|
|
67
|
-
+ "
|
|
68
|
-
+ "
|
|
69
|
-
+ "
|
|
70
|
-
+ "
|
|
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: "
|
|
36
|
+
name: "shopping_user_forget",
|
|
83
37
|
method: "POST",
|
|
84
|
-
path: "/
|
|
85
|
-
label: "
|
|
86
|
-
description: "
|
|
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: "
|
|
43
|
+
name: "shopping_brief_write",
|
|
107
44
|
method: "POST",
|
|
108
|
-
path: "/briefs/
|
|
109
|
-
label: "
|
|
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: "
|
|
113
|
-
+ "
|
|
114
|
-
+ "
|
|
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
|
|
138
|
-
description: "
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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: "
|
|
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: "/
|
|
153
|
-
label: "
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
+ "
|
|
157
|
-
+ "
|
|
158
|
-
+ "
|
|
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:
|
|
92
|
+
name: "shopping_search",
|
|
175
93
|
method: "POST",
|
|
176
94
|
path: "/catalog/search",
|
|
177
|
-
label: "Search sil
|
|
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: "
|
|
182
|
-
+ "
|
|
183
|
-
+ "
|
|
184
|
-
+ "
|
|
185
|
-
+ "
|
|
186
|
-
+ "
|
|
187
|
-
+ "
|
|
188
|
-
+ "
|
|
189
|
-
+ "
|
|
190
|
-
+ "
|
|
191
|
-
+ "
|
|
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
|
|
206
|
-
description: "
|
|
207
|
-
+ "
|
|
208
|
-
+ "
|
|
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: "
|
|
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: "
|
|
230
|
-
+ "
|
|
231
|
-
+ "
|
|
232
|
-
+ "
|
|
233
|
-
+ "
|
|
234
|
-
+ "
|
|
235
|
-
+ "
|
|
236
|
-
+ "
|
|
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
|
|
253
|
-
description: "
|
|
254
|
-
+ "
|
|
255
|
-
+ "
|
|
256
|
-
+ "
|
|
257
|
-
+ "
|
|
258
|
-
+ "
|
|
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
|
|
272
|
-
*
|
|
273
|
-
*
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
-
}
|