sil-openclaw 0.4.6 → 0.5.1
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 +185 -0
- package/README.md +34 -46
- package/SECURITY.md +61 -11
- package/dist/gateway/search-results.js +11 -7
- package/dist/index.js +24 -24
- package/dist/lib/allowlist-script.js +13 -0
- package/dist/lib/artifacts.js +30 -0
- package/dist/lib/credentials.js +2 -3
- package/dist/lib/host-wiring.js +44 -15
- package/dist/lib/pkce.js +3 -3
- package/dist/lib/search-results-log.js +23 -0
- package/dist/lib/search-results-store.js +4 -4
- package/dist/lib/shopping-call.js +143 -0
- package/dist/lib/sil-client.js +185 -1046
- package/dist/lib/tool-result.js +10 -3
- package/dist/tools/catalog.js +311 -1197
- package/dist/tools/doctor.js +25 -63
- package/dist/tools/identity.js +110 -245
- package/openclaw.plugin.json +12 -33
- package/package.json +10 -9
- package/schema/PROVENANCE.md +15 -0
- package/schema/shopping-brief-create-request.schema.json +98 -0
- package/schema/shopping-brief-create-response.schema.json +24 -0
- package/schema/shopping-brief-edit-request.schema.json +125 -0
- package/schema/shopping-brief-edit-response.schema.json +24 -0
- package/schema/shopping-brief-read-request.schema.json +15 -0
- package/schema/shopping-brief-read-response.schema.json +235 -0
- package/schema/shopping-domain-create-request.schema.json +160 -0
- package/schema/shopping-domain-create-response.schema.json +60 -0
- package/schema/shopping-domain-get-request.schema.json +18 -0
- package/schema/shopping-domain-get-response.schema.json +307 -0
- package/schema/shopping-domain-search-request.schema.json +18 -0
- package/schema/shopping-domain-search-response.schema.json +92 -0
- package/schema/shopping-offers-request.schema.json +31 -0
- package/schema/shopping-offers-response.schema.json +172 -0
- package/schema/shopping-product-get-request.schema.json +24 -0
- package/schema/shopping-product-get-response.schema.json +121 -0
- package/schema/shopping-profile-edit-request.schema.json +97 -0
- package/schema/shopping-profile-edit-response.schema.json +17 -0
- package/schema/shopping-search-request.schema.json +106 -0
- package/schema/shopping-search-response.schema.json +182 -0
- package/schema/shopping-seller-get-request.schema.json +24 -0
- package/schema/shopping-seller-get-response.schema.json +342 -0
- package/scripts/allowlist-openclaw.mjs +6 -7
- package/sil-shopping/SKILL.md +196 -97
- package/sil-shopping/references/mint.md +190 -0
- package/dist/lib/bind-channel.js +0 -10
- package/dist/lib/creation-entrypoint.js +0 -111
- package/dist/lib/derive-agent-id.js +0 -36
- package/dist/lib/profile-store.js +0 -568
- package/dist/tools/profile.js +0 -300
- package/scripts/create-shopper.mjs +0 -677
- package/sil-shopping/examples/multi_domain_shopper_walkthrough.md +0 -65
- package/sil-shopping/references/agent_creation_engine.md +0 -223
- package/sil-shopping/references/fill_and_feedback.md +0 -102
- package/sil-shopping/references/method_and_prds.md +0 -143
- package/sil-shopping/references/setup_onboarding.md +0 -64
- package/sil-shopping/references/shop_loop.md +0 -118
package/dist/tools/doctor.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* a complete, successful run. Mutation is a bounded side-effect — the ONLY
|
|
7
7
|
* writes are the two safe auto-fixes (tighten a too-open mode, create the
|
|
8
8
|
* missing data dir), both under `getDataDir()`. Destructive fixes (anything that
|
|
9
|
-
* mutates the BYTES of an existing
|
|
9
|
+
* mutates the BYTES of an existing file, including clearing a corrupt
|
|
10
10
|
* `tokens.json`) are surfaced as `needs_confirmation` and never run: delete-first
|
|
11
11
|
* does not apply to user data.
|
|
12
12
|
*
|
|
@@ -26,19 +26,17 @@ import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, statSync, unl
|
|
|
26
26
|
import { randomBytes } from "node:crypto";
|
|
27
27
|
import { join, relative } from "node:path";
|
|
28
28
|
import { Type } from "typebox";
|
|
29
|
-
import { buildCreationEntrypointFinding, probeCreationEntrypoint, resolveCreationEntrypoint, } from "../lib/creation-entrypoint.js";
|
|
30
29
|
import { DIR_MODE, getConfigPath, getDataDir, getTokensPath, hasTokens, readConfig, readTokens, } from "../lib/credentials.js";
|
|
31
30
|
import { sortFindings } from "../lib/findings.js";
|
|
32
31
|
import { detectWiringDrift, readHostVersion, readSilWiringFacts, } from "../lib/host-wiring.js";
|
|
33
|
-
import { readShopperIdentity, searchProfileFrontmatter, } from "../lib/profile-store.js";
|
|
34
32
|
import { jsonResult } from "../lib/tool-result.js";
|
|
35
33
|
import { buildGatewayCompatFinding, buildVersionBehindFinding, probeLatestVersion, readInstalledVersion, } from "../lib/version-advisory.js";
|
|
36
34
|
/** Owner-only file mode. `DIR_MODE` (0o700) is owned by `credentials.ts` and
|
|
37
|
-
* imported; the file mode is private per-module there
|
|
38
|
-
*
|
|
35
|
+
* imported; the file mode is private per-module there, so this mirrors that
|
|
36
|
+
* pattern rather than exporting a third copy. */
|
|
39
37
|
const FILE_MODE = 0o600;
|
|
40
38
|
/** An interrupted atomic write leaves `<path>.<hex>.tmp` behind
|
|
41
|
-
* (`
|
|
39
|
+
* (`credentials.ts`'s tmp → rename). The hex length is not pinned: it is a
|
|
42
40
|
* detail of one call site's `randomBytes(n)`, and an orphan is an orphan.
|
|
43
41
|
* Bytes on disk ⇒ surfaced, never deleted. */
|
|
44
42
|
const STALE_TMP_RE = /\.[0-9a-f]+\.tmp$/;
|
|
@@ -52,7 +50,7 @@ fetchImpl = fetch) {
|
|
|
52
50
|
name: "sil_doctor",
|
|
53
51
|
label: "Diagnose sil",
|
|
54
52
|
description: "Diagnose this sil install: check the local data directory, file"
|
|
55
|
-
+ " permissions
|
|
53
|
+
+ " permissions and stored identity/token health,"
|
|
56
54
|
+ " and report whether a newer sil plugin is published. Returns a"
|
|
57
55
|
+ " machine-readable findings array. Safe permission fixes apply"
|
|
58
56
|
+ " automatically; anything that could lose data is only reported, never"
|
|
@@ -64,10 +62,8 @@ fetchImpl = fetch) {
|
|
|
64
62
|
const findings = [];
|
|
65
63
|
const dir = checkDataDir(dataDir);
|
|
66
64
|
findings.push(...dir.findings);
|
|
67
|
-
if (dir.usable)
|
|
65
|
+
if (dir.usable)
|
|
68
66
|
findings.push(...walkDataDir(dataDir));
|
|
69
|
-
findings.push(...checkStore());
|
|
70
|
-
}
|
|
71
67
|
findings.push(...checkIdentity());
|
|
72
68
|
// Host wiring + host compat: both read the tree already in memory, so they
|
|
73
69
|
// are local and unconditional — they still report with the network down.
|
|
@@ -78,28 +74,18 @@ fetchImpl = fetch) {
|
|
|
78
74
|
const compat = buildGatewayCompatFinding(readHostVersion(api));
|
|
79
75
|
if (compat !== null)
|
|
80
76
|
findings.push(compat);
|
|
81
|
-
// The creation entrypoint: resolved ONCE, then both reported and probed —
|
|
82
|
-
// so the path the report hands the agent to run is, by construction, the
|
|
83
|
-
// path the verdict is about. A local stat, so it still answers offline.
|
|
84
|
-
const creationEntrypoint = resolveCreationEntrypoint();
|
|
85
|
-
findings.push(buildCreationEntrypointFinding(creationEntrypoint, probeCreationEntrypoint(creationEntrypoint)));
|
|
86
77
|
const installedVersion = readInstalledVersion();
|
|
87
78
|
const behind = buildVersionBehindFinding(installedVersion, await probeLatestVersion(fetchImpl));
|
|
88
79
|
if (behind !== null)
|
|
89
80
|
findings.push(behind);
|
|
90
|
-
return jsonResult(buildDoctorReport({
|
|
91
|
-
dataDir,
|
|
92
|
-
installedVersion,
|
|
93
|
-
creationEntrypoint,
|
|
94
|
-
findings,
|
|
95
|
-
}));
|
|
81
|
+
return jsonResult(buildDoctorReport({ dataDir, installedVersion, findings }));
|
|
96
82
|
},
|
|
97
83
|
});
|
|
98
84
|
}
|
|
99
85
|
/** Roll-ups the consumer would otherwise re-derive, over a deterministic order.
|
|
100
86
|
* Pure: it never invents a finding, it only rolls up the ones it is handed. */
|
|
101
87
|
export function buildDoctorReport(input) {
|
|
102
|
-
const { dataDir, installedVersion,
|
|
88
|
+
const { dataDir, installedVersion, findings } = input;
|
|
103
89
|
const sorted = sortFindings(findings);
|
|
104
90
|
const counts = { info: 0, warn: 0, critical: 0 };
|
|
105
91
|
for (const f of sorted)
|
|
@@ -109,7 +95,6 @@ export function buildDoctorReport(input) {
|
|
|
109
95
|
healthy: counts.warn === 0 && counts.critical === 0,
|
|
110
96
|
dataDir,
|
|
111
97
|
installedVersion,
|
|
112
|
-
creationEntrypoint,
|
|
113
98
|
counts,
|
|
114
99
|
findings: sorted,
|
|
115
100
|
};
|
|
@@ -118,7 +103,7 @@ export function buildDoctorReport(input) {
|
|
|
118
103
|
// Filesystem hygiene
|
|
119
104
|
// ===========================================================================
|
|
120
105
|
/** The data dir gates every other filesystem check: an unwritable or
|
|
121
|
-
* non-directory home means no
|
|
106
|
+
* non-directory home means no token can EVER persist. */
|
|
122
107
|
function checkDataDir(dataDir) {
|
|
123
108
|
const id = "fs.data_dir_writable";
|
|
124
109
|
if (!existsSync(dataDir)) {
|
|
@@ -160,7 +145,7 @@ function checkDataDir(dataDir) {
|
|
|
160
145
|
severity: "critical",
|
|
161
146
|
status: "advisory",
|
|
162
147
|
detected: `The sil data directory path ${dataDir} exists but is not a`
|
|
163
|
-
+ " directory, so no token
|
|
148
|
+
+ " directory, so no token can be stored.",
|
|
164
149
|
suggestedAction: `Move or remove the file at ${dataDir}, or point $SIL_DATA_DIR at a`
|
|
165
150
|
+ " writable directory.",
|
|
166
151
|
appliedAction: null,
|
|
@@ -168,7 +153,7 @@ function checkDataDir(dataDir) {
|
|
|
168
153
|
usable: false,
|
|
169
154
|
};
|
|
170
155
|
}
|
|
171
|
-
// Prove writability the way
|
|
156
|
+
// Prove writability the way sil actually writes — an atomic tmp file —
|
|
172
157
|
// rather than trusting the mode bits (a read-only mount passes a mode check).
|
|
173
158
|
const probe = join(dataDir, `.doctor.${randomBytes(6).toString("hex")}.tmp`);
|
|
174
159
|
try {
|
|
@@ -182,7 +167,7 @@ function checkDataDir(dataDir) {
|
|
|
182
167
|
severity: "critical",
|
|
183
168
|
status: "advisory",
|
|
184
169
|
detected: `The sil data directory ${dataDir} is not writable, so every token`
|
|
185
|
-
+ `
|
|
170
|
+
+ ` write would fail: ${causeOf(err)}`,
|
|
186
171
|
suggestedAction: `Make ${dataDir} writable by its owner (mode 0700), or point`
|
|
187
172
|
+ " $SIL_DATA_DIR at a writable directory.",
|
|
188
173
|
appliedAction: null,
|
|
@@ -241,8 +226,8 @@ function checkDataDirMode(dataDir) {
|
|
|
241
226
|
mode,
|
|
242
227
|
expected: DIR_MODE,
|
|
243
228
|
detected: `The sil data directory ${dataDir} is mode ${oct(mode)} — readable beyond`
|
|
244
|
-
+ " its owner. It holds this install's stored credentials
|
|
245
|
-
+ `
|
|
229
|
+
+ " its owner. It holds this install's stored credentials, so it must be"
|
|
230
|
+
+ ` owner-only ${oct(DIR_MODE)}.`,
|
|
246
231
|
}) ?? {
|
|
247
232
|
id,
|
|
248
233
|
severity: "info",
|
|
@@ -255,8 +240,8 @@ function checkDataDirMode(dataDir) {
|
|
|
255
240
|
/**
|
|
256
241
|
* Walk `$SIL_DATA_DIR` for too-open modes and orphaned tmp files.
|
|
257
242
|
*
|
|
258
|
-
* Enumerated ⇒ emits ONLY on a problem: a healthy
|
|
259
|
-
*
|
|
243
|
+
* Enumerated ⇒ emits ONLY on a problem: a healthy dir with 200 files yields
|
|
244
|
+
* zero findings, not 200 `ok` ones.
|
|
260
245
|
*
|
|
261
246
|
* `lstat`, never `stat`: a symlink under the data dir is REPORTED, never
|
|
262
247
|
* chmod'd-through — chmod follows the link and would mutate a file outside
|
|
@@ -293,10 +278,10 @@ function walkDataDir(dataDir) {
|
|
|
293
278
|
stats = lstatSync(path);
|
|
294
279
|
}
|
|
295
280
|
catch {
|
|
296
|
-
// This repo MANUFACTURES this race:
|
|
297
|
-
// `<path>.<hex>.tmp` and rename it away,
|
|
298
|
-
//
|
|
299
|
-
//
|
|
281
|
+
// This repo MANUFACTURES this race: sil's own atomic writes create
|
|
282
|
+
// `<path>.<hex>.tmp` and rename it away, so a token write can land while
|
|
283
|
+
// the agent self-diagnoses. An entry that vanished between readdir and
|
|
284
|
+
// lstat is not a finding — and must never throw out of execute().
|
|
300
285
|
continue;
|
|
301
286
|
}
|
|
302
287
|
if (stats.isSymbolicLink()) {
|
|
@@ -332,7 +317,7 @@ function walkDataDir(dataDir) {
|
|
|
332
317
|
+ " atomic write.",
|
|
333
318
|
// Bytes on disk ⇒ destructive to remove ⇒ the doctor only reports it.
|
|
334
319
|
suggestedAction: "Safe to delete once you have confirmed nothing else is writing"
|
|
335
|
-
+ " it — sil does not delete
|
|
320
|
+
+ " it — sil does not delete file bytes itself.",
|
|
336
321
|
appliedAction: null,
|
|
337
322
|
});
|
|
338
323
|
}
|
|
@@ -382,7 +367,7 @@ function tightenMode(input) {
|
|
|
382
367
|
};
|
|
383
368
|
}
|
|
384
369
|
}
|
|
385
|
-
/** Enumerated ⇒ silence when healthy: 200 clean
|
|
370
|
+
/** Enumerated ⇒ silence when healthy: 200 clean files emit zero findings. */
|
|
386
371
|
function checkMode(dataDir, path, rawMode, expected) {
|
|
387
372
|
const mode = rawMode & 0o777;
|
|
388
373
|
const finding = tightenMode({
|
|
@@ -402,7 +387,7 @@ function checkIdentity() {
|
|
|
402
387
|
const findings = [];
|
|
403
388
|
const tokensPath = getTokensPath();
|
|
404
389
|
if (!hasTokens()) {
|
|
405
|
-
// A valid state, not an error: bare
|
|
390
|
+
// A valid state, not an error: a bare shopping search works unregistered.
|
|
406
391
|
findings.push({
|
|
407
392
|
id: "identity.tokens_present",
|
|
408
393
|
severity: "info",
|
|
@@ -421,7 +406,7 @@ function checkIdentity() {
|
|
|
421
406
|
suggestedAction: null,
|
|
422
407
|
appliedAction: null,
|
|
423
408
|
});
|
|
424
|
-
// tokens.json is a SINGLETON
|
|
409
|
+
// tokens.json is a SINGLETON file, so its mode carries a STABLE id every
|
|
425
410
|
// run — that is what makes the fix's idempotence observable to a consumer:
|
|
426
411
|
// `fixed → re-run → ok` needs the same id to still be there. The enumerated
|
|
427
412
|
// `fs.mode:` walk could not provide that: it emits only on a problem, so it
|
|
@@ -561,30 +546,7 @@ function configFinding() {
|
|
|
561
546
|
};
|
|
562
547
|
}
|
|
563
548
|
// ===========================================================================
|
|
564
|
-
|
|
565
|
-
// ===========================================================================
|
|
566
|
-
/** Consume the store's OWN fail-closed `unreadable[]` surfacing — never re-parse
|
|
567
|
-
* the artefacts, never aggregate entries away, and never overwrite one. Each
|
|
568
|
-
* entry becomes exactly one finding. */
|
|
569
|
-
function checkStore() {
|
|
570
|
-
return [
|
|
571
|
-
...readShopperIdentity().unreadable,
|
|
572
|
-
...searchProfileFrontmatter().unreadable,
|
|
573
|
-
].map(({ id, error }) => ({
|
|
574
|
-
id: `store.unreadable:${id}`,
|
|
575
|
-
severity: "warn",
|
|
576
|
-
status: "advisory",
|
|
577
|
-
// Name the artefact AND the corruption — this is what a human reads to go
|
|
578
|
-
// repair the file. The store's own error text describes only the corruption.
|
|
579
|
-
detected: `${id}: ${error}`,
|
|
580
|
-
suggestedAction: "Inspect and repair the artefact by hand — sil never overwrites a corrupt"
|
|
581
|
-
+ " artefact, because it may still be recoverable.",
|
|
582
|
-
appliedAction: null,
|
|
583
|
-
}));
|
|
584
|
-
}
|
|
585
|
-
// ===========================================================================
|
|
586
|
-
/** The OS cause, never a token or PII — mirrors the store's
|
|
587
|
-
* `persistence_failed.error` discipline. */
|
|
549
|
+
/** The OS cause, never a token or PII. */
|
|
588
550
|
function causeOf(err) {
|
|
589
551
|
return err instanceof Error ? err.message : String(err);
|
|
590
552
|
}
|