sil-openclaw 0.5.1 → 0.5.2

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 CHANGED
@@ -10,6 +10,16 @@ release (`clawhub package publish --changelog`). See [README](./README.md#releas
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.5.2] - 2026-10-06
14
+
15
+ ### Added
16
+
17
+ - **Every `shopping_*` call says who is calling**, as sil-api now requires: the
18
+ conversation (`sil-session-id`), the tool call (`sil-tool-call-id`, `sil-attempt` —
19
+ `2` on the one retry after a refreshed sign-in), the model (`sil-model`) and both
20
+ versions (`sil-openclaw-version`, `sil-plugin-version`). The tools are registered as
21
+ per-run factories to read these from the host. Never the chat-handle session key.
22
+
13
23
  ## [0.5.1] - 2026-09-30
14
24
 
15
25
  ### Changed
@@ -18,12 +18,12 @@ function refused(status, result) {
18
18
  * Every non-`ok` outcome comes back as its finished envelope, so no caller re-derives
19
19
  * the taxonomy.
20
20
  */
21
- export async function callRoute(api, call, args) {
21
+ export async function callRoute(api, call, args, caller) {
22
22
  const stored = readTokens();
23
23
  if (stored === null)
24
24
  return refused("not_registered", notRegistered(call.name));
25
- const first = await callShopping(getApiUrl(), stored.access_token, call, args);
26
- const recovered = await refreshAndRetryOnce(first, (o) => o.kind === "unauthorized", (accessToken) => callShopping(getApiUrl(), accessToken, call, args));
25
+ const first = await callShopping(getApiUrl(), stored.access_token, call, args, caller, 1);
26
+ const recovered = await refreshAndRetryOnce(first, (o) => o.kind === "unauthorized", (accessToken) => callShopping(getApiUrl(), accessToken, call, args, caller, 2));
27
27
  switch (recovered.kind) {
28
28
  case "result":
29
29
  if (recovered.refreshed)
@@ -274,7 +274,7 @@ export async function fetchIdentity(silApiUrl, token) {
274
274
  * The Bearer header is built HERE and never logged; the token travels only in the
275
275
  * outbound request, never into the returned union.
276
276
  */
277
- export async function callShopping(silApiUrl, token, route, args) {
277
+ export async function callShopping(silApiUrl, token, route, args, caller, attempt) {
278
278
  const path = routePath(route, args);
279
279
  if (typeof path !== "string") {
280
280
  return {
@@ -285,19 +285,34 @@ export async function callShopping(silApiUrl, token, route, args) {
285
285
  };
286
286
  }
287
287
  const url = `${stripTrailingSlash(silApiUrl)}${path}`;
288
+ const headers = { authorization: `Bearer ${token}`, ...callerHeaders(caller, attempt) };
288
289
  let res;
289
290
  try {
290
291
  const timeoutMs = requestTimeoutMs(route);
291
292
  res =
292
293
  route.method === "GET"
293
- ? await getJson(url, { authorization: `Bearer ${token}` }, timeoutMs)
294
- : await postJson(url, args, { authorization: `Bearer ${token}` }, timeoutMs);
294
+ ? await getJson(url, headers, timeoutMs)
295
+ : await postJson(url, args, headers, timeoutMs);
295
296
  }
296
297
  catch {
297
298
  return { kind: "retryable" };
298
299
  }
299
300
  return classifyShoppingResponse(res.status, await readJsonBody(res));
300
301
  }
302
+ /** sil-api's rule for every caller header. A value outside it is dropped, not sent: fetch
303
+ * throws on a non-Latin-1 header before sending, and the catch would read that as retryable. */
304
+ const HEADER_VALUE = /^[\x21-\x7E]+$/;
305
+ function callerHeaders(caller, attempt) {
306
+ const headers = [
307
+ ["sil-session-id", caller.sessionId],
308
+ ["sil-tool-call-id", caller.toolCallId],
309
+ ["sil-attempt", String(attempt)],
310
+ ["sil-model", caller.model],
311
+ ["sil-openclaw-version", caller.openclawVersion],
312
+ ["sil-plugin-version", caller.pluginVersion],
313
+ ];
314
+ return Object.fromEntries(headers.filter((h) => h[1] !== undefined && HEADER_VALUE.test(h[1])));
315
+ }
301
316
  /**
302
317
  * The route's path with its `:name` segment filled and its querystring built — or the
303
318
  * name of the segment the arguments could not fill.
@@ -8,11 +8,12 @@
8
8
  */
9
9
  import { requestSchema } from "../lib/artifacts.js";
10
10
  import { readConfig } from "../lib/credentials.js";
11
- import { wiringAdvisoryBlocks } from "../lib/host-wiring.js";
11
+ import { readHostVersion, wiringAdvisoryBlocks } from "../lib/host-wiring.js";
12
12
  import { logSearchResults } from "../lib/search-results-log.js";
13
13
  import { putSearchResult } from "../lib/search-results-store.js";
14
14
  import { DOMAIN_GET_ROUTE, callRoute } from "../lib/shopping-call.js";
15
15
  import { jsonResult } from "../lib/tool-result.js";
16
+ import { readInstalledVersion } from "../lib/version-advisory.js";
16
17
  /** The tool whose page a paired client can pull back by `callId`. */
17
18
  const SEARCH_TOOL = "shopping_search";
18
19
  export const SHOPPING_TOOLS = [
@@ -277,19 +278,35 @@ export const SHOPPING_TOOLS = [
277
278
  * `ensureDataDir`'s `mkdirSync` does. It is deliberately eager — an unreadable artifact
278
279
  * is a broken build, and failing loud at load beats a tool whose `parameters` the host
279
280
  * has already published by the time anyone finds out.
281
+ *
282
+ * Each tool is a factory because the host hands the conversation and the model only to a
283
+ * factory, once per agent run; every call that run makes says who is calling.
280
284
  */
281
285
  export function registerCatalogTools(api) {
282
- for (const tool of SHOPPING_TOOLS)
283
- api.registerTool(defineTool(api, tool));
286
+ const pluginVersion = readInstalledVersion();
287
+ const openclawVersion = readHostVersion(api) ?? undefined;
288
+ for (const tool of SHOPPING_TOOLS) {
289
+ const parameters = requestSchema(tool.name);
290
+ api.registerTool((ctx) => {
291
+ const { provider, modelId } = ctx.activeModel ?? {};
292
+ const run = {
293
+ pluginVersion,
294
+ ...(openclawVersion !== undefined ? { openclawVersion } : {}),
295
+ ...(ctx.sessionId ? { sessionId: ctx.sessionId } : {}),
296
+ ...(provider && modelId ? { model: `${provider}/${modelId}` } : {}),
297
+ };
298
+ return defineTool(api, tool, parameters, run);
299
+ }, { name: tool.name });
300
+ }
284
301
  }
285
- function defineTool(api, tool) {
302
+ function defineTool(api, tool, parameters, run) {
286
303
  return {
287
304
  name: tool.name,
288
305
  label: tool.label,
289
306
  description: tool.description,
290
- parameters: requestSchema(tool.name),
307
+ parameters,
291
308
  async execute(callId, params) {
292
- const called = await callRoute(api, tool, params);
309
+ const called = await callRoute(api, tool, params, { ...run, toolCallId: callId });
293
310
  if (called.kind === "refused") {
294
311
  if (tool.name === SEARCH_TOOL)
295
312
  skipped(api, callId, `refused:${called.status}`);
@@ -2,7 +2,7 @@
2
2
  "id": "sil",
3
3
  "name": "sil",
4
4
  "description": "Turn your OpenClaw into an expert shopping agent.",
5
- "version": "0.5.1",
5
+ "version": "0.5.2",
6
6
  "skills": ["./sil-shopping"],
7
7
  "activation": {
8
8
  "onCapabilities": ["tool"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sil-openclaw",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Turn your OpenClaw into an expert shopping agent.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {