@hginsights/hgi 0.2.0-rc.1 → 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.
- package/README.md +6 -2
- package/dist/bin.js +850 -129
- package/docs/exit-codes.md +59 -7
- package/docs/output-formats.md +66 -3
- package/docs/security.md +2 -2
- package/npm-shrinkwrap.json +98 -178
- package/package.json +1 -1
- package/skills/hgi/SKILL.md +22 -17
package/skills/hgi/SKILL.md
CHANGED
|
@@ -38,6 +38,8 @@ hgi call company_enrich --input '{"domain":"acme.com"}' # lookup, JSON on stdout
|
|
|
38
38
|
hgi call search_companies --input '{"query":"saas"}' --select name,domain -f csv
|
|
39
39
|
hgi call <tool> --input '{"limit":100}' --out result.json # big result to a new file
|
|
40
40
|
hgi call <tool> --ids @hg_ids.txt --input '{...}' # a whole list: one JSONL row per line
|
|
41
|
+
hgi call <tool> --ids @hg_ids.txt --all-pages # a whole list, every page per company
|
|
42
|
+
hgi call <tool> --all-pages --input '{...}' # every page of an offset-paged tool, merged
|
|
41
43
|
hgi run <tool> --input '{...}' # only after the user approves
|
|
42
44
|
```
|
|
43
45
|
|
|
@@ -50,6 +52,16 @@ hgi run <tool> --input '{...}' # only after the user a
|
|
|
50
52
|
- A `{"warning":"ledger_not_updated",...}` line on stderr means the call still succeeded; do not re-run it.
|
|
51
53
|
- For more than one company, use `--ids @file` (one HG id or domain per line; `--ids -` for stdin; `--ids-column <name>` for a CSV; `--batch-size <n>` to send fewer per call than the tool's limit) instead of looping. hgi batches by the tool's limit, sends batches one at a time, and prints `{"input", "result"}` or `{"input", "error"}` rows as JSONL in input order. Exit 3 means a batch failed (its rows carry the error, the rest are fine); any other non-zero exit stopped the run, and `details.rows_emitted` / `calls_made` say how far it got: keep the rows already printed and resume from there.
|
|
52
54
|
|
|
55
|
+
### Paging (`--all-pages`)
|
|
56
|
+
|
|
57
|
+
For every row of an offset-paged tool, use `hgi call <tool> --all-pages` instead of an `offset` loop. hgi pages only tools whose schemas show it is safe (an integer `offset` input and a rows array with `has_more` or a total); anything else is refused with exit 2 `not_pageable`, nothing sent. Don't pass `offset` yourself.
|
|
58
|
+
|
|
59
|
+
- **Each extra page is a separate, billed call.** For batch tools (`hg_ids`/`domains`), follow-ups go one call per unfinished company.
|
|
60
|
+
- It stops on `has_more: false`, an empty or short page, or the total reached, never on `has_more: true` alone (the server can say `true` after the last row). `--max-pages <n>` caps pages per page object (default 10, page 1 included).
|
|
61
|
+
- The result keeps the server's shape. Each page object (the result, or each `companies[]` entry) gets `pages_fetched`; one cut short says `truncated: true` and `truncated_reason`: `max_pages`, `unmatched` (a batch entry hgi could not tie to one input, so it never guesses) or the code of the call that failed. Report truncated parts as incomplete.
|
|
62
|
+
- One credit line at the end with the sum. `--meta` adds `pages_fetched` (pages requested), `retries` (re-sends) and `calls_without_cost`.
|
|
63
|
+
- With `--ids`: each batch is sent as usual, then every unfinished company is paged on its own (`--max-pages` per company), and each row's `result` is that company's merged entry. A tool error on a follow-up truncates only that row (`truncated_reason: "tool_error"`, exit 3 at the end); any other failure stops the run with the rows so far printed and `details.partial_result: true`. `--meta`'s stderr summary adds `truncated_rows`.
|
|
64
|
+
|
|
53
65
|
## Recipes
|
|
54
66
|
|
|
55
67
|
These recipes name tools as examples. Before each one:
|
|
@@ -59,7 +71,7 @@ These recipes name tools as examples. Before each one:
|
|
|
59
71
|
- **Keep batches stable.** The server caches identical inputs for 30 days (7 for search), and a cached call costs nothing (observed). Sort ids and keep the same batches, so a re-run is free. Changing one id in a batch makes the whole batch a new input.
|
|
60
72
|
- **Missing is not zero.** No installs, no intent, or a company left out of a batch response means unknown, not zero. Record it as unknown; don't score the account down.
|
|
61
73
|
- **Show a plan first** for more than one batch (Rule 7).
|
|
62
|
-
-
|
|
74
|
+
- Batching is manual for now: sorted id batches, as below. Paging is `--all-pages` where the tool allows it (`not_pageable` otherwise).
|
|
63
75
|
|
|
64
76
|
### Match an account list
|
|
65
77
|
|
|
@@ -82,24 +94,16 @@ hgi call company_firmographic --input '{"hg_ids":["<id1>","<id2>"]}' --select co
|
|
|
82
94
|
**Batch:** read `maxItems` on `hg_ids` in `company_technographic`'s `input_schema`, and the maximum of `max_results` and `offset`. `company_intent` takes one company per call.
|
|
83
95
|
**Order:**
|
|
84
96
|
|
|
85
|
-
1. **Fit:** `company_technographic` on a
|
|
97
|
+
1. **Fit:** `company_technographic` on a batch of `hg_ids`, filtered (`vendor_names`, `product_names` or `category_ids`) so pages stay small, with `--all-pages` (above). It pages each company on its own and stops on a short page or `total_installs_count`, not on `has_more` alone (it can be wrong at page boundaries). A company with `truncated: true` is partial: say so, and narrow the filter rather than raising `--max-pages`.
|
|
86
98
|
2. **Topics:** resolve curated topic names to ids with `list_intent_topics`.
|
|
87
99
|
3. **Intent:** `company_intent` on the company's web domain (`company_domain`), not only its HQ id: intent is observed on web domains. In one run, Accor had 0 topics on its HQ id and 18 on `accor.com` (observed; counts change over time). Check `company.id` and `company.name` in the response: a domain can resolve to a subsidiary.
|
|
88
100
|
4. **Baseline:** large companies are active on about 70% of the ~20,000-topic catalogue (observed), so a raw topic count measures size, not interest. Compare the curated topics (`topic_ids`) with the company's own unfiltered summary. A summary with `topic_ids` counts only those topics. `fields:["summary"]` without a topic filter rejects `granularity` (422). When you request `fields:["topics"]`, pass `granularity:"global"`: the default is one row per state, which counts a topic several times.
|
|
89
101
|
|
|
90
102
|
```bash
|
|
91
|
-
#
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
ids='["<id1>","<id2>"]'; off=0 # one sorted batch of at most hg_ids.maxItems ids
|
|
96
|
-
while [ "$ids" != "[]" ]; do
|
|
97
|
-
if [ "$off" -gt "$maxoff" ]; then echo "partial: offset maximum reached for $ids" >&2; break; fi
|
|
98
|
-
hgi call company_technographic --input "{\"hg_ids\":$ids,\"vendor_names\":[\"<vendor>\"],\"max_results\":$max,\"offset\":$off}" -f json > "$dir/tech-$off.json" || break
|
|
99
|
-
# next page only for companies that filled this page and are short of their stated total, sorted
|
|
100
|
-
ids=$(jq -c --argjson max "$max" --argjson off "$off" '[.companies[] | select(.installs_count == $max and $off + $max < .total_installs_count) | .company_id] | sort' "$dir/tech-$off.json")
|
|
101
|
-
off=$((off + max))
|
|
102
|
-
done
|
|
103
|
+
# every install per company, paged safely; max_results up to the schema's maximum keeps the call count down
|
|
104
|
+
hgi call company_technographic --all-pages --max-pages 5 \
|
|
105
|
+
--input '{"hg_ids":["<id1>","<id2>"],"vendor_names":["<vendor>"],"max_results":<schema maximum>}' -f json > tech.json
|
|
106
|
+
# exit 0 with truncated companies = capped; non-zero with details.partial_result = stopped early, tech.json still holds what was paid for
|
|
103
107
|
hgi call company_intent --input '{"company_domain":"accor.com"}'
|
|
104
108
|
hgi call company_intent --input '{"company_domain":"accor.com","fields":["summary"],"topic_ids":["<topic id>"]}'
|
|
105
109
|
```
|
|
@@ -113,7 +117,7 @@ hgi call company_intent --input '{"company_domain":"accor.com","fields":["summar
|
|
|
113
117
|
1. Use the `hg_id`s from the matching recipe, sorted.
|
|
114
118
|
2. To size one area, resolve its category ids first with `get_product_category`, as `company_spend`'s description says. Don't pass guessed `category_names`: a name that matches nothing returns 0 rows without an error.
|
|
115
119
|
3. One `company_spend` call per batch of `hg_ids`, with `category_ids` set in that same call, not filtered afterwards.
|
|
116
|
-
4. Page with `max_results` and `offset` only when `all_count` exceeds the rows returned,
|
|
120
|
+
4. `company_spend` is not pageable with `--all-pages` (its per-company spend has no rows array). Page with `max_results` and `offset` by hand only when `all_count` exceeds the rows returned; stop on a short page or once `all_count` is reached, never on a has-more flag alone.
|
|
117
121
|
5. Rows are per country, and categories form a tree through `category_parent_id` (Total IT → Total External IT → Software, …). Sum across countries, never a parent with its children.
|
|
118
122
|
|
|
119
123
|
```bash
|
|
@@ -152,15 +156,16 @@ Not null, but easy to misread:
|
|
|
152
156
|
| 3 | the tool reported an error | read the message; do not blindly retry |
|
|
153
157
|
| 4 | not signed in, or login expired | ask the user to run `hgi auth login` |
|
|
154
158
|
| 4 `phoenix_account_required` | the signed-in identity has no Phoenix account | stop; tell the user to sign up, or to sign in with `hgi auth login` as an account that has one |
|
|
155
|
-
| 5 | rate limited | wait `retry_after_seconds` from the error, then retry |
|
|
159
|
+
| 5 | rate limited (after hgi's own retries) | wait `retry_after_seconds` from the error, then retry. For a long batch of lookups, pass `--retries 6` instead of writing your own retry loop |
|
|
156
160
|
| 6 | out of credits: `credit_limit_exceeded` (the organization) or `user_credit_limit_exceeded` (the user's personal budget) | stop; tell the user which one, and to ask an admin. Retrying will not help |
|
|
157
161
|
| 7 | server unreachable | retry later. If `outcome_unknown` is `true`, check state before re-running a `run` |
|
|
158
|
-
| 7 `governance_unavailable` | the server could not check the budget; nothing ran (`retryable: true`) | wait a little, then retry once
|
|
162
|
+
| 7 `governance_unavailable` | the server could not check the budget; nothing ran (`retryable: true`) | wait a little, then retry once. `hgi call --retries <n>` retries it itself; `hgi run` never does |
|
|
159
163
|
| 8 | OAuth or sign-in failure | ask the user to run `hgi auth login` again |
|
|
160
164
|
| 9 | proxy or TLS problem | the error names the cause (see `NODE_EXTRA_CA_CERTS`, `HTTPS_PROXY`). After a `run`, check `outcome_unknown` before retrying |
|
|
161
165
|
| 10 | wrong verb | use the verb the error names |
|
|
162
166
|
| 11 | forbidden, or `tool_not_enabled_for_team` | the account, organization or team lacks access to this tool; stop and tell the user to ask an admin |
|
|
163
167
|
| 12 | local credential or file problem | follow the hint. If `details.tool_ran` is `true`, the tool already ran and its result is on stdout: do not re-run it |
|
|
168
|
+
| any, with `details.partial_result: true` | `--all-pages` stopped on a later page; the pages fetched so far are on stdout (or `--out`), unfinished parts marked `truncated`. With `--ids`, the rows so far, the last one possibly `truncated` (`rows_emitted`, `calls_made`) | keep them, they were billed; then act on the code as its own row says. Don't re-fetch pages you already have |
|
|
164
169
|
| 13 `budget_exceeded` | the run spent its `--max-credits` cap; nothing more was sent (with `--ids`, keep the rows already printed) | stop; tell the user what was spent (`details.spent` of `details.max`). Only the user raises the cap or runs `hgi budget reset` |
|
|
165
170
|
|
|
166
171
|
Errors are JSON on stderr when it is not a terminal: `{"schema":1,"error":{"code","exit_code","message","hint","details"}}`. Branch on `error.code`, not on the message.
|