@remits/remits-cli 0.1.91 → 0.1.93

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remits/remits-cli",
3
- "version": "0.1.91",
3
+ "version": "0.1.93",
4
4
  "description": "Local CLI for auth, component sync, and live test execution against Remits",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -95,6 +95,7 @@ description: Use remits-cli for fast branch-scoped component staging, test execu
95
95
  - Line 2169: `mcp_run_agent`
96
96
  - Line 2205: `mcp_system_logs`
97
97
  - Line 2228: `mcp_performance_trace`
98
+ - Line 2260: `mcp_event_diagnostics`
98
99
  - Line 2263: `mcp_component_view`
99
100
  - Line 2286: `mcp_component_grep`
100
101
  - Line 2299: `mcp_support_ticket`
@@ -1179,9 +1180,17 @@ the compile cache without colliding.
1179
1180
  That signature is logged. Querying for it is the single most reliable way to know what ran:
1180
1181
 
1181
1182
  ```bash
1182
- remits-cli tool --name mcp_system_logs --input '{"node":"remitsAdmin-east5","timeRange":"1h","filter":"textPayload:\"Using Cached BCD\""}' --data-mode prod
1183
+ remits-cli tool --name mcp_system_logs --input '{"node":"remitsAdmin-east5","timeRange":"1h","filter":"Using Cached BCD"}' --data-mode prod
1183
1184
  ```
1184
1185
 
1186
+ > **Pass the bare phrase — never hand-write a `textPayload:` filter.** In production the platform's
1187
+ > logback encoder writes every `log.*` line to **`jsonPayload.message`**; only `println`/stdout lands in
1188
+ > `textPayload`. A `textPayload:"..."` filter therefore matches **zero** rows for nearly every platform
1189
+ > log line, and zero rows is indistinguishable from "it never happened" — which has already caused a real
1190
+ > misdiagnosis. `mcp_system_logs` now widens a bare phrase (and any `textPayload:"..."` clause) to cover
1191
+ > both shapes, and echoes the executed filter back as `filterApplied`. A filter that names `jsonPayload`
1192
+ > explicitly is passed through untouched.
1193
+
1185
1194
  `Using Cached BCD [ID: 230, Type: Action, Signature: cli:08cc...]` → ran a **staged** override.
1186
1195
  `...Signature: variant:14:9f2c1a...]` → ran a **committed branch variant**.
1187
1196
  `...Signature: version:37:abc123def456]` → ran the **committed trunk** version.
@@ -1739,8 +1748,13 @@ Before starting an investigation outside the confirmed current repo:
1739
1748
  **Stuck / failed / recovered Event:**
1740
1749
 
1741
1750
  Do **not** open the Action source first. The platform records each attempt's delivery envelope (which
1742
- queue delivered it, which delivery attempt this was, which instance owned it, how long it was ever
1743
- allowed to run) and will classify the failure for you. From a Test or any component:
1751
+ queue delivered it, which delivery attempt this was, and how long it was ever allowed to run) and will classify the failure for you. From remits-cli / MCP, use `mcp_event_diagnostics` first:
1752
+
1753
+ ```bash
1754
+ remits-cli tool --name mcp_event_diagnostics --input '{"accountId":49,"eventId":18838}' --data-mode prod
1755
+ ```
1756
+
1757
+ From a Test or any component, the same platform classifier is available directly:
1744
1758
 
