sil-openclaw 0.3.8 → 0.4.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 +116 -0
- package/dist/lib/bind-channel.js +10 -0
- package/dist/lib/profile-store.js +578 -581
- package/dist/lib/sil-client.js +282 -33
- package/dist/tools/catalog.js +485 -7
- package/dist/tools/profile.js +235 -371
- package/openclaw.plugin.json +6 -4
- package/package.json +1 -1
- package/scripts/create-shopper.mjs +188 -32
- package/sil-shopping/SKILL.md +85 -54
- package/sil-shopping/examples/multi_domain_shopper_walkthrough.md +56 -190
- package/sil-shopping/references/agent_creation_engine.md +113 -63
- package/sil-shopping/references/brainstorm_interview.md +95 -69
- package/sil-shopping/references/catalog_tools_reference.md +27 -29
- package/sil-shopping/references/fill_and_feedback.md +88 -0
- package/sil-shopping/references/method_and_prds.md +110 -0
- package/sil-shopping/references/search_param_mapping.md +72 -47
- package/sil-shopping/references/setup_onboarding.md +68 -0
- package/sil-shopping/references/shop_loop.md +117 -134
- package/sil-shopping/references/manage_domains.md +0 -56
- package/sil-shopping/references/refine_shopper.md +0 -48
package/openclaw.plugin.json
CHANGED
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
"id": "sil",
|
|
3
3
|
"name": "sil",
|
|
4
4
|
"description": "Turn your OpenClaw into an expert shopping agent.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.4.0",
|
|
6
6
|
"skills": ["./sil-shopping"],
|
|
7
7
|
"activation": {
|
|
8
8
|
"onCapabilities": ["tool"]
|
|
9
9
|
},
|
|
10
10
|
"contracts": {
|
|
11
11
|
"tools": [
|
|
12
|
+
"sil_learn",
|
|
12
13
|
"sil_product_get",
|
|
13
14
|
"sil_profile_get",
|
|
14
15
|
"sil_profile_materialize",
|
|
15
16
|
"sil_profile_remove",
|
|
17
|
+
"sil_profile_search",
|
|
16
18
|
"sil_register",
|
|
17
|
-
"sil_remember",
|
|
18
19
|
"sil_search",
|
|
20
|
+
"sil_specs",
|
|
19
21
|
"sil_whoami"
|
|
20
22
|
]
|
|
21
23
|
},
|
|
@@ -51,7 +53,7 @@
|
|
|
51
53
|
},
|
|
52
54
|
"security": {
|
|
53
55
|
"shipsRuntimeCode": true,
|
|
54
|
-
"packagingNote": "Compiled JavaScript ships under ./dist. register() stays synchronous and opens nothing — it only registers tools. ALL I/O happens inside a tool's execute(): sil_register calls sil-web over the network, writes tokens.json + config.json to the plugin data directory (owner-only, 0600), and arms a bounded background poll timer that stops on the first terminal claim outcome or after the session deadline. sil_whoami reads the stored session token and calls sil-api for the user's identity, refreshing transparently via sil-web on a 401 (at most one refresh + one retry per call, no timer); a confirmed-dead session clears tokens.json. sil_search and sil_product_get read the stored session token and call sil-api's catalog endpoints (search / lookup) with it — read-only on catalog data, no timer, but with the SAME bounded 401 recovery as sil_whoami: on a 401 they refresh ONCE via sil-web (rotating tokens.json) and retry the read ONCE; a second 401 or a dead (invalid_grant) refresh token clears tokens.json and is reported as a terminal re-register hint. A non-401 error writes no token.
|
|
56
|
+
"packagingNote": "Compiled JavaScript ships under ./dist. register() stays synchronous and opens nothing — it only registers tools. ALL I/O happens inside a tool's execute(): sil_register calls sil-web over the network, writes tokens.json + config.json to the plugin data directory (owner-only, 0600), and arms a bounded background poll timer that stops on the first terminal claim outcome or after the session deadline. sil_whoami reads the stored session token and calls sil-api for the user's identity, refreshing transparently via sil-web on a 401 (at most one refresh + one retry per call, no timer); a confirmed-dead session clears tokens.json. sil_search and sil_product_get read the stored session token and call sil-api's catalog endpoints (search / lookup) with it — read-only on catalog data, no timer, but with the SAME bounded 401 recovery as sil_whoami: on a 401 they refresh ONCE via sil-web (rotating tokens.json) and retry the read ONCE; a second 401 or a dead (invalid_grant) refresh token clears tokens.json and is reported as a terminal re-register hint. A non-401 error writes no token. The five profile verbs make NO network call and read no token; they write the one sil shopper's SINGLETON behaviour artefacts under a fixed $SIL_DATA_DIR/shopper/ (owner-only, files 0600, dirs 0700) as frontmatter-as-truth markdown — there is NO profile.json manifest; each file's own frontmatter IS the source of truth, discovered by a filesystem scan. sil_profile_materialize is SETUP-ONLY: it writes shopper/user_spec.md (the shared person spec; its frontmatter carries the shopper name), minting no domain. sil_learn is the single target+change verb over shopper/domains/<slug>/{method.md, prds/<product>-<intent>.md, assets/}: create mints a whole method or PRD; append/amend/retract refine a section-aware markdown body in place (single-occurrence match, fail-closed if the target or the named section is absent); attach-asset persists image bytes (size-capped, image MIME allowlist) into the domain's assets/ owner-only and links them by RELATIVE path, never inline bytes. sil_profile_search scans artefact FRONTMATTER and returns coordinates only (no bodies) — a domain/PRD with malformed frontmatter is skipped and surfaced as unreadable, never silently dropped or half-read. sil_profile_get reads ONE whole body (method or PRD); sil_profile_remove deletes a whole validated domain subtree, or one PRD file, fail-closed on a malformed/traversal/\"main\" or missing slug (never the whole shopper). The only caller-supplied path segments are the domain slug and the PRD key, both validated (lower-kebab, not \"main\") before any join; the shopper segment is a compile-time constant. Every write is atomic (tmp file → rename over target → chmod), so a reader sees a whole file or none. The persona is the shopper's host workspace SOUL.md, written by the host CLI (not this plugin, not a sil artefact), and the shopper's host-config wiring is driven separately by the host CLI. The PKCE verifier is held only in memory and is never written to disk. Artefact bodies, tokens, and identity PII are never logged.",
|
|
55
57
|
"registersLongLivedService": false,
|
|
56
58
|
"serviceIds": [],
|
|
57
59
|
"runsTimers": true,
|
|
@@ -61,7 +63,7 @@
|
|
|
61
63
|
"https://sil.4gpts.com"
|
|
62
64
|
],
|
|
63
65
|
"filesystemScope": [
|
|
64
|
-
"$SIL_DATA_DIR (default $XDG_DATA_HOME/sil, else ~/.local/share/sil) — tokens.json, config.json, shopper/
|
|
66
|
+
"$SIL_DATA_DIR (default $XDG_DATA_HOME/sil, else ~/.local/share/sil) — tokens.json, config.json, shopper/user_spec.md + shopper/domains/<slug>/{method.md, prds/<product>-<intent>.md, assets/<content-hash>.<ext>} (the ONE sil shopper's singleton behaviour artefacts, frontmatter-as-truth with NO profile.json manifest: sil_profile_materialize writes the shared user_spec.md at setup (its frontmatter carries the shopper name), and sil_learn mints/refines per-domain methods, intent-keyed PRDs, and per-domain image assets. The `shopper` segment is a fixed compile-time constant, not caller input; the domain slug and PRD key are the only caller-supplied path segments, validated (lower-kebab, not \"main\") before any join. All writes are atomic + owner-only (files 0600, dirs 0700). The persona is the host workspace SOUL.md, not a sil artefact)"
|
|
65
67
|
],
|
|
66
68
|
"credentialsOnDisk": [
|
|
67
69
|
"tokens.json (access + refresh token)",
|
package/package.json
CHANGED
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* consent gate; this bin executes an already-assembled, already-endorsed spec
|
|
14
14
|
* non-interactively. It never prompts, never re-runs the interview.
|
|
15
15
|
*
|
|
16
|
-
* Input — ONE JSON object `{ agentId, name, workspace, persona, userSpec }`,
|
|
17
|
-
* from stdin (primary) or `--spec <path>` (fallback). Passing multiline
|
|
16
|
+
* Input — ONE JSON object `{ agentId, name, workspace, persona, userSpec, channel? }`,
|
|
17
|
+
* read from stdin (primary) or `--spec <path>` (fallback). Passing multiline
|
|
18
18
|
* persona/userSpec as JSON dodges shell-arg escaping. Unparseable/blank input →
|
|
19
|
-
* `invalid_request`, nothing attempted.
|
|
19
|
+
* `invalid_request`, nothing attempted. `channel` is OPTIONAL — the current-channel
|
|
20
|
+
* override for the step-10 bind; absent/blank is fail-open, never invalid_request.
|
|
20
21
|
*
|
|
21
22
|
* Choreography (validate-first, then atomic, fail-closed):
|
|
22
23
|
* 1. validate the spec — bad/blank field ⇒ invalid_request, nothing attempted
|
|
@@ -27,13 +28,19 @@
|
|
|
27
28
|
* 4. snapshot openclaw.json — the whole-file teardown anchor, taken BEFORE step 5
|
|
28
29
|
* 5. openclaw agents add — create the real agents.list entry + workspace bootstrap
|
|
29
30
|
* 6. write <workspace>/SOUL.md — the persona (atomic tmp→rename); never a sil artefact
|
|
30
|
-
* 7. materializeProfile — REUSED; { name, userSpec }
|
|
31
|
-
*
|
|
31
|
+
* 7. materializeProfile — REUSED; SETUP-ONLY { name, userSpec } ⇒ shared
|
|
32
|
+
* user_spec.md (its frontmatter carries the name);
|
|
33
|
+
* NO manifest, no domain minted at create
|
|
32
34
|
* 8. attach the sil skill + enable the sil plugin (openclaw config set --strict-json)
|
|
33
35
|
* 9. sil-openclaw-allowlist — REUSED whole; additive/idempotent/atomic three-surface
|
|
34
36
|
* trust merge (plugins.allow + tools.alsoAllow + plugins.entries.sil)
|
|
35
|
-
* 10.
|
|
36
|
-
*
|
|
37
|
+
* 10. bind the current channel — FAIL-OPEN convenience, NOT fail-closed: resolve the channel
|
|
38
|
+
* (spec.channel > OPENCLAW_MCP_MESSAGE_CHANNEL), bind + VERIFY
|
|
39
|
+
* from the JSON verdict (never the exit code), keep a verified
|
|
40
|
+
* route, revert an unverifiable one; an undetermined/unverifiable
|
|
41
|
+
* channel degrades to a manual-bind hint — it NEVER fails creation
|
|
42
|
+
* 11. openclaw config validate — success keys off `.valid`, never an `ok` field
|
|
43
|
+
* 12. one { status, … } JSON result; exit 0 ONLY on `created`.
|
|
37
44
|
*
|
|
38
45
|
* Teardown on ANY failure after step 5 = whole-file snapshot-restore of
|
|
39
46
|
* openclaw.json (reverses the agents.list entry + skill + plugin + trust in ONE
|
|
@@ -45,6 +52,12 @@
|
|
|
45
52
|
* LOUDER outcome (`teardown_failed`) that names the residue — never a green-washed
|
|
46
53
|
* `persistence_failed`.
|
|
47
54
|
*
|
|
55
|
+
* The step-10 channel bind is the ONE step that never routes into teardown: it is
|
|
56
|
+
* fail-open by design (a convenience, not a precondition), so it self-reverts a bad
|
|
57
|
+
* bind in place and continues. Because a VERIFIED route lives in openclaw.json, the
|
|
58
|
+
* step-4 snapshot restore reverses it FOR FREE if any earlier-or-later step then
|
|
59
|
+
* fails — no `agents unbind`, no bind-specific teardown code.
|
|
60
|
+
*
|
|
48
61
|
* Outcome taxonomy (four terminal, + the louder teardown_failed), in sil's
|
|
49
62
|
* `snake_case_marker` NDJSON style (no api.logger outside the gateway). No PII, no
|
|
50
63
|
* secrets — the persona/userSpec text is NEVER logged:
|
|
@@ -63,19 +76,23 @@
|
|
|
63
76
|
import { execFileSync } from "node:child_process";
|
|
64
77
|
import { existsSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
65
78
|
import { homedir } from "node:os";
|
|
66
|
-
import { dirname, join, resolve } from "node:path";
|
|
79
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
67
80
|
import { randomBytes } from "node:crypto";
|
|
68
81
|
import { fileURLToPath } from "node:url";
|
|
69
82
|
|
|
70
83
|
import {
|
|
71
84
|
materializeProfile,
|
|
72
|
-
|
|
85
|
+
readShopperIdentity,
|
|
73
86
|
getShopperArtefactDir,
|
|
74
87
|
} from "../dist/lib/profile-store.js";
|
|
88
|
+
import { resolveBindChannel } from "../dist/lib/bind-channel.js";
|
|
75
89
|
|
|
76
90
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
77
91
|
/** The sibling operator bin that performs the additive, self-validating trust merge. */
|
|
78
92
|
const ALLOWLIST_BIN = resolve(ROOT, "scripts", "allowlist-openclaw.mjs");
|
|
93
|
+
/** The shipped plugin manifest — the single source of truth for sil's facts (id,
|
|
94
|
+
* skill name), read the same way `scripts/allowlist-openclaw.mjs` reads it. */
|
|
95
|
+
const MANIFEST_PATH = resolve(ROOT, "openclaw.plugin.json");
|
|
79
96
|
|
|
80
97
|
/** A shopper id path-segment shape — lower-kebab, never `main` (host-reserved). */
|
|
81
98
|
const AGENT_ID_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
@@ -161,12 +178,15 @@ function readSpecRaw() {
|
|
|
161
178
|
|
|
162
179
|
/** Validate the endorsed spec — deterministic field order (agentId → name →
|
|
163
180
|
* workspace → persona → userSpec). Returns `{ field, message }` on the FIRST bad
|
|
164
|
-
* field, or null when the whole spec is good. Writes/attempts nothing.
|
|
181
|
+
* field, or null when the whole spec is good. Writes/attempts nothing. `channel`
|
|
182
|
+
* is deliberately NOT validated: it is an optional fail-open convenience, so an
|
|
183
|
+
* absent/blank/malformed channel is never invalid_request — it folds to `null` in
|
|
184
|
+
* `resolveBindChannel` and degrades to a manual-bind hint at step 10. */
|
|
165
185
|
function validateSpec(spec) {
|
|
166
186
|
if (typeof spec !== "object" || spec === null || Array.isArray(spec)) {
|
|
167
187
|
return {
|
|
168
188
|
field: "spec",
|
|
169
|
-
message: "spec must be a JSON object with { agentId, name, workspace, persona, userSpec }.",
|
|
189
|
+
message: "spec must be a JSON object with { agentId, name, workspace, persona, userSpec, channel? }.",
|
|
170
190
|
};
|
|
171
191
|
}
|
|
172
192
|
if (!nonBlank(spec.agentId)) {
|
|
@@ -225,6 +245,32 @@ function readConfig(configPath) {
|
|
|
225
245
|
}
|
|
226
246
|
}
|
|
227
247
|
|
|
248
|
+
/** Resolve the sil SKILL's published name to attach at `agents.list[i].skills`,
|
|
249
|
+
* single-sourced from the shipped manifest (mirrors `allowlist-openclaw.mjs`'s
|
|
250
|
+
* `readSilFacts`). A skill attaches by its PUBLISHED name = the skill-dir basename
|
|
251
|
+
* = `basename(openclaw.plugin.json#skills[0])` (`sil-shopping`) — NOT the plugin id
|
|
252
|
+
* (`sil`), which is the tools/trust key. The per-agent attach is the ONLY skill
|
|
253
|
+
* surface (no global skill allow-list), so the plugin id here loads no skill at
|
|
254
|
+
* all. Fail-closed: an unreadable manifest or a blank/absent `skills[0]` returns
|
|
255
|
+
* `{ error }` so the create errors rather than attaching `[""]`. */
|
|
256
|
+
function readSkillAttachName() {
|
|
257
|
+
let manifest;
|
|
258
|
+
try {
|
|
259
|
+
manifest = JSON.parse(readFileSync(MANIFEST_PATH, "utf8"));
|
|
260
|
+
} catch (err) {
|
|
261
|
+
return { error: "the shipped manifest " + MANIFEST_PATH + " is not readable/parseable JSON: " + errCause(err) };
|
|
262
|
+
}
|
|
263
|
+
const ref = Array.isArray(manifest.skills) ? manifest.skills[0] : undefined;
|
|
264
|
+
if (!nonBlank(ref)) {
|
|
265
|
+
return { error: "the shipped manifest " + MANIFEST_PATH + " declares no skills[0] — cannot resolve the sil skill name to attach" };
|
|
266
|
+
}
|
|
267
|
+
const name = basename(ref);
|
|
268
|
+
if (!nonBlank(name)) {
|
|
269
|
+
return { error: "the shipped manifest skills[0] " + JSON.stringify(ref) + " has no usable basename" };
|
|
270
|
+
}
|
|
271
|
+
return { name };
|
|
272
|
+
}
|
|
273
|
+
|
|
228
274
|
/** The agentId path-segment ids already registered in the host config's
|
|
229
275
|
* `agents.list` — the authoritative, shim-independent clash source. */
|
|
230
276
|
function existingAgentIds(config) {
|
|
@@ -256,6 +302,64 @@ function webCapabilityWarnings(config) {
|
|
|
256
302
|
];
|
|
257
303
|
}
|
|
258
304
|
|
|
305
|
+
/** True iff `openclaw config validate --json` reported `{valid:true}`. The host
|
|
306
|
+
* writes its verdict to stdout even on a non-zero exit, so read stdout, never the
|
|
307
|
+
* exit code (fail closed if it is not JSON). */
|
|
308
|
+
function configValidates(stdout) {
|
|
309
|
+
try {
|
|
310
|
+
const verdict = JSON.parse(stdout);
|
|
311
|
+
return verdict !== null && verdict.valid === true;
|
|
312
|
+
} catch {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** True iff `openclaw agents bind --json` reported the channel APPLIED — landed in
|
|
318
|
+
* `added` or `updated`, with an EMPTY `conflicts`. `agents bind` exits 0 even on a
|
|
319
|
+
* conflict or an empty `--bind`, so the JSON verdict — never the exit code — is the
|
|
320
|
+
* source of truth (the same discipline the bin applies to `config validate.valid`). */
|
|
321
|
+
function bindApplied(stdout) {
|
|
322
|
+
let v;
|
|
323
|
+
try {
|
|
324
|
+
v = JSON.parse(stdout);
|
|
325
|
+
} catch {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
if (v === null || typeof v !== "object") return false;
|
|
329
|
+
const added = Array.isArray(v.added) ? v.added : [];
|
|
330
|
+
const updated = Array.isArray(v.updated) ? v.updated : [];
|
|
331
|
+
const conflicts = Array.isArray(v.conflicts) ? v.conflicts : [];
|
|
332
|
+
return (added.length > 0 || updated.length > 0) && conflicts.length === 0;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** True iff the `openclaw agents bindings --json` read-back (an ARRAY of
|
|
336
|
+
* `{agentId, match:{channel}}`) actually shows the route `<channel> → <agentId>`.
|
|
337
|
+
* This is the honesty rail: a bind is only "verified" once the read-back proves the
|
|
338
|
+
* write stuck — issuing the write is not the same as the next message reaching it. */
|
|
339
|
+
function bindingPresent(stdout, agentId, channel) {
|
|
340
|
+
let v;
|
|
341
|
+
try {
|
|
342
|
+
v = JSON.parse(stdout);
|
|
343
|
+
} catch {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
if (!Array.isArray(v)) return false;
|
|
347
|
+
return v.some((b) => b?.agentId === agentId && b?.match?.channel === channel);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** The fail-open manual-bind hint appended to `created` warnings when the channel
|
|
351
|
+
* could not be auto-routed (undetermined) or the bind could not be verified. It
|
|
352
|
+
* states the shopper WAS created, names the one-command manual bind, and never
|
|
353
|
+
* implies a broken create — a convenience that didn't fire, not an error. */
|
|
354
|
+
function manualBindHint(agentId, channel) {
|
|
355
|
+
const target = channel ? `the "${channel}" channel` : "the current channel";
|
|
356
|
+
return (
|
|
357
|
+
`the shopper "${agentId}" was created but ${target} was not auto-routed to it. `
|
|
358
|
+
+ `To route it manually, run: openclaw agents bind --agent ${agentId} --bind <channel> `
|
|
359
|
+
+ `(or switch in-chat with /agent ${agentId}). The shopper is fully created and ready.`
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
|
|
259
363
|
/**
|
|
260
364
|
* Whole-file snapshot-restore teardown. Reverses everything this run created and
|
|
261
365
|
* returns the residue it could NOT revert (empty ⇒ clean, host at exact pre-run
|
|
@@ -295,14 +399,12 @@ function teardown({ configPath, snapshot, mode, bakPreexisted, workspace, worksp
|
|
|
295
399
|
// 3. Remove the singleton shopper dir ONLY if it did not pre-exist (the singleton
|
|
296
400
|
// pre-flight guarantees it was ours this run).
|
|
297
401
|
// KNOWN GAP (narrow): this keys on WHOLE-DIR pre-existence, not on the leaf we
|
|
298
|
-
// wrote
|
|
299
|
-
// (profile-store.ts). If `shopper/` pre-existed but EMPTY (no profile.json), the
|
|
402
|
+
// wrote. If `shopper/` pre-existed but held no readable user_spec.md, the
|
|
300
403
|
// singleton read passes ("no shopper") yet `shopperDirPreexisted` is true, so a
|
|
301
|
-
// post-materialize failure leaves THIS run's
|
|
302
|
-
//
|
|
303
|
-
//
|
|
304
|
-
//
|
|
305
|
-
// this removal on "we wrote profile.json this run", mirroring `!leafPreexisted`.
|
|
404
|
+
// post-materialize failure leaves THIS run's user_spec.md un-removed and does NOT
|
|
405
|
+
// surface as residue → `teardown_failed`. Extremely narrow (normal operation
|
|
406
|
+
// never leaves an empty `shopper/`). To close it, key this removal on "we wrote
|
|
407
|
+
// user_spec.md this run".
|
|
306
408
|
if (!shopperDirPreexisted) {
|
|
307
409
|
const shopperDir = getShopperArtefactDir();
|
|
308
410
|
try {
|
|
@@ -334,7 +436,7 @@ function main() {
|
|
|
334
436
|
if (bad) {
|
|
335
437
|
emitFailure("invalid_request", { field: bad.field, cause: bad.message });
|
|
336
438
|
}
|
|
337
|
-
const { agentId, name, workspace, persona, userSpec } = spec;
|
|
439
|
+
const { agentId, name, workspace, persona, userSpec, channel } = spec;
|
|
338
440
|
|
|
339
441
|
// --- 2. Resolve the host config (precondition — nothing written yet) ---
|
|
340
442
|
const configPath = resolveConfigPath();
|
|
@@ -354,15 +456,19 @@ function main() {
|
|
|
354
456
|
});
|
|
355
457
|
}
|
|
356
458
|
|
|
357
|
-
// ---
|
|
358
|
-
//
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
cause: "could not read the sil shopper store to check the singleton — failing closed rather than risk a second shopper",
|
|
364
|
-
});
|
|
459
|
+
// --- 2b. Resolve the sil skill's published name to attach (shipped manifest is the
|
|
460
|
+
// single source of truth) — a packaging defect fails closed BEFORE any host
|
|
461
|
+
// write, so nothing is attempted. Reused at step 8. ---
|
|
462
|
+
const skill = readSkillAttachName();
|
|
463
|
+
if (skill.error) {
|
|
464
|
+
emitFailure("persistence_failed", { path: MANIFEST_PATH, cause: skill.error });
|
|
365
465
|
}
|
|
466
|
+
const skillAttachName = skill.name;
|
|
467
|
+
|
|
468
|
+
// --- 3. Singleton + agentId pre-flight (nothing written; inconclusive → fail closed) ---
|
|
469
|
+
// The sil artefact store is the source of truth for "a shopper exists": user_spec.md
|
|
470
|
+
// present + its frontmatter `name` reads (frontmatter-as-truth, no manifest).
|
|
471
|
+
const overview = readShopperIdentity();
|
|
366
472
|
if (Array.isArray(overview.unreadable) && overview.unreadable.length > 0) {
|
|
367
473
|
// A degraded store is INCONCLUSIVE — never fabricate a "no shopper" verdict.
|
|
368
474
|
emitFailure("persistence_failed", {
|
|
@@ -455,8 +561,11 @@ function main() {
|
|
|
455
561
|
if (idx < 0) {
|
|
456
562
|
failAndTeardown(configPath, "the created agent " + JSON.stringify(agentId) + " is not in agents.list after `openclaw agents add`");
|
|
457
563
|
}
|
|
564
|
+
// Attach the skill by its PUBLISHED name (`sil-shopping`), NOT the plugin id
|
|
565
|
+
// (`sil`) — a skill and the plugin are two distinct host keys, and the per-agent
|
|
566
|
+
// attach is the only skill surface, so the plugin id here would load no skill.
|
|
458
567
|
const skillRes = runOpenclaw(
|
|
459
|
-
["config", "set", `agents.list[${idx}].skills`,
|
|
568
|
+
["config", "set", `agents.list[${idx}].skills`, JSON.stringify([skillAttachName]), "--strict-json"],
|
|
460
569
|
configPath,
|
|
461
570
|
);
|
|
462
571
|
if (!skillRes.ok) {
|
|
@@ -490,7 +599,54 @@ function main() {
|
|
|
490
599
|
failAndTeardown(configPath, "the sil-openclaw-allowlist admission helper failed: " + allowlistCause);
|
|
491
600
|
}
|
|
492
601
|
|
|
493
|
-
// --- 10.
|
|
602
|
+
// --- 10. Bind the current channel to the new shopper (FAIL-OPEN convenience) ---
|
|
603
|
+
// Route the channel the user is talking on to the new shopper by default, so their
|
|
604
|
+
// next message reaches it with no manual bind. This step NEVER fails creation: an
|
|
605
|
+
// undetermined channel, a conflict (already owned by another agent — no auto-steal),
|
|
606
|
+
// or an unverifiable bind all degrade to a manual-bind hint. The bind lands in
|
|
607
|
+
// openclaw.json `bindings[]`, so a VERIFIED route is reversed for free by the
|
|
608
|
+
// step-4 snapshot if a later step tears the whole create down.
|
|
609
|
+
const bindWarnings = [];
|
|
610
|
+
// The channel the route was VERIFIED-bound to (null ⇒ nothing bound). It rides in
|
|
611
|
+
// `created` as the honesty rail: a bound channel is named ONLY when the read-back +
|
|
612
|
+
// config validate confirm it — issuing the write is never enough.
|
|
613
|
+
let boundChannel = null;
|
|
614
|
+
const channelToBind = resolveBindChannel({
|
|
615
|
+
specChannel: channel,
|
|
616
|
+
envChannel: process.env["OPENCLAW_MCP_MESSAGE_CHANNEL"],
|
|
617
|
+
});
|
|
618
|
+
if (channelToBind === null) {
|
|
619
|
+
bindWarnings.push(manualBindHint(agentId, null));
|
|
620
|
+
} else {
|
|
621
|
+
// Snapshot BEFORE the bind so an unverifiable write reverts to a valid config —
|
|
622
|
+
// never falling through to the fail-closed step-11 validate (which would tear
|
|
623
|
+
// down a fully-created shopper over a convenience shortfall).
|
|
624
|
+
const bindSnapshot = readFileSync(configPath, "utf8");
|
|
625
|
+
const bindRes = runOpenclaw(["agents", "bind", "--agent", agentId, "--bind", channelToBind, "--json"], configPath);
|
|
626
|
+
const readBack = runOpenclaw(["agents", "bindings", "--agent", agentId, "--json"], configPath);
|
|
627
|
+
const bindValidateRes = runOpenclaw(["config", "validate", "--json"], configPath);
|
|
628
|
+
const verified =
|
|
629
|
+
bindRes.ok
|
|
630
|
+
&& bindApplied(bindRes.stdout)
|
|
631
|
+
&& readBack.ok
|
|
632
|
+
&& bindingPresent(readBack.stdout, agentId, channelToBind)
|
|
633
|
+
&& configValidates(bindValidateRes.stdout);
|
|
634
|
+
if (verified) {
|
|
635
|
+
boundChannel = channelToBind;
|
|
636
|
+
} else {
|
|
637
|
+
// Revert JUST the route (config back to its pre-bind valid state) and degrade
|
|
638
|
+
// to the manual-bind hint. A failed revert is still fail-open: a well-formed
|
|
639
|
+
// bind is validation-safe, so step 11 certifies the config either way.
|
|
640
|
+
try {
|
|
641
|
+
atomicWrite(configPath, bindSnapshot, mode);
|
|
642
|
+
} catch {
|
|
643
|
+
// best-effort — never escalate a convenience revert into a torn-down create
|
|
644
|
+
}
|
|
645
|
+
bindWarnings.push(manualBindHint(agentId, channelToBind));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// --- 11. Validate with the host's OWN check — success keys off `.valid` ---
|
|
494
650
|
// The shim/host writes its structured verdict to stdout even on a non-zero exit,
|
|
495
651
|
// so read stdout regardless of the exit code (fail closed if it is not JSON).
|
|
496
652
|
const validateRes = runOpenclaw(["config", "validate", "--json"], configPath);
|
|
@@ -508,9 +664,9 @@ function main() {
|
|
|
508
664
|
failAndTeardown(configPath, issues ? cause + " — issues: " + issues : cause);
|
|
509
665
|
}
|
|
510
666
|
|
|
511
|
-
// ---
|
|
512
|
-
const warnings = webCapabilityWarnings(readConfig(configPath) ?? postAddConfig);
|
|
513
|
-
emitCreated({ name, agentId, workspace, warnings });
|
|
667
|
+
// --- 12. Declare created — carry the identity + the bound channel (honesty rail) ---
|
|
668
|
+
const warnings = [...webCapabilityWarnings(readConfig(configPath) ?? postAddConfig), ...bindWarnings];
|
|
669
|
+
emitCreated({ name, agentId, workspace, boundChannel, warnings });
|
|
514
670
|
}
|
|
515
671
|
|
|
516
672
|
main();
|
package/sil-shopping/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sil-shopping
|
|
3
|
-
description:
|
|
3
|
+
description: 'Use for any sil shopping, identity, or shopper-setup intent: register or sign in, check the account, search the sil catalog for purchasable products, or look up products by id — plus the single-shopper lifecycle: create the shopper (a short two-touchpoint onboarding), search what it knows or which domains (niches) it has learned, view or forget a domain or one of its PRDs, refine it — or, as the shopper, run the six-beat Spec-Driven Shopping loop on any niche and learn a fact or buying taste it surfaces. Drives sil_register, sil_whoami, sil_search, sil_product_get, sil_specs, sil_profile_materialize, sil_profile_search, sil_profile_get, sil_profile_remove, and sil_learn.'
|
|
4
4
|
metadata:
|
|
5
5
|
openclaw:
|
|
6
6
|
emoji: "\U0001F6D2"
|
|
@@ -8,68 +8,99 @@ metadata:
|
|
|
8
8
|
|
|
9
9
|
# sil-shopping
|
|
10
10
|
|
|
11
|
-
Drive the sil plugin's tools on the user's behalf: register them
|
|
11
|
+
Drive the sil plugin's tools on the user's behalf: register them, read their
|
|
12
|
+
identity, help them find purchasable products — and, when asked, set up their
|
|
13
|
+
**shopper** (one sil-wired agent that shops every niche), then search what it
|
|
14
|
+
knows, view or forget a domain, or refine it. Read intent, route to the matching
|
|
15
|
+
tool or reference (loading it on demand), call it, and report what came back.
|
|
12
16
|
|
|
13
|
-
## Always-on
|
|
17
|
+
## Always-on contract
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- **
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
- **Act, don't narrate.** When intent maps to a tool, call it — don't re-confirm
|
|
20
|
+
what was already stated.
|
|
21
|
+
- **Follow the tool's own `recovery`.** Every tool returns a `status`; on a
|
|
22
|
+
non-`ok` one, say what happened and follow that tool's `recovery` hint, never
|
|
23
|
+
improvise another. The taxonomy lives in
|
|
24
|
+
[`references/catalog_tools_reference.md`](references/catalog_tools_reference.md).
|
|
25
|
+
- **Prices are point-in-time.** Before the user buys, re-fetch the item with
|
|
26
|
+
`sil_product_get` rather than trusting an earlier `sil_search` snapshot.
|
|
20
27
|
|
|
21
28
|
## Session start
|
|
22
29
|
|
|
23
|
-
Confirm the `sil_*` tools are exposed. If they are missing
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- **Empty store (no shopper yet):** introduce the shopper in one short beat and offer to set it up. Name the value in its own terms — it shops each niche in depth, reuses the sizes and hard limits it already knows so nothing is re-asked, and explains why each pick fits — a standing buyer's advisor, not a one-off search. Only on a yes, load [`references/brainstorm_interview.md`](references/brainstorm_interview.md) (a two-touchpoint onboarding, never a form). Take no for an answer: bare `sil_search` stays a first-class path, so don't re-offer in the same turn.
|
|
30
|
-
- **A shopper already exists:** skip this beat entirely. The shopper is a singleton — never offer a second one.
|
|
30
|
+
Confirm the `sil_*` tools are exposed. If they are missing, the host is filtering
|
|
31
|
+
them — run the shipped admission helper `sil-openclaw-allowlist` (it additively
|
|
32
|
+
admits sil at `plugins.allow` + `tools.alsoAllow`), then reopen the session. Most
|
|
33
|
+
flows need an identity: calling a catalog tool first lets an unregistered outcome
|
|
34
|
+
route to `sil_register`, or run `sil_register` up front when intent requires it.
|
|
31
35
|
|
|
32
|
-
##
|
|
36
|
+
## Routing — read the stage, then match intent to a tool
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
**Read the stage from state — never guess it.** Two cheap reads settle it:
|
|
39
|
+
`sil_whoami` (is a sil identity **registered** yet?) and `sil_profile_search` (is
|
|
40
|
+
a shopper set up — does it return any `domains`?).
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
- **No identity** ⇒ guide the user to register.
|
|
43
|
+
- **No shopper / no domains** ⇒ bare shopping is a first-class quick lookup; the
|
|
44
|
+
setup path is offered alongside it.
|
|
45
|
+
- **Shopper present** ⇒ shop through what you know about the person via the loop.
|
|
37
46
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
[`references/setup_onboarding.md`](references/setup_onboarding.md) owns the setup
|
|
48
|
+
script — the staged ladder, the after-register offer, the per-search pitch. Load
|
|
49
|
+
it while setup is incomplete; it sheds once a shopper exists.
|
|
41
50
|
|
|
42
|
-
|
|
51
|
+
### Intent → tool / reference (load on demand)
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
| Intent | Tool | Reference to load |
|
|
53
|
+
| Intent | Tool / path | Reference |
|
|
47
54
|
|---|---|---|
|
|
48
|
-
| "sign me up" / "log me in
|
|
49
|
-
| "who am I?" /
|
|
50
|
-
| "find X" / "search for X" / browse a category or price range | `sil_search` | [`
|
|
51
|
-
| "look up these items" / re-check ids from a prior result
|
|
52
|
-
| "set up an agent that shops for me" / "create my shopper" | (onboarding, then the engine) |
|
|
53
|
-
| "what does my shopper know?" / "which domains
|
|
54
|
-
| "show me the
|
|
55
|
-
| "forget
|
|
56
|
-
| (as the shopper) a shopping intent
|
|
57
|
-
| "remember this" — a fact or
|
|
58
|
-
| "refine / sharpen my shopper" /
|
|
59
|
-
|
|
60
|
-
[`references/catalog_tools_reference.md`](references/catalog_tools_reference.md)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
| "sign me up" / "log me in" / "register" | `sil_register` | [`catalog_tools_reference.md`](references/catalog_tools_reference.md) |
|
|
56
|
+
| "who am I?" / show my saved name + addresses | `sil_whoami` | [`catalog_tools_reference.md`](references/catalog_tools_reference.md) |
|
|
57
|
+
| "find X" / "search for X" / browse a category or price range | `sil_search` | [`catalog_tools_reference.md`](references/catalog_tools_reference.md) |
|
|
58
|
+
| "look up these items" / re-check ids from a prior result | `sil_product_get` | [`catalog_tools_reference.md`](references/catalog_tools_reference.md) |
|
|
59
|
+
| "set up an agent that shops for me" / "create my shopper" | (onboarding, then the engine) | the two-step below |
|
|
60
|
+
| "what does my shopper know?" / "which domains / PRDs?" | `sil_profile_search` | [`method_and_prds.md`](references/method_and_prds.md) |
|
|
61
|
+
| "show me the <niche> domain" (method or one PRD) | `sil_profile_get` | [`method_and_prds.md`](references/method_and_prds.md) |
|
|
62
|
+
| "forget the <niche> domain" (or one PRD) | `sil_profile_remove` | [`method_and_prds.md`](references/method_and_prds.md) |
|
|
63
|
+
| (as the shopper) a shopping intent on any niche | the six-beat loop | [`shop_loop.md`](references/shop_loop.md) |
|
|
64
|
+
| "learn / remember this" — a fact or taste the shopper surfaced | `sil_learn` | [`fill_and_feedback.md`](references/fill_and_feedback.md) |
|
|
65
|
+
| "refine / sharpen my shopper" / fix a niche | `sil_learn` (target + change) | [`fill_and_feedback.md`](references/fill_and_feedback.md) |
|
|
66
|
+
|
|
67
|
+
[`references/catalog_tools_reference.md`](references/catalog_tools_reference.md)
|
|
68
|
+
holds the per-tool behaviour + status taxonomy — basic shopping needs only that.
|
|
69
|
+
The answer→`sil_search`-param mapping is
|
|
70
|
+
[`references/search_param_mapping.md`](references/search_param_mapping.md); a full
|
|
71
|
+
run is
|
|
72
|
+
[`examples/multi_domain_shopper_walkthrough.md`](examples/multi_domain_shopper_walkthrough.md).
|
|
73
|
+
|
|
74
|
+
**Setting up the shopper — the endorsement-gated two-step.** The shopper is a
|
|
75
|
+
singleton (refused once one exists). (1) **Onboard first:** run
|
|
76
|
+
[`references/brainstorm_interview.md`](references/brainstorm_interview.md), the
|
|
77
|
+
two-touchpoint onboarding. (2) **Only after** the user explicitly **endorses** the
|
|
78
|
+
assembled draft, run
|
|
79
|
+
[`references/agent_creation_engine.md`](references/agent_creation_engine.md), the
|
|
80
|
+
engine that persists the one sil-wired shopper. No engine step runs before that
|
|
81
|
+
endorsement.
|
|
82
|
+
|
|
83
|
+
## As the shopper — the six-beat Spec-Driven-Shopping loop
|
|
84
|
+
|
|
85
|
+
Once a shopper exists, shop through what you know about the person. The loop is a
|
|
86
|
+
**six-beat** state machine — **classify → method → fill → search-space → reflect →
|
|
87
|
+
feedback** — and its detail lives in the references that own each beat, loaded on
|
|
88
|
+
demand:
|
|
89
|
+
|
|
90
|
+
1. **Classify** the request's `{domain, product, intent}` and reuse a learned
|
|
91
|
+
domain/PRD before minting — [`references/shop_loop.md`](references/shop_loop.md).
|
|
92
|
+
2. **Method** load (hot path) or research-and-mint, then intent-keyed PRDs and the
|
|
93
|
+
frontmatter-as-truth store — [`references/method_and_prds.md`](references/method_and_prds.md).
|
|
94
|
+
3. **Fill** the PRD by precedence, eliciting only the residue —
|
|
95
|
+
[`references/fill_and_feedback.md`](references/fill_and_feedback.md).
|
|
96
|
+
4. **Search-space** — the bounded fan-out —
|
|
97
|
+
[`references/shop_loop.md`](references/shop_loop.md).
|
|
98
|
+
5. **Reflect** on best-available vs the PRD —
|
|
99
|
+
[`references/shop_loop.md`](references/shop_loop.md).
|
|
100
|
+
6. **Feedback** — capture what surfaced via `sil_learn` —
|
|
101
|
+
[`references/fill_and_feedback.md`](references/fill_and_feedback.md).
|
|
102
|
+
|
|
103
|
+
The loop shapes the shopper's **reasoning, not the user's inbox**: a reused domain
|
|
104
|
+
plus a fully-resolved request **passes straight through, asking nothing**. It
|
|
105
|
+
scopes to `sil_search`-driven discovery — identity, a direct `sil_product_get`
|
|
106
|
+
re-check, and shopper-management route normally, ungated.
|