@moda-ai/cli 1.49.0 → 1.52.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.
@@ -364,8 +364,8 @@ Fields an agent should read:
364
364
 
365
365
  `errors[].code` is one of `input_error`, `api_error`, `network_error`,
366
366
  `auth_required`, `input_required`, `cancelled`, `command_error`,
367
- `access_denied`, `unknown_error`, or a documented domain code such as
368
- `cloud_unavailable`. `access_denied` (exit 1) is an access problem — no
367
+ `access_denied`, `output_error`, `unknown_error`, or a documented domain
368
+ code such as `cloud_unavailable`. `access_denied` (exit 1) is an access problem — no
369
369
  organizations or an insufficient (viewer) role — distinct from `auth_required`
370
370
  (exit 4, missing/expired credentials).
371
371
 
@@ -408,14 +408,26 @@ Treat an answer as degraded if **any** of these hold:
408
408
 
409
409
  ### Large outputs and unknown flags
410
410
 
411
- - **Byte limit.** In `--agent` mode, envelopes over 200 KB are bounded
412
- *without* breaking their shape: long text fields (usually embedded
413
- transcripts) are shortened with `… [truncated N chars]`, then trailing list
414
- items are dropped. `warnings[]` and `truncation.data` say exactly what was
415
- cut (`dropped_items`, `complete: false`). `data` is still normal JSON, so
416
- `data.frustrations[0].conversation_id` keeps working. For complete results,
417
- page with a smaller `--limit` and `--offset`, or rerun with `--json` (no byte
418
- limit).
411
+ - **Byte limit.** In `--agent` mode, envelopes over 200 KB
412
+ (`MODA_AGENT_MAX_OUTPUT_BYTES`) are bounded *without* cutting any text or
413
+ breaking their shape: the complete output (the same JSON `--json` prints) is
414
+ written to a local file, and whole trailing list items are dropped from
415
+ `data`. `truncation.data.full_output_path` (also an `artifacts[]` entry of
416
+ kind `full_output`) is that file; read it in line ranges or with `jq`.
417
+ These files are pruned after 24 hours (`MODA_AGENT_OUTPUT_RETENTION_HOURS`).
418
+ `truncation.data` also says what was dropped (`dropped_items`,
419
+ `complete: false`). `data` is still normal JSON, so
420
+ `data.frustrations[0].conversation_id` keeps working. If even one item is
421
+ over budget, `data` is a stub `{ truncated, original_bytes, max_bytes,
422
+ full_output_path }`. If that file cannot be written (unwritable
423
+ `MODA_AGENT_OUTPUT_DIR`, full disk), nothing is dropped: the envelope keeps
424
+ the whole result over the limit with `status: "error"`, an `output_error`
425
+ (`cause: "full_output_save_failed"`), and exit `1`. If only the oversized
426
+ envelope text could not be saved (`cause: "envelope_text_save_failed"`),
427
+ that text stays whole, and the error message says whether `data` is whole
428
+ or bounded with its complete copy at `truncation.data.full_output_path`.
429
+ You can also page with a smaller `--limit` and
430
+ `--offset`, or rerun with `--json` (no byte limit).
419
431
  - **Unknown flags fail.** A flag the command doesn't take (a typo, or a
420
432
  filter it lacks) exits `1` with the valid flag list and a "did you mean",
421
433
  instead of being silently ignored. Stray arguments on commands that take
@@ -446,6 +458,8 @@ fail instead of being clamped.
446
458
  time window. On `context`, `--window=0` returns only the anchor message (plus
447
459
  `total_messages`), and a value above 5 is clamped to 5 with a warning that
448
460
  prints the `--all --from --max-messages` command for a wider slice.
461
+ `--metadata-only` returns only the summary and `total_messages`, with no
462
+ messages.
449
463
 
450
464
  ### Schema introspection
451
465
 
@@ -534,11 +548,13 @@ compare scores across modes.
534
548
  Hand the anchors straight to `moda context`:
535
549
 
536
550
  ```bash
537
- # Find, then read the exact turn
538
- hit=$(moda search "double charge" --limit=1 | jq -r '.results[0]')
551
+ # Find, then read the exact turn. --json prints the bare payload; piped output
552
+ # without it is the agent envelope, where results sit under .data.results.
553
+ hit=$(moda search "double charge" --limit=1 --json | jq -c '.results[0] // empty')
539
554
  cid=$(echo "$hit" | jq -r '.conversation_id')
540
- idx=$(echo "$hit" | jq -r '.message_index')
541
- moda context "$cid" --msg-index="$idx"
555
+ # Trace-level fallback hits (match_grain: "trace") have no message_index.
556
+ idx=$(echo "$hit" | jq -r '.message_index // empty')
557
+ moda context "$cid" ${idx:+--msg-index="$idx"}
542
558
  ```
543
559
 
544
560
  ### 2. Overview (start here for health questions)
@@ -635,6 +651,7 @@ moda context <conversation_id> # default window around middle
635
651
  moda context <conversation_id> --msg-index=5 # center on message 5
636
652
  moda context <conversation_id> --window=3 # 3 messages each side (max 5)
637
653
  moda context <conversation_id> --msg-index=40 --window=0 # just message 40 + total_messages
654
+ moda context <conversation_id> --metadata-only # summary + total_messages, no messages
638
655
  moda context <conversation_id> --all # whole trace in order, first 500 messages
639
656
  moda context <conversation_id> --all --from=500 --max-messages=500 # continue (max 5000)
640
657
  ```
@@ -746,9 +763,9 @@ Pass `--include-window` to attach a `window` field per row (instead of
746
763
  (1–5, default `1`) is the half-width; `--window=1` ⇒ 3 messages total
747
764
  (anchor ± 1).
748
765
 
749
- Examples default to `--limit=5` (max 20). Strings inside `examples[]` longer
750
- than 300 characters are cut, and a warning says so; read the full text with
751
- the row's `context_command`. Agent output lists the 20 most frequent
766
+ Examples default to `--limit=5` (max 20). Example text is returned whole; if
767
+ the agent envelope goes over its byte limit, whole trailing examples are
768
+ dropped and `truncation.data.full_output_path` holds every example. Agent output lists the 20 most frequent
752
769
  `subtypes` (`subtypes_total` has the full count); `--json` lists all.
753
770
 
754
771
  ### 7. Prompt management
@@ -1116,16 +1133,17 @@ and archiving an active custom signal (pause it, or delete a draft).
1116
1133
 
1117
1134
  ```bash
1118
1135
  # Semantic: find the moment a user expressed an intent, in their own words
1119
- moda search "user wants to cancel subscription" --mode=semantic --limit=5 \
1136
+ moda search "user wants to cancel subscription" --mode=semantic --limit=5 --json \
1120
1137
  | jq -r '.results[] | "\(.conversation_id) @\(.message_index) \(.snippet)"'
1121
1138
 
1122
1139
  # Keyword: locate every tool call/result mentioning an exact identifier
1123
1140
  moda search "stripe.refunds.create" --mode=keyword --limit=10
1124
1141
 
1125
- # Search, then open the top hit at the exact turn
1126
- moda search "rate limit exceeded" --limit=1 \
1127
- | jq -r '.results[0] | "\(.conversation_id) \(.message_index)"' \
1128
- | xargs -n2 sh -c 'moda context "$0" --msg-index="$1"'
1142
+ # Search, then open the top message-level hit at the exact turn (skips
1143
+ # trace-level fallback hits, which have no message_index)
1144
+ moda search "rate limit exceeded" --limit=5 --json \
1145
+ | jq -r 'first(.results[] | select(.message_index != null)) | "\(.conversation_id) \(.message_index)"' \
1146
+ | xargs -r -n2 sh -c 'moda context "$0" --msg-index="$1"'
1129
1147
  ```
1130
1148
 
1131
1149
  ### Daily health check