sil-openclaw 0.3.0 → 0.3.3
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 +72 -0
- package/README.md +33 -37
- package/dist/lib/credentials.js +1 -1
- package/dist/lib/profile-store.js +126 -67
- package/dist/lib/sil-client.js +2 -2
- package/dist/tools/catalog.js +10 -8
- package/dist/tools/identity.js +3 -3
- package/dist/tools/profile.js +91 -55
- package/openclaw.plugin.json +3 -3
- package/package.json +1 -1
- package/skill/SKILL.md +1 -1
- package/skill/examples/road_cycling_expert_walkthrough.md +112 -68
- package/skill/references/agent_creation_engine.md +41 -30
- package/skill/references/brainstorm_interview.md +49 -40
- package/skill/references/catalog_tools_reference.md +1 -1
- package/skill/references/expert_shopping.md +51 -84
- package/skill/references/manage_experts.md +17 -75
- package/skill/references/refine_expert.md +11 -9
- package/skill/references/search_param_mapping.md +25 -5
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,78 @@ release (`clawhub package publish --changelog`). See [README](./README.md#releas
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.3.3] - 2026-06-25
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **Manifest security disclosure now matches the code's credential behaviour.**
|
|
18
|
+
`openclaw.plugin.json#security.packagingNote` claimed `sil_search` /
|
|
19
|
+
`sil_product_get` did "a single round-trip (a 401 is a terminal re-register
|
|
20
|
+
hint, no refresh)" with "no token write" — stale prose predating the uniform
|
|
21
|
+
401-refresh work. Corrected to state the real behaviour: catalog tools share
|
|
22
|
+
`sil_whoami`'s bounded 401 recovery (refresh once via sil-web, rotating
|
|
23
|
+
`tokens.json`, retry once; a second 401 or dead refresh clears `tokens.json`).
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- **Profile-rewrite failure guarantee stated precisely.** The manifest and
|
|
28
|
+
`profile-store.ts` header now describe the actual write contract instead of a
|
|
29
|
+
blanket "atomic / all-or-nothing": each artefact is written atomically, a fresh
|
|
30
|
+
create is torn down on failure, and a re-materialize over an existing expert is
|
|
31
|
+
per-file atomic and dir-preserving (not a cross-file transaction) — the prior
|
|
32
|
+
expert is left intact and never served half-refined.
|
|
33
|
+
- **Local-data disclosure added to the README.** A "what it remembers, and where
|
|
34
|
+
it lives" note: a created expert's learned facts/taste are stored locally
|
|
35
|
+
(`$SIL_DATA_DIR`, owner-only), per-user, never pooled or sent to a server, and
|
|
36
|
+
are inspectable with `sil_profile_get` and removable with `sil_profile_remove`.
|
|
37
|
+
- **Local-shop language tactic reframed as optional.** Guidance to issue the
|
|
38
|
+
`query` in a country's language (to surface local shops) is now explicitly an
|
|
39
|
+
optional tactic, never an override of a language the user deliberately chose —
|
|
40
|
+
in the README, the `sil_search` description, and `search_param_mapping.md`.
|
|
41
|
+
- **Refine trigger tightened.** `refine_expert.md` now starts a refinement only on
|
|
42
|
+
an explicit request to sharpen a named expert; an end-of-session prompt merely
|
|
43
|
+
offers and persists nothing without the existing confirm gate.
|
|
44
|
+
- **Disclosure wording reworded to clear automated-scanner false positives.** No
|
|
45
|
+
behaviour change — the shipped disclosure says exactly what it did before. In the
|
|
46
|
+
manifest, the tool descriptions, and the bundled skill/comments, "access token"
|
|
47
|
+
is now "session token", the path-traversal guards are described in prose instead
|
|
48
|
+
of `rm`/`rmSync`/`../` literals, and the no-web-access fallback says "compose from
|
|
49
|
+
well-established public knowledge" instead of "write from its own knowledge".
|
|
50
|
+
|
|
51
|
+
## [0.3.1] - 2026-06-24
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- **Spec-Driven Shopping (SDS) is the operating model for created experts.** A
|
|
56
|
+
created shopping expert now runs **entirely** on SDS — not coarse attribute
|
|
57
|
+
matching, and not an optional layer. The persona left the sil store: it is the
|
|
58
|
+
agent's host workspace **`SOUL.md`** (identity/voice), written by the engine via
|
|
59
|
+
the host CLI — there is **no `persona.md`**. The sil store holds **four SDS
|
|
60
|
+
behaviour artefacts**: two **required at creation** — **`domain_spec.md`** (deep
|
|
61
|
+
*researched* niche expertise — how to buy well, the full mechanics; the agent
|
|
62
|
+
researches it itself from web + knowledge, and **web-refreshes it on every
|
|
63
|
+
query**) and **`intent_spec.md`** (the agent-specific **decomposition dimensions**,
|
|
64
|
+
a PRD-style schema derived from the domain) — and **`user_spec.md`** (the user's
|
|
65
|
+
domain-relevant facts + **hard constraints**) and **`playbook.md`** (the user's
|
|
66
|
+
**buying taste** — price sensitivity, brand, preferences). **All four are required
|
|
67
|
+
and present from creation** — seeded *partial* by the light setup, then **augmented
|
|
68
|
+
every query** (we keep learning), never re-asked. The per-query **intent** (the
|
|
69
|
+
dimensions filled in for one request) is
|
|
70
|
+
**ephemeral** — only the dimension *schema* is persisted. The shop-time loop
|
|
71
|
+
web-refreshes the domain, decomposes the request, lazily captures the user side,
|
|
72
|
+
and layers **intent → playbook → user_spec → domain_spec** (a user-spec **hard
|
|
73
|
+
constraint is inviolable** — routed to a real `sil_search` filter *and* a
|
|
74
|
+
reject-at-pick rubric rule, never only soft `query` text), recommending with a
|
|
75
|
+
"why" that visibly cites the intent + a stored user fact + a domain mechanic.
|
|
76
|
+
Setup stays **light (≤10 questions)** — the depth comes from the agent's own
|
|
77
|
+
research. All four artefacts ride the existing **`sil_profile_materialize`** store
|
|
78
|
+
path (`domainSpec` + `intentSpec` + `userSpec` + `playbook` all required) with
|
|
79
|
+
**no new tool** (the 8-tool manifest is unchanged) and the same atomic,
|
|
80
|
+
validate-first, per-file-all-or-nothing discipline. Refinement can target the
|
|
81
|
+
domain spec, the intent-spec dimensions, a user-spec fact/hard-constraint, or the
|
|
82
|
+
buying taste as distinct refinable elements (a persona refinement refreshes
|
|
83
|
+
`SOUL.md` via the host CLI).
|
|
84
|
+
|
|
13
85
|
## [0.3.0] - 2026-06-23
|
|
14
86
|
|
|
15
87
|
### Added
|
package/README.md
CHANGED
|
@@ -6,13 +6,12 @@
|
|
|
6
6
|
███████║██║███████╗
|
|
7
7
|
╚══════╝╚═╝╚══════╝
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Shop like you code
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
**The shopping layer your agent runs for you.**
|
|
13
13
|
|
|
14
|
-
*
|
|
15
|
-
*No store. No tabs. No forms.*
|
|
14
|
+
*Introducing Spec Driven Shopping: the way Agents should be shopping.*
|
|
16
15
|
|
|
17
16
|
[](https://github.com/Context4GPTs/sil-openclaw/blob/main/LICENSE)
|
|
18
17
|
[](https://www.npmjs.com/package/sil-openclaw)
|
|
@@ -58,7 +57,7 @@ The agent loads the bundled skill on first commerce intent and takes it from the
|
|
|
58
57
|
|
|
59
58
|
sil is a [UCP](https://github.com/universal-commerce-protocol/ucp) (Universal Commerce Protocol) commerce service, and `sil-openclaw` wires it into your OpenClaw agent — so it can find products, compare prices and availability, pull up full detail, and surface a checkout link the moment you say *buy*. Powered by [4GPTs](https://4gpts.com).
|
|
60
59
|
|
|
61
|
-
Today the plugin covers **identity, catalog, and dedicated shopping experts
|
|
60
|
+
Today the plugin covers **identity, catalog, and dedicated shopping experts**. The rest of the UCP journey (cart, checkout, order, fulfillment) lands as those domains ship, and the same plugin grows with them.
|
|
62
61
|
|
|
63
62
|
---
|
|
64
63
|
|
|
@@ -96,27 +95,28 @@ agent done — here's your checkout link, ready to pay:
|
|
|
96
95
|
|
|
97
96
|
## Turn your OpenClaw into a shopping expert
|
|
98
97
|
|
|
99
|
-
So far your *general* agent did the shopping. Go one step further: mint a **dedicated** OpenClaw agent that shops a single niche like a specialist —
|
|
98
|
+
So far your *general* agent did the shopping. Go one step further: mint a **dedicated** OpenClaw agent that shops a single niche like a true specialist — it **researches how to buy well in that niche itself**, then fits *you* the way an expert would.
|
|
100
99
|
|
|
101
|
-
**
|
|
100
|
+
**Spec-Driven Shopping (SDS).** Say *"make me a shopping expert for road-cycling gear"* and the plugin runs a **light** interview (≤10 questions) to narrow the niche and shape the persona — then **researches the niche deeply on its own** (the full how-to-buy-well: fit, gearing, geometry, the trade-offs) and derives the **dimensions** every request should be decomposed along. Open it later and on **every query** it refreshes that knowledge from the web, decomposes what you asked, and **learns your facts and taste as it goes** (your measurements, your budget, the rules it must never break) — captured once, never re-asked. It recommends with a "why" that cites *what you asked*, *a fact it remembered*, and *a niche mechanic you'd never have named*. **Nothing is created until you say "create it"** — and building one is local and offline, no sign-in required.
|
|
102
101
|
|
|
103
|
-
**1 — One conversation builds the expert:**
|
|
102
|
+
**1 — One light conversation builds the expert (it does the deep research itself):**
|
|
104
103
|
|
|
105
104
|
```text
|
|
106
105
|
you make me a shopping expert for road-cycling gear
|
|
107
106
|
|
|
108
|
-
agent Love it — let's shape it
|
|
109
|
-
|
|
107
|
+
agent Love it — let's shape it lightly. A complete bike, or
|
|
108
|
+
components and apparel?
|
|
110
109
|
|
|
111
|
-
you
|
|
112
|
-
secondhand is fine, and I'm in France
|
|
110
|
+
you a complete road bike, my first proper one
|
|
113
111
|
|
|
114
|
-
agent
|
|
112
|
+
agent Got it. I've researched how to buy a first road bike well —
|
|
113
|
+
fit (size from height AND inseam, stack/reach, saddle setback),
|
|
114
|
+
endurance-vs-race geometry, gearing theory, the comfort/speed
|
|
115
|
+
trade-offs. I'll decompose every request along use-case, terrain,
|
|
116
|
+
budget, your fit envelope, timeline, and priorities.
|
|
115
117
|
|
|
116
|
-
Road-Cycling Buyer — a
|
|
117
|
-
· always
|
|
118
|
-
· searches secondhand to ~€1200, French shops first
|
|
119
|
-
· ranks compatibility → value → weight
|
|
118
|
+
Road-Cycling Buyer — a patient first-bike advisor
|
|
119
|
+
· always explains fit · never carbon bars
|
|
120
120
|
|
|
121
121
|
shall I create it?
|
|
122
122
|
|
|
@@ -126,33 +126,29 @@ agent done — "Road-Cycling Buyer" is live. Open it anytime;
|
|
|
126
126
|
it shops your niche with no further setup.
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
**2 — The expert shops like a specialist,
|
|
129
|
+
**2 — The expert shops like a specialist, learning you as it goes:**
|
|
130
130
|
|
|
131
131
|
```text
|
|
132
|
-
you (inside Road-Cycling Buyer)
|
|
132
|
+
you (inside Road-Cycling Buyer) find me a road bike, ~€1500
|
|
133
133
|
|
|
134
|
-
agent
|
|
134
|
+
agent Before I search — two numbers I'll keep so I never re-ask:
|
|
135
|
+
your height and inseam. Any brand you won't touch?
|
|
135
136
|
|
|
136
|
-
you
|
|
137
|
+
you 178cm, 81cm inseam. No strong feelings, secondhand is fine
|
|
137
138
|
|
|
138
|
-
agent searched sil —
|
|
139
|
+
agent searched sil — endurance, 54cm for your fit, ~€1500:
|
|
139
140
|
|
|
140
|
-
1.
|
|
141
|
-
2.
|
|
141
|
+
1. Alloy endurance bike, 54cm, 105 (used) €1420
|
|
142
|
+
2. Carbon endurance bike, 54cm, 105 (used) €1610
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
Why #1: for your 178/81 fit a 54cm endurance frame sits where a
|
|
145
|
+
first buyer wants it — fit and comfort outrank outright speed on a
|
|
146
|
+
first bike — and it's inside your budget. Want detail or a link?
|
|
145
147
|
```
|
|
146
148
|
|
|
147
|
-
> **You teach it once; it stays an expert.** List the experts you've made, look at how one is set up, retire one you're done with — or **refine** one from what it watched you reject, so it gets sharper every session.
|
|
149
|
+
> **You teach it once; it stays an expert.** It keeps your facts and taste, web-refreshes its niche knowledge each visit, and never re-asks what it already knows. List the experts you've made, look at how one is set up, retire one you're done with — or **refine** one from what it watched you reject, so it gets sharper every session.
|
|
148
150
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
## Identity & authentication
|
|
152
|
-
|
|
153
|
-
**sil gives your agent an identity — and the capability to use it.** One browser sign-in links your OpenClaw agent to a sil identity it holds on your behalf — your name, your saved addresses. That identity is what lets the agent *transact*: it can search, compare, and surface checkout links with any merchant that speaks [UCP](https://github.com/universal-commerce-protocol/ucp) (the Universal Commerce Protocol), all under your account, without you ever touching a store login.
|
|
154
|
-
|
|
155
|
-
Registering is the only manual step. After that the agent carries your identity for you — ask *"who am I on sil?"* anytime to see exactly what it's holding.
|
|
151
|
+
**What it remembers, and where it lives.** A dedicated expert learns your shopping-relevant facts as it goes — measurements, budget band, the rules it must never break, brand likes/dislikes — captured **only when a request actually needs them** (never a big up-front form) so it doesn't re-ask. All of it is stored **locally on your machine** (`$SIL_DATA_DIR/agents/<id>/`, owner-only `0600`), **per-user and per-expert**. It is **never pooled across users and never sent to a server** for training or aggregation — creating and running an expert is local and offline. The niche web-refresh reads public sources to keep the *domain* knowledge current; it does not upload anything about you. Inspect exactly what an expert holds with `sil_profile_get`, and delete an expert and everything it remembered with `sil_profile_remove`.
|
|
156
152
|
|
|
157
153
|
---
|
|
158
154
|
|
|
@@ -171,16 +167,16 @@ Namespaced `sil_*` so they never collide with other plugins. Your agent calls th
|
|
|
171
167
|
|
|
172
168
|
| Tool | What it does |
|
|
173
169
|
|---|---|
|
|
174
|
-
| `sil_search` | Search for purchasable products. A free-text `query` plus optional filters: `category`, `price_min`/`price_max`, `ship_to` (delivery destination — leave empty to ship to your registered address), `condition` (`new` / `secondhand`), `available`, and `local_merchants` (best-effort bias toward shops in the user's own country). Results are **localized** to the shopper
|
|
170
|
+
| `sil_search` | Search for purchasable products. A free-text `query` plus optional filters: `category`, `price_min`/`price_max`, `ship_to` (delivery destination — leave empty to ship to your registered address), `condition` (`new` / `secondhand`), `available`, and `local_merchants` (best-effort bias toward shops in the user's own country). Results are **localized** to the shopper; when they ask for local shops you can *optionally* issue the `query` in that country's language to surface more of them (e.g. a French query surfaces French stores) — a tactic, not a requirement, and never an override of a language the user deliberately chose. Returns a ranked list of variants — each with `id`, `title`, `price`, `availability`, `checkout_url`, `source`, plus (where the source provides them) evaluate-before-buy detail: a product/variant `url` to view, a `description`, `media`, the product `options`, and the `seller`'s **shipping & return policy links** — and a pagination `cursor`. Location filters take ISO codes (`US`, `CA`), not place names. |
|
|
175
171
|
| `sil_product_get` | Resolve `ids` you already hold to full products in UCP shape — `description`, `options`, `media`, the `seller`'s shipping & return policy links, and the featured purchasable variant with fresh `price`, `availability`, `url` (the page to view), and `checkout_url` (the link that buys). Re-fetch right before buying; those values are point-in-time, not guarantees. Ids that no longer resolve come back in `not_found`. |
|
|
176
172
|
|
|
177
173
|
**Experts** — create and manage dedicated shopping agents
|
|
178
174
|
|
|
179
175
|
| Tool | What it does |
|
|
180
176
|
|---|---|
|
|
181
|
-
| `sil_profile_materialize` | Persist a created expert's behaviour artefacts — `
|
|
177
|
+
| `sil_profile_materialize` | Persist a created expert's SDS behaviour artefacts — `domain_spec.md` (deep researched niche expertise) + `intent_spec.md` (the decomposition-dimension schema) + `user_spec.md` (your facts + hard constraints) + `playbook.md` (your buying taste), all four required and present from creation, plus a `profile.json` manifest — under `$SIL_DATA_DIR/agents/<id>/`. (The persona is the agent's host workspace `SOUL.md`, not a sil artefact.) Driven by the skill's creation engine once you endorse the draft, and again per-query to web-refresh the domain and augment your facts/taste; validate-first and fail-closed, it never clobbers an existing expert. |
|
|
182
178
|
| `sil_profile_list` | List the experts you've created, most-recently-made first. Takes no arguments. |
|
|
183
|
-
| `sil_profile_get` | Show one expert in full — `name`, `
|
|
179
|
+
| `sil_profile_get` | Show one expert in full — `name`, its `domainSpec` + `intentSpec` + `userSpec` + `playbook` (all four present), manifest path, and `createdAt`. |
|
|
184
180
|
| `sil_profile_remove` | Delete one expert's behaviour artefacts. Scoped and idempotent; the agent confirms with you before removing. |
|
|
185
181
|
|
|
186
182
|
---
|
|
@@ -190,7 +186,7 @@ Namespaced `sil_*` so they never collide with other plugins. Your agent calls th
|
|
|
190
186
|
The plugin ships one bundled skill — **`sil`** 🛒 — that your agent loads automatically the first time you express a shopping intent. You don't invoke it; it's the playbook that makes the tools work well together:
|
|
191
187
|
|
|
192
188
|
- **Routes intent to the right tool.** *"find me a keyboard"* → `sil_search`, *"look these up"* → `sil_product_get`, *"who am I?"* → `sil_whoami`, *"sign me up"* → `sil_register`, *"make me an expert for X"* → the create flow, *"list / show / remove my experts"* → the `sil_profile_*` tools.
|
|
193
|
-
- **Interviews
|
|
189
|
+
- **Interviews lightly, then researches deeply.** Asked for a shopping expert, it runs a light interview (≤10 questions) to shape the niche and persona *with* you, then researches the niche itself and derives how to decompose every request — and creates nothing until you explicitly endorse the assembled draft.
|
|
194
190
|
- **Recovers the right way.** Every tool reports a status; the skill follows that tool's own recovery hint — re-register, fix the query, or retry — instead of guessing a fix that won't work.
|
|
195
191
|
- **Keeps prices honest.** It treats price, availability, and checkout links as point-in-time and re-checks an item right before you buy, so the link you get is the link you pay.
|
|
196
192
|
|
package/dist/lib/credentials.js
CHANGED
|
@@ -57,7 +57,7 @@ export function getConfigPath() {
|
|
|
57
57
|
/**
|
|
58
58
|
* True iff a `tokens.json` exists on disk. This is the already-registered
|
|
59
59
|
* short-circuit's gate — it is PRESENCE-based, not freshness-based: an expired
|
|
60
|
-
*
|
|
60
|
+
* session token still counts as "registered" for this card (refresh is SC7, the
|
|
61
61
|
* sil_whoami card). Note carried forward in the card body.
|
|
62
62
|
*/
|
|
63
63
|
export function hasTokens() {
|
|
@@ -9,29 +9,60 @@
|
|
|
9
9
|
*
|
|
10
10
|
* What the plugin DOES own is the agent's *behaviour* layer, materialized into
|
|
11
11
|
* its own disclosed `filesystemScope` — `$SIL_DATA_DIR` (the same directory
|
|
12
|
-
* `lib/credentials.ts` uses for tokens/identity).
|
|
13
|
-
* (
|
|
14
|
-
*
|
|
12
|
+
* `lib/credentials.ts` uses for tokens/identity). The created expert runs
|
|
13
|
+
* entirely on Spec-Driven Shopping (SDS): the engine writes the SDS behaviour
|
|
14
|
+
* artefacts there, read by the sil skill at runtime:
|
|
15
15
|
*
|
|
16
16
|
* $SIL_DATA_DIR/agents/<agentId>/
|
|
17
|
-
* ├─
|
|
18
|
-
* │
|
|
19
|
-
* │
|
|
20
|
-
* │
|
|
21
|
-
* ├─
|
|
22
|
-
* │
|
|
23
|
-
* │
|
|
24
|
-
*
|
|
25
|
-
*
|
|
17
|
+
* ├─ domain_spec.md the SDS DOMAIN SPEC — deep researched niche expertise:
|
|
18
|
+
* │ how to buy well, the full mechanics (gearing theory,
|
|
19
|
+
* │ frame geometry, the complete bike-fit process…).
|
|
20
|
+
* │ REQUIRED at creation; web-refreshed every query.
|
|
21
|
+
* ├─ intent_spec.md the SDS INTENT SPEC — the agent-specific decomposition
|
|
22
|
+
* │ DIMENSIONS (a PRD-style template) a query must resolve,
|
|
23
|
+
* │ derived from domain_spec. REQUIRED at creation. The
|
|
24
|
+
* │ per-query intent (dimensions filled in) is EPHEMERAL —
|
|
25
|
+
* │ never persisted.
|
|
26
|
+
* ├─ user_spec.md the SDS USER SPEC — the user's domain-relevant facts +
|
|
27
|
+
* │ hard constraints. REQUIRED at creation (seeded partial
|
|
28
|
+
* │ by the ≤10-question setup), AUGMENTED every query.
|
|
29
|
+
* ├─ playbook.md the SDS PLAYBOOK — the user's buying TASTE (price
|
|
30
|
+
* │ sensitivity, brand, preferences). REQUIRED at creation
|
|
31
|
+
* │ (seeded partial), AUGMENTED every query.
|
|
32
|
+
* └─ profile.json the strictly-typed manifest the sil skill resolves the
|
|
33
|
+
* artefacts from (no filesystem guessing)
|
|
26
34
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
35
|
+
* The persona is NOT a sil artefact: the agent's identity/voice/standing rules
|
|
36
|
+
* are the host workspace `SOUL.md`, written directly via the host CLI by the
|
|
37
|
+
* engine — there is no `persona.md` in this store and no copy step. This store
|
|
38
|
+
* holds only the four SDS BEHAVIOUR artefacts.
|
|
30
39
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
40
|
+
* All FOUR slots are REQUIRED at creation (`domainSpec` + `intentSpec` +
|
|
41
|
+
* `userSpec` + `playbook`) — SDS is the operating model, not an optional layer,
|
|
42
|
+
* so a created expert without all four is a defect (Founder review round 2: all
|
|
43
|
+
* four sil docs are present, non-blank, from creation). They are seeded *partial*
|
|
44
|
+
* (the ≤10-question setup + a quick initial research pass), then lazily
|
|
45
|
+
* AUGMENTED / reinforced on EVERY query — domain_spec web-refreshed, intent_spec
|
|
46
|
+
* dimensions sharpened, user_spec facts and playbook taste reinforced. We keep
|
|
47
|
+
* learning. All four are refine-mutable in place. The per-query intent is NOT a
|
|
48
|
+
* slot here: only the intent_spec *dimension schema* is persisted; the filled
|
|
49
|
+
* dimensions for one request are ephemeral, derived in the conversation.
|
|
50
|
+
*
|
|
51
|
+
* Store boundary: host config + `SOUL.md` (identity/wiring) = host; the four SDS
|
|
52
|
+
* behaviour artefacts = `$SIL_DATA_DIR` via this plugin tool. Identity/tokens
|
|
53
|
+
* already live in `$SIL_DATA_DIR` but stay logically separate (no identity
|
|
54
|
+
* coupling — creating an expert reads/writes no token).
|
|
55
|
+
*
|
|
56
|
+
* Write safety (Product invariant 7): a bad spec writes NOTHING (validate
|
|
57
|
+
* first). Each artefact is written atomically — tmp file → write → rename over
|
|
58
|
+
* target → chmod 0600, dir 0700 (mirroring `credentials.ts`) — so a reader never
|
|
59
|
+
* sees a half-written file. On a mid-write failure the guarantee depends on
|
|
60
|
+
* whether the expert is new: a FRESH create (the dir did not pre-exist) is torn
|
|
61
|
+
* down, leaving no partial directory behind (all-or-nothing); a RE-MATERIALIZE
|
|
62
|
+
* over an existing expert is per-file atomic and dir-preserving — it is NOT a
|
|
63
|
+
* cross-file transaction, so on failure the prior expert is left intact and is
|
|
64
|
+
* never served half-refined (a referenced-but-missing body fails the read closed
|
|
65
|
+
* — see `readAgentProfile`). The catch block below encodes exactly this split.
|
|
35
66
|
*/
|
|
36
67
|
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync, } from "node:fs";
|
|
37
68
|
import { dirname, join } from "node:path";
|
|
@@ -43,8 +74,11 @@ const DIR_MODE = 0o700;
|
|
|
43
74
|
/** The sub-tree under `$SIL_DATA_DIR` that holds per-agent behaviour artefacts. */
|
|
44
75
|
const AGENTS_SUBDIR = "agents";
|
|
45
76
|
/** Artefact filenames (stable — the sil skill resolves them from profile.json,
|
|
46
|
-
* but the names are also documented so a human can find them).
|
|
47
|
-
|
|
77
|
+
* but the names are also documented so a human can find them). The three SDS
|
|
78
|
+
* *specs* carry the `_spec.md` suffix; `playbook.md` (taste) does not. */
|
|
79
|
+
const DOMAIN_SPEC_FILE = "domain_spec.md";
|
|
80
|
+
const INTENT_SPEC_FILE = "intent_spec.md";
|
|
81
|
+
const USER_SPEC_FILE = "user_spec.md";
|
|
48
82
|
const PLAYBOOK_FILE = "playbook.md";
|
|
49
83
|
const PROFILE_FILE = "profile.json";
|
|
50
84
|
/** A host-agent id must be lower-kebab and is never `main` (host-reserved). */
|
|
@@ -55,7 +89,8 @@ const AGENT_ID_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
|
55
89
|
* SAFETY: this resolver does NOT guard `agentId` — it joins it as a path segment
|
|
56
90
|
* verbatim. The path-traversal guard lives at the only caller, `materializeProfile`,
|
|
57
91
|
* which validates `agentId` against `AGENT_ID_RE` (lower-kebab, not `main`) BEFORE
|
|
58
|
-
* the join, so
|
|
92
|
+
* the join, so a traversal-shaped id (a parent-directory hop, a nested back-step,
|
|
93
|
+
* a bare dot) never reaches here. The guard is
|
|
59
94
|
* placed at the caller (not here) because validation must precede ALL writes for
|
|
60
95
|
* the validate-first / write-nothing-on-bad-input invariant to hold; a guard
|
|
61
96
|
* duplicated here would be redundant for that path. A FUTURE DIRECT CALLER of this
|
|
@@ -93,23 +128,36 @@ export function materializeProfile(spec) {
|
|
|
93
128
|
if (!nonBlank(spec.name)) {
|
|
94
129
|
return invalid("name", "name is required and must be non-empty.");
|
|
95
130
|
}
|
|
96
|
-
|
|
97
|
-
|
|
131
|
+
// All FOUR SDS specs are REQUIRED at creation — SDS is the operating model,
|
|
132
|
+
// not an optional layer. A created expert always carries all four (Founder
|
|
133
|
+
// review round 2): they are seeded *partial* at creation, then augmented every
|
|
134
|
+
// query. A present-but-blank or omitted spec is rejected (validate-first; write
|
|
135
|
+
// nothing).
|
|
136
|
+
if (!nonBlank(spec.domainSpec)) {
|
|
137
|
+
return invalid("domainSpec", "domainSpec is required and must be non-empty.");
|
|
138
|
+
}
|
|
139
|
+
if (!nonBlank(spec.intentSpec)) {
|
|
140
|
+
return invalid("intentSpec", "intentSpec is required and must be non-empty.");
|
|
98
141
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
142
|
+
if (!nonBlank(spec.userSpec)) {
|
|
143
|
+
return invalid("userSpec", "userSpec is required and must be non-empty.");
|
|
144
|
+
}
|
|
145
|
+
if (!nonBlank(spec.playbook)) {
|
|
146
|
+
return invalid("playbook", "playbook is required and must be non-empty.");
|
|
103
147
|
}
|
|
104
148
|
const dir = getAgentArtefactDir(spec.agentId);
|
|
105
|
-
const
|
|
106
|
-
const
|
|
149
|
+
const domainSpecPath = join(dir, DOMAIN_SPEC_FILE);
|
|
150
|
+
const intentSpecPath = join(dir, INTENT_SPEC_FILE);
|
|
151
|
+
const userSpecPath = join(dir, USER_SPEC_FILE);
|
|
152
|
+
const playbookPath = join(dir, PLAYBOOK_FILE);
|
|
107
153
|
const profilePath = join(dir, PROFILE_FILE);
|
|
108
154
|
const manifest = {
|
|
109
155
|
agentId: spec.agentId,
|
|
110
156
|
name: spec.name,
|
|
111
|
-
|
|
112
|
-
|
|
157
|
+
domainSpecPath,
|
|
158
|
+
intentSpecPath,
|
|
159
|
+
userSpecPath,
|
|
160
|
+
playbookPath,
|
|
113
161
|
createdAt: new Date().toISOString(),
|
|
114
162
|
};
|
|
115
163
|
// Whether the artefact directory already existed before this call. If it did,
|
|
@@ -120,10 +168,10 @@ export function materializeProfile(spec) {
|
|
|
120
168
|
const dirPreexisted = existsSync(dir);
|
|
121
169
|
try {
|
|
122
170
|
mkdirSync(dir, { recursive: true, mode: DIR_MODE });
|
|
123
|
-
atomicWrite(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
171
|
+
atomicWrite(domainSpecPath, spec.domainSpec);
|
|
172
|
+
atomicWrite(intentSpecPath, spec.intentSpec);
|
|
173
|
+
atomicWrite(userSpecPath, spec.userSpec);
|
|
174
|
+
atomicWrite(playbookPath, spec.playbook);
|
|
127
175
|
atomicWrite(profilePath, JSON.stringify(manifest, null, 2) + "\n");
|
|
128
176
|
}
|
|
129
177
|
catch (err) {
|
|
@@ -151,8 +199,10 @@ export function materializeProfile(spec) {
|
|
|
151
199
|
ok: true,
|
|
152
200
|
agentId: spec.agentId,
|
|
153
201
|
dir,
|
|
154
|
-
|
|
155
|
-
|
|
202
|
+
domainSpecPath,
|
|
203
|
+
intentSpecPath,
|
|
204
|
+
userSpecPath,
|
|
205
|
+
playbookPath,
|
|
156
206
|
profilePath,
|
|
157
207
|
};
|
|
158
208
|
}
|
|
@@ -189,8 +239,8 @@ function getAgentsRoot() {
|
|
|
189
239
|
* `getAgentArtefactDir`. Returns `null` when valid; an `invalid_request`
|
|
190
240
|
* variant naming the field otherwise. The gate is identical to
|
|
191
241
|
* `materializeProfile`'s validate-first block (`AGENT_ID_RE` + non-`main`),
|
|
192
|
-
* applied BEFORE any
|
|
193
|
-
* becomes a filesystem path segment. `getAgentArtefactDir`'s SAFETY note
|
|
242
|
+
* applied BEFORE any path join, read, or delete so a parent-directory traversal,
|
|
243
|
+
* an absolute path, a bare dot, or `main` never becomes a filesystem path segment. `getAgentArtefactDir`'s SAFETY note
|
|
194
244
|
* mandates exactly this for every direct caller — list does not (it never
|
|
195
245
|
* trusts a caller-supplied id; it reads only ids it discovered on disk), but
|
|
196
246
|
* read and remove DO take a caller id and so call this first. */
|
|
@@ -221,7 +271,10 @@ function readManifestFile(profilePath) {
|
|
|
221
271
|
parsed === null ||
|
|
222
272
|
typeof parsed.agentId !== "string" ||
|
|
223
273
|
typeof parsed.name !== "string" ||
|
|
224
|
-
typeof parsed.
|
|
274
|
+
typeof parsed.domainSpecPath !== "string" ||
|
|
275
|
+
typeof parsed.intentSpecPath !== "string" ||
|
|
276
|
+
typeof parsed.userSpecPath !== "string" ||
|
|
277
|
+
typeof parsed.playbookPath !== "string" ||
|
|
225
278
|
typeof parsed.createdAt !== "string") {
|
|
226
279
|
throw new Error("profile.json is missing required manifest fields");
|
|
227
280
|
}
|
|
@@ -274,7 +327,6 @@ export function listAgentProfiles() {
|
|
|
274
327
|
experts.push({
|
|
275
328
|
agentId: manifest.agentId,
|
|
276
329
|
name: manifest.name,
|
|
277
|
-
hasPlaybook: manifest.playbookPath !== undefined,
|
|
278
330
|
createdAt: manifest.createdAt,
|
|
279
331
|
});
|
|
280
332
|
}
|
|
@@ -299,13 +351,17 @@ function createdAtDesc(a, b) {
|
|
|
299
351
|
return tb - ta;
|
|
300
352
|
}
|
|
301
353
|
/**
|
|
302
|
-
* Read one expert's full detail — the manifest PLUS the
|
|
303
|
-
*
|
|
354
|
+
* Read one expert's full detail — the manifest PLUS the SDS artefact bodies from
|
|
355
|
+
* the files it points at — so the skill can render a complete view.
|
|
304
356
|
*
|
|
305
357
|
* Re-runs the writer's `agentId` gate BEFORE any `join`/read (a traversal-shaped
|
|
306
358
|
* id → `invalid_request`, reading nothing). An unknown id, an absent/unreadable
|
|
307
|
-
* manifest, or an absent
|
|
308
|
-
*
|
|
359
|
+
* manifest, or an absent body of ANY of the four REQUIRED SDS specs
|
|
360
|
+
* (`domain_spec.md` / `intent_spec.md` / `user_spec.md` / `playbook.md`) →
|
|
361
|
+
* `not_found` (Founder review round 2: all four always exist; a degraded expert
|
|
362
|
+
* is, from the user's view, not viewable). There is no degrade-to-undefined path
|
|
363
|
+
* any more — a referenced-but-missing body of any of the four fails the read
|
|
364
|
+
* closed. Never throws across the boundary; reads only.
|
|
309
365
|
*/
|
|
310
366
|
export function readAgentProfile(agentId) {
|
|
311
367
|
const bad = rejectBadAgentId(agentId);
|
|
@@ -326,32 +382,35 @@ export function readAgentProfile(agentId) {
|
|
|
326
382
|
// raw parse error across the boundary.
|
|
327
383
|
return notFoundRead(agentId);
|
|
328
384
|
}
|
|
329
|
-
|
|
385
|
+
// All FOUR SDS spec bodies are REQUIRED for a created expert — they gate the
|
|
386
|
+
// read fail-closed (the role the persona body played pre-SDS). A manifest that
|
|
387
|
+
// points at a domain_spec.md / intent_spec.md / user_spec.md / playbook.md whose
|
|
388
|
+
// body is gone (a partial write, a hand-deleted file) is, to the viewer, an
|
|
389
|
+
// expert that cannot be loaded. This is the per-file-atomic, NOT-cross-file-
|
|
390
|
+
// transactional safety boundary: a partial write degrades to a fail-closed
|
|
391
|
+
// not_found, never a coherent-but-incomplete expert (Founder review round 2:
|
|
392
|
+
// all four are present from creation, so none degrades to absence).
|
|
393
|
+
let domainSpec;
|
|
394
|
+
let intentSpec;
|
|
395
|
+
let userSpec;
|
|
396
|
+
let playbook;
|
|
330
397
|
try {
|
|
331
|
-
|
|
398
|
+
domainSpec = readFileSync(manifest.domainSpecPath, "utf8");
|
|
399
|
+
intentSpec = readFileSync(manifest.intentSpecPath, "utf8");
|
|
400
|
+
userSpec = readFileSync(manifest.userSpecPath, "utf8");
|
|
401
|
+
playbook = readFileSync(manifest.playbookPath, "utf8");
|
|
332
402
|
}
|
|
333
403
|
catch {
|
|
334
|
-
// Manifest present but its persona body is gone (a partial removal, or a
|
|
335
|
-
// hand-deleted file) — the expert is not viewable.
|
|
336
404
|
return notFoundRead(agentId);
|
|
337
405
|
}
|
|
338
|
-
let playbook;
|
|
339
|
-
if (manifest.playbookPath !== undefined) {
|
|
340
|
-
try {
|
|
341
|
-
playbook = readFileSync(manifest.playbookPath, "utf8");
|
|
342
|
-
}
|
|
343
|
-
catch {
|
|
344
|
-
// The playbook is optional detail; its absence does not make the expert
|
|
345
|
-
// unviewable. Render the rest without it.
|
|
346
|
-
playbook = undefined;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
406
|
return {
|
|
350
407
|
ok: true,
|
|
351
408
|
agentId: manifest.agentId,
|
|
352
409
|
name: manifest.name,
|
|
353
|
-
|
|
354
|
-
|
|
410
|
+
domainSpec,
|
|
411
|
+
intentSpec,
|
|
412
|
+
userSpec,
|
|
413
|
+
playbook,
|
|
355
414
|
profilePath,
|
|
356
415
|
createdAt: manifest.createdAt,
|
|
357
416
|
};
|
|
@@ -375,10 +434,10 @@ function notFoundRead(agentId) {
|
|
|
375
434
|
* - asserts the resolved target is strictly UNDER `getDataDir()/agents/` and
|
|
376
435
|
* is NOT the `agents/` parent, so a delete can never escape the subtree or
|
|
377
436
|
* wipe sibling experts;
|
|
378
|
-
* -
|
|
437
|
+
* - recursively delete the single validated leaf dir.
|
|
379
438
|
*
|
|
380
439
|
* Absent target → `not_found` (idempotent — a re-run after a partial host-CLI
|
|
381
|
-
* failure is safe). A genuine
|
|
440
|
+
* failure is safe). A genuine delete failure (e.g. EACCES) →
|
|
382
441
|
* `persistence_failed` with `<dir>: <cause>`. Never throws across the boundary.
|
|
383
442
|
*/
|
|
384
443
|
export function removeAgentArtefacts(agentId) {
|
|
@@ -387,8 +446,8 @@ export function removeAgentArtefacts(agentId) {
|
|
|
387
446
|
return bad;
|
|
388
447
|
const dir = getAgentArtefactDir(agentId);
|
|
389
448
|
// Defence in depth beyond the id gate: assert the resolved path is strictly a
|
|
390
|
-
// child of the agents root and never the root itself.
|
|
391
|
-
//
|
|
449
|
+
// child of the agents root and never the root itself. Deleting the parent
|
|
450
|
+
// directory would wipe every sibling expert — refuse it even if some future
|
|
392
451
|
// change to the gate let a separator-bearing id through.
|
|
393
452
|
const root = getAgentsRoot();
|
|
394
453
|
if (dirname(dir) !== root || dir === root) {
|
package/dist/lib/sil-client.js
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* Wire contract for the sil-API identity read (a SECOND origin — sil-api, the
|
|
32
32
|
* Fastify domain service — NOT sil-web; bare path, not /api/v1; see the
|
|
33
33
|
* sil-whoami card). The authenticated self-read is a BODYLESS GET; the
|
|
34
|
-
* Authorization header carries the stored
|
|
34
|
+
* Authorization header carries the stored session token and IS the principal —
|
|
35
35
|
* sil-api derives the user from the JWT `sub`, not a request body:
|
|
36
36
|
*
|
|
37
37
|
* GET <silApiUrl>/identity Authorization: Bearer <access_token>
|
|
@@ -519,7 +519,7 @@ export async function refreshStoredTokens() {
|
|
|
519
519
|
* module's `readTokens` (so a TOCTOU on
|
|
520
520
|
* the on-disk pair is observed):
|
|
521
521
|
* re-read empty (TOCTOU) → must_reregister(no_stored_tokens), NO retry.
|
|
522
|
-
* re-read ok → retry ONCE with the rotated
|
|
522
|
+
* re-read ok → retry ONCE with the rotated session token:
|
|
523
523
|
* retry still unauthorized → second_unauthorized (the rotated token is
|
|
524
524
|
* structurally dead — NEVER refresh again).
|
|
525
525
|
* retry otherwise → `{ result, retry }`.
|
package/dist/tools/catalog.js
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
* `sil_register`; a transient/invalid must NOT (re-registering can't fix a 5xx or
|
|
41
41
|
* a bad query and would derail the user).
|
|
42
42
|
*
|
|
43
|
-
* Privacy: the
|
|
43
|
+
* Privacy: the session token and Bearer header never reach a log line or the
|
|
44
44
|
* result; logs carry only non-credential status markers (search params are not
|
|
45
45
|
* credentials, but are not logged either — nothing here needs them).
|
|
46
46
|
*
|
|
@@ -125,9 +125,10 @@ function registerSearch(api) {
|
|
|
125
125
|
+ " in the user's OWN country (home-country / domestic / local sellers) — set it"
|
|
126
126
|
+ " ONLY when the shopper asks for local/domestic shops; it nudges local shops up"
|
|
127
127
|
+ " the ranking but does NOT restrict results to them, so never tell the user the"
|
|
128
|
-
+ " results are all local. To
|
|
129
|
-
+ " `query` in
|
|
130
|
-
+ "
|
|
128
|
+
+ " results are all local. To surface MORE local shops you MAY also issue the"
|
|
129
|
+
+ " `query` in that country's language (a Greek-language query surfaces Greek"
|
|
130
|
+
+ " shops) — optional, and never an override of a language the user deliberately"
|
|
131
|
+
+ " chose; pass NO country — sil resolves it server-side. Requires registration (run"
|
|
131
132
|
+ " sil_register first).",
|
|
132
133
|
parameters: Type.Object({
|
|
133
134
|
query: Type.Optional(Type.String({
|
|
@@ -183,9 +184,10 @@ function registerSearch(api) {
|
|
|
183
184
|
+ " nudges local shops up the ranking but does NOT restrict results to them"
|
|
184
185
|
+ " and does NOT guarantee every result is local — some local shops won't"
|
|
185
186
|
+ " be detected and some non-local shops may still appear, so never tell"
|
|
186
|
-
+ " the user the results are all local sellers. To
|
|
187
|
-
+ " shops
|
|
188
|
-
+ " query surfaces Greek shops; an English query will not)
|
|
187
|
+
+ " the user the results are all local sellers. To surface MORE local"
|
|
188
|
+
+ " shops you MAY also issue the `query` in that country's language (a"
|
|
189
|
+
+ " Greek-language query surfaces Greek shops; an English query will not)"
|
|
190
|
+
+ " — optional, never overriding a language the user deliberately chose. You pass NO"
|
|
189
191
|
+ " country — sil resolves the user's country server-side from their"
|
|
190
192
|
+ " registered address, so do NOT call sil_whoami or pass a country. Omit"
|
|
191
193
|
+ " (or false) for the normal unbiased ranking.",
|
|
@@ -334,7 +336,7 @@ function mapSearchOutcome(api, outcome) {
|
|
|
334
336
|
* classes (not-registered/401 and source/transport failure) by DISTINCT recovery
|
|
335
337
|
* hints. One wrong hint = one misdirected user.
|
|
336
338
|
*
|
|
337
|
-
* Privacy + freshness: the
|
|
339
|
+
* Privacy + freshness: the session token and Bearer header never reach a log line
|
|
338
340
|
* or the result; the products are always live-fetched (never cached — freshness is
|
|
339
341
|
* the reason this tool exists; a cached `checkout_url`/price is a broken purchase).
|
|
340
342
|
*/
|