1745
1759
  ```groovy
1746
1760
  eventDiagnostics(18838)
@@ -1764,6 +1778,8 @@ Read `classification` before anything else:
1764
1778
  non-idempotent side effect may have run more than once — check for duplicate records before concluding
1765
1779
  the component "ran twice for no reason".
1766
1780
 
1781
+ `mcp_event_diagnostics` returns the same classification, `delivery.threadGroupingId`, and ready-to-run
1782
+ `pivots` for `mcp_performance_trace`, `mcp_system_logs`, `mcp_record_listing`, and `mcp_object_activity`.
1767
1783
  `delivery.threadGroupingId` is the same id everything else uses, so you can pivot straight into
1768
1784
  `mcp_performance_trace` (`action:"trace"`) or `mcp_system_logs` with it. `logQuery` in the response
1769
1785
  carries ready-made Cloud Logging filters, including the container-lifecycle and 504 queries.
@@ -1889,9 +1905,10 @@ account).
1889
1905
  tells you when the fields shown belong to a different account.
1890
1906
  - `action: 'account_update'` — write Account-schema configuration `fields`, and/or `name`/`status`
1891
1907
  (`ACTIVE`/`ON_HOLD`/`PENDING`).
1892
- - `action: 'user_update'` — write User-schema `fields` under the named account (refused unless the user is a
1893
- member or you pass `addAccount: true`, because the write would otherwise land on another account), plus
1894
- `name`/`enabled` and membership add/remove.
1908
+ - `action: 'user_update'` — write User-schema `fields` under the named account, plus `name`/`enabled` and
1909
+ membership add/remove. Refused unless the user is a member or you pass `addAccount: true`, because the
1910
+ write would otherwise land on another account. If an email does not exist globally, `addAccount: true`
1911
+ intentionally creates that user first, then binds them to the named account before writing fields.
1895
1912
 
1896
1913
  **Building an account hierarchy** (the structural writes — this is how a coding agent provisions accounts
1897
1914
  without a browser):
@@ -2169,6 +2186,41 @@ Returned fields on the async/event start: `actionRunId`, `status:"running"`, `ex
2169
2186
  `threadGroupingId`, `componentSource`, `componentSignature`, and (event mode) `eventId`/`eventStatus`. The
2170
2187
  `status` poll adds `result` on completion, or `message`/`error` on failure.
2171
2188
 
2189
+ > **In event mode the EVENT is the source of truth, not the promise.** `status` is driven by the Event's
2190
+ > own state; the value the dispatch call returned is reported separately as `dispatchResult` and is **not**
2191
+ > the Action's result. Read `eventStatus` for the outcome.
2192
+
2193
+ #### Stopping a run — `controlAction:'interrupt'`
2194
+
2195
+ The tool counterpart of the **Interrupt** button on the admin Events page. Use it when an investigation
2196
+ turns up a run that is consuming resources and should not finish — the case this exists for is finding a
2197
+ `PROCESSING` event that has been running far too long.
2198
+
2199
+ ```bash
2200
+ # the usual path: you found the event in mcp_record_listing / mcp_object_activity
2201
+ remits-cli tool --name mcp_run_action --data-mode prod --input '{"controlAction":"interrupt","accountId":49,"eventId":19102,"reason":"runaway extraction, 45min"}'
2202
+
2203
+ # or stop a run you started yourself (executionMode:'event' only)
2204
+ remits-cli tool --name mcp_run_action --data-mode prod --input '{"controlAction":"interrupt","accountId":4,"actionRunId":"my-run-id"}'
2205
+ ```
2206
+
2207
+ Aliases `cancel` / `stop` / `kill` all work. What you need to know before using it:
2208
+
2209
+ - **It is COOPERATIVE cancellation, not a thread kill.** It sets a flag the running work observes at its
2210
+ next checkpoint, then throws. Checkpoints are dense across everything that matters — every Firestore
2211
+ read/write, outbound HTTP call, AI turn, and front-stage DSL call — so a normal run stops promptly. A
2212
+ run blocked inside a *single* long call (one slow AI turn) stops when that call returns, not instantly.
2213
+ - **Work already committed is NOT rolled back.** This stops further work; it does not undo what has run.
2214
+ - **Only `PENDING`/`QUEUED`/`PROCESSING` can be interrupted.** A terminal event is reported back with its
2215
+ status rather than being silently reported as "interrupted".
2216
+ - **Event-scoped.** A `direct` or `async` run has no Event and cannot be stopped this way.
2217
+ - Tenant-scoped: you cannot interrupt another account's event.
2218
+ - The response returns `previousStatus`, `eventStatus`, and `threadGroupingId`, so you can pivot straight
2219
+ into `mcp_performance_trace` / `mcp_system_logs` to see what it was doing when you stopped it.
2220
+
2221
+ **AI sessions are stopped separately** with `mcp_ai_session_search` (`action:'interrupt'`, plus
2222
+ `pause`/`unpause`) — that controls an agent's conversation loop, whereas this controls an Action's Event.
2223
+
2172
2224
  ### `mcp_run_agent`
