humanish 0.62.0 → 0.64.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.
@@ -26,6 +26,16 @@ export declare function telemetryStatePath(env?: NodeJS.ProcessEnv, home?: strin
26
26
  * `DO_NOT_TRACK` standard, our own env var, and the persisted opt-out.
27
27
  */
28
28
  export declare function disabledByEnvironment(env: NodeJS.ProcessEnv): boolean;
29
+ /**
30
+ * True when this process is running from a humanish SOURCE CHECKOUT rather than an install.
31
+ *
32
+ * Checked by walking up from cwd for a package.json whose name is `humanish` AND which carries
33
+ * this repo's private marker. An adopter with a dependency named humanish in node_modules is not
34
+ * matched: node_modules copies are skipped, and a consumer's own package.json has a different
35
+ * name. Falls back to "not a checkout" on any read error, because the failure direction that
36
+ * loses one event is better than the one that silently disables real telemetry.
37
+ */
38
+ export declare function inHumanishCheckout(startDir: string, readFileSyncFn: (p: string) => string): boolean;
29
39
  export declare function readTelemetryState(env?: NodeJS.ProcessEnv, home?: string): Promise<TelemetryState>;
30
40
  export declare function writeTelemetryState(state: TelemetryState, env?: NodeJS.ProcessEnv, home?: string): Promise<void>;
31
41
  /** Coarse enough that a duration cannot fingerprint a session. */
package/dist/telemetry.js CHANGED
@@ -34,7 +34,50 @@ export function telemetryStatePath(env = process.env, home = homedir()) {
34
34
  */
35
35
  export function disabledByEnvironment(env) {
36
36
  const truthy = (value) => value !== undefined && value.trim() !== "" && value.trim() !== "0" && value.trim().toLowerCase() !== "false";
37
- return truthy(env.DO_NOT_TRACK) || truthy(env.HUMANISH_TELEMETRY_DISABLED);
37
+ return (truthy(env.DO_NOT_TRACK)
38
+ || truthy(env.HUMANISH_TELEMETRY_DISABLED)
39
+ // Our OWN development and test runs must never reach the adoption dataset. In the first two
40
+ // days after telemetry shipped, 82% of events (4,042 of 4,932, from 49 of 59 anonymous ids)
41
+ // came from humanish's own CI and suite: ~50 ids each running nearly every subcommand about
42
+ // once, which is the shape of a test matrix and not of people. That made the one number whose
43
+ // job is measuring adoption measure us instead.
44
+ //
45
+ // Deliberately NOT keyed on CI. An adopter running humanish in their pipeline is real usage
46
+ // and stays countable; the `ci` property already separates it, which is what Next.js does.
47
+ // This keys on being inside the humanish source tree, which only we ever are.
48
+ || truthy(env.HUMANISH_DEV));
49
+ }
50
+ /**
51
+ * True when this process is running from a humanish SOURCE CHECKOUT rather than an install.
52
+ *
53
+ * Checked by walking up from cwd for a package.json whose name is `humanish` AND which carries
54
+ * this repo's private marker. An adopter with a dependency named humanish in node_modules is not
55
+ * matched: node_modules copies are skipped, and a consumer's own package.json has a different
56
+ * name. Falls back to "not a checkout" on any read error, because the failure direction that
57
+ * loses one event is better than the one that silently disables real telemetry.
58
+ */
59
+ export function inHumanishCheckout(startDir, readFileSyncFn) {
60
+ let dir = path.resolve(startDir);
61
+ // Any node_modules ANYWHERE in the path means this is an installed copy, not our checkout.
62
+ // Checking only the basename missed `/app/node_modules/humanish`, which is the single most
63
+ // likely real-world path to get wrong: it would silence a genuine adopter.
64
+ if (dir.split(path.sep).includes("node_modules"))
65
+ return false;
66
+ for (let depth = 0; depth < 12; depth += 1) {
67
+ try {
68
+ const parsed = JSON.parse(readFileSyncFn(path.join(dir, "package.json")));
69
+ if (parsed.name === "humanish")
70
+ return true;
71
+ }
72
+ catch {
73
+ // No package.json here, or unreadable. Keep walking up.
74
+ }
75
+ const parent = path.dirname(dir);
76
+ if (parent === dir)
77
+ break;
78
+ dir = parent;
79
+ }
80
+ return false;
38
81
  }
39
82
  export async function readTelemetryState(env = process.env, home = homedir()) {
40
83
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,yFAAyF;AACzF,EAAE;AACF,iGAAiG;AACjG,oGAAoG;AACpG,iGAAiG;AACjG,EAAE;AACF,iGAAiG;AACjG,oGAAoG;AACpG,8FAA8F;AAC9F,iGAAiG;AACjG,mGAAmG;AAEnG,OA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IAAC,MAAM,CAAC;QACP,+DAA+D;IACjE,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ActorTokenUsage } from "./actor-contract.js";
2
+ /**
3
+ * Accumulate per-turn provider token usage from a captured `codex exec --json` stream.
4
+ *
5
+ * Returns undefined when the stream carried no usage record at all, which is the honest "no
6
+ * signal" case and must stay distinguishable from a measured zero. Per-turn records are preserved
7
+ * in `turns` because long-context pricing can only be computed from per-request sizes
8
+ * (src/pricing.ts), and totals cannot say which requests crossed a threshold.
9
+ */
10
+ export declare function parseTerminalTokenUsage(transcript: string): ActorTokenUsage | undefined;
11
+ /** Human-readable token statement for the cost ledger and the no-spend proof. Reports what was
12
+ * counted and says plainly that it is unpriced, so a reader never reads "no charge recorded" as
13
+ * "nothing was consumed". */
14
+ export declare function describeTokenUsage(usage: ActorTokenUsage): string;
@@ -0,0 +1,93 @@
1
+ // Provider token accounting for the terminal lane (#531).
2
+ //
3
+ // THE GAP THIS CLOSES. A live terminal run reported `cost.lines.provider = null` with source
4
+ // "unmeasured", and the no-spend proof then read `satisfied: true` for `maxUsd: 0` on a run that
5
+ // had demonstrably consumed hundreds of thousands of provider tokens. The statement was honest
6
+ // (it listed provider as unmeasured) but it conflated two very different states: having no signal
7
+ // at all, and knowing exactly how many tokens were spent while lacking a rate to price them.
8
+ //
9
+ // The counts were already in the bundle. `codex exec --json` emits one usage record per turn:
10
+ // {"type":"turn.completed","usage":{"input_tokens":201536,"cached_input_tokens":170558,
11
+ // "cache_write_input_tokens":30951,"output_tokens":2283,"reasoning_output_tokens":902}}
12
+ //
13
+ // So the lane can record a MEASURED token fact even when it cannot record a priced one. Rates stay
14
+ // out of this module deliberately: pricing lives in src/pricing.ts, and the terminal lane has no
15
+ // real model id to price against (it records `model: "codex"`), so the honest output is
16
+ // tokens-known-rate-unknown rather than a guessed dollar figure.
17
+ // Bounded to a single line on purpose. `[^}]*` would run past a TRUNCATED record's missing brace
18
+ // and swallow the next, valid record's body, silently dropping a real turn from the count.
19
+ const USAGE_RE = /"type"\s*:\s*"turn\.completed"\s*,\s*"usage"\s*:\s*(\{[^}\n]*\})/g;
20
+ function num(value) {
21
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;
22
+ }
23
+ /**
24
+ * Accumulate per-turn provider token usage from a captured `codex exec --json` stream.
25
+ *
26
+ * Returns undefined when the stream carried no usage record at all, which is the honest "no
27
+ * signal" case and must stay distinguishable from a measured zero. Per-turn records are preserved
28
+ * in `turns` because long-context pricing can only be computed from per-request sizes
29
+ * (src/pricing.ts), and totals cannot say which requests crossed a threshold.
30
+ */
31
+ export function parseTerminalTokenUsage(transcript) {
32
+ const turns = [];
33
+ for (const match of transcript.matchAll(USAGE_RE)) {
34
+ const body = match[1];
35
+ if (body === undefined)
36
+ continue;
37
+ let raw;
38
+ try {
39
+ raw = JSON.parse(body);
40
+ }
41
+ catch {
42
+ continue; // A truncated or interleaved record is skipped rather than guessed at.
43
+ }
44
+ const input = num(raw.input_tokens);
45
+ const output = num(raw.output_tokens);
46
+ const cachedInput = num(raw.cached_input_tokens);
47
+ const cacheWriteInput = num(raw.cache_write_input_tokens);
48
+ if (input === undefined && output === undefined)
49
+ continue;
50
+ turns.push({
51
+ ...(input === undefined ? {} : { input }),
52
+ ...(output === undefined ? {} : { output }),
53
+ ...(cachedInput === undefined ? {} : { cachedInput }),
54
+ ...(cacheWriteInput === undefined ? {} : { cacheWriteInput })
55
+ });
56
+ }
57
+ if (turns.length === 0)
58
+ return undefined;
59
+ const sum = (field) => {
60
+ const present = turns.filter((t) => t[field] !== undefined);
61
+ if (present.length === 0)
62
+ return undefined;
63
+ return present.reduce((acc, t) => acc + (t[field] ?? 0), 0);
64
+ };
65
+ const input = sum("input");
66
+ const output = sum("output");
67
+ const cachedInput = sum("cachedInput");
68
+ const cacheWriteInput = sum("cacheWriteInput");
69
+ return {
70
+ ...(input === undefined ? {} : { input }),
71
+ ...(output === undefined ? {} : { output }),
72
+ ...(cachedInput === undefined ? {} : { cachedInput }),
73
+ ...(cacheWriteInput === undefined ? {} : { cacheWriteInput }),
74
+ ...(input === undefined && output === undefined ? {} : { total: (input ?? 0) + (output ?? 0) }),
75
+ turns
76
+ };
77
+ }
78
+ /** Human-readable token statement for the cost ledger and the no-spend proof. Reports what was
79
+ * counted and says plainly that it is unpriced, so a reader never reads "no charge recorded" as
80
+ * "nothing was consumed". */
81
+ export function describeTokenUsage(usage) {
82
+ const parts = [];
83
+ if (usage.input !== undefined)
84
+ parts.push(`${usage.input.toLocaleString("en-US")} input`);
85
+ if (usage.cachedInput !== undefined) {
86
+ parts.push(`${usage.cachedInput.toLocaleString("en-US")} of them cached`);
87
+ }
88
+ if (usage.output !== undefined)
89
+ parts.push(`${usage.output.toLocaleString("en-US")} output`);
90
+ const turns = usage.turns?.length ?? 0;
91
+ return `${parts.join(", ")} tokens over ${turns} provider turn${turns === 1 ? "" : "s"}`;
92
+ }
93
+ //# sourceMappingURL=terminal-token-usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-token-usage.js","sourceRoot":"","sources":["../src/terminal-token-usage.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,6FAA6F;AAC7F,iGAAiG;AACjG,+FAA+F;AAC/F,kGAAkG;AAClG,6FAA6F;AAC7F,EAAE;AACF,8FAA8F;AAC9F,0FAA0F;AAC1F,2FAA2F;AAC3F,EAAE;AACF,mGAAmG;AACnG,iGAAiG;AACjG,wFAAwF;AACxF,iEAAiE;AAcjE,iGAAiG;AACjG,2FAA2F;AAC3F,MAAM,QAAQ,GAAG,mEAAmE,CAAC;AAErF,SAAS,GAAG,CAAC,KAAc;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CA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KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC;QAC/F,KAAK;KACN,CAAC;AACJ,CAAC;AAED;;8BAE8B;AAC9B,MAAM,UAAU,kBAAkB,CAAC,KAAsB;IACvD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1F,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7F,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,KAAK,iBAAiB,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAC3F,CAAC"}
@@ -3,7 +3,7 @@
3
3
  Date: 2026-06-02 (current-state note updated 2026-07-14)
4
4
 
5
5
  Status: reference map for the major contracts shipped through source version
6
- `0.62.0`; it is not an exhaustive inventory of command/result envelopes. Exported types,
6
+ `0.64.0`; it is not an exhaustive inventory of command/result envelopes. Exported types,
7
7
  schema constants, parsers, and validators in `src/` are authoritative. Rows
8
8
  marked "reserved" name layering intent only — no code emits or validates them
9
9
  yet. Do not emit a reserved schema.
@@ -29,7 +29,7 @@ study completed, reproduced, and produced a real accessibility finding via a
29
29
  keyboard-first participant
30
30
  ([docs/goals/email-gated-signup/receipts/](email-gated-signup/receipts/)).
31
31
 
32
- ## Current Program Truth (source `0.62.0`)
32
+ ## Current Program Truth (source `0.64.0`)
33
33
 
34
34
  The package source and repository implementation in this tree agree on these
35
35
  points:
@@ -2,7 +2,7 @@
2
2
 
3
3
  Status: public-safe contributor and agent ramp.
4
4
 
5
- Package/source version in this tree: `0.62.0` (2026-08-31). The Observer is phone-usable as a stated requirement (observer/AGENTS.md); interactive primitives start from Base UI. The Observer renderer is the observer/ workspace artifact only; the legacy string-concat renderer was deleted at cutover (#426), and rollback is a version pin to 0.42.0. The containment boundary introduced in
5
+ Package/source version in this tree: `0.64.0` (2026-09-01). The Observer is phone-usable as a stated requirement (observer/AGENTS.md); interactive primitives start from Base UI. The Observer renderer is the observer/ workspace artifact only; the legacy string-concat renderer was deleted at cutover (#426), and rollback is a version pin to 0.42.0. The containment boundary introduced in
6
6
  `0.15.1` remains in force: managed run and output paths bind to validated
7
7
  physical filesystem identities, and stored provider IDs are evidence, not
8
8
  cleanup authority. The bundled OSS meta-lab is dry-run only until
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humanish",
3
- "version": "0.62.0",
3
+ "version": "0.64.0",
4
4
  "description": "Open-source-safe CLI for persona simulation, observer review, and public-safe feedback drafts.",
5
5
  "author": "Daniel G Wilson <daniel@danielgwilson.com>",
6
6
  "keywords": [