sil-openclaw 0.4.5 → 0.5.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 +186 -0
- package/README.md +33 -45
- package/dist/gateway/search-results.js +11 -7
- package/dist/index.js +24 -24
- package/dist/lib/allowlist-script.js +13 -0
- package/dist/lib/artifacts.js +30 -0
- package/dist/lib/credentials.js +2 -3
- package/dist/lib/host-wiring.js +44 -15
- package/dist/lib/pkce.js +3 -3
- package/dist/lib/search-results-log.js +23 -0
- package/dist/lib/search-results-store.js +13 -10
- package/dist/lib/shopping-call.js +143 -0
- package/dist/lib/sil-client.js +185 -1046
- package/dist/lib/tool-result.js +10 -3
- package/dist/tools/catalog.js +311 -1197
- package/dist/tools/doctor.js +25 -63
- package/dist/tools/identity.js +110 -245
- package/openclaw.plugin.json +16 -12
- package/package.json +7 -6
- package/schema/PROVENANCE.md +15 -0
- package/schema/shopping-brief-create-request.schema.json +98 -0
- package/schema/shopping-brief-create-response.schema.json +24 -0
- package/schema/shopping-brief-edit-request.schema.json +125 -0
- package/schema/shopping-brief-edit-response.schema.json +24 -0
- package/schema/shopping-brief-read-request.schema.json +15 -0
- package/schema/shopping-brief-read-response.schema.json +235 -0
- package/schema/shopping-domain-create-request.schema.json +160 -0
- package/schema/shopping-domain-create-response.schema.json +60 -0
- package/schema/shopping-domain-get-request.schema.json +18 -0
- package/schema/shopping-domain-get-response.schema.json +307 -0
- package/schema/shopping-domain-search-request.schema.json +18 -0
- package/schema/shopping-domain-search-response.schema.json +92 -0
- package/schema/shopping-offers-request.schema.json +31 -0
- package/schema/shopping-offers-response.schema.json +172 -0
- package/schema/shopping-product-get-request.schema.json +24 -0
- package/schema/shopping-product-get-response.schema.json +121 -0
- package/schema/shopping-profile-edit-request.schema.json +97 -0
- package/schema/shopping-profile-edit-response.schema.json +17 -0
- package/schema/shopping-search-request.schema.json +106 -0
- package/schema/shopping-search-response.schema.json +182 -0
- package/schema/shopping-seller-get-request.schema.json +24 -0
- package/schema/shopping-seller-get-response.schema.json +342 -0
- package/scripts/allowlist-openclaw.mjs +4 -5
- package/sil-shopping/SKILL.md +196 -97
- package/sil-shopping/references/mint.md +190 -0
- package/dist/lib/bind-channel.js +0 -10
- package/dist/lib/creation-entrypoint.js +0 -111
- package/dist/lib/derive-agent-id.js +0 -36
- package/dist/lib/profile-store.js +0 -568
- package/dist/tools/profile.js +0 -300
- package/scripts/create-shopper.mjs +0 -677
- package/sil-shopping/examples/multi_domain_shopper_walkthrough.md +0 -65
- package/sil-shopping/references/agent_creation_engine.md +0 -223
- package/sil-shopping/references/fill_and_feedback.md +0 -102
- package/sil-shopping/references/method_and_prds.md +0 -143
- package/sil-shopping/references/setup_onboarding.md +0 -64
- package/sil-shopping/references/shop_loop.md +0 -118
package/dist/tools/profile.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* sil shopper profile tools — the frontmatter-as-truth artefact seam.
|
|
3
|
-
*
|
|
4
|
-
* FIVE local verbs over the singleton shopper store ($SIL_DATA_DIR/shopper), each
|
|
5
|
-
* making NO network call and reading no token:
|
|
6
|
-
*
|
|
7
|
-
* - `sil_profile_materialize { name, userSpec }` — SETUP-ONLY: write user_spec.md
|
|
8
|
-
* (its frontmatter carries the shopper name). Does NOT mint methods/PRDs.
|
|
9
|
-
* - `sil_learn { target, domain?, prd?, kind, … }` — the single target+change verb
|
|
10
|
-
* for the whole method/PRD lifecycle: create mints a NEW doc; write replaces an
|
|
11
|
-
* existing doc's whole body (reconciled); attach-asset persists image bytes by path.
|
|
12
|
-
* - `sil_profile_search { domain?, product?, intent?, query? }` — query artefact
|
|
13
|
-
* FRONTMATTER (coordinates only, no bodies); the discovery / reuse-before-mint
|
|
14
|
-
* primitive. Malformed frontmatter surfaces in `unreadable`, never dropped.
|
|
15
|
-
* - `sil_profile_get { domainSlug, prd? }` — the rich read (one whole body).
|
|
16
|
-
* - `sil_profile_remove { domainSlug, prd? }` — remove a whole domain, or one PRD.
|
|
17
|
-
*
|
|
18
|
-
* This follows `identity.ts` (the reference group): a `registerXTools(api)` function,
|
|
19
|
-
* a `Type.Object` schema the host validates inputs against, the `jsonResult`
|
|
20
|
-
* success/structured-error envelope, and ALL I/O inside `execute()` (register() opens
|
|
21
|
-
* nothing). The persona is NOT written here — it is the host workspace SOUL.md.
|
|
22
|
-
*/
|
|
23
|
-
import { Type } from "typebox";
|
|
24
|
-
import { wiringAdvisories } from "../lib/host-wiring.js";
|
|
25
|
-
import { learnArtefact, materializeProfile, readArtefactBody, removeArtefact, searchProfileFrontmatter, } from "../lib/profile-store.js";
|
|
26
|
-
import { jsonResult } from "../lib/tool-result.js";
|
|
27
|
-
/** Narrow a host-validated param to a string, defaulting to "" so the store does the
|
|
28
|
-
* real, structured-error validation (validate-first / write-nothing). */
|
|
29
|
-
function asString(value) {
|
|
30
|
-
return typeof value === "string" ? value : "";
|
|
31
|
-
}
|
|
32
|
-
/** Narrow an optional string param — `undefined` unless a non-empty string is given,
|
|
33
|
-
* so a selector is never carried as a spurious empty value. */
|
|
34
|
-
function optString(value) {
|
|
35
|
-
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
36
|
-
}
|
|
37
|
-
export function registerProfileTools(api) {
|
|
38
|
-
registerMaterialize(api);
|
|
39
|
-
registerLearn(api);
|
|
40
|
-
registerSearch(api);
|
|
41
|
-
registerGet(api);
|
|
42
|
-
registerRemove(api);
|
|
43
|
-
}
|
|
44
|
-
function registerMaterialize(api) {
|
|
45
|
-
api.registerTool({
|
|
46
|
-
name: "sil_profile_materialize",
|
|
47
|
-
label: "Set up the sil shopper",
|
|
48
|
-
description: "SETUP-ONLY: create the one sil shopper by writing its shared user_spec.md — the"
|
|
49
|
-
+ " person's cross-niche facts + hard constraints — with the shopper `name` in the"
|
|
50
|
-
+ " file's frontmatter (no manifest). Does NOT mint any domain method or PRD (that"
|
|
51
|
-
+ " is sil_learn create). Run ONCE at setup; refine later with sil_learn, never a"
|
|
52
|
-
+ " re-materialize (it overwrites the whole body). `name` + `userSpec` required and"
|
|
53
|
-
+ " non-empty. Local-only, no network. Blank input → invalid_request; write failure"
|
|
54
|
-
+ " → persistence_failed.",
|
|
55
|
-
parameters: Type.Object({
|
|
56
|
-
name: Type.String({
|
|
57
|
-
description: "The human-readable shopper name (recorded in user_spec.md frontmatter).",
|
|
58
|
-
}),
|
|
59
|
-
userSpec: Type.String({
|
|
60
|
-
description: "The shared user spec — the one person's cross-domain facts + hard"
|
|
61
|
-
+ " constraints. REQUIRED, non-empty. Read by every domain's shop loop, so a"
|
|
62
|
-
+ " fact captured in one niche is reused in another without re-asking.",
|
|
63
|
-
}),
|
|
64
|
-
}),
|
|
65
|
-
async execute(_callId, params) {
|
|
66
|
-
const result = materializeProfile({
|
|
67
|
-
name: asString(params["name"]),
|
|
68
|
-
userSpec: asString(params["userSpec"]),
|
|
69
|
-
});
|
|
70
|
-
if (result.ok) {
|
|
71
|
-
api.logger.info("sil_profile_materialized", {});
|
|
72
|
-
return jsonResult({
|
|
73
|
-
status: "ok",
|
|
74
|
-
dir: result.dir,
|
|
75
|
-
userSpecPath: result.userSpecPath,
|
|
76
|
-
...wiringAdvisories(api),
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return mapFailure(api, "sil_profile_materialize", result);
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function registerLearn(api) {
|
|
84
|
-
api.registerTool({
|
|
85
|
-
name: "sil_learn",
|
|
86
|
-
label: "Teach the sil shopper (create or refine a method / PRD)",
|
|
87
|
-
description: "The single target+change verb owning the sil shopper's method/PRD lifecycle."
|
|
88
|
-
+ " `target` (user_spec | method | prd) picks WHERE the change lands; `kind`"
|
|
89
|
-
+ " (create | write | attach-asset) picks the change. `create` mints a NEW method/"
|
|
90
|
-
+ "PRD (not valid for user_spec; errors if one already exists — use write). `write`"
|
|
91
|
-
+ " replaces an EXISTING doc's whole body with a reconciled version you author (read"
|
|
92
|
-
+ " it first with sil_profile_get and carry every buyer line forward; else not_found)."
|
|
93
|
-
+ " `attach-asset` links image bytes. To change anything, WRITE the whole reconciled"
|
|
94
|
-
+ " doc — there is no append/amend, so a correction never stacks a contradicting"
|
|
95
|
-
+ " line. Local-only, atomic, owner-only, no network; a bad field → invalid_request"
|
|
96
|
-
+ " and writes nothing.",
|
|
97
|
-
parameters: Type.Object({
|
|
98
|
-
target: Type.Union([Type.Literal("user_spec"), Type.Literal("method"), Type.Literal("prd")], { description: "WHERE the change lands: user_spec | method | prd." }),
|
|
99
|
-
kind: Type.Union([
|
|
100
|
-
Type.Literal("create"),
|
|
101
|
-
Type.Literal("write"),
|
|
102
|
-
Type.Literal("attach-asset"),
|
|
103
|
-
], { description: "The change: create (mint new) | write (replace whole body) | attach-asset." }),
|
|
104
|
-
domain: Type.Optional(Type.String({ description: "The domain slug (lower-kebab, not \"main\") — required for method/prd." })),
|
|
105
|
-
prd: Type.Optional(Type.String({ description: "The PRD key <product>-<intent> (lower-kebab) — required for a prd target." })),
|
|
106
|
-
name: Type.Optional(Type.String({ description: "create method: the human-readable domain name." })),
|
|
107
|
-
body: Type.Optional(Type.String({ description: "create / write: the whole markdown body (mint, or the reconciled replacement)." })),
|
|
108
|
-
product: Type.Optional(Type.String({ description: "create prd: the product type." })),
|
|
109
|
-
intent: Type.Optional(Type.String({ description: "create prd: the use-context (general when context-free)." })),
|
|
110
|
-
title: Type.Optional(Type.String({ description: "create prd: the human-readable job title." })),
|
|
111
|
-
bytes: Type.Optional(Type.String({ description: "attach-asset: the image bytes, base64-encoded." })),
|
|
112
|
-
mime: Type.Optional(Type.String({ description: "attach-asset: image/jpeg | image/png | image/webp | image/gif." })),
|
|
113
|
-
caption: Type.Optional(Type.String({ description: "attach-asset: an optional caption for the markdown link." })),
|
|
114
|
-
}),
|
|
115
|
-
async execute(_callId, params) {
|
|
116
|
-
const spec = {
|
|
117
|
-
target: params["target"] ?? "method",
|
|
118
|
-
kind: params["kind"] ?? "write",
|
|
119
|
-
domain: optString(params["domain"]),
|
|
120
|
-
prd: optString(params["prd"]),
|
|
121
|
-
name: optString(params["name"]),
|
|
122
|
-
body: optString(params["body"]),
|
|
123
|
-
product: optString(params["product"]),
|
|
124
|
-
intent: optString(params["intent"]),
|
|
125
|
-
title: optString(params["title"]),
|
|
126
|
-
bytes: optString(params["bytes"]),
|
|
127
|
-
mime: optString(params["mime"]),
|
|
128
|
-
caption: optString(params["caption"]),
|
|
129
|
-
};
|
|
130
|
-
const result = learnArtefact(spec);
|
|
131
|
-
if (result.ok) {
|
|
132
|
-
// Non-PII markers only — no artefact body/text is ever logged.
|
|
133
|
-
api.logger.info("sil_learned", {
|
|
134
|
-
kind: result.kind,
|
|
135
|
-
target: result.target,
|
|
136
|
-
domain_slug: result.domain,
|
|
137
|
-
prd: result.prd,
|
|
138
|
-
});
|
|
139
|
-
return jsonResult({
|
|
140
|
-
status: "ok",
|
|
141
|
-
kind: result.kind,
|
|
142
|
-
target: result.target,
|
|
143
|
-
...(result.domain !== undefined ? { domain: result.domain } : {}),
|
|
144
|
-
...(result.prd !== undefined ? { prd: result.prd } : {}),
|
|
145
|
-
path: result.path,
|
|
146
|
-
...(result.assetPath !== undefined ? { assetPath: result.assetPath } : {}),
|
|
147
|
-
...wiringAdvisories(api),
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return mapFailure(api, "sil_learn", result);
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function registerSearch(api) {
|
|
155
|
-
api.registerTool({
|
|
156
|
-
name: "sil_profile_search",
|
|
157
|
-
label: "Search what the sil shopper knows (domains + PRDs)",
|
|
158
|
-
description: "Query the sil shopper's artefact FRONTMATTER — the discovery / reuse-before-mint"
|
|
159
|
-
+ " primitive. Returns COORDINATES only (no bodies): the domains learned ({slug,"
|
|
160
|
-
+ " name}) and their PRDs ({domain, key, product, intent, title}). All filters"
|
|
161
|
-
+ " optional — none = full overview; narrow by domain/product/intent/query. A"
|
|
162
|
-
+ " filesystem scan: malformed frontmatter is surfaced in `unreadable`, never"
|
|
163
|
-
+ " dropped; healthy siblings still list. Empty store → ok with empty lists. When"
|
|
164
|
-
+ " NO domain matches, the result carries `next_step: mint_domain` — the cue to"
|
|
165
|
-
+ " mint the niche (sil_learn create) BEFORE shopping. Local-only, no network.",
|
|
166
|
-
parameters: Type.Object({
|
|
167
|
-
domain: Type.Optional(Type.String({ description: "Filter to one domain slug." })),
|
|
168
|
-
product: Type.Optional(Type.String({ description: "Filter PRDs by product type." })),
|
|
169
|
-
intent: Type.Optional(Type.String({ description: "Filter PRDs by intent (use-context)." })),
|
|
170
|
-
query: Type.Optional(Type.String({ description: "Free-text substring match over the coordinates." })),
|
|
171
|
-
}),
|
|
172
|
-
async execute(_callId, params) {
|
|
173
|
-
const result = searchProfileFrontmatter({
|
|
174
|
-
domain: optString(params["domain"]),
|
|
175
|
-
product: optString(params["product"]),
|
|
176
|
-
intent: optString(params["intent"]),
|
|
177
|
-
query: optString(params["query"]),
|
|
178
|
-
});
|
|
179
|
-
api.logger.info("sil_profile_searched", {
|
|
180
|
-
domain_count: result.domains.length,
|
|
181
|
-
prd_count: result.prds.length,
|
|
182
|
-
unreadable_count: result.unreadable.length,
|
|
183
|
-
});
|
|
184
|
-
// The mint trigger. No matching domain came back (an empty store, or a
|
|
185
|
-
// filtered miss on a populated one) — this IS the reuse-before-mint MISS, and
|
|
186
|
-
// it is where a first shop silently stalls: the model finds nothing to reuse
|
|
187
|
-
// and, with no next move in hand, answers a buy-intent off the open web. Carry
|
|
188
|
-
// the next action in the result so the MISS itself points at the mint, the way
|
|
189
|
-
// the catalog tools carry `recovery`. Absent when a domain matched.
|
|
190
|
-
const noMatch = result.domains.length === 0;
|
|
191
|
-
return jsonResult({
|
|
192
|
-
status: "ok",
|
|
193
|
-
domains: result.domains,
|
|
194
|
-
prds: result.prds,
|
|
195
|
-
unreadable: result.unreadable,
|
|
196
|
-
...(noMatch
|
|
197
|
-
? {
|
|
198
|
-
next_step: "mint_domain",
|
|
199
|
-
guidance: "No learned domain matches this request. To shop this niche, mint"
|
|
200
|
-
+ " its domain FIRST: research the buying guide, then sil_learn create"
|
|
201
|
-
+ " (target: method). Then shop with sil_search — a buy-intent is"
|
|
202
|
-
+ " answered from the sil catalog, never from the open web.",
|
|
203
|
-
}
|
|
204
|
-
: {}),
|
|
205
|
-
...wiringAdvisories(api),
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
function registerGet(api) {
|
|
211
|
-
api.registerTool({
|
|
212
|
-
name: "sil_profile_get",
|
|
213
|
-
label: "Read one sil shopper document (method or PRD)",
|
|
214
|
-
description: "Read ONE full body from the sil shopper's store. `domainSlug` alone → the method"
|
|
215
|
-
+ " body (buying guide + taste + search vocabulary); `domainSlug` + `prd` → that"
|
|
216
|
-
+ " PRD body (requirements + filled preferences). Discover coordinates with"
|
|
217
|
-
+ " sil_profile_search first. Missing → not_found; present-but-corrupt frontmatter"
|
|
218
|
-
+ " → unreadable (inspect/repair — do NOT overwrite, it may be recoverable), distinct"
|
|
219
|
-
+ " from not_found; a bad/traversal/\"main\" slug → invalid_request. Local-only, no"
|
|
220
|
-
+ " network.",
|
|
221
|
-
parameters: Type.Object({
|
|
222
|
-
domainSlug: Type.String({
|
|
223
|
-
description: "The domain slug to read (lower-kebab, not \"main\"). REQUIRED.",
|
|
224
|
-
}),
|
|
225
|
-
prd: Type.Optional(Type.String({ description: "OPTIONAL. A PRD key to read that PRD's body instead of the method." })),
|
|
226
|
-
}),
|
|
227
|
-
async execute(_callId, params) {
|
|
228
|
-
const result = readArtefactBody(asString(params["domainSlug"]), optString(params["prd"]));
|
|
229
|
-
if (result.ok) {
|
|
230
|
-
api.logger.info("sil_profile_read", { target: result.target, domain_slug: result.domain, prd: result.prd });
|
|
231
|
-
return jsonResult({
|
|
232
|
-
status: "ok",
|
|
233
|
-
target: result.target,
|
|
234
|
-
domain: result.domain,
|
|
235
|
-
...(result.prd !== undefined ? { prd: result.prd } : {}),
|
|
236
|
-
fields: result.fields,
|
|
237
|
-
body: result.body,
|
|
238
|
-
path: result.path,
|
|
239
|
-
...wiringAdvisories(api),
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
return mapFailure(api, "sil_profile_get", result);
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
function registerRemove(api) {
|
|
247
|
-
api.registerTool({
|
|
248
|
-
name: "sil_profile_remove",
|
|
249
|
-
label: "Remove a sil shopper domain, or one of its PRDs",
|
|
250
|
-
description: "Remove artefacts from the sil shopper's store. `domainSlug` alone removes the"
|
|
251
|
-
+ " WHOLE domain subtree (method + all PRDs + assets); `domainSlug` + `prd` removes"
|
|
252
|
-
+ " just that ONE PRD (method + siblings survive). Destructive — confirm with the"
|
|
253
|
-
+ " user first. A bad/traversal/\"main\" slug → invalid_request (deletes nothing); an"
|
|
254
|
-
+ " unregistered domain/PRD → not_found (idempotent); a filesystem failure →"
|
|
255
|
-
+ " persistence_failed. Never removes the shopper itself. Local-only, no network.",
|
|
256
|
-
parameters: Type.Object({
|
|
257
|
-
domainSlug: Type.String({
|
|
258
|
-
description: "The domain slug to remove from (lower-kebab, not \"main\"). REQUIRED.",
|
|
259
|
-
}),
|
|
260
|
-
prd: Type.Optional(Type.String({ description: "OPTIONAL. A PRD key to remove just that PRD instead of the whole domain." })),
|
|
261
|
-
}),
|
|
262
|
-
async execute(_callId, params) {
|
|
263
|
-
const result = removeArtefact(asString(params["domainSlug"]), optString(params["prd"]));
|
|
264
|
-
if (result.ok) {
|
|
265
|
-
api.logger.info("sil_profile_removed", { domain_slug: result.domainSlug, prd: result.prd });
|
|
266
|
-
return jsonResult({
|
|
267
|
-
status: "removed",
|
|
268
|
-
domainSlug: result.domainSlug,
|
|
269
|
-
...(result.prd !== undefined ? { prd: result.prd } : {}),
|
|
270
|
-
...wiringAdvisories(api),
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
return mapFailure(api, "sil_profile_remove", result);
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
/** Map a store failure variant to the canonical structured envelope + a non-PII log. */
|
|
278
|
-
function mapFailure(api, tool, result) {
|
|
279
|
-
if (result.kind === "invalid_request") {
|
|
280
|
-
api.logger.warn(tool + "_invalid_request", { field: result.field });
|
|
281
|
-
return jsonResult({ status: "invalid_request", field: result.field, message: result.message });
|
|
282
|
-
}
|
|
283
|
-
if (result.kind === "not_found") {
|
|
284
|
-
api.logger.info(tool + "_not_found", {});
|
|
285
|
-
return jsonResult({ status: "not_found", message: result.message });
|
|
286
|
-
}
|
|
287
|
-
if (result.kind === "unreadable") {
|
|
288
|
-
// A present-but-corrupt artefact — steer the agent to inspect/repair, NEVER re-mint
|
|
289
|
-
// over it (silent data loss on a recoverable artefact). Distinct from not_found.
|
|
290
|
-
api.logger.warn(tool + "_unreadable", {});
|
|
291
|
-
return jsonResult({ status: "unreadable", message: result.message, recovery: "inspect_artefact" });
|
|
292
|
-
}
|
|
293
|
-
api.logger.error(tool + "_persistence_failed", { error: result.error });
|
|
294
|
-
return jsonResult({
|
|
295
|
-
status: "persistence_failed",
|
|
296
|
-
error: result.error,
|
|
297
|
-
message: result.message,
|
|
298
|
-
recovery: result.recovery,
|
|
299
|
-
});
|
|
300
|
-
}
|