sil-openclaw 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/EXAMPLES.md +93 -0
- package/README.md +50 -113
- package/SECURITY.md +9 -6
- package/assets/banner-dark.svg +15 -0
- package/assets/banner.svg +15 -0
- package/dist/gateway/screen.js +174 -0
- package/dist/index.js +5 -9
- package/dist/lib/answers.js +59 -0
- package/dist/lib/screen-log.js +13 -0
- package/dist/lib/shopping-call.js +23 -28
- package/dist/lib/sil-client.js +19 -8
- package/dist/tools/catalog.js +69 -72
- package/dist/tools/identity.js +10 -6
- package/openclaw.plugin.json +2 -2
- package/package.json +4 -2
- package/schema/PROVENANCE.md +1 -1
- package/schema/shopping-brief-read-request.schema.json +2 -1
- package/schema/shopping-brief-read-response.schema.json +98 -50
- package/schema/shopping-brief-write-request.schema.json +202 -105
- package/schema/shopping-content-request.schema.json +12 -28
- package/schema/shopping-content-response.schema.json +49 -256
- package/schema/shopping-domain-get-request.schema.json +16 -11
- package/schema/shopping-domain-get-response.schema.json +24 -460
- package/schema/shopping-domain-search-request.schema.json +3 -3
- package/schema/shopping-domain-search-response.schema.json +3 -56
- package/schema/shopping-offers-request.schema.json +28 -174
- package/schema/shopping-offers-response.schema.json +369 -102
- package/schema/shopping-product-get-request.schema.json +3 -2
- package/schema/shopping-product-get-response.schema.json +332 -128
- package/schema/shopping-search-request.schema.json +41 -19
- package/schema/shopping-search-response.schema.json +405 -187
- package/schema/shopping-seller-get-request.schema.json +13 -1
- package/schema/shopping-seller-get-response.schema.json +488 -147
- package/schema/shopping-user-read-request.schema.json +2 -1
- package/schema/shopping-user-read-response.schema.json +2 -2
- package/schema/shopping-user-remember-request.schema.json +9 -8
- package/schema/sil-whoami-response.schema.json +37 -28
- package/sil-shopping/SKILL.md +132 -137
- package/dist/gateway/search-results.js +0 -99
- package/dist/lib/search-results-log.js +0 -23
- package/dist/lib/search-results-store.js +0 -116
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The search-results delivery buffer.
|
|
3
|
-
*
|
|
4
|
-
* `shopping_search` returns its full page to the agent exactly as it always has —
|
|
5
|
-
* this store is a pure SIDE EFFECT on the `ok` path, invisible to every
|
|
6
|
-
* channel. It exists because the host's projection of a tool result is not a
|
|
7
|
-
* dependable transport for structured data: under codex `data.result` is absent
|
|
8
|
-
* from every frame, and the transcript that would otherwise carry it is both
|
|
9
|
-
* provider-capped and rewritten under context pressure as a run grows. A client
|
|
10
|
-
* that wants to render an intermediate search therefore needs its own way to
|
|
11
|
-
* fetch it — `sil.search_results` (see `../gateway/search-results.ts`) reads
|
|
12
|
-
* this map and answers over the paired `deviceToken` WS.
|
|
13
|
-
*
|
|
14
|
-
* The key is the HOST's `callId`, verbatim — never prefixed, hashed, or
|
|
15
|
-
* re-minted. `execute()` receives it BEFORE any I/O, so a page can never be
|
|
16
|
-
* orphaned by a failing search. A client joins on
|
|
17
|
-
* `data.toolCallId ?? data.itemId`, in that order: the id is the same string on
|
|
18
|
-
* every frame, but the FIELD NAME differs per family (`session.tool` carries
|
|
19
|
-
* only `toolCallId`, the `agent`/`stream:"item"` frames only `itemId`) and on
|
|
20
|
-
* the non-codex path `itemId` is `tool:`-prefixed — see
|
|
21
|
-
* `docs/decisions/search-results-pull-surface.md`. Because that id is visible to
|
|
22
|
-
* anyone who can see the frames, knowledge of a `callId` is NOT evidence of
|
|
23
|
-
* entitlement: the principal check below is the only gate that matters.
|
|
24
|
-
*
|
|
25
|
-
* In-memory, by choice. Process death is the strongest retention ceiling
|
|
26
|
-
* available and costs nothing; an on-disk buffer would put prices, seller
|
|
27
|
-
* identity, and buy URLs at rest, widen the plugin's declared filesystem
|
|
28
|
-
* scope, and — with no timers allowed — leave the last pages there forever once
|
|
29
|
-
* the user stops searching.
|
|
30
|
-
*
|
|
31
|
-
* TIMER-FREE, and that is load-bearing: `register()` must stay synchronous and
|
|
32
|
-
* open nothing, so eviction is lazy on write. Reads are pure — they never
|
|
33
|
-
* evict, never reorder, and never consume, because a client remount or reload
|
|
34
|
-
* re-resolves the same page and a one-shot read would blank the shopper's
|
|
35
|
-
* screen on the first refresh.
|
|
36
|
-
*/
|
|
37
|
-
/**
|
|
38
|
-
* Fifteen minutes. A search result is point-in-time — the price range and the page it
|
|
39
|
-
* was read off are exactly what a shopper must re-read before buying —
|
|
40
|
-
* so this is long enough for the settle edge, a client reload, a reconnect, and
|
|
41
|
-
* a short step-away, and short enough that nothing renders as stale truth. It
|
|
42
|
-
* is a delivery buffer, not scrollback and not history.
|
|
43
|
-
*/
|
|
44
|
-
export const RETENTION_MS = 15 * 60_000;
|
|
45
|
-
/**
|
|
46
|
-
* Sized against a whole RUN, not a single request: a real run issues 5–10 tool
|
|
47
|
-
* calls and a client must be able to render EVERY intermediate search in it,
|
|
48
|
-
* not just the last — so a "latest result" slot (or anything near the ≤4-call
|
|
49
|
-
* fan-out one shopper request makes) would evict an early search before the run
|
|
50
|
-
* ends. 32 leaves several runs' worth of headroom at a worst case of roughly
|
|
51
|
-
* 32 × ~51 KB ≈ 1.6 MB, which is nothing against the gateway's own 25 MB frame
|
|
52
|
-
* ceiling. Retention is a CEILING, not a guarantee: past it the product answer
|
|
53
|
-
* is always the same — run a fresh search.
|
|
54
|
-
*/
|
|
55
|
-
export const MAX_ENTRIES = 32;
|
|
56
|
-
const entries = new Map();
|
|
57
|
-
/** Store one `ok` page under the host's `callId`, bound to the sil account that
|
|
58
|
-
* produced it. An empty principal is refused: a page has an owner or it is
|
|
59
|
-
* unreachable, and an ownerless entry would only burn capacity. */
|
|
60
|
-
export function putSearchResult(callId, page, principal) {
|
|
61
|
-
if (principal.length === 0)
|
|
62
|
-
return;
|
|
63
|
-
evict();
|
|
64
|
-
entries.set(callId, { principal, page, expiresAtMs: Date.now() + RETENTION_MS });
|
|
65
|
-
}
|
|
66
|
-
/** The stored page, or `null` for every miss — unknown, expired, and foreign are
|
|
67
|
-
* ONE outcome to the caller. Pure: no eviction, no reordering, no consumption,
|
|
68
|
-
* so a client remount re-resolves the same page and a foreign probe cannot deny
|
|
69
|
-
* the owner theirs. */
|
|
70
|
-
export function getSearchResult(callId, principal) {
|
|
71
|
-
return lookup(callId, principal).page;
|
|
72
|
-
}
|
|
73
|
-
/** The miss cause, for the OPERATOR LOG only (criterion C3) — never the wire.
|
|
74
|
-
* A separate query rather than a richer return, because the wire path must not
|
|
75
|
-
* be able to reach the cause by accident: reading it is a deliberate call. */
|
|
76
|
-
export function searchResultMiss(callId, principal) {
|
|
77
|
-
return lookup(callId, principal).miss;
|
|
78
|
-
}
|
|
79
|
-
/** Reset for tests. Production never calls this — the process IS the lifetime. */
|
|
80
|
-
export function __resetSearchResultsStore() {
|
|
81
|
-
entries.clear();
|
|
82
|
-
}
|
|
83
|
-
function lookup(callId, principal) {
|
|
84
|
-
const entry = entries.get(callId);
|
|
85
|
-
if (entry === undefined)
|
|
86
|
-
return { page: null, miss: "unknown" };
|
|
87
|
-
if (entry.expiresAtMs <= Date.now())
|
|
88
|
-
return { page: null, miss: "expired" };
|
|
89
|
-
// An empty principal is the anonymous bucket, and there is no legitimate
|
|
90
|
-
// anonymous owner — it must not match, not even an entry stored under one.
|
|
91
|
-
if (principal.length === 0 || entry.principal !== principal) {
|
|
92
|
-
return { page: null, miss: "principal_mismatch" };
|
|
93
|
-
}
|
|
94
|
-
return { page: entry.page, miss: null };
|
|
95
|
-
}
|
|
96
|
-
/** Lazy eviction, run on every write: drop what has expired, then trim to
|
|
97
|
-
* capacity oldest-first. `Map` preserves insertion order and reads never touch
|
|
98
|
-
* it, so "oldest" is insertion order — deliberately not LRU-on-read, which
|
|
99
|
-
* would make a read mutate the store. */
|
|
100
|
-
function evict() {
|
|
101
|
-
const now = Date.now();
|
|
102
|
-
for (const [callId, entry] of entries) {
|
|
103
|
-
if (entry.expiresAtMs <= now)
|
|
104
|
-
entries.delete(callId);
|
|
105
|
-
}
|
|
106
|
-
// `>=` because this runs BEFORE the `set`, so the store never exceeds the
|
|
107
|
-
// ceiling. Re-writing an existing `callId` can trim one entry it did not need
|
|
108
|
-
// to; a `callId` is unique per tool call, so that branch is unreachable in
|
|
109
|
-
// practice and guarding it would cost more than it saves.
|
|
110
|
-
while (entries.size >= MAX_ENTRIES) {
|
|
111
|
-
const oldest = entries.keys().next();
|
|
112
|
-
if (oldest.done === true)
|
|
113
|
-
return;
|
|
114
|
-
entries.delete(oldest.value);
|
|
115
|
-
}
|
|
116
|
-
}
|