2173
2225
  Run one real Agent turn on a target account. The Agent hooks and tools execute for real against the requested
2174
2226
  `dataMode`; pass `dataMode:"test"` for safer tuning.
@@ -2205,6 +2257,24 @@ remits-cli tool --name mcp_ai_session_search --input '{"action":"detail","sessio
2205
2257
  Key returned fields: `agentRunId`, `sessionId`, `status`, `threadGroupingId`, runtime pause/interruption
2206
2258
  hints, `lastAssistantMessage`, `toolCallCount`, `result`, `message`, and `error`.
2207
2259
 
2260
+ #### Controlling a live agent — `pause` / `unpause` / `interrupt`
2261
+
2262
+ ```bash
2263
+ remits-cli tool --name mcp_run_agent --data-mode prod --input '{"controlAction":"pause","accountId":49,"agentRunId":"my-run-id"}'
2264
+ remits-cli tool --name mcp_run_agent --data-mode prod --input '{"controlAction":"interrupt","accountId":49,"sessionId":"<sessionId>"}'
2265
+ ```
2266
+
2267
+ Target the session with the `agentRunId` an async start returned, or the `sessionId` directly.
2268
+
2269
+ - **`interrupt` is TERMINAL** (aliases `stop`/`cancel`/`kill`). It clears any pending resume and pending
2270
+ guardrails and persists a terminal lifecycle status. An interrupted session **cannot be unpaused** —
2271
+ attempting it is refused with that reason rather than silently doing nothing. Use `pause` if you intend
2272
+ to resume.
2273
+ - If the session is not resident on the serving node, it is rehydrated by agent name — so pass `agentName`
2274
+ (or an `agentRunId`, which carries it) when controlling a session you did not just start.
2275
+ - The same controls remain available on `mcp_ai_session_search`, which is the right tool when you are
2276
+ *searching* for the session; this is the right one when you *started* the run.
2277
+
2208
2278
  ### `mcp_system_logs`
2209
2279
  Query Cloud Run service logs.
2210
2280
 
@@ -2218,7 +2288,8 @@ Query Cloud Run service logs.
2218
2288
  | `endTime` | no | ISO 8601 upper bound (defaults to now) |
2219
2289
  | `severity` | no | Minimum: `INFO`, `WARNING`, `ERROR`, etc. |
2220
2290
  | `threadGroupingId` | no | Filter by processing chain ID |
2221
- | `filter` | no | Additional Cloud Logging filter (LQL) |
2291
+ | `filter` | no | Additional Cloud Logging filter (LQL). **To search message text, pass the bare phrase** — it is widened automatically to match both `jsonPayload.message` (all `log.*` output) and `textPayload` (`println`/stdout). See the warning under "Diagnosing which version is in play". |
2292
+ | `maxPreviewChars` | no | Per-entry truncation width. Default 512, max 8000. Raise it when an entry carries a structured payload (a serialized `RemitsTrace`, a long stack frame) that the default cuts mid-JSON. |
2222
2293
  | `pageSize` | no | Default 25, max 100. Also accepts `limit`. |
2223
2294
 
2224
2295
  *Provide either `node` or `serviceName`+`region`. Provide either `timeRange` or `startTime`.
@@ -2252,17 +2323,64 @@ remits-cli tool --name mcp_performance_trace --input '{"action":"snapshot","limi
2252
2323
  | `traceId` / `threadGroupingId` | for `trace` | Request/grouping id to open across local ring and Cloud Logging. |
2253
2324
  | `lookbackHours` | no | Cloud Logging window for `trace`/`slowest`. Defaults are 6 and 4 hours. |
2254
2325
  | `accountId` | no | Account filter for `slowest`. |
2255
- | `kind` | no | Operation kind filter for `slowest`, e.g. `embeddable`, `action`, `reader`. |
2326
+ | `kind` | no | Operation kind filter for `slowest`. **Rarely what you want** — see the note below. |
2327
+ | `componentType` | no | Filter `slowest` by the component that did the work: `Action`, `Reader`, `Rule`, `Embeddable`, `Tool`, `Test`. **This is the right axis for "which Actions/Rules are slow".** |
2328
+ | `componentId` / `componentName` | no | Narrow `slowest` to one component. |
2329
+
2330
+ > **Filter by `componentType`, not `kind`.** `kind` is set by whoever OPENS the trace. An Action delivered
2331
+ > by Cloud Tasks arrives over HTTP, so the trace is `kind:'web'` and the Action is a `component.Action`
2332
+ > *span inside it*; a Rule fired during a request and a Tool invoked by an agent are the same. So
2333
+ > `kind:'action'` matches almost nothing in production. Every component execution annotates
2334
+ > `componentType`/`componentId`/`componentName` — filter on those.
2256
2335
  | `minMs` | no | Minimum duration for `slowest`. Default: 1500. |
2257
2336
  | `limit` | no | Result limit. |
2258
2337
  | `format` / `markdown` | no | Set `format:"markdown"` or `markdown:true` for a rendered trace report. |
2259
2338
 
2339
+ > **Tools are components, so availability is per ACCOUNT.** `Tool not found: mcp_performance_trace` does
2340
+ > not mean the tool is broken or that tracing is off — it means that tool has not been synced to the
2341
+ > account you are resolving against. This bites most often on **localhost** (a Test Account that has not
2342
+ > pulled the System Account's tool set) and on **client accounts**. Run `remits-cli tools` for the account
2343
+ > in question, or re-run against an account that owns the tool (`--account-id 4` for the System Account).
2344
+ > The same is true of every `mcp_*` tool, including the component tools noted below.
2345
+
2260
2346
  Reading rule: first use `slowest` to get candidate trace ids, then call `trace` on the suspicious id, then use
2261
2347
  `mcp_system_logs` only if you need surrounding log lines. A trace dominated by `firestore.*`, `http.*`,
2262
2348
  `gorm.save.*`, or component spans points you at the relevant platform seam or front-stage component. Large
2263
2349
  unaccounted wall time is itself a finding: check cold compile, queueing, blocking I/O, or missing
2264
2350
  `measure(...)` instrumentation.
2265
2351
 
2352
+ ### `mcp_event_diagnostics`
2353
+ Diagnose one Event's infrastructure outcome through the same `eventDiagnostics(eventId)` DSL described in
2354
+ `docs/guides/features/observability.md`. Use this before opening Action source when an Event is stuck,
2355
+ recovered, timed out, retried, or appears to have been killed.
2356
+
2357
+ ```bash
2358
+ remits-cli tool --name mcp_event_diagnostics --input '{"accountId":49,"eventId":18838}' --data-mode prod
2359
+ ```
2360
+
2361
+ | Parameter | Required | Description |
2362
+ |-----------|----------|-------------|
2363
+ | `accountId` | yes | Tenant scope. The Event must belong to this account unless `includeChildren:true`. |
2364
+ | `eventId` / `id` | yes | Event primary key to diagnose. |
2365
+ | `includeChildren` | no | Allow the Event to belong to the requested account or one of its child accounts. Default: `false`. |
2366
+
2367
+ Read `classification` first:
2368
+
2369
+ - `APPLICATION_FAILURE` — the Action failed in application code; read `event.errorMessage`, correlated
2370
+ alerts, and the producing component.
2371
+ - `ORPHANED_*` / `RECOVERED_*` — the attempt was abandoned; read `abandonmentCause`.
2372
+ - `REQUEST_TIMEOUT_LIKELY` means the work likely used its whole deadline, so split it into resumable batches.
2373
+ - `PROCESS_TERMINATED_LIKELY` means the worker likely disappeared before its deadline; inspect JVM/node
2374
+ health and container lifecycle logs.
2375
+ - `UNKNOWN_NO_DEADLINE_EVIDENCE` means the platform refuses to guess; use the returned `logQuery` filters.
2376
+ - `AWAITING_DELIVERY` means the Event has not been claimed; check queue delivery and action-node health.
2377
+ - `IN_FLIGHT_HEALTHY` means the Event is still heartbeating; inspect trace/logs before interrupting.
2378
+
2379
+ The response returns `threadGroupingId`, the full `result` map, `diagnosisHints`, and `pivots` containing
2380
+ ready-to-run inputs for `mcp_performance_trace`, `mcp_system_logs`, `mcp_record_listing`, and
2381
+ `mcp_object_activity` when those handles are present. For a performance question, open the returned
2382
+ `mcp_performance_trace` pivot next; for raw failure context, open logs and records by `threadGroupingId`.
2383
+
2266
2384
  ### `mcp_component_view`
2267
2385
  Read component field content with line numbers.
2268
2386
 
@@ -2367,6 +2485,34 @@ Execute a Test component.
2367
2485
  | `accountId` | yes | Account ID |
2368
2486
  | `testId` | yes | Test component ID |
2369
2487
  | `testNames` | no | Array of specific test case names |
2488
+ | `taskId` | no | Stable id for the run. **Declare your own if you may need to stop it** — see below. Echoed back either way. |
2489
+ | `controlAction` | no | `interrupt` (aliases `stop`/`cancel`/`kill`) stops a running suite identified by `taskId`. |
2490
+
2491
+ #### Stopping a running suite
2492
+
2493
+ A suite that loops dozens of cases — or sits in one slow AI/HTTP call — used to have to be waited out.
2494
+ It can now be stopped, from the admin test runner's **Stop** button or from here.
2495
+
2496
+ ```bash
2497
+ # declare the id when you start, so the run is addressable while it is still going
2498
+ remits-cli tool --name mcp_run_test --data-mode test --input '{"accountId":1,"testId":7,"taskId":"my-run"}'
2499
+
2500
+ # ...then from another call/session:
2501
+ remits-cli tool --name mcp_run_test --data-mode test --input '{"controlAction":"interrupt","accountId":1,"taskId":"my-run"}'
2502
+ ```
2503
+
2504
+ > **This tool runs the suite SYNCHRONOUSLY**, so you cannot stop a run you are yourself blocked on —
2505
+ > which is exactly why you declare `taskId` up front. Without one, a run gets a generated id you never see.
2506
+
2507
+ Semantics, same as everywhere else in the platform:
2508
+
2509
+ - **Cooperative.** The suite ends at its next checkpoint — between cases, or mid-case at any
2510
+ Firestore/HTTP/AI/DSL call. A case stuck in one long external call stops when that call returns.
2511
+ - **Cases already completed keep their results**, and committed work is **not** rolled back.
2512
+ - An interrupted run returns `interrupted: true` and its partial results. A stop is reported as
2513
+ **INTERRUPTED, never as a test failure** — so it can't be mistaken for a broken suite.
2514
+ - Keyed per RUN, not per Test: the same Test can be running concurrently (different users, branches, or
2515
+ data modes), and stopping one never stops another.
2370
2516
 
2371
2517
  ### `mcp_component_edit`
2372
2518
  Edit a component field, server-side, with stage or commit semantics. The agent counterpart to local file