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.
@@ -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.3.8",
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. sil_profile_materialize makes no network call and reads no token: it writes the one sil shopper's SINGLETON behaviour artefacts under a fixed $SIL_DATA_DIR/shopper/ (owner-only, 0600) — a SHARED user_spec.md + profile.json manifest, plus per-domain packs (domain_spec.md + intent_spec.md + playbook.md) minted LAZILY under shopper/domains/<slug>/ on first shop in a niche. The shopper segment is a compile-time constant (NOT caller input — no agentId); the only caller-supplied path segment is the domain slug, validated (lower-kebab, not \"main\") before any join. Each artefact is written atomically (tmp file → rename over target). Failure guarantee: a FRESH create that fails mid-write is torn down (no partial directory survives); a re-mint of an EXISTING domain is per-file atomic and dir-preserving (NOT a cross-file transaction) — on failure the prior pack is left intact and is never served half-refined (a missing body fails the read closed). 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. sil_profile_get / sil_profile_remove are the local domain lifecycle over the same artefact store, also making no network call and reading no token: get with no domainSlug reads the manifest overview read-only (the shared user_spec + the domains index, the folded listing — an empty store is healthy), get with a domainSlug reads that one domain's domain_spec/intent_spec/playbook bodies + the shared user_spec read-only, and remove deletes exactly one validated shopper/domains/<slug>/ leaf directory (fail-closed on a malformed/traversal/\"main\" or missing slug — deletes nothing, and never the whole shopper) — the host-wiring half of removal is the host CLI's, not this plugin's. sil_remember is the lightweight per-query memory verb over the same artefact store, also making no network call and reading no token: it appends ONE short typed entry (a fact to the shared user_spec.md, or a taste to the active domain's playbook.md) via a single O_APPEND write (flag \"a\", owner-only 0600), with NO whole-doc read or re-serialize and NO manifest rewrite. It is fail-closed: append never creates a file (an unknown shopper / unminted domain / missing body returns not_found), and validate-first rejects a blank text, a fact carrying a domain, a taste carrying hard:true, or a malformed/traversal taste domain slug (writing nothing). The remembered text is user content and is never logged. The PKCE verifier is held only in memory and is never written to disk. Tokens and identity PII are never logged.",
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/{user_spec.md,profile.json} + shopper/domains/<slug>/{domain_spec.md,intent_spec.md,playbook.md} (the ONE sil shopper's singleton SDS behaviour artefacts written by sil_profile_materialize: a SHARED user_spec.md + a profile.json manifest at create, plus per-domain packs minted LAZILY on first shop — the domain spec (domain_spec.md) + intent-spec dimension schema (intent_spec.md) + buying taste (playbook.md). The `shopper` segment is a fixed compile-time constant, not caller input; the domain slug is the only caller-supplied path segment, validated before any join. The persona is the host workspace SOUL.md, not a sil artefact)"
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sil-openclaw",
3
- "version": "0.3.8",
3
+ "version": "0.4.0",
4
4
  "description": "Turn your OpenClaw into an expert shopping agent.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -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 }`, read
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 }, NO domain ⇒ shared user_spec.md
31
- * + profile.json with an empty `domains: {}` map
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. openclaw config validate — success keys off `.valid`, never an `ok` field
36
- * 11. one { status, … } JSON result; exit 0 ONLY on `created`.
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
- readAgentProfile,
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 — it DIVERGES from `materializeProfile`'s `!leafPreexisted` discipline
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 profile.json/user_spec.md un-removed
302
- // and does NOT surface as residue → `teardown_failed`. Extremely narrow (normal
303
- // operation never leaves an empty `shopper/`; a materialize-STEP failure is
304
- // already covered by materializeProfile's own leaf teardown). To close it, key
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
- // --- 3. Singleton + agentId pre-flight (nothing written; inconclusive → fail closed) ---
358
- // The sil artefact store is the source of truth for "a shopper exists".
359
- const overview = readAgentProfile();
360
- if (!overview.ok) {
361
- emitFailure("persistence_failed", {
362
- path: getShopperArtefactDir(),
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`, '["sil"]', "--strict-json"],
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. Validate with the host's OWN check — success keys off `.valid` ---
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
- // --- 11. Declare created — carry the identity so the agent can open the shopper ---
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();
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sil-shopping
3
- description: This skill should be used whenever the user wants to shop on sil or set up their sil shopper: register or sign in to sil, check who they are, search the sil catalog for purchasable products, or look up specific products by id — and for the full single-shopper lifecycle: "set up an agent that shops for me" / "create my shopper" (a short two-touchpoint onboarding, then create ONE shopper), see what their shopper knows or which domains (niches) it has learned, view or forget a domain, refine the shopper or one domain — or, as the shopper, run a profile-driven Spec-Driven Shopping query on any niche (reusing a learned domain or minting one on the fly) and remember a fact or buying taste it surfaces. Route here for any shopping, identity, or shopper-setup intent on sil. Drives sil_register, sil_whoami, sil_search, sil_product_get, sil_profile_materialize, sil_profile_get, sil_profile_remove, and sil_remember.
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 on sil, read their identity, help them find purchasable products in the sil catalog — and, when asked, set up their **shopper** (one sil-wired agent that shops every niche), then see what it knows, view or forget a domain, or refine it. Read user intent, route to the matching tool (loading its reference on demand), call it, and report what came back.
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 behavioural contract
17
+ ## Always-on contract
14
18
 
15
- These three principles hold on every path, before any reference is loaded:
16
-
17
- - **Act, don't narrate.** When intent maps to a tool, call it. Don't re-confirm what was already stated.
18
- - **Fail visibly, recover correctly.** Every tool returns a `status`. On a non-`ok` status, say what happened and follow the tool's own `recovery` hint — never improvise a different one.
19
- - **Relay prices as point-in-time.** A product's price, availability, and `checkout_url` are a snapshot, not a guarantee. Before the user buys, re-fetch with `sil_product_get` rather than trusting an earlier `sil_search` result.
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 from the available tool list, the host runtime is filtering them out because sil is not admitted at the host allow surfaces — run the shipped admission helper `sil-openclaw-allowlist` (it additively admits sil at `plugins.allow` + `tools.alsoAllow`, leaving any other trusted plugin untouched), then reopen the session so the tools load. Most flows need an identity: if the user has not registered this session, the catalog tools return an unregistered status whose `recovery` points at `sil_register` (the [catalog tools reference](references/catalog_tools_reference.md) has the full taxonomy) — so calling a catalog tool first lets that outcome route, or run `sil_register` up front when the user's intent clearly requires it.
24
-
25
- ## After register — offer to set up the shopper (once, only when there's none)
26
-
27
- `sil_register` returns `already_registered` with `next_step: "offer_shopper"` on a confirmed registration (a fresh sign-in this session, or a returning session that was already signed in). That hint is a routing breadcrumb, not a decision — act on it by first running a no-arg `sil_profile_get` to read shopper state, then branch:
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
- ## After a bare search — name what a shopper would add (recurring, by design)
36
+ ## Routing — read the stage, then match intent to a tool
33
37
 
34
- When a plain `sil_search` completes with status `ok` in a profile-less session, present the results best-first exactly as they came back, then append **one** short trailing line — a post-result tip with a soft CTA — naming what a shopper would add on top. It is never a pre-search question and never a re-rank: bare search stays a legitimate quick lookup, and these are the same results a shopper would start from.
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
- Name one or two of the three levers a bare search leaves on the table, and rotate which you lead with so the recurring line stays fresh:
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
- - **niche depth** — a shopper weighs these against how the niche actually buys, instead of just listing them;
39
- - **memory** — it keeps your sizes and hard limits on file, so no search re-asks them;
40
- - **the why** — it explains which pick fits you and why, instead of a flat ranked list.
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
- This line recurs on **every** completed profile-less search: there is no fire-once or seen-it gate, and no cooldown — the recurrence is the point, and brevity plus lever rotation are all that keep it from nagging. Exactly two things suppress it, and only these two: a shopper already exists (that session is the shopper's — drop the line), or the search did not complete `ok` (a non-`ok` status carries its own recovery, so follow that and add no tip).
51
+ ### Intent → tool / reference (load on demand)
43
52
 
44
- ## Routing — match intent to a tool, load its reference on demand
45
-
46
- | Intent | Tool | Reference to load |
53
+ | Intent | Tool / path | Reference |
47
54
  |---|---|---|
48
- | "sign me up" / "log me in to sil" / "register" | `sil_register` | [`references/catalog_tools_reference.md`](references/catalog_tools_reference.md) |
49
- | "who am I?" / "what's on my account" / show my saved name + addresses | `sil_whoami` | [`references/catalog_tools_reference.md`](references/catalog_tools_reference.md) |
50
- | "find X" / "search for X" / browse a category or price range | `sil_search` | [`references/catalog_tools_reference.md`](references/catalog_tools_reference.md) |
51
- | "look up these items" / re-check ids from a prior result, a saved list, or a deep link | `sil_product_get` | [`references/catalog_tools_reference.md`](references/catalog_tools_reference.md) |
52
- | "set up an agent that shops for me" / "create my shopper" | (onboarding, then the engine) | see the two-step gate below |
53
- | "what does my shopper know?" / "which domains has it learned?" | `sil_profile_get` (no `domainSlug` — the shopper overview, which absorbs the old listing) | [`references/manage_domains.md`](references/manage_domains.md) |
54
- | "show me the shopper / the &lt;niche&gt; domain" | `sil_profile_get` (`domainSlug` for one domain) | [`references/manage_domains.md`](references/manage_domains.md) |
55
- | "forget / remove the &lt;niche&gt; domain" | `sil_profile_remove` (per-domain; whole-shopper teardown is host-CLI-first — see the reference) | [`references/manage_domains.md`](references/manage_domains.md) |
56
- | (as the shopper) a shopping intent — "find me something for X" on any niche | `sil_search` → `sil_product_get` (driven by the loaded profile, reusing or minting the domain) | [`references/shop_loop.md`](references/shop_loop.md) |
57
- | "remember this" — a fact or buying taste the shopper surfaced this query | `sil_remember` | [`references/shop_loop.md`](references/shop_loop.md) |
58
- | "refine / sharpen my shopper" / "the cycling domain keeps surfacing the wrong stuff — fix it" | (load → propose → confirm → persist — see the reference) | [`references/refine_shopper.md`](references/refine_shopper.md) |
59
-
60
- [`references/catalog_tools_reference.md`](references/catalog_tools_reference.md) holds the per-tool behaviour for the four core tools and the shared status taxonomy. Basic shopping needs only that one reference.
61
-
62
- When the session is running **as the shopper** (a loaded profile under `$SIL_DATA_DIR/shopper/` — the shared `user_spec` plus a slug-keyed `domains` map) and the user states a shopping intent, follow [`references/shop_loop.md`](references/shop_loop.md) — the profile-driven, **Spec-Driven Shopping (SDS)** shop-time loop that classifies the niche, **reuses a learned domain or mints one on the fly**, web-refreshes that domain's spec, decomposes the request along its intent spec, and learns every query — persisting each surfaced fact (→ the shared user spec) or taste (→ the active domain) with a single lightweight `sil_remember` append. **As the shopper, the domain-exists check is non-skippable on every query: classify the niche and reuse a learned domain or mint one first, before any `sil_search` — it is the shop loop's first beat, never skipped.** The one shopper shops every niche; a plain, profile-less session keeps shopping via the "find X" → `sil_search` row above, unchanged — Lane 1 stays bare, with no domain check and no pre-search questions.
63
-
64
- [`references/manage_domains.md`](references/manage_domains.md) holds the list / view / forget flow over the shopper's domains — including the **two remove granularities** (forget one domain vs decommission the whole shopper, host-CLI-first) and the confirm-before-remove gate. Load it the moment the user wants to see what the shopper knows or forget a niche.
65
-
66
- [`references/refine_shopper.md`](references/refine_shopper.md) holds the refinement loop — sharpening the shopper (the shared user spec or the persona) or **one domain** from observed sessions, with a confirm-before-persist gate (nothing changes silently). Load it when the user wants to refine, sharpen, or amend their shopper or a niche.
67
-
68
- ### Setting up your shopper — the endorsement-gated two-step
69
-
70
- When the user asks to set up / create their shopper (the singleton agent that shops every niche):
71
-
72
- 1. **Onboard first.** Read and run [`references/brainstorm_interview.md`](references/brainstorm_interview.md) — the short, two-touchpoint onboarding (persona + a shared user-spec seed) that converges a draft *with* the user. It researches **no** niche — the shopper is a generalist that mints domains lazily on first shop. While running it, load [`references/search_param_mapping.md`](references/search_param_mapping.md) only if you need the shop-time answer→`sil_search`-param mapping (it is a shop-time reference, not an onboarding one).
73
- 2. **Engine only after explicit endorsement.** Only after the user explicitly endorses the assembled draft, read and follow [`references/agent_creation_engine.md`](references/agent_creation_engine.md) — the ordered engine that persists the one sil-wired shopper. Running ANY engine step before that explicit endorsement is forbidden (the onboarding reference owns the endorsement gate). The shopper is a **singleton**: a second create attempt is refused ("a shopper already exists").
74
-
75
- Want a concrete walkthrough? [`examples/multi_domain_shopper_walkthrough.md`](examples/multi_domain_shopper_walkthrough.md) is an end-to-end worked example: create one shopper → shop two unrelated niches in one session (the second minted on the fly) → a shared fact reused across both → per-domain taste that does not leak.
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 &lt;niche&gt; domain" (method or one PRD) | `sil_profile_get` | [`method_and_prds.md`](references/method_and_prds.md) |
62
+ | "forget the &lt;niche&gt; 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.