@hginsights/hgi 0.2.0 → 0.3.0-rc.1

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.
@@ -7,7 +7,7 @@ Every failure has its own exit code, so a script can branch without parsing Engl
7
7
  | 0 | | success |
8
8
  | 1 | `internal_error` | a bug in `hgi`. Never used for a server response or a usage error |
9
9
  | 2 | `invalid_input` | bad flags or usage; invalid JSON; input that fails the tool's schema; unknown tool; unreadable `--input @file` or `--ids @file`; `--out` refusals (exists, symlink, protected path, `--force` on `call`); config-dir or `HGI_LEDGER` workspace guard (`workspace_guard`); a bad `--label` (`bad_label`), `hgi usage --since` (`bad_since`) or `--by` (`bad_by`); any `--ids` refusal (see [below](#partial-output-from---ids)); any `--all-pages` refusal, `not_pageable` among them (see [below](#partial-output-from---all-pages)). Nothing is sent |
10
- | 3 | `tool_error` | the tool returned `isError` (including server-side invalid arguments, which the server reports in-band), a JSON-RPC error, or a response `hgi` could not parse after the call was sent. With `--ids`: at least one batch call failed (every row is printed first) |
10
+ | 3 | `tool_error` | the tool returned `isError` (including server-side invalid arguments, which the server reports in-band), a JSON-RPC error, or a response `hgi` could not parse after the call was sent. With `--ids`: at least one batch call failed, or (with `--all-pages`) a follow-up page failed for at least one company (every row is printed first) |
11
11
  | 4 | `login_required`, `login_expired`, `phoenix_account_required` | no credentials; a second 401 after one refresh; the refresh token was rejected (`invalid_grant`). `phoenix_account_required`: the server says the signed-in identity has no Phoenix account; sign up, or sign in with `hgi auth login` as an account that has one |
