Skip to Content
API ReferenceClassesClass: CostBucketId

Class: CostBucketId

Defined in: src/libs/cost_bucket_id.ts:35 

Constructors

Constructor

new CostBucketId(): CostBucketId

Returns

CostBucketId

Properties

DEFAULT_BUCKET

readonly static DEFAULT_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

readonly static NAMESPACE: "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

readonly static PATTERN: "{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

readonly static SEGMENT_COUNT: 4 = 4

Defined in: src/libs/cost_bucket_id.ts:44 

Number of /-delimited segments a well-formed bucketId has.

Methods

build()

static build(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

CostBucketParts

Returns

string


parse()

static parse(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

Last updated on