sil-openclaw 0.2.1 → 0.2.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 +19 -1
- package/dist/lib/sil-client.js +25 -7
- package/dist/tools/identity.js +21 -11
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
All notable changes to the `sil-openclaw` plugin (npm `sil-openclaw`, ClawHub
|
|
3
|
+
All notable changes to the `sil-openclaw` plugin (npm `sil-openclaw`, ClawHub `@4gpts/sil`) are documented here. The format follows
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project adheres
|
|
5
5
|
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
@@ -10,6 +10,24 @@ release (`clawhub package publish --changelog`). See [README](./README.md#releas
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.2.2] - 2026-06-13
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **`sil_register` no longer aborts registration on the first premature claim
|
|
18
|
+
`404`.** The claim poll's first tick fires seconds in, before the user opens
|
|
19
|
+
the auth URL — but the session row is created server-side only when they do, so
|
|
20
|
+
the endpoint returns `404` (`not_found`) until then. That first `not_found` was
|
|
21
|
+
grouped with the genuine terminals, killing registration before the human could
|
|
22
|
+
act. `not_found` is now a keep-polling state (like `pending`), bounded by the
|
|
23
|
+
30-min deadline: a session that never appears settles as `timeout`, never as
|
|
24
|
+
`not_found`. Terminality now lives at the poll loop, not the wire classifier. (#18)
|
|
25
|
+
- **`400` / unexpected non-2xx claim responses now fail fast** via a new distinct
|
|
26
|
+
`invalid_request` outcome, instead of riding the keep-polling `not_found` path
|
|
27
|
+
and spinning to a misleading `timeout`. Unreachable from this client today (the
|
|
28
|
+
plugin always sends a valid verifier), so it logs at WARN as contract-drift
|
|
29
|
+
insurance.
|
|
30
|
+
|
|
13
31
|
## [0.2.1] - 2026-06-11
|
|
14
32
|
|
|
15
33
|
### Changed
|
package/dist/lib/sil-client.js
CHANGED
|
@@ -10,10 +10,17 @@
|
|
|
10
10
|
* POST /api/v1/sessions/{id}/claim body { code_verifier }
|
|
11
11
|
* 200 { access_token, refresh_token, user:{id} } → success (EXACTLY once)
|
|
12
12
|
* 200 { status: "pending" } → pending
|
|
13
|
-
* 409 → already_claimed
|
|
14
|
-
* 410 → expired
|
|
13
|
+
* 409 → already_claimed (terminal)
|
|
14
|
+
* 410 → expired (terminal)
|
|
15
15
|
* 404 → not_found (wrong verifier
|
|
16
|
-
* ≡ unknown session, uniform)
|
|
16
|
+
* ≡ unknown session, uniform);
|
|
17
|
+
* the NORMAL pre-session early
|
|
18
|
+
* state — KEEP POLLING at the
|
|
19
|
+
* loop (non-terminal); only the
|
|
20
|
+
* deadline ends it (as timeout)
|
|
21
|
+
* 400 / other unexpected non-2xx → invalid_request (non-polling
|
|
22
|
+
* terminal — fail fast; a bad
|
|
23
|
+
* request can't be re-polled)
|
|
17
24
|
* 5xx / network / abort → retryable
|
|
18
25
|
*
|
|
19
26
|
* POST /api/v1/auth/refresh body { refresh_token }
|
|
@@ -134,7 +141,16 @@ const REQUEST_TIMEOUT_MS = 15_000;
|
|
|
134
141
|
* Classify a claim response from its HTTP status AND body. The discriminant for
|
|
135
142
|
* the two-200s split is the PRESENCE OF BOTH TOKENS in the body — never the
|
|
136
143
|
* status code. A 200 that is not a complete token pair is `pending` (the safe
|
|
137
|
-
* non-terminal landing)
|
|
144
|
+
* non-terminal landing). 409/410 are distinct terminals; 5xx is retryable.
|
|
145
|
+
*
|
|
146
|
+
* 404 is `not_found` ON THE WIRE — but it is the NORMAL pre-session early state
|
|
147
|
+
* (the session row is INSERTed server-side only when the user opens the auth
|
|
148
|
+
* URL), so its terminality lives at the LOOP, not here: `claimStep` keeps polling
|
|
149
|
+
* on `not_found` and only the 30-min deadline ends a never-appearing session (as
|
|
150
|
+
* `timeout`). A 400 / any other unexpected non-{200,409,410,404,5xx} status is a
|
|
151
|
+
* structurally-malformed request that re-polling can never fix, so it is its OWN
|
|
152
|
+
* non-polling terminal `invalid_request` (fail fast) rather than riding the
|
|
153
|
+
* keep-polling `not_found` path and spinning for the full deadline.
|
|
138
154
|
*
|
|
139
155
|
* Pure and exported — this is the highest-risk subtle branch, unit-tested in
|
|
140
156
|
* isolation (sil-client.test.ts).
|
|
@@ -149,9 +165,11 @@ export function classifyClaimResponse(status, body) {
|
|
|
149
165
|
if (status >= 500)
|
|
150
166
|
return { kind: "retryable" };
|
|
151
167
|
if (status !== 200) {
|
|
152
|
-
// 400 (malformed request) or any other unexpected
|
|
153
|
-
//
|
|
154
|
-
|
|
168
|
+
// 400 (malformed request) or any other unexpected non-2xx: a NON-polling
|
|
169
|
+
// terminal — re-polling can't fix a structurally-bad request, so fail fast
|
|
170
|
+
// and loud rather than spinning to the deadline. Distinct from the early
|
|
171
|
+
// 404 `not_found`, which DOES keep polling.
|
|
172
|
+
return { kind: "invalid_request" };
|
|
155
173
|
}
|
|
156
174
|
// 200 — classify by body shape. Both tokens required for a clean success;
|
|
157
175
|
// anything short of that is the safe non-terminal `pending`.
|
package/dist/tools/identity.js
CHANGED
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
* 4. Start a fire-and-forget bounded poll of the claim endpoint, then return
|
|
20
20
|
* promptly with `{ status: "awaiting_browser", auth_url, session_id }`.
|
|
21
21
|
* 5. On the poll's terminal success, persist tokens.json + config.json
|
|
22
|
-
* atomically. Other terminals (expired / already_claimed /
|
|
22
|
+
* atomically. Other terminals (expired / already_claimed / invalid_request /
|
|
23
23
|
* timeout) persist nothing; the agent learns the outcome by re-calling
|
|
24
|
-
* sil_register (→ already_registered) or sil_whoami.
|
|
24
|
+
* sil_register (→ already_registered) or sil_whoami. A claim 404 (`not_found`)
|
|
25
|
+
* is NOT a terminal — it is the normal pre-session early state and keeps the
|
|
26
|
+
* poll ticking; a session that never appears ends as `timeout` at the deadline.
|
|
25
27
|
*
|
|
26
28
|
* register() must stay synchronous and side-effect-free beyond registering the
|
|
27
29
|
* tool — no fetch, no timer, no unawaited promise here. The poll timer is armed
|
|
@@ -232,17 +234,22 @@ function transient() {
|
|
|
232
234
|
}
|
|
233
235
|
/**
|
|
234
236
|
* One poll step: claim, then map the outcome to the loop's done/continue signal.
|
|
235
|
-
* `pending`/`retryable` keep the loop alive (`done:false`).
|
|
236
|
-
* is
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
237
|
+
* `pending`/`retryable`/`not_found` keep the loop alive (`done:false`). The 404
|
|
238
|
+
* `not_found` is the NORMAL pre-session early state (the session row is INSERTed
|
|
239
|
+
* server-side only when the user opens the auth URL), so it keeps polling exactly
|
|
240
|
+
* like `pending`, bounded by the 30-min deadline — a session that never appears
|
|
241
|
+
* settles as `timeout`, never as `not_found`. A successful claim is persisted
|
|
242
|
+
* HERE — tokens.json + config.json written atomically inside this awaited tick —
|
|
243
|
+
* so the files are on disk before the loop settles; the step then carries only
|
|
244
|
+
* the user_id forward (the tokens never travel past this closure). The terminals
|
|
245
|
+
* (expired / already_claimed / invalid_request) persist nothing.
|
|
240
246
|
*/
|
|
241
247
|
async function claimStep(apiUrl, sessionId, verifier) {
|
|
242
248
|
const outcome = await claimSession(apiUrl, sessionId, verifier);
|
|
243
249
|
switch (outcome.kind) {
|
|
244
250
|
case "pending":
|
|
245
251
|
case "retryable":
|
|
252
|
+
case "not_found":
|
|
246
253
|
return { done: false };
|
|
247
254
|
case "success":
|
|
248
255
|
await writeTokens({
|
|
@@ -253,7 +260,7 @@ async function claimStep(apiUrl, sessionId, verifier) {
|
|
|
253
260
|
return { done: true, outcome: "success", user_id: outcome.user.id };
|
|
254
261
|
case "expired":
|
|
255
262
|
case "already_claimed":
|
|
256
|
-
case "
|
|
263
|
+
case "invalid_request":
|
|
257
264
|
return { done: true, outcome: outcome.kind };
|
|
258
265
|
}
|
|
259
266
|
}
|
|
@@ -275,11 +282,14 @@ function handleDone(api, sessionId, result) {
|
|
|
275
282
|
api.logger.info("sil_register_timeout", { session_id: sessionId });
|
|
276
283
|
return;
|
|
277
284
|
}
|
|
278
|
-
// expired / already_claimed /
|
|
279
|
-
// never silent; the agent learns it on its next sil_register / sil_whoami.
|
|
285
|
+
// expired / already_claimed / invalid_request — log the terminal so the outcome
|
|
286
|
+
// is never silent; the agent learns it on its next sil_register / sil_whoami.
|
|
287
|
+
// `invalid_request` logs at WARN: a malformed claim request is unreachable from
|
|
288
|
+
// this client today, so it signals a contract-drift bug, not a user outcome —
|
|
289
|
+
// make it loud (the genuine `expired`/`already_claimed` are routine, at info).
|
|
280
290
|
const outcome = typeof step.outcome === "string" ? step.outcome : "unknown";
|
|
281
291
|
const marker = `sil_register_${outcome}`;
|
|
282
|
-
if (outcome === "
|
|
292
|
+
if (outcome === "invalid_request") {
|
|
283
293
|
api.logger.warn(marker, { session_id: sessionId });
|
|
284
294
|
}
|
|
285
295
|
else {
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "sil",
|
|
3
3
|
"name": "sil",
|
|
4
4
|
"description": "sil commerce plugin for OpenClaw — register on sil, read your identity, and search and look up products in the sil catalog.",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.2",
|
|
6
6
|
"skills": ["./skill"],
|
|
7
7
|
"activation": {
|
|
8
8
|
"onCapabilities": ["tool"]
|
package/package.json
CHANGED