humanish 0.17.0 → 0.19.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.
- package/README.md +53 -21
- package/dist/actor-contract.d.ts +11 -1
- package/dist/actor-contract.js.map +1 -1
- package/dist/computer-use-actor.d.ts +4 -0
- package/dist/computer-use-actor.js +3 -1
- package/dist/computer-use-actor.js.map +1 -1
- package/dist/computer-use.d.ts +16 -0
- package/dist/computer-use.js +59 -6
- package/dist/computer-use.js.map +1 -1
- package/dist/concurrent-shared-world-lab.js +1 -0
- package/dist/concurrent-shared-world-lab.js.map +1 -1
- package/dist/cua-actor-lab.d.ts +33 -3
- package/dist/cua-actor-lab.js +169 -2
- package/dist/cua-actor-lab.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lab-config.d.ts +12 -0
- package/dist/lab-config.js +12 -0
- package/dist/lab-config.js.map +1 -1
- package/dist/observer-assets.js +37 -3
- package/dist/observer-assets.js.map +1 -1
- package/dist/observer-data.d.ts +7 -1
- package/dist/observer-data.js +1 -0
- package/dist/observer-data.js.map +1 -1
- package/dist/observer-library.d.ts +5 -1
- package/dist/observer-library.js +9 -7
- package/dist/observer-library.js.map +1 -1
- package/dist/observer-serve.d.ts +11 -23
- package/dist/observer-serve.js +12 -92
- package/dist/observer-serve.js.map +1 -1
- package/dist/observer.d.ts +6 -0
- package/dist/observer.js +52 -1
- package/dist/observer.js.map +1 -1
- package/dist/pricing.d.ts +78 -0
- package/dist/pricing.js +100 -0
- package/dist/pricing.js.map +1 -0
- package/dist/program.js +294 -122
- package/dist/program.js.map +1 -1
- package/dist/run.d.ts +54 -0
- package/dist/run.js +86 -0
- package/dist/run.js.map +1 -1
- package/dist/serve-exposure.d.ts +62 -0
- package/dist/serve-exposure.js +129 -0
- package/dist/serve-exposure.js.map +1 -0
- package/dist/serve-http.d.ts +8 -0
- package/dist/serve-http.js +37 -0
- package/dist/serve-http.js.map +1 -0
- package/dist/serve-tunnel.d.ts +6 -2
- package/dist/serve-tunnel.js +9 -0
- package/dist/serve-tunnel.js.map +1 -1
- package/docs/architecture/actor-contract.md +41 -3
- package/docs/architecture/observer.md +30 -0
- package/docs/architecture/serve.md +138 -82
- package/docs/contracts/run-bundle.md +23 -0
- package/docs/contracts/schemas.md +111 -15
- package/docs/goals/current.md +1 -1
- package/docs/principles/invariants-and-defaults.md +2 -1
- package/docs/ramp/README.md +1 -1
- package/package.json +1 -1
- package/dist/observer-auth.d.ts +0 -21
- package/dist/observer-auth.js +0 -92
- package/dist/observer-auth.js.map +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ActorTokenUsage } from "./actor-contract.js";
|
|
2
|
+
export declare const PRICING_SCHEMA = "humanish.pricing.v1";
|
|
3
|
+
export declare const ACTOR_ESTIMATED_COST_SCHEMA = "humanish.actor-estimated-cost.v1";
|
|
4
|
+
export interface ModelRate {
|
|
5
|
+
/** USD per input token (the per-1M equivalent is noted in the comment beside each entry). */
|
|
6
|
+
inputUsdPerToken: number;
|
|
7
|
+
/** USD per output token. */
|
|
8
|
+
outputUsdPerToken: number;
|
|
9
|
+
/** "YYYY-MM-DD" the entry was last checked against `source`. */
|
|
10
|
+
asOf: string;
|
|
11
|
+
/** Public pricing page the number came from (a comment/URL, never a secret). */
|
|
12
|
+
source: string;
|
|
13
|
+
/** true = a stand-in NOT copied from a live sheet; the estimate carries this flag so a
|
|
14
|
+
* placeholder rate is never mistaken for a confirmed one. */
|
|
15
|
+
placeholder?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface DesktopRate {
|
|
18
|
+
usdPerMinute: number;
|
|
19
|
+
asOf: string;
|
|
20
|
+
source: string;
|
|
21
|
+
placeholder?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The token-derived cost ESTIMATE for one actor lane. `estimatedCostUsd: null` = DECLARED ABSENT
|
|
25
|
+
* (unknown rate or no token usage) — never coerced to 0. A non-null figure ALWAYS carries its
|
|
26
|
+
* pricing provenance (`ratesAsOf` + `source`) so the mechanism (a rate-table multiply) matches
|
|
27
|
+
* the claim (an estimate, not a charge). Defined here so the rate table and the field that
|
|
28
|
+
* consumes it live together; `ActorTrace` imports it type-only.
|
|
29
|
+
*/
|
|
30
|
+
export interface ActorEstimatedCost {
|
|
31
|
+
schema: typeof ACTOR_ESTIMATED_COST_SCHEMA;
|
|
32
|
+
/** null = declared absent (no rate for the model / no token usage). */
|
|
33
|
+
estimatedCostUsd: number | null;
|
|
34
|
+
reason?: "no_rate_for_model" | "no_token_usage";
|
|
35
|
+
/** Pricing provenance date; null iff estimatedCostUsd is null. */
|
|
36
|
+
ratesAsOf: string | null;
|
|
37
|
+
/** The pricing-page URL/comment that produced the rate. */
|
|
38
|
+
source?: string;
|
|
39
|
+
/** The model id the estimate was keyed on. */
|
|
40
|
+
modelId?: string;
|
|
41
|
+
/** true when the rate is a stand-in, not a live sheet. */
|
|
42
|
+
placeholder?: boolean;
|
|
43
|
+
breakdown?: {
|
|
44
|
+
inputUsd: number;
|
|
45
|
+
outputUsd: number;
|
|
46
|
+
inputTokens: number;
|
|
47
|
+
outputTokens: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** The desktop-minute cost ESTIMATE (host-side create->teardown span * a per-minute rate). Same
|
|
51
|
+
* null-discipline as ActorEstimatedCost: `estimatedCostUsd: null` = not measured (no duration). */
|
|
52
|
+
export interface DesktopCostEstimate {
|
|
53
|
+
estimatedCostUsd: number | null;
|
|
54
|
+
reason?: "no_duration";
|
|
55
|
+
ratesAsOf: string | null;
|
|
56
|
+
source?: string;
|
|
57
|
+
/** The billed minutes the estimate was keyed on; null when no duration was measured. */
|
|
58
|
+
minutes: number | null;
|
|
59
|
+
placeholder?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export declare const MODEL_RATES: Record<string, ModelRate>;
|
|
62
|
+
export declare const DESKTOP_RATE: DesktopRate;
|
|
63
|
+
/** Round a USD figure to 6 decimals so a float-accumulated total never carries spurious
|
|
64
|
+
* precision. This mirrors the SPIRIT of the terminal ledger's private roundUsd (6dp) without
|
|
65
|
+
* importing it — pricing stays a standalone pure module. */
|
|
66
|
+
export declare function round6(n: number): number;
|
|
67
|
+
/**
|
|
68
|
+
* Estimate one actor lane's model-token cost from its trace tokenUsage + model id. Deterministic;
|
|
69
|
+
* the rate table is injectable (tests pass a fake sheet). Returns a DECLARED-ABSENT estimate
|
|
70
|
+
* (estimatedCostUsd: null + a reason) for a missing rate or missing usage — never a guessed cost.
|
|
71
|
+
*/
|
|
72
|
+
export declare function estimateActorCost(tokenUsage: ActorTokenUsage | undefined, modelId: string | undefined, rates?: Record<string, ModelRate>): ActorEstimatedCost;
|
|
73
|
+
/**
|
|
74
|
+
* Estimate the E2B desktop-minute cost from a host-side create->teardown span (minutes). The rate
|
|
75
|
+
* is injectable. Returns a DECLARED-ABSENT estimate (null + "no_duration") when no duration was
|
|
76
|
+
* measured (no sandbox / unmeasurable span) — never a guessed 0.
|
|
77
|
+
*/
|
|
78
|
+
export declare function estimateDesktopCost(minutes: number | undefined, rate?: DesktopRate): DesktopCostEstimate;
|
package/dist/pricing.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// OPERATOR-EDITABLE ESTIMATES — NOT authoritative prices. Providers change pricing without
|
|
2
|
+
// notice. When they do, update BOTH the number AND the `asOf` date on the affected entry.
|
|
3
|
+
// Every dollar figure humanish derives from this table is surfaced/persisted as an ESTIMATE,
|
|
4
|
+
// labeled "estimated (rates as of <asOf>)", and is NEVER presented as an exact charge.
|
|
5
|
+
//
|
|
6
|
+
// This module is PURE (node builtins only, no deps) and deterministic: the two estimator
|
|
7
|
+
// functions take an OPTIONAL injected rate table/rate so tests drive assertions with a fake
|
|
8
|
+
// sheet and never depend on the live numbers below. An UNKNOWN model/desktop rate yields a
|
|
9
|
+
// DECLARED-ABSENT estimate (estimatedCostUsd: null + a reason), NEVER a guessed or silent-zero
|
|
10
|
+
// cost (invariant 5). A bare `costUsd` elsewhere in the contract means a provider actually
|
|
11
|
+
// billed that amount; the token-derived estimate here always lives under `estimatedCostUsd`
|
|
12
|
+
// so a reader can never confuse an estimate for an authoritative charge (invariant 6).
|
|
13
|
+
export const PRICING_SCHEMA = "humanish.pricing.v1";
|
|
14
|
+
export const ACTOR_ESTIMATED_COST_SCHEMA = "humanish.actor-estimated-cost.v1";
|
|
15
|
+
// Per-model rates, keyed on the model id that lands in trace.ids.model (lookup is
|
|
16
|
+
// case-insensitive on a trimmed id). An id NOT present here is DECLARED ABSENT, never guessed.
|
|
17
|
+
export const MODEL_RATES = {
|
|
18
|
+
// OpenAI computer-use-preview (the classic CUA model). ~$3 / 1M input, ~$12 / 1M output.
|
|
19
|
+
// source: openai.com/api/pricing (verify — providers change without notice).
|
|
20
|
+
"computer-use-preview": {
|
|
21
|
+
inputUsdPerToken: 3e-6,
|
|
22
|
+
outputUsdPerToken: 12e-6,
|
|
23
|
+
asOf: "2026-08-01",
|
|
24
|
+
source: "openai.com/api/pricing (computer-use-preview)"
|
|
25
|
+
},
|
|
26
|
+
// gpt-5.5 = the shipped CUA default (DEFAULT_OPENAI_CU_MODEL). PLACEHOLDER shaped like a
|
|
27
|
+
// GPT-5-class rate (~$1.25 / 1M input, ~$10 / 1M output) until confirmed against the live sheet.
|
|
28
|
+
"gpt-5.5": {
|
|
29
|
+
inputUsdPerToken: 1.25e-6,
|
|
30
|
+
outputUsdPerToken: 10e-6,
|
|
31
|
+
asOf: "2026-08-01",
|
|
32
|
+
source: "PLACEHOLDER — confirm at openai.com/api/pricing",
|
|
33
|
+
placeholder: true
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
// E2B desktop sandbox compute, billed per-second by vCPU+RAM. PLACEHOLDER ~ $0.10 / hr for a
|
|
37
|
+
// ~2 vCPU desktop => ~$0.00167 / minute. Confirm at e2b.dev/pricing.
|
|
38
|
+
export const DESKTOP_RATE = {
|
|
39
|
+
usdPerMinute: 0.00167,
|
|
40
|
+
asOf: "2026-08-01",
|
|
41
|
+
source: "PLACEHOLDER — confirm at e2b.dev/pricing",
|
|
42
|
+
placeholder: true
|
|
43
|
+
};
|
|
44
|
+
/** Round a USD figure to 6 decimals so a float-accumulated total never carries spurious
|
|
45
|
+
* precision. This mirrors the SPIRIT of the terminal ledger's private roundUsd (6dp) without
|
|
46
|
+
* importing it — pricing stays a standalone pure module. */
|
|
47
|
+
export function round6(n) {
|
|
48
|
+
return Math.round(n * 1e6) / 1e6;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Estimate one actor lane's model-token cost from its trace tokenUsage + model id. Deterministic;
|
|
52
|
+
* the rate table is injectable (tests pass a fake sheet). Returns a DECLARED-ABSENT estimate
|
|
53
|
+
* (estimatedCostUsd: null + a reason) for a missing rate or missing usage — never a guessed cost.
|
|
54
|
+
*/
|
|
55
|
+
export function estimateActorCost(tokenUsage, modelId, rates = MODEL_RATES) {
|
|
56
|
+
if (!tokenUsage || (tokenUsage.input === undefined && tokenUsage.output === undefined)) {
|
|
57
|
+
return { schema: ACTOR_ESTIMATED_COST_SCHEMA, estimatedCostUsd: null, reason: "no_token_usage", ratesAsOf: null };
|
|
58
|
+
}
|
|
59
|
+
const rate = modelId ? rates[modelId.trim().toLowerCase()] : undefined;
|
|
60
|
+
if (!rate) {
|
|
61
|
+
return {
|
|
62
|
+
schema: ACTOR_ESTIMATED_COST_SCHEMA,
|
|
63
|
+
estimatedCostUsd: null,
|
|
64
|
+
reason: "no_rate_for_model",
|
|
65
|
+
ratesAsOf: null,
|
|
66
|
+
...(modelId ? { modelId } : {})
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const inTok = tokenUsage.input ?? 0;
|
|
70
|
+
const outTok = tokenUsage.output ?? 0;
|
|
71
|
+
const inputUsd = round6(inTok * rate.inputUsdPerToken);
|
|
72
|
+
const outputUsd = round6(outTok * rate.outputUsdPerToken);
|
|
73
|
+
return {
|
|
74
|
+
schema: ACTOR_ESTIMATED_COST_SCHEMA,
|
|
75
|
+
estimatedCostUsd: round6(inputUsd + outputUsd),
|
|
76
|
+
ratesAsOf: rate.asOf,
|
|
77
|
+
source: rate.source,
|
|
78
|
+
...(modelId ? { modelId } : {}),
|
|
79
|
+
...(rate.placeholder ? { placeholder: true } : {}),
|
|
80
|
+
breakdown: { inputUsd, outputUsd, inputTokens: inTok, outputTokens: outTok }
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Estimate the E2B desktop-minute cost from a host-side create->teardown span (minutes). The rate
|
|
85
|
+
* is injectable. Returns a DECLARED-ABSENT estimate (null + "no_duration") when no duration was
|
|
86
|
+
* measured (no sandbox / unmeasurable span) — never a guessed 0.
|
|
87
|
+
*/
|
|
88
|
+
export function estimateDesktopCost(minutes, rate = DESKTOP_RATE) {
|
|
89
|
+
if (minutes === undefined || !(minutes >= 0)) {
|
|
90
|
+
return { estimatedCostUsd: null, reason: "no_duration", ratesAsOf: null, minutes: null };
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
estimatedCostUsd: round6(minutes * rate.usdPerMinute),
|
|
94
|
+
ratesAsOf: rate.asOf,
|
|
95
|
+
source: rate.source,
|
|
96
|
+
minutes: round6(minutes),
|
|
97
|
+
...(rate.placeholder ? { placeholder: true } : {})
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=pricing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,0FAA0F;AAC1F,6FAA6F;AAC7F,uFAAuF;AACvF,EAAE;AACF,yFAAyF;AACzF,4FAA4F;AAC5F,2FAA2F;AAC3F,+FAA+F;AAC/F,2FAA2F;AAC3F,4FAA4F;AAC5F,uFAAuF;AAMvF,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AACpD,MAA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