Class: CostBucketId
Defined in: src/libs/cost_bucket_id.ts:35
Constructors
Constructor
new CostBucketId():
CostBucketId
Returns
CostBucketId
Properties
DEFAULT_BUCKET
readonlystaticDEFAULT_BUCKET:"default_bucket"='default_bucket'
Defined in: src/libs/cost_bucket_id.ts:41
Bucket used when a caller does not attribute its spend to a specific run.
NAMESPACE
readonlystaticNAMESPACE:"tracker_bucket"='tracker_bucket'
Defined in: src/libs/cost_bucket_id.ts:38
Literal first path segment. Maps to the {namespace} variable of the
openai_cost_pp pattern used by the dev:cost:list npm script.
PATTERN
readonlystaticPATTERN:"{namespace}/{userId}/{skilletId}/{sessionId}"='{namespace}/{userId}/{skilletId}/{sessionId}'
Defined in: src/libs/cost_bucket_id.ts:49
Canonical openai_cost_pp pattern. MUST stay equal to the -p value in the
dev:cost:list / dev:cost:list:watch scripts in package.json so the
in-code rollup and the CLI grouping never diverge.
SEGMENT_COUNT
readonlystaticSEGMENT_COUNT:4=4
Defined in: src/libs/cost_bucket_id.ts:44
Number of /-delimited segments a well-formed bucketId has.
Methods
build()
staticbuild(parts):string
Defined in: src/libs/cost_bucket_id.ts:61
Build a cost bucketId from its parts.
userId and skilletId are fixed-position segments that the per-user /
per-skillet CLI grouping keys on, so a / in either would add spurious
segments and desync that grouping from the per-run rollup. We fail loud
rather than silently miscost (#225). sessionId is the trailing segment and
is intentionally not guarded — the job lane always passes a slash-free
<jobId>_<runId>, and a chat-mode session name keeps its existing behaviour.
Parameters
parts
Returns
string
parse()
staticparse(bucketId):CostBucketIdParsed|null
Defined in: src/libs/cost_bucket_id.ts:76
Parse a cost bucketId into its parts, or return null when it does not match
the canonical 4-segment tracker_bucket/... shape (e.g. the DEFAULT_BUCKET,
or a bucket written by some other tool). Callers skip unparseable buckets
rather than guessing.
Parameters
bucketId
string
Returns
CostBucketIdParsed | null