@senpi-ai/runtime 3.0.98 → 3.0.105
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/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +38 -0
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +29 -1
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/cli/update-command.d.ts +69 -0
- package/dist/cli/update-command.d.ts.map +1 -0
- package/dist/cli/update-command.js +153 -0
- package/dist/cli/update-command.js.map +1 -0
- package/dist/dsl/plugin/index.d.ts +35 -1
- package/dist/dsl/plugin/index.d.ts.map +1 -1
- package/dist/dsl/plugin/index.js +62 -7
- package/dist/dsl/plugin/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +205 -27
- package/dist/index.js.map +1 -1
- package/dist/runtime/effective-config.d.ts +67 -0
- package/dist/runtime/effective-config.d.ts.map +1 -0
- package/dist/runtime/effective-config.js +324 -0
- package/dist/runtime/effective-config.js.map +1 -0
- package/dist/runtime/lifecycle-events.d.ts +19 -0
- package/dist/runtime/lifecycle-events.d.ts.map +1 -1
- package/dist/runtime/lifecycle-events.js +27 -0
- package/dist/runtime/lifecycle-events.js.map +1 -1
- package/dist/runtime/rebuild-errors.d.ts +26 -0
- package/dist/runtime/rebuild-errors.d.ts.map +1 -0
- package/dist/runtime/rebuild-errors.js +36 -0
- package/dist/runtime/rebuild-errors.js.map +1 -0
- package/dist/runtime/run.d.ts +10 -0
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +13 -1
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime.d.ts +146 -1
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +511 -148
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/strategy-registry.d.ts +1 -0
- package/dist/runtime/strategy-registry.d.ts.map +1 -1
- package/dist/runtime/strategy-registry.js +19 -0
- package/dist/runtime/strategy-registry.js.map +1 -1
- package/dist/runtime/update-apply-deps.d.ts +101 -0
- package/dist/runtime/update-apply-deps.d.ts.map +1 -0
- package/dist/runtime/update-apply-deps.js +159 -0
- package/dist/runtime/update-apply-deps.js.map +1 -0
- package/dist/runtime/update-handler.d.ts +197 -0
- package/dist/runtime/update-handler.d.ts.map +1 -0
- package/dist/runtime/update-handler.js +381 -0
- package/dist/runtime/update-handler.js.map +1 -0
- package/dist/runtime/update-plan.d.ts +60 -0
- package/dist/runtime/update-plan.d.ts.map +1 -0
- package/dist/runtime/update-plan.js +203 -0
- package/dist/runtime/update-plan.js.map +1 -0
- package/dist/runtime/update-register.d.ts +67 -0
- package/dist/runtime/update-register.d.ts.map +1 -0
- package/dist/runtime/update-register.js +173 -0
- package/dist/runtime/update-register.js.map +1 -0
- package/dist/runtime/update-report.d.ts +125 -0
- package/dist/runtime/update-report.d.ts.map +1 -0
- package/dist/runtime/update-report.js +215 -0
- package/dist/runtime/update-report.js.map +1 -0
- package/dist/runtime-api/intake/intake-events.d.ts +4 -2
- package/dist/runtime-api/intake/intake-events.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-events.js +4 -2
- package/dist/runtime-api/intake/intake-events.js.map +1 -1
- package/dist/runtime-api/intake/intake-mount.d.ts +2 -0
- package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-mount.js +8 -20
- package/dist/runtime-api/intake/intake-mount.js.map +1 -1
- package/dist/runtime-api/intake/scaffold-error-router.d.ts +43 -0
- package/dist/runtime-api/intake/scaffold-error-router.d.ts.map +1 -0
- package/dist/runtime-api/intake/scaffold-error-router.js +63 -0
- package/dist/runtime-api/intake/scaffold-error-router.js.map +1 -0
- package/dist/scanners/external/scaffold/scaffold.py +94 -1
- package/dist/scanners/external/scaffold/senpi_mcp.py +427 -71
- package/dist/utils/event-catalog.d.ts +29 -2
- package/dist/utils/event-catalog.d.ts.map +1 -1
- package/dist/utils/event-catalog.js +2 -1
- package/dist/utils/event-catalog.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `/errors` route's `onError` — ONE implementation, used by both call sites.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* TICK_FAILURE_TYPES — the body types that mean "tick failed"
|
|
6
|
+
* buildScaffoldErrorRouter(ctx, runtimeHandles) → (scannerId, error) => void
|
|
7
|
+
*
|
|
8
|
+
* WHY THIS MODULE EXISTS: this routing decision used to be written twice — once
|
|
9
|
+
* as `buildIntakeMount`'s `onScaffoldError` (which the only production caller
|
|
10
|
+
* destructures away, so it ran in tests only) and once hand-copied into a closure
|
|
11
|
+
* inside `initCore`, which is what the route actually installs. The copies drifted
|
|
12
|
+
* the moment `mcp_error` was added to the list: the tested one counted it, the
|
|
13
|
+
* live one dropped it, and the failure was self-concealing because the signal that
|
|
14
|
+
* would have surfaced it IS the signal that was broken. Both sites now call this.
|
|
15
|
+
*/
|
|
16
|
+
// ── scaffold tick failure types ──────────────────────────────────────────────
|
|
17
|
+
/**
|
|
18
|
+
* The `/errors` body types that mean "this tick failed" and are recorded as an
|
|
19
|
+
* error-outcome run. Everything else the scaffold POSTs (`candidate_rejected`) is a
|
|
20
|
+
* per-candidate note on an otherwise-OK tick and must not degrade the scanner.
|
|
21
|
+
*
|
|
22
|
+
* - `error` / `timeout` / `state_persist_failed` — scan() threw, overran, or its
|
|
23
|
+
* state could not be committed (scaffold.py).
|
|
24
|
+
* - `mcp_error` — an otherwise-`ok` tick in which one or more MCP tool calls failed
|
|
25
|
+
* AND scan() produced no candidates (`scaffold.py:_classify_mcp_errors`): the
|
|
26
|
+
* scaffold's own tally reclassifies the tick, because authored code swallows the
|
|
27
|
+
* exception and would otherwise report `ok` forever while blind. MCP errors WITH
|
|
28
|
+
* candidates stay `ok` — a partial read still produced work. The body carries
|
|
29
|
+
* `error_type` (dominant) and `error_count`.
|
|
30
|
+
*/
|
|
31
|
+
export const TICK_FAILURE_TYPES = new Set([
|
|
32
|
+
"error",
|
|
33
|
+
"timeout",
|
|
34
|
+
"state_persist_failed",
|
|
35
|
+
"mcp_error",
|
|
36
|
+
]);
|
|
37
|
+
// ── buildScaffoldErrorRouter ─────────────────────────────────────────────────
|
|
38
|
+
/**
|
|
39
|
+
* Builds the `/errors` counterpart of `onAccepted`. Instead of an ingest it records
|
|
40
|
+
* the failed tick into the owning runtime's scanner telemetry, so a scanner that
|
|
41
|
+
* fails every tick stops rendering "healthy" — `consecutiveErrorCount` and
|
|
42
|
+
* `lastRunStatus` move, and `scanner.runs{outcome=error}` becomes a real series.
|
|
43
|
+
*
|
|
44
|
+
* Resolves against the SHARED IntakeContext registry, so the route and the launcher
|
|
45
|
+
* see the same in-process Map.
|
|
46
|
+
*/
|
|
47
|
+
export function buildScaffoldErrorRouter(ctx, runtimeHandles) {
|
|
48
|
+
return (scannerId, error) => {
|
|
49
|
+
const type = typeof error.type === "string" ? error.type : undefined;
|
|
50
|
+
if (type === undefined || !TICK_FAILURE_TYPES.has(type)) {
|
|
51
|
+
return; // candidate_rejected (or any non-tick-level body) is not a failed run
|
|
52
|
+
}
|
|
53
|
+
const entry = ctx.registry.resolve(scannerId);
|
|
54
|
+
if (!entry)
|
|
55
|
+
return; // zombie fence — should not happen post-accept
|
|
56
|
+
const handle = runtimeHandles.get(entry.runtimeId);
|
|
57
|
+
if (!handle)
|
|
58
|
+
return;
|
|
59
|
+
handle.recordExternalScannerError(entry.scannerName, // configured NAME from registry, not scanner_id
|
|
60
|
+
error);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=scaffold-error-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold-error-router.js","sourceRoot":"","sources":["../../../src/runtime-api/intake/scaffold-error-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,gFAAgF;AAEhF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IAC7D,OAAO;IACP,SAAS;IACT,sBAAsB;IACtB,WAAW;CACZ,CAAC,CAAC;AAEH,gFAAgF;AAEhF;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAAkB,EAClB,cAA0C;IAE1C,OAAO,CAAC,SAAiB,EAAE,KAA8B,EAAQ,EAAE;QACjE,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACrE,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACxD,OAAO,CAAC,sEAAsE;QAChF,CAAC;QACD,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,+CAA+C;QACnE,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,CAAC,0BAA0B,CAC/B,KAAK,CAAC,WAAW,EAAE,gDAAgD;QACnE,KAAgE,CACjE,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -9,9 +9,17 @@ ctx.state, candidates to sink.
|
|
|
9
9
|
passed to scan(). scan() is called as scan(inputs, ctx) — 2-arg, sync, returning a
|
|
10
10
|
plain list[dict]. State mutates ONLY via ctx.state (commit on a clean tick, rollback
|
|
11
11
|
on error/timeout/malformed/failed-persist — transactional discard wins on failure).
|
|
12
|
+
|
|
13
|
+
A tick is also NOT clean when every ctx.senpi_mcp call in it failed and scan()
|
|
14
|
+
returned no candidates (`mcp_error`): authored code routinely swallows the MCP
|
|
15
|
+
exception and returns [], which would otherwise report a blind scanner as ok
|
|
16
|
+
forever. The client tallies its failures per tick; the loop reads the tally after
|
|
17
|
+
scan() returns and reclassifies. MCP failures alongside candidates stay ok, with
|
|
18
|
+
the count carried on `scaffold_tick_finished` as `mcp_error_count`.
|
|
12
19
|
"""
|
|
13
20
|
|
|
14
21
|
import inspect
|
|
22
|
+
import math
|
|
15
23
|
import os
|
|
16
24
|
import time
|
|
17
25
|
import threading
|
|
@@ -36,6 +44,35 @@ from .loop_primitives import (
|
|
|
36
44
|
from .state_manager import StateManager
|
|
37
45
|
|
|
38
46
|
|
|
47
|
+
def _read_call_timeout_seconds(senpi_mcp_mod: Any) -> float:
|
|
48
|
+
"""The per-call MCP bound from the launch env, or the documented default.
|
|
49
|
+
|
|
50
|
+
`SENPI_MCP_CALL_TIMEOUT_SECONDS` is operator-set on the runtime box and
|
|
51
|
+
reaches the scaffold child through the supervisor's inherited env. A value
|
|
52
|
+
that is not a positive finite number must not take the scanner down at
|
|
53
|
+
launch — it falls back to the default and says so (`senpi_mcp_config_invalid`),
|
|
54
|
+
the same "loud, not fatal" shape as a malformed launch config field.
|
|
55
|
+
"""
|
|
56
|
+
variable = senpi_mcp_mod.CALL_TIMEOUT_ENV_VAR
|
|
57
|
+
default = senpi_mcp_mod.DEFAULT_CALL_TIMEOUT_SECONDS
|
|
58
|
+
raw = os.environ.get(variable)
|
|
59
|
+
if raw is None:
|
|
60
|
+
return default
|
|
61
|
+
try:
|
|
62
|
+
seconds = float(raw)
|
|
63
|
+
except ValueError:
|
|
64
|
+
seconds = math.nan
|
|
65
|
+
if not senpi_mcp_mod.is_valid_call_timeout(seconds):
|
|
66
|
+
log_event(
|
|
67
|
+
"senpi_mcp_config_invalid",
|
|
68
|
+
variable=variable,
|
|
69
|
+
value=raw[:100],
|
|
70
|
+
fallback_seconds=default,
|
|
71
|
+
)
|
|
72
|
+
return default
|
|
73
|
+
return seconds
|
|
74
|
+
|
|
75
|
+
|
|
39
76
|
def _build_senpi_mcp() -> Any:
|
|
40
77
|
"""Construct the MCP client when creds are present; else return None.
|
|
41
78
|
|
|
@@ -43,7 +80,8 @@ def _build_senpi_mcp() -> Any:
|
|
|
43
80
|
the launcher regardless of how the operator supplied them. With neither set,
|
|
44
81
|
return None so the no-creds path does not crash — the client is loud at FIRST
|
|
45
82
|
USE (see scaffold.senpi_mcp). Reference the class through the module attribute
|
|
46
|
-
so a test stub patched onto scaffold.senpi_mcp is honored.
|
|
83
|
+
so a test stub patched onto scaffold.senpi_mcp is honored. The per-call bound
|
|
84
|
+
comes from SENPI_MCP_CALL_TIMEOUT_SECONDS (see _read_call_timeout_seconds).
|
|
47
85
|
"""
|
|
48
86
|
api_key = os.environ.get("SENPI_AUTH_TOKEN") or os.environ.get("SENPI_API_KEY") or None
|
|
49
87
|
mcp_url = os.environ.get("SENPI_MCP_URL") or None
|
|
@@ -61,6 +99,7 @@ def _build_senpi_mcp() -> Any:
|
|
|
61
99
|
api_key=api_key,
|
|
62
100
|
mcp_url=mcp_url,
|
|
63
101
|
write_allowlist=senpi_mcp_mod.PRODUCER_WRITE_ALLOWLIST,
|
|
102
|
+
call_timeout_seconds=_read_call_timeout_seconds(senpi_mcp_mod),
|
|
64
103
|
)
|
|
65
104
|
|
|
66
105
|
|
|
@@ -193,6 +232,9 @@ def run_scaffold(
|
|
|
193
232
|
)
|
|
194
233
|
|
|
195
234
|
tick_count = 0
|
|
235
|
+
# The MCP boundary's per-tick failure tally, when the client exposes one. Duck-typed:
|
|
236
|
+
# an injected stub without it (a validation run) simply never reclassifies a tick.
|
|
237
|
+
mcp_tally = getattr(senpi_mcp, "tick_errors", None)
|
|
196
238
|
|
|
197
239
|
try:
|
|
198
240
|
while not stop_event.is_set():
|
|
@@ -207,6 +249,9 @@ def run_scaffold(
|
|
|
207
249
|
tick_status = "ok"
|
|
208
250
|
tick_error = None
|
|
209
251
|
candidates: list = []
|
|
252
|
+
mcp_error_count = 0
|
|
253
|
+
if mcp_tally is not None:
|
|
254
|
+
mcp_tally.reset()
|
|
210
255
|
|
|
211
256
|
armed = False
|
|
212
257
|
try:
|
|
@@ -262,6 +307,24 @@ def run_scaffold(
|
|
|
262
307
|
|
|
263
308
|
duration_ms = int((time.time() - tick_started_at) * 1000)
|
|
264
309
|
|
|
310
|
+
# Authored code routinely catches the MCP exception and returns [], so a
|
|
311
|
+
# scanner whose every tool call failed would otherwise finish `ok` with zero
|
|
312
|
+
# candidates — and keep refreshing liveness while blind. Read the boundary's
|
|
313
|
+
# own tally instead of trusting the return value: on an otherwise-ok tick,
|
|
314
|
+
# MCP errors + no candidates is a failed tick; MCP errors + candidates stays
|
|
315
|
+
# ok (a partial read still produced work). The count rides on the finished
|
|
316
|
+
# event whatever the status, so an error/timeout tick shows its MCP side too.
|
|
317
|
+
mcp_error_count, mcp_failure = _classify_mcp_errors(mcp_tally, candidates)
|
|
318
|
+
if tick_status == "ok" and mcp_failure is not None:
|
|
319
|
+
tick_status = "mcp_error"
|
|
320
|
+
tick_error = mcp_failure
|
|
321
|
+
log_event(
|
|
322
|
+
"scaffold_tick_mcp_error",
|
|
323
|
+
tick=tick_count,
|
|
324
|
+
error_type=mcp_failure["error_type"],
|
|
325
|
+
error_count=mcp_error_count,
|
|
326
|
+
)
|
|
327
|
+
|
|
265
328
|
# --- Clean tick: commit ctx.state, deliver candidates ---
|
|
266
329
|
if tick_status == "ok":
|
|
267
330
|
# Transactional commit. A failed persist RAISES (StateManager
|
|
@@ -321,6 +384,9 @@ def run_scaffold(
|
|
|
321
384
|
status=tick_status,
|
|
322
385
|
duration_ms=duration_ms,
|
|
323
386
|
candidate_count=len(candidates),
|
|
387
|
+
# Present only when the tick saw MCP failures — an absent key is the
|
|
388
|
+
# honest "none", a 0 every tick would be noise on the fingerprint.
|
|
389
|
+
**({"mcp_error_count": mcp_error_count} if mcp_error_count else {}),
|
|
324
390
|
)
|
|
325
391
|
|
|
326
392
|
except _TickTimeout as late_exc:
|
|
@@ -361,6 +427,33 @@ def run_scaffold(
|
|
|
361
427
|
return tick_count
|
|
362
428
|
|
|
363
429
|
|
|
430
|
+
def _classify_mcp_errors(mcp_tally: Any, candidates: list) -> tuple[int, Optional[dict]]:
|
|
431
|
+
"""Read the tick's MCP failure tally and decide whether the tick was really ok.
|
|
432
|
+
|
|
433
|
+
Returns (mcp_error_count, tick_error). tick_error is an `mcp_error` record —
|
|
434
|
+
dominant error type and count — ONLY when the tick had MCP failures and produced
|
|
435
|
+
no candidates; a tick with failures that still produced candidates is ok and
|
|
436
|
+
carries only the count. No tally (no client, or a stub without one) is clean.
|
|
437
|
+
"""
|
|
438
|
+
if mcp_tally is None:
|
|
439
|
+
return 0, None
|
|
440
|
+
snapshot = mcp_tally.snapshot()
|
|
441
|
+
count = int(snapshot.get("count") or 0)
|
|
442
|
+
if count == 0 or candidates:
|
|
443
|
+
return count, None
|
|
444
|
+
dominant = snapshot.get("dominant_error_type") or "unknown"
|
|
445
|
+
plural = "" if count == 1 else "s"
|
|
446
|
+
return count, {
|
|
447
|
+
"type": "mcp_error",
|
|
448
|
+
"error_type": dominant,
|
|
449
|
+
"error_count": count,
|
|
450
|
+
"message": (
|
|
451
|
+
f"{count} MCP tool call{plural} failed this tick (dominant {dominant}) "
|
|
452
|
+
"and scan() produced no candidates; tick discarded"
|
|
453
|
+
),
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
|
|
364
457
|
def _post_error_safe(sink: Any, error: dict, tick_count: int) -> None:
|
|
365
458
|
"""Call sink.post_error(error), swallowing/logging any failure."""
|
|
366
459
|
try:
|