12
12
  | 5 | `rate_limited` | 429 after bounded retries (MCP calls: 3 by default, `--retries` to change; see [Retries](#retries)), or a `Retry-After` longer than what is left of the retry budget; `details.attempts` says how many times the request was sent. A 429 from the userinfo or revoke endpoint exits at once |
13
13
  | 6 | `credit_limit_exceeded`, `user_credit_limit_exceeded` | the server refused the call: your organization's credit allowance (`credit_limit_exceeded`) or your personal credit budget (`user_credit_limit_exceeded`) is used up. Retrying will not help; ask an admin, or wait for the next billing period |
@@ -57,6 +57,12 @@ On a terminal, errors are plain text with a hint.
57
57
  - **Any other code stops the run at once** (out of credits, sign-in expired, rate limited, unreachable, proxy/TLS, forbidden, a failure with `outcome_unknown: true`, and any later client-side stop): no further batch is sent and nothing is retried. The rows already printed stay on stdout (for `-f json|csv|yaml|table` and `--out`, the rows so far are written before the error). `details` adds `rows_emitted` (rows printed, in input order) and `calls_made` (`tools/call` requests attempted, including the one that failed), so you know where to resume. If `--out` cannot be written at that point, the rows go to stdout instead and `details.out_write_failed` is `true`; the exit code is still the original one.
58
58
  - **12 with `details.tool_ran: true`**: every call ran, but `--out` could not be written at the end; the rows are on stdout. Do not re-run.
59
59
 
60
+ **With `--all-pages` too** ([output formats](output-formats.md#--ids-with---all-pages)), both partial-result rules apply, per company:
61
+
62
+ - A follow-up page that fails with a tool error (the exit-3 class above) ends paging for **that company only**: its row keeps the pages fetched before it, marked `truncated: true, truncated_reason: "tool_error"`, and the run goes on. The run ends with exit 3, `details.paging_failures` (companies cut short this way) next to `failed_batches`, `rows_emitted` and `calls_made`.
63
+ - Any other failure, on a batch call or a follow-up page, stops the run at once, as above. The rows already printed stay; the company that was being paged gets its row, with the pages fetched so far and `truncated_reason: "<error.code>"`; companies not reached yet get no row. `details` adds `partial_result: true` (as with [`--all-pages`](#partial-output-from---all-pages)) next to `rows_emitted` and `calls_made`, and the exit code is the error's own.
64
+ - When a batch call's spend cannot be recorded under a run cap, no follow-up page is sent: that batch's rows are printed with page 1 only (unfinished companies marked `truncated_reason: "local_state_error"`), then exit 12 `budget_write_failed` with `tool_ran: true` and `partial_result: true`.
65
+
60
66
  Exit 2 refusals specific to `--ids`, each before anything is sent (`details.reason`):
61
67
 
62
68
  | `reason` | When |
@@ -87,11 +93,10 @@ Exit 2 refusals specific to `--all-pages`, each before anything is sent (`detail
87
93
 
88
94
  | `reason` | When |
89
95
  |---|---|
90
- | `not_pageable` | the tool's schemas don't show it can be paged safely: no integer `offset` input, or no output object with exactly one rows array plus `has_more`/`hasMore` or a total (`details.tool`) |
96
+ | `not_pageable` | the tool's schemas don't show it can be paged safely: no integer `offset` input, or no output object with exactly one rows array plus `has_more`/`hasMore` or a total (`details.tool`). With `--ids`, also when the page objects are not the items of the array `--ids` reads its rows from |
91
97
  | `max_pages_without_all_pages` | `--max-pages` without `--all-pages` |
92
98
  | `bad_max_pages` | `--max-pages` is not a whole number of at least 1 |
93
99
  | `offset_with_all_pages` | `--input` already has `offset`; `--all-pages` sets it |
94
- | `all_pages_with_ids` | `--all-pages` together with `--ids` |
95
100
 
96
101
  ## `outcome_unknown`
97
102
 
@@ -133,7 +138,7 @@ Success prints the tool result on stdout and the credit cost on stderr (`credit_
133
138
  - It covers `hgi call` only. `hgi run` has no `--max-credits`, ignores `HGI_MAX_CREDITS`, and is neither checked nor counted.
134
139
  - Before each capped call, `hgi` refuses with exit 13 when the budget has already spent its cap, and sends nothing. After the call, it adds the cost the server reported (`_meta.creditCost`), for error results too. A tool that reports no cost counts as 0 and is counted in `unknown_cost_calls`.
135
140
  - With `--all-pages`, every page is a capped call: checked before it is sent and counted after it. When the cap is reached partway, the next page is not sent, the pages so far are printed, and `hgi` exits 13 with `details.partial_result: true` ([above](#partial-output-from---all-pages)).
136
- - With `--ids`, every batch call is a capped call: checked before it is sent and counted after it. When the cap is reached partway, the run stops with exit 13 and the rows so far stay printed, with `rows_emitted` and `calls_made` as in [Partial output from `--ids`](#partial-output-from---ids). When a batch's spend cannot be recorded, its rows are printed first (to `--out` when given), then the run stops with exit 12 `budget_write_failed` and `details.tool_ran: true`.
141
+ - With `--ids`, every batch call (and, with `--all-pages`, every follow-up page) is a capped call: checked before it is sent and counted after it. When the cap is reached partway, the run stops with exit 13 and the rows so far stay printed, with `rows_emitted` and `calls_made` as in [Partial output from `--ids`](#partial-output-from---ids). When a batch's spend cannot be recorded, its rows are printed first (to `--out` when given), then the run stops with exit 12 `budget_write_failed` and `details.tool_ran: true`.
137
142
  - The server gives no price before a call, so a run can overshoot its cap by the calls running at the same time: one call when calls run one after another, more when they run in parallel.
138
143
  - Spend is recorded only when a cap is set. It lives in `~/.config/hgi/budgets/` (see [security](security.md)); a file not updated for 7 days is deleted on the next budget write.
139
144
  - `hgi budget status [--max-credits <n>]` prints `{budget_id, spent, max, remaining, calls, unknown_cost_calls}`; `hgi budget reset` starts the count over. Neither needs a sign-in or sends anything.
@@ -112,7 +112,18 @@ Anything else is refused before anything is sent (exit 2, `details.reason: "not_
112
112
 
113
113
  With `--retries`, each page gets the same retries as a single `hgi call`, `governance_unavailable` re-sends included; a page whose retries run out stops paging like any later-page failure, with `details.attempts`.
114
114
 
115
- Without `--all-pages`, `--meta` is unchanged. `--all-pages` is not available with `--ids` or on `hgi run`.
115
+ Without `--all-pages`, `--meta` is unchanged. `--all-pages` is not available on `hgi run`.
116
+
117
+ ### `--ids` with `--all-pages`
118
+
119
+ `hgi call <batch tool> --ids @file --all-pages` batches first, then pages each company on its own, and prints the [`--ids` rows](#hgi-call---ids-batches) with every page in them:
120
+
121
+ - Each batch is sent exactly as `--ids` sends it (page 1). Then every company of that batch whose stop rule has not fired is followed up, **one company per call** (`{"hg_ids": ["<id>"], "offset": n}` or `domains`, the other `--input` fields kept), with the same stop rule and matching as above. The tool's page objects must be the items of the array `--ids` reads its rows from, else exit 2 `not_pageable`.
122
+ - Work goes in input order: a batch is sent when its first company is reached, then that company is paged. For a file of one kind that is batch 1, its follow-ups, batch 2, its follow-ups, and so on.
123
+ - Each row's `result` is that company's **merged entry**: all its rows, `pages_fetched`, and `truncated: true` with `truncated_reason` when it was cut short (`max_pages`, `unmatched`, `tool_error`, or the code of the failure that stopped the run). Rows still stream in input order; a row is printed once its company has finished paging, so it may wait for the companies before it. A duplicate line repeats the same merged entry; the company is paged once.
124
+ - `--max-pages` (default 10) applies per company.
125
+ - A follow-up that fails with a tool error ends paging for that company only; the run goes on and ends with exit 3. Any other failure stops the run; see [exit codes](exit-codes.md#partial-output-from---ids).
126
+ - One credit line at the end, the sum of every call. `--meta`'s summary counts follow-ups in `calls` and adds `truncated_rows` (rows whose `result` is marked truncated): `{"calls", "retries", "rows", "row_errors", "truncated_rows", "credit_cost", "calls_without_cost"}`. With `--retries`, follow-up pages get the same retries as batch calls; one whose retries run out is handled like any other follow-up failure.
116
127
 
117
128
  ## `hgi tools list`
